Author: jonesde
Date: Sat Nov 18 15:03:25 2006 New Revision: 476650 URL: http://svn.apache.org/viewvc?view=rev&rev=476650 Log: Created ecomclone webapp in the ecommerce component that uses the new include stuff, and acts as a test case for it; as part of this found a couple of bugs and some room for improvement in the ConfigXMLReader, and fixed those up Added: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml (with props) incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml (with props) incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp (with props) Modified: incubator/ofbiz/trunk/applications/ecommerce/ofbiz-component.xml incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml incubator/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java Modified: incubator/ofbiz/trunk/applications/ecommerce/ofbiz-component.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/ofbiz-component.xml?view=diff&rev=476650&r1=476649&r2=476650 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/ofbiz-component.xml (original) +++ incubator/ofbiz/trunk/applications/ecommerce/ofbiz-component.xml Sat Nov 18 15:03:25 2006 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright 2001-2006 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -46,9 +45,15 @@ <entity-resource type="data" reader-name="demo" loader="main" location="data/DemoStoreGiftCertificateSettings.xml"/> <entity-resource type="data" reader-name="demo" loader="main" location="data/DemoProductCategoriesI18nData.xml"/> <webapp name="ecommerce" - title="ECommerce" + title="eCommerce" server="default-server" location="webapp/ecommerce" mount-point="/ecommerce" + app-bar-display="false"/> + <webapp name="ecomclone" + title="eCommerce Clone" + server="default-server" + location="webapp/ecomclone" + mount-point="/ecomclone" app-bar-display="false"/> </ofbiz-component> Added: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml?view=auto&rev=476650 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml (added) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml Sat Nov 18 15:03:25 2006 @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--> + +<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/site-conf.xsd"> + <include location="component://ecommerce/webapp/ecommerce/WEB-INF/controller.xml"/> + <description>OFBiz: Cloned eCommerce Controller Configuration File</description> +</site-conf> Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/controller.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml?view=auto&rev=476650 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml (added) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml Sat Nov 18 15:03:25 2006 @@ -0,0 +1,123 @@ +<?xml version="1.0"?> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> + +<!-- + +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--> + +<web-app> + <display-name>Open For Business - demostore</display-name> + <description>Cloned Demo Store for the Open For Business Project</description> + + <context-param> + <param-name>webSiteId</param-name> + <param-value>WebStore</param-value> + <description>A unique ID used to look up the WebSite entity to get information about catalogs, etc.</description> + </context-param> + <context-param> + <param-name>localDispatcherName</param-name> + <param-value>ecommerce</param-value> + <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description> + </context-param> + <context-param> + <param-name>serviceReaderUrls</param-name> + <param-value>/WEB-INF/services.xml</param-value> + <description>Configuration File(s) For The Service Dispatcher</description> + </context-param> + <context-param> + <param-name>entityDelegatorName</param-name> + <param-value>default</param-value> + <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description> + </context-param> + <context-param> + <param-name>mainDecoratorLocation</param-name> + <param-value>component://ecommerce/widget/CommonScreens.xml</param-value> + <description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description> + </context-param> + + <filter> + <filter-name>ContextFilter</filter-name> + <display-name>ContextFilter</display-name> + <filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class> + <init-param> + <param-name>disableContextSecurity</param-name> + <param-value>N</param-value> + </init-param> + <init-param> + <param-name>allowedPaths</param-name> + <param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images</param-value> + </init-param> + <init-param> + <param-name>errorCode</param-name> + <param-value>403</param-value> + </init-param> + <init-param> + <param-name>redirectPath</param-name> + <param-value>/control/main</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>ContextFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <listener><listener-class>org.ofbiz.webapp.control.ControlEventListener</listener-class></listener> + <!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface --> + <!-- <listener><listener-class>org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> --> + + <!-- this listener will save any abandoned cart info --> + <listener><listener-class>org.ofbiz.order.shoppingcart.CartEventListener</listener-class></listener> + <!-- this listener will clean up info --> + <listener><listener-class>org.ofbiz.webapp.control.LoginEventListener</listener-class></listener> + + <servlet> + <servlet-name>ControlServlet</servlet-name> + <display-name>ControlServlet</display-name> + <description>Main Control Servlet</description> + <servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <!-- un-comment for Worldpay + <servlet> + <servlet-name>select</servlet-name> + <display-name>SelectHandler</display-name> + <description>WorldPay Select Handler Service</description> + <servlet-class>com.worldpay.select.merchant.SelectHandler</servlet-class> + <load-on-startup>5</load-on-startup> + </servlet> + --> + + <servlet-mapping> + <servlet-name>ControlServlet</servlet-name> + <url-pattern>/control/*</url-pattern> + </servlet-mapping> + <!-- un-comment for Worldpay + <servlet-mapping> + <servlet-name>select</servlet-name> + <url-pattern>/select/*</url-pattern> + </servlet-mapping> + --> + + <session-config> + <session-timeout>60</session-timeout> + </session-config> + + <welcome-file-list> + <welcome-file>index.jsp</welcome-file> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + </welcome-file-list> +</web-app> Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp?view=auto&rev=476650 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp (added) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp Sat Nov 18 15:03:25 2006 @@ -0,0 +1,18 @@ +<%-- + +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--%> + +<%response.sendRedirect("control/main");%> Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecomclone/index.jsp ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?view=diff&rev=476650&r1=476649&r2=476650 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Sat Nov 18 15:03:25 2006 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> <!-- - Copyright 2001-2006 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not Modified: incubator/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd?view=diff&rev=476650&r1=476649&r2=476650 ============================================================================== --- incubator/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd (original) +++ incubator/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd Sat Nov 18 15:03:25 2006 @@ -21,15 +21,15 @@ <xs:element minOccurs="0" ref="include"/> <xs:element minOccurs="0" ref="description"/> <xs:element minOccurs="0" ref="owner"/> - <xs:element ref="errorpage"/> - <xs:element maxOccurs="unbounded" ref="handler"/> + <xs:element minOccurs="0" ref="errorpage"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="handler"/> <xs:element minOccurs="0" ref="firstvisit"/> <xs:element minOccurs="0" ref="preprocessor"/> <xs:element minOccurs="0" ref="postprocessor"/> <xs:element minOccurs="0" ref="after-login"/> <xs:element minOccurs="0" ref="before-logout"/> - <xs:element maxOccurs="unbounded" ref="request-map"/> - <xs:element maxOccurs="unbounded" ref="view-map"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="request-map"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="view-map"/> </xs:sequence> </xs:complexType> </xs:element> Modified: incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java?view=diff&rev=476650&r1=476649&r2=476650 ============================================================================== --- incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java Sat Nov 18 15:03:25 2006 @@ -168,11 +168,9 @@ while (includeElementIter.hasNext()) { Element includeElement = (Element) includeElementIter.next(); String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION); - if ((includeLocation != null) && (includeLocation.length() > 0)) { try { Map subMap = loadRequestMap(null, FlexibleLocation.resolveLocation(includeLocation)); - map.putAll(subMap); } catch (MalformedURLException mue) { Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module); @@ -304,11 +302,9 @@ while (includeElementIter.hasNext()) { Element includeElement = (Element) includeElementIter.next(); String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION); - if ((includeLocation != null) && (includeLocation.length() > 0)) { try { Map subMap = loadViewMap(null, FlexibleLocation.resolveLocation(includeLocation)); - map.putAll(subMap); } catch (MalformedURLException mue) { Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module); @@ -574,15 +570,34 @@ if ((includeLocation != null) && (includeLocation.length() > 0)) { try { Map subMap = loadHandlerMap(null, FlexibleLocation.resolveLocation(includeLocation)); - map.putAll(subMap); + + Map newViewHandlerMap = (Map) subMap.get("view"); + Map viewHandlerMap = (Map) map.get("view"); + if (viewHandlerMap == null) { + map.put("view", newViewHandlerMap); + } else { + if (newViewHandlerMap != null) { + viewHandlerMap.putAll(newViewHandlerMap); + } + } + + Map newEventHandlerMap = (Map) subMap.get("event"); + Map eventHandlerMap = (Map) map.get("event"); + if (eventHandlerMap == null) { + map.put("event", newEventHandlerMap); + } else { + if (newEventHandlerMap != null) { + eventHandlerMap.putAll(newEventHandlerMap); + } + } } catch (MalformedURLException mue) { Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module); } } } - Map rMap = FastMap.newInstance(); - Map vMap = FastMap.newInstance(); + Map eventMap = FastMap.newInstance(); + Map viewMap = FastMap.newInstance(); List handlerElementList = UtilXml.childElementList(root, HANDLER); Iterator handlerElementIter = handlerElementList.iterator(); @@ -592,13 +607,28 @@ String hClass = checkEmpty(handlerElement.getAttribute(HANDLER_CLASS)); String hType = checkEmpty(handlerElement.getAttribute(HANDLER_TYPE)); if (hType.equals("view")) { - vMap.put(hName, hClass); + viewMap.put(hName, hClass); } else { - rMap.put(hName, hClass); + eventMap.put(hName, hClass); + } + } + + Map viewHandlerMap = (Map) map.get("view"); + if (viewHandlerMap == null) { + map.put("view", viewMap); + } else { + if (viewMap != null) { + viewHandlerMap.putAll(viewMap); + } + } + Map eventHandlerMap = (Map) map.get("event"); + if (eventHandlerMap == null) { + map.put("event", eventMap); + } else { + if (eventMap != null) { + eventHandlerMap.putAll(eventMap); } } - map.put("view", vMap); - map.put("event", rMap); /* Debugging */ if (Debug.verboseOn()) { @@ -632,7 +662,7 @@ } double totalSeconds = (System.currentTimeMillis() - startTime)/1000.0; - if (Debug.infoOn()) Debug.logInfo("HandlerMap Created: (" + map.size() + ") records in " + totalSeconds + "s", module); + if (Debug.infoOn()) Debug.logInfo("HandlerMap Created: (" + ((Map) map.get("view")).size() + ") view handlers and (" + ((Map) map.get("event")).size() + ") request/event handlers in " + totalSeconds + "s", module); return map; } |
Free forum by Nabble | Edit this page |