Adrian, What is all of this, and how does it relate to what I've been working on in the executioncontext20090716 branch? It seems like this will: 1. cause some inconvenience now, while more comprehensive changes are being made in the executioncontext20090716 branch 2. make it a LOT more difficult (perhaps impossible) to merge the executioncontext20090716 branch What is your plan with this? It would make life a lot easier for all of us if you would do some research on what I've already done in the executioncontext20090716 branch before continuing with this. -David On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: > Author: adrianc > Date: Sun Aug 9 18:04:26 2009 > New Revision: 802567 > > URL: http://svn.apache.org/viewvc?rev=802567&view=rev > Log: > Refactored GenericDelegator: > > 1. Converted GenericDelegator to an interface. We already have > DelegatorInterface, but it isn't being used anywhere. Removed > DelegatorInterface.java. > > 2. Extracted the static, cached data from the GenericDelegator > implementation and put it in its own class - DelegatorData. The > GenericDelegator implementation holds a reference to the > DelegatorData instance. This makes it possible to have per-thread > instances of GenericDelegator. > > 3. Replaced the ThreadLocal variables with regular variables. > ThreadLocal variables are no longer needed. Client code doesn't need > to be concerned with pushing and popping the GenericDelegator state. > > This commit paves the way for the forthcoming ExecutionContext. > > User modifications will have to replace > GenericDelegator.getGenericDelegator(...) with > DelegatorFactory.getGenericDelegator(...). Also, replace the push > code with the new setXxx methods, and remove the pop code. If > modifications used DelegatorInterface, replace that with > GenericDelegator. > > Aside from those changes, this commit is backwards compatible. > > Added: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java (with props) > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java (with props) > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorImpl.java (with props) > Removed: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorInterface.java > Modified: > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > CartEventListener.java > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCart.java > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCartItem.java > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ > PackingSession.java > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ > VerifyPickSession.java > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > weightPackage/WeightPackageSession.java > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ > CatalinaContainer.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > GenericDelegator.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > GenericEntity.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/ > AbstractCache.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/ > EntityExpr.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ > ListFinder.java > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/ > EntityDataLoadContainer.java > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ > synchronization/EntitySyncContext.java > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ > synchronization/EntitySyncServices.java > ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/ > XuiContainer.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ > entityops/EntityCount.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ > entityops/EntityData.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ > entityops/FindByAnd.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ > entityops/FindByPrimaryKey.java > ofbiz/trunk/framework/service/src/org/ofbiz/service/ > ServiceDispatcher.java > ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/ > JavaMailContainer.java > ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ > RmiServiceContainer.java > ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ > ModelTestSuite.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ > ContextFilter.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ > ControlServlet.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ > RequestHandler.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ > CoreEvents.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ > ServiceStreamHandler.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ > XmlRpcEventHandler.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ > ServerHitBin.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ > VisitHandler.java > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/ > WebDavServlet.java > ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ > WebslingerContextMapper.java > ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/ > WebToolsServices.java > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/ > AuditEntityObject.java > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/ > SharkContainer.java > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/ > InstanceEntityObject.java > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/ > AbstractRequester.java > ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/ > WebPosSession.java > ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/ > definition/XpdlReader.java > > Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ > shoppingcart/CartEventListener.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > CartEventListener.java (original) > +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > CartEventListener.java Sun Aug 9 18:04:26 2009 > @@ -28,6 +28,7 @@ > import org.ofbiz.base.util.Debug; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.webapp.stats.VisitHandler; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > @@ -58,7 +59,7 @@ > String delegatorName = (String) > session.getAttribute("delegatorName"); > GenericDelegator delegator = null; > if (UtilValidate.isNotEmpty(delegatorName)) { > - delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > if (delegator == null) { > Debug.logError("Could not find delegator with > delegatorName in session, not saving abandoned cart info.", module); > > Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ > shoppingcart/ShoppingCart.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCart.java (original) > +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCart.java Sun Aug 9 18:04:26 2009 > @@ -21,6 +21,7 @@ > import javolution.util.FastList; > import javolution.util.FastMap; > import org.ofbiz.base.util.*; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericPK; > @@ -275,7 +276,7 @@ > > public GenericDelegator getDelegator() { > if (delegator == null) { > - delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > return delegator; > } > > Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ > shoppingcart/ShoppingCartItem.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCartItem.java (original) > +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ > ShoppingCartItem.java Sun Aug 9 18:04:26 2009 > @@ -41,6 +41,7 @@ > import org.ofbiz.base.util.UtilMisc; > import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericPK; > @@ -2406,7 +2407,7 @@ > if (UtilValidate.isEmpty(delegatorName)) { > throw new IllegalStateException("Bad delegator name"); > } > - delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > return delegator; > } > > Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > packing/PackingSession.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ > PackingSession.java (original) > +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ > PackingSession.java Sun Aug 9 18:04:26 2009 > @@ -35,6 +35,7 @@ > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilMisc; > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > @@ -500,7 +501,7 @@ > > public GenericDelegator getDelegator() { > if (_delegator == null) { > - _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > return _delegator; > } > > Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > verify/VerifyPickSession.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ > VerifyPickSession.java (original) > +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ > VerifyPickSession.java Sun Aug 9 18:04:26 2009 > @@ -32,6 +32,7 @@ > import org.ofbiz.base.util.UtilMisc; > import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > @@ -76,7 +77,7 @@ > > public GenericDelegator getDelegator() { > if (_delegator == null) { > - _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > return _delegator; > } > > Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > weightPackage/WeightPackageSession.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > weightPackage/WeightPackageSession.java (original) > +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ > weightPackage/WeightPackageSession.java Sun Aug 9 18:04:26 2009 > @@ -34,6 +34,7 @@ > import org.ofbiz.base.util.UtilNumber; > import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > @@ -102,7 +103,7 @@ > > public GenericDelegator getDelegator() { > if (_delegator == null) { > - _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > + _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > } > return _delegator; > } > > Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ > container/CatalinaContainer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ > CatalinaContainer.java (original) > +++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ > CatalinaContainer.java Sun Aug 9 18:04:26 2009 > @@ -36,6 +36,7 @@ > import org.ofbiz.base.container.ContainerException; > import org.ofbiz.base.container.ContainerConfig.Container.Property; > import org.ofbiz.base.util.*; > +import org.ofbiz.entity.DelegatorFactory; > import org.ofbiz.entity.GenericDelegator; > > import org.apache.catalina.Cluster; > @@ -168,7 +169,7 @@ > //int debug = ContainerConfig.getPropertyValue(cc, "debug", > 0); > > // grab some global context settings > - this.delegator = > GenericDelegator > .getGenericDelegator(ContainerConfig.getPropertyValue(cc, "delegator- > name", "default")); > + this.delegator = > DelegatorFactory > .getGenericDelegator(ContainerConfig.getPropertyValue(cc, "delegator- > name", "default")); > this.contextReloadable = > ContainerConfig.getPropertyValue(cc, "apps-context-reloadable", > false); > this.crossContext = ContainerConfig.getPropertyValue(cc, > "apps-cross-context", true); > this.distribute = ContainerConfig.getPropertyValue(cc, "apps- > distributable", true); > > Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java (added) > +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java Sun Aug 9 18:04:26 2009 > @@ -0,0 +1,110 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you 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. > + */ > +package org.ofbiz.entity; > + > +import java.util.Map; > + > +import javolution.util.FastMap; > + > +import org.ofbiz.base.util.Debug; > +import org.ofbiz.entity.cache.Cache; > +import org.ofbiz.entity.config.DelegatorInfo; > +import org.ofbiz.entity.config.EntityConfigUtil; > +import org.ofbiz.entity.eca.EntityEcaHandler; > +import org.ofbiz.entity.model.ModelGroupReader; > +import org.ofbiz.entity.model.ModelReader; > +import org.ofbiz.entity.util.DistributedCacheClear; > +import org.ofbiz.entity.util.EntityCrypto; > +import org.ofbiz.entity.util.SequenceUtil; > + > +/** Data source for the DelegatorImpl Class. */ > +public class DelegatorData implements Cloneable { > + > + public static final String module = > DelegatorData.class.getName(); > + /** > + * the delegatorDataCache will now be a HashMap, allowing > reload of > + * definitions, but the delegator will always be the same > object for the > + * given name > + */ > + protected static final Map<String, DelegatorData> > delegatorDataCache = FastMap.newInstance(); > + > + /** > + * keeps a list of field key sets used in the by and cache, a > Set (of Sets > + * of fieldNames) for each entityName > + */ > + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); > + protected Cache cache = null; > + protected EntityCrypto crypto = null; > + protected DelegatorInfo delegatorInfo = null; > + protected String delegatorName = null; > + protected DistributedCacheClear distributedCacheClear = null; > + protected EntityEcaHandler<?> entityEcaHandler = null; > + protected ModelGroupReader modelGroupReader = null; > + protected ModelReader modelReader = null; > + protected String originalDelegatorName = null; > + protected SequenceUtil sequencer = null; > + protected boolean initialized = false; > + > + public static synchronized DelegatorData getInstance(String > delegatorName) throws GenericEntityException { > + if (delegatorName == null) { > + delegatorName = "default"; > + Debug.logWarning(new Exception("Location where getting > delegator with null name"), "Got a getGenericDelegator call with a > null delegatorName, assuming \"default\" for the name.", module); > + } > + DelegatorData delegatorData = > delegatorDataCache.get(delegatorName); > + if (delegatorData == null) { > + if (Debug.infoOn()) { > + Debug.logInfo("Creating new delegator data instance > [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", > module); > + } > + delegatorData = new DelegatorData(delegatorName); > + delegatorDataCache.put(delegatorName, delegatorData); > + } > + return delegatorData; > + } > + > + /** Only allow creation through the factory method */ > + protected DelegatorData() { > + } > + > + /** Only allow creation through the factory method */ > + protected DelegatorData(String delegatorName) throws > GenericEntityException { > + this.delegatorName = delegatorName; > + this.originalDelegatorName = delegatorName; > + this.modelReader = ModelReader.getModelReader(delegatorName); > + this.modelGroupReader = > ModelGroupReader.getModelGroupReader(delegatorName); > + this.cache = new Cache(delegatorName); > + this.delegatorInfo = > EntityConfigUtil.getDelegatorInfo(this.delegatorName); > + } > + > + @Override > + protected Object clone() { > + DelegatorData delegatorData = new DelegatorData(); > + delegatorData.modelReader = this.modelReader; > + delegatorData.modelGroupReader = this.modelGroupReader; > + delegatorData.delegatorName = this.delegatorName; > + delegatorData.delegatorInfo = this.delegatorInfo; > + delegatorData.cache = this.cache; > + delegatorData.andCacheFieldSets = this.andCacheFieldSets; > + delegatorData.distributedCacheClear = > this.distributedCacheClear; > + delegatorData.originalDelegatorName = > this.originalDelegatorName; > + delegatorData.entityEcaHandler = this.entityEcaHandler; > + delegatorData.sequencer = this.sequencer; > + delegatorData.crypto = this.crypto; > + return delegatorData; > + } > +} > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java > ------------------------------------------------------------------------------ > svn:keywords = "Date Rev Author URL Id" > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorData.java > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java (added) > +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java Sun Aug 9 18:04:26 2009 > @@ -0,0 +1,44 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you 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. > + */ > +package org.ofbiz.entity; > + > +import org.ofbiz.base.util.Debug; > + > +/** GenericDelegator Factory Class. */ > +public class DelegatorFactory { > + > + public static final String module = > DelegatorFactory.class.getName(); > + > + public static GenericDelegator getGenericDelegator(String > delegatorName) { > + if (delegatorName == null) { > + delegatorName = "default"; > + Debug.logWarning(new Exception("Location where getting > delegator with null name"), "Got a getGenericDelegator call with a > null delegatorName, assuming default for the name.", module); > + } > + DelegatorData delegatorData = null; > + try { > + delegatorData = DelegatorData.getInstance(delegatorName); > + } catch (GenericEntityException e) { > + Debug.logError(e, "Could not create delegator with name > \"" + delegatorName + "\": ", module); > + } > + if (delegatorData != null) { > + return new DelegatorImpl(delegatorData); > + } > + return null; > + } > +} > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java > ------------------------------------------------------------------------------ > svn:keywords = "Date Rev Author URL Id" > > Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ > DelegatorFactory.java > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > |
I checked out the branch and examined it. After looking over your ideas,
I saw a way to make incremental changes to the trunk - negating the need for a branch. The GenericDelegator refactor was done for two reasons: 1. To eliminate the hundreds of references to a concrete class, that have caused inconvenience in the past. 2. Eliminate thread local variables and the cumbersome pushing and popping of the GenericDelegator state. How it relates to the ExecutionContext is, we have the ability to keep an instance in the GenericDelegator without having to create more thread local variables and have even more things to push/pop. It's a cleaner design. -Adrian David E Jones wrote: > > Adrian, > > What is all of this, and how does it relate to what I've been working on > in the executioncontext20090716 branch? > > It seems like this will: > > 1. cause some inconvenience now, while more comprehensive changes are > being made in the executioncontext20090716 branch > 2. make it a LOT more difficult (perhaps impossible) to merge the > executioncontext20090716 branch > > What is your plan with this? > > It would make life a lot easier for all of us if you would do some > research on what I've already done in the executioncontext20090716 > branch before continuing with this. > > -David > > > On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: > >> Author: adrianc >> Date: Sun Aug 9 18:04:26 2009 >> New Revision: 802567 >> >> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >> Log: >> Refactored GenericDelegator: >> >> 1. Converted GenericDelegator to an interface. We already have >> DelegatorInterface, but it isn't being used anywhere. Removed >> DelegatorInterface.java. >> >> 2. Extracted the static, cached data from the GenericDelegator >> implementation and put it in its own class - DelegatorData. The >> GenericDelegator implementation holds a reference to the DelegatorData >> instance. This makes it possible to have per-thread instances of >> GenericDelegator. >> >> 3. Replaced the ThreadLocal variables with regular variables. >> ThreadLocal variables are no longer needed. Client code doesn't need >> to be concerned with pushing and popping the GenericDelegator state. >> >> This commit paves the way for the forthcoming ExecutionContext. >> >> User modifications will have to replace >> GenericDelegator.getGenericDelegator(...) with >> DelegatorFactory.getGenericDelegator(...). Also, replace the push code >> with the new setXxx methods, and remove the pop code. If modifications >> used DelegatorInterface, replace that with GenericDelegator. >> >> Aside from those changes, this commit is backwards compatible. >> >> Added: >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> (with props) >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> (with props) >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java >> (with props) >> Removed: >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java >> Modified: >> >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >> >> >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >> >> >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >> >> >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >> >> >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >> >> >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >> >> >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java >> >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java >> >> >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java >> >> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java >> >> >> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java >> >> >> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java >> >> >> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/XuiContainer.java >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java >> >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java >> >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java >> >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java >> >> >> ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java >> >> >> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java >> >> >> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java >> >> >> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java >> >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java >> >> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/WebDavServlet.java >> >> >> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java >> >> >> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java >> >> >> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/AuditEntityObject.java >> >> >> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java >> >> >> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/InstanceEntityObject.java >> >> >> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/AbstractRequester.java >> >> >> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java >> >> >> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java >> >> >> Modified: >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >> (original) >> +++ >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >> Sun Aug 9 18:04:26 2009 >> @@ -28,6 +28,7 @@ >> import org.ofbiz.base.util.Debug; >> import org.ofbiz.base.util.UtilValidate; >> import org.ofbiz.webapp.stats.VisitHandler; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> @@ -58,7 +59,7 @@ >> String delegatorName = (String) >> session.getAttribute("delegatorName"); >> GenericDelegator delegator = null; >> if (UtilValidate.isNotEmpty(delegatorName)) { >> - delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> if (delegator == null) { >> Debug.logError("Could not find delegator with >> delegatorName in session, not saving abandoned cart info.", module); >> >> Modified: >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >> (original) >> +++ >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >> Sun Aug 9 18:04:26 2009 >> @@ -21,6 +21,7 @@ >> import javolution.util.FastList; >> import javolution.util.FastMap; >> import org.ofbiz.base.util.*; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericPK; >> @@ -275,7 +276,7 @@ >> >> public GenericDelegator getDelegator() { >> if (delegator == null) { >> - delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> return delegator; >> } >> >> Modified: >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >> (original) >> +++ >> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >> Sun Aug 9 18:04:26 2009 >> @@ -41,6 +41,7 @@ >> import org.ofbiz.base.util.UtilMisc; >> import org.ofbiz.base.util.UtilProperties; >> import org.ofbiz.base.util.UtilValidate; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericPK; >> @@ -2406,7 +2407,7 @@ >> if (UtilValidate.isEmpty(delegatorName)) { >> throw new IllegalStateException("Bad delegator name"); >> } >> - delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> return delegator; >> } >> >> Modified: >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >> (original) >> +++ >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >> Sun Aug 9 18:04:26 2009 >> @@ -35,6 +35,7 @@ >> import org.ofbiz.base.util.UtilFormatOut; >> import org.ofbiz.base.util.UtilMisc; >> import org.ofbiz.base.util.UtilValidate; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> @@ -500,7 +501,7 @@ >> >> public GenericDelegator getDelegator() { >> if (_delegator == null) { >> - _delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + _delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> return _delegator; >> } >> >> Modified: >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >> (original) >> +++ >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >> Sun Aug 9 18:04:26 2009 >> @@ -32,6 +32,7 @@ >> import org.ofbiz.base.util.UtilMisc; >> import org.ofbiz.base.util.UtilProperties; >> import org.ofbiz.base.util.UtilValidate; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> @@ -76,7 +77,7 @@ >> >> public GenericDelegator getDelegator() { >> if (_delegator == null) { >> - _delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + _delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> return _delegator; >> } >> >> Modified: >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >> (original) >> +++ >> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >> Sun Aug 9 18:04:26 2009 >> @@ -34,6 +34,7 @@ >> import org.ofbiz.base.util.UtilNumber; >> import org.ofbiz.base.util.UtilProperties; >> import org.ofbiz.base.util.UtilValidate; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> @@ -102,7 +103,7 @@ >> >> public GenericDelegator getDelegator() { >> if (_delegator == null) { >> - _delegator = >> GenericDelegator.getGenericDelegator(delegatorName); >> + _delegator = >> DelegatorFactory.getGenericDelegator(delegatorName); >> } >> return _delegator; >> } >> >> Modified: >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >> >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> (original) >> +++ >> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >> Sun Aug 9 18:04:26 2009 >> @@ -36,6 +36,7 @@ >> import org.ofbiz.base.container.ContainerException; >> import org.ofbiz.base.container.ContainerConfig.Container.Property; >> import org.ofbiz.base.util.*; >> +import org.ofbiz.entity.DelegatorFactory; >> import org.ofbiz.entity.GenericDelegator; >> >> import org.apache.catalina.Cluster; >> @@ -168,7 +169,7 @@ >> //int debug = ContainerConfig.getPropertyValue(cc, "debug", 0); >> >> // grab some global context settings >> - this.delegator = >> GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >> "delegator-name", "default")); >> + this.delegator = >> DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >> "delegator-name", "default")); >> this.contextReloadable = ContainerConfig.getPropertyValue(cc, >> "apps-context-reloadable", false); >> this.crossContext = ContainerConfig.getPropertyValue(cc, >> "apps-cross-context", true); >> this.distribute = ContainerConfig.getPropertyValue(cc, >> "apps-distributable", true); >> >> Added: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >> >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> (added) >> +++ >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> Sun Aug 9 18:04:26 2009 >> @@ -0,0 +1,110 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one >> + * or more contributor license agreements. See the NOTICE file >> + * distributed with this work for additional information >> + * regarding copyright ownership. The ASF licenses this file >> + * to you 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. >> + */ >> +package org.ofbiz.entity; >> + >> +import java.util.Map; >> + >> +import javolution.util.FastMap; >> + >> +import org.ofbiz.base.util.Debug; >> +import org.ofbiz.entity.cache.Cache; >> +import org.ofbiz.entity.config.DelegatorInfo; >> +import org.ofbiz.entity.config.EntityConfigUtil; >> +import org.ofbiz.entity.eca.EntityEcaHandler; >> +import org.ofbiz.entity.model.ModelGroupReader; >> +import org.ofbiz.entity.model.ModelReader; >> +import org.ofbiz.entity.util.DistributedCacheClear; >> +import org.ofbiz.entity.util.EntityCrypto; >> +import org.ofbiz.entity.util.SequenceUtil; >> + >> +/** Data source for the DelegatorImpl Class. */ >> +public class DelegatorData implements Cloneable { >> + >> + public static final String module = DelegatorData.class.getName(); >> + /** >> + * the delegatorDataCache will now be a HashMap, allowing reload of >> + * definitions, but the delegator will always be the same object >> for the >> + * given name >> + */ >> + protected static final Map<String, DelegatorData> >> delegatorDataCache = FastMap.newInstance(); >> + >> + /** >> + * keeps a list of field key sets used in the by and cache, a Set >> (of Sets >> + * of fieldNames) for each entityName >> + */ >> + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); >> + protected Cache cache = null; >> + protected EntityCrypto crypto = null; >> + protected DelegatorInfo delegatorInfo = null; >> + protected String delegatorName = null; >> + protected DistributedCacheClear distributedCacheClear = null; >> + protected EntityEcaHandler<?> entityEcaHandler = null; >> + protected ModelGroupReader modelGroupReader = null; >> + protected ModelReader modelReader = null; >> + protected String originalDelegatorName = null; >> + protected SequenceUtil sequencer = null; >> + protected boolean initialized = false; >> + >> + public static synchronized DelegatorData getInstance(String >> delegatorName) throws GenericEntityException { >> + if (delegatorName == null) { >> + delegatorName = "default"; >> + Debug.logWarning(new Exception("Location where getting >> delegator with null name"), "Got a getGenericDelegator call with a >> null delegatorName, assuming \"default\" for the name.", module); >> + } >> + DelegatorData delegatorData = >> delegatorDataCache.get(delegatorName); >> + if (delegatorData == null) { >> + if (Debug.infoOn()) { >> + Debug.logInfo("Creating new delegator data instance >> [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", >> module); >> + } >> + delegatorData = new DelegatorData(delegatorName); >> + delegatorDataCache.put(delegatorName, delegatorData); >> + } >> + return delegatorData; >> + } >> + >> + /** Only allow creation through the factory method */ >> + protected DelegatorData() { >> + } >> + >> + /** Only allow creation through the factory method */ >> + protected DelegatorData(String delegatorName) throws >> GenericEntityException { >> + this.delegatorName = delegatorName; >> + this.originalDelegatorName = delegatorName; >> + this.modelReader = ModelReader.getModelReader(delegatorName); >> + this.modelGroupReader = >> ModelGroupReader.getModelGroupReader(delegatorName); >> + this.cache = new Cache(delegatorName); >> + this.delegatorInfo = >> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >> + } >> + >> + @Override >> + protected Object clone() { >> + DelegatorData delegatorData = new DelegatorData(); >> + delegatorData.modelReader = this.modelReader; >> + delegatorData.modelGroupReader = this.modelGroupReader; >> + delegatorData.delegatorName = this.delegatorName; >> + delegatorData.delegatorInfo = this.delegatorInfo; >> + delegatorData.cache = this.cache; >> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >> + delegatorData.distributedCacheClear = >> this.distributedCacheClear; >> + delegatorData.originalDelegatorName = >> this.originalDelegatorName; >> + delegatorData.entityEcaHandler = this.entityEcaHandler; >> + delegatorData.sequencer = this.sequencer; >> + delegatorData.crypto = this.crypto; >> + return delegatorData; >> + } >> +} >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> ------------------------------------------------------------------------------ >> >> svn:eol-style = native >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> ------------------------------------------------------------------------------ >> >> svn:keywords = "Date Rev Author URL Id" >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >> ------------------------------------------------------------------------------ >> >> svn:mime-type = text/plain >> >> Added: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >> >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> (added) >> +++ >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> Sun Aug 9 18:04:26 2009 >> @@ -0,0 +1,44 @@ >> +/* >> + * Licensed to the Apache Software Foundation (ASF) under one >> + * or more contributor license agreements. See the NOTICE file >> + * distributed with this work for additional information >> + * regarding copyright ownership. The ASF licenses this file >> + * to you 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. >> + */ >> +package org.ofbiz.entity; >> + >> +import org.ofbiz.base.util.Debug; >> + >> +/** GenericDelegator Factory Class. */ >> +public class DelegatorFactory { >> + >> + public static final String module = >> DelegatorFactory.class.getName(); >> + >> + public static GenericDelegator getGenericDelegator(String >> delegatorName) { >> + if (delegatorName == null) { >> + delegatorName = "default"; >> + Debug.logWarning(new Exception("Location where getting >> delegator with null name"), "Got a getGenericDelegator call with a >> null delegatorName, assuming default for the name.", module); >> + } >> + DelegatorData delegatorData = null; >> + try { >> + delegatorData = DelegatorData.getInstance(delegatorName); >> + } catch (GenericEntityException e) { >> + Debug.logError(e, "Could not create delegator with name >> \"" + delegatorName + "\": ", module); >> + } >> + if (delegatorData != null) { >> + return new DelegatorImpl(delegatorData); >> + } >> + return null; >> + } >> +} >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> ------------------------------------------------------------------------------ >> >> svn:eol-style = native >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> ------------------------------------------------------------------------------ >> >> svn:keywords = "Date Rev Author URL Id" >> >> Propchange: >> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >> ------------------------------------------------------------------------------ >> >> svn:mime-type = text/plain >> >> > > |
I would repository not be a battle ground for conflicting designs, if
David started the work first then that work should be discussed fully before just dumping code into the trunk that conflicts with what he's already done in the branch (even if it is in your opinion cleaner). Regards Scott On 11/08/2009, at 10:42 AM, Adrian Crum wrote: > I checked out the branch and examined it. After looking over your > ideas, I saw a way to make incremental changes to the trunk - > negating the need for a branch. > > The GenericDelegator refactor was done for two reasons: > > 1. To eliminate the hundreds of references to a concrete class, that > have caused inconvenience in the past. > 2. Eliminate thread local variables and the cumbersome pushing and > popping of the GenericDelegator state. > > How it relates to the ExecutionContext is, we have the ability to > keep an instance in the GenericDelegator without having to create > more thread local variables and have even more things to push/pop. > > It's a cleaner design. > > -Adrian > > David E Jones wrote: >> Adrian, >> What is all of this, and how does it relate to what I've been >> working on in the executioncontext20090716 branch? >> It seems like this will: >> 1. cause some inconvenience now, while more comprehensive changes >> are being made in the executioncontext20090716 branch >> 2. make it a LOT more difficult (perhaps impossible) to merge the >> executioncontext20090716 branch >> What is your plan with this? >> It would make life a lot easier for all of us if you would do some >> research on what I've already done in the executioncontext20090716 >> branch before continuing with this. >> -David >> On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: >>> Author: adrianc >>> Date: Sun Aug 9 18:04:26 2009 >>> New Revision: 802567 >>> >>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >>> Log: >>> Refactored GenericDelegator: >>> >>> 1. Converted GenericDelegator to an interface. We already have >>> DelegatorInterface, but it isn't being used anywhere. Removed >>> DelegatorInterface.java. >>> >>> 2. Extracted the static, cached data from the GenericDelegator >>> implementation and put it in its own class - DelegatorData. The >>> GenericDelegator implementation holds a reference to the >>> DelegatorData instance. This makes it possible to have per-thread >>> instances of GenericDelegator. >>> >>> 3. Replaced the ThreadLocal variables with regular variables. >>> ThreadLocal variables are no longer needed. Client code doesn't >>> need to be concerned with pushing and popping the GenericDelegator >>> state. >>> >>> This commit paves the way for the forthcoming ExecutionContext. >>> >>> User modifications will have to replace >>> GenericDelegator.getGenericDelegator(...) with >>> DelegatorFactory.getGenericDelegator(...). Also, replace the push >>> code with the new setXxx methods, and remove the pop code. If >>> modifications used DelegatorInterface, replace that with >>> GenericDelegator. >>> >>> Aside from those changes, this commit is backwards compatible. >>> >>> Added: >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java (with props) >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java (with props) >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorImpl.java (with props) >>> Removed: >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorInterface.java >>> Modified: >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> CartEventListener.java >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> ShoppingCart.java >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> ShoppingCartItem.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ >>> PackingSession.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java >>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ >>> CatalinaContainer.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> GenericDelegator.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> GenericEntity.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/ >>> AbstractCache.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/ >>> EntityExpr.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ >>> ListFinder.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/ >>> EntityDataLoadContainer.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>> synchronization/EntitySyncContext.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>> synchronization/EntitySyncServices.java >>> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/ >>> XuiContainer.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/EntityCount.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/EntityData.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/FindByAnd.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/FindByPrimaryKey.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/ >>> ServiceDispatcher.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/ >>> JavaMailContainer.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ >>> RmiServiceContainer.java >>> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ >>> ModelTestSuite.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> ContextFilter.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> ControlServlet.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> RequestHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> CoreEvents.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> ServiceStreamHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> XmlRpcEventHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>> ServerHitBin.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>> VisitHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/ >>> WebDavServlet.java >>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ >>> WebslingerContextMapper.java >>> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/ >>> WebToolsServices.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/ >>> AuditEntityObject.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/ >>> SharkContainer.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/ >>> InstanceEntityObject.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/ >>> AbstractRequester.java >>> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/ >>> WebPosSession.java >>> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/ >>> definition/XpdlReader.java >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java Sun Aug 9 18:04:26 2009 >>> @@ -28,6 +28,7 @@ >>> import org.ofbiz.base.util.Debug; >>> import org.ofbiz.base.util.UtilValidate; >>> import org.ofbiz.webapp.stats.VisitHandler; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -58,7 +59,7 @@ >>> String delegatorName = (String) >>> session.getAttribute("delegatorName"); >>> GenericDelegator delegator = null; >>> if (UtilValidate.isNotEmpty(delegatorName)) { >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> if (delegator == null) { >>> Debug.logError("Could not find delegator with >>> delegatorName in session, not saving abandoned cart info.", module); >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java Sun Aug 9 18:04:26 2009 >>> @@ -21,6 +21,7 @@ >>> import javolution.util.FastList; >>> import javolution.util.FastMap; >>> import org.ofbiz.base.util.*; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericPK; >>> @@ -275,7 +276,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (delegator == null) { >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java Sun Aug 9 18:04:26 2009 >>> @@ -41,6 +41,7 @@ >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericPK; >>> @@ -2406,7 +2407,7 @@ >>> if (UtilValidate.isEmpty(delegatorName)) { >>> throw new IllegalStateException("Bad delegator >>> name"); >>> } >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java Sun Aug 9 18:04:26 2009 >>> @@ -35,6 +35,7 @@ >>> import org.ofbiz.base.util.UtilFormatOut; >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -500,7 +501,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> verify/VerifyPickSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java Sun Aug 9 18:04:26 2009 >>> @@ -32,6 +32,7 @@ >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -76,7 +77,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java Sun Aug 9 18:04:26 2009 >>> @@ -34,6 +34,7 @@ >>> import org.ofbiz.base.util.UtilNumber; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -102,7 +103,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java (original) >>> +++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java Sun Aug 9 18:04:26 2009 >>> @@ -36,6 +36,7 @@ >>> import org.ofbiz.base.container.ContainerException; >>> import org.ofbiz.base.container.ContainerConfig.Container.Property; >>> import org.ofbiz.base.util.*; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> >>> import org.apache.catalina.Cluster; >>> @@ -168,7 +169,7 @@ >>> //int debug = ContainerConfig.getPropertyValue(cc, "debug", >>> 0); >>> >>> // grab some global context settings >>> - this.delegator = >>> GenericDelegator >>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>> "delegator-name", "default")); >>> + this.delegator = >>> DelegatorFactory >>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>> "delegator-name", "default")); >>> this.contextReloadable = >>> ContainerConfig.getPropertyValue(cc, "apps-context-reloadable", >>> false); >>> this.crossContext = ContainerConfig.getPropertyValue(cc, >>> "apps-cross-context", true); >>> this.distribute = ContainerConfig.getPropertyValue(cc, >>> "apps-distributable", true); >>> >>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java (added) >>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java Sun Aug 9 18:04:26 2009 >>> @@ -0,0 +1,110 @@ >>> +/* >>> + * Licensed to the Apache Software Foundation (ASF) under one >>> + * or more contributor license agreements. See the NOTICE file >>> + * distributed with this work for additional information >>> + * regarding copyright ownership. The ASF licenses this file >>> + * to you 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. >>> + */ >>> +package org.ofbiz.entity; >>> + >>> +import java.util.Map; >>> + >>> +import javolution.util.FastMap; >>> + >>> +import org.ofbiz.base.util.Debug; >>> +import org.ofbiz.entity.cache.Cache; >>> +import org.ofbiz.entity.config.DelegatorInfo; >>> +import org.ofbiz.entity.config.EntityConfigUtil; >>> +import org.ofbiz.entity.eca.EntityEcaHandler; >>> +import org.ofbiz.entity.model.ModelGroupReader; >>> +import org.ofbiz.entity.model.ModelReader; >>> +import org.ofbiz.entity.util.DistributedCacheClear; >>> +import org.ofbiz.entity.util.EntityCrypto; >>> +import org.ofbiz.entity.util.SequenceUtil; >>> + >>> +/** Data source for the DelegatorImpl Class. */ >>> +public class DelegatorData implements Cloneable { >>> + >>> + public static final String module = >>> DelegatorData.class.getName(); >>> + /** >>> + * the delegatorDataCache will now be a HashMap, allowing >>> reload of >>> + * definitions, but the delegator will always be the same >>> object for the >>> + * given name >>> + */ >>> + protected static final Map<String, DelegatorData> >>> delegatorDataCache = FastMap.newInstance(); >>> + >>> + /** >>> + * keeps a list of field key sets used in the by and cache, a >>> Set (of Sets >>> + * of fieldNames) for each entityName >>> + */ >>> + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); >>> + protected Cache cache = null; >>> + protected EntityCrypto crypto = null; >>> + protected DelegatorInfo delegatorInfo = null; >>> + protected String delegatorName = null; >>> + protected DistributedCacheClear distributedCacheClear = null; >>> + protected EntityEcaHandler<?> entityEcaHandler = null; >>> + protected ModelGroupReader modelGroupReader = null; >>> + protected ModelReader modelReader = null; >>> + protected String originalDelegatorName = null; >>> + protected SequenceUtil sequencer = null; >>> + protected boolean initialized = false; >>> + >>> + public static synchronized DelegatorData getInstance(String >>> delegatorName) throws GenericEntityException { >>> + if (delegatorName == null) { >>> + delegatorName = "default"; >>> + Debug.logWarning(new Exception("Location where >>> getting delegator with null name"), "Got a getGenericDelegator >>> call with a null delegatorName, assuming \"default\" for the >>> name.", module); >>> + } >>> + DelegatorData delegatorData = >>> delegatorDataCache.get(delegatorName); >>> + if (delegatorData == null) { >>> + if (Debug.infoOn()) { >>> + Debug.logInfo("Creating new delegator data >>> instance [" + delegatorName + "] (" + >>> Thread.currentThread().getName() + ")", module); >>> + } >>> + delegatorData = new DelegatorData(delegatorName); >>> + delegatorDataCache.put(delegatorName, delegatorData); >>> + } >>> + return delegatorData; >>> + } >>> + >>> + /** Only allow creation through the factory method */ >>> + protected DelegatorData() { >>> + } >>> + >>> + /** Only allow creation through the factory method */ >>> + protected DelegatorData(String delegatorName) throws >>> GenericEntityException { >>> + this.delegatorName = delegatorName; >>> + this.originalDelegatorName = delegatorName; >>> + this.modelReader = >>> ModelReader.getModelReader(delegatorName); >>> + this.modelGroupReader = >>> ModelGroupReader.getModelGroupReader(delegatorName); >>> + this.cache = new Cache(delegatorName); >>> + this.delegatorInfo = >>> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >>> + } >>> + >>> + @Override >>> + protected Object clone() { >>> + DelegatorData delegatorData = new DelegatorData(); >>> + delegatorData.modelReader = this.modelReader; >>> + delegatorData.modelGroupReader = this.modelGroupReader; >>> + delegatorData.delegatorName = this.delegatorName; >>> + delegatorData.delegatorInfo = this.delegatorInfo; >>> + delegatorData.cache = this.cache; >>> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >>> + delegatorData.distributedCacheClear = >>> this.distributedCacheClear; >>> + delegatorData.originalDelegatorName = >>> this.originalDelegatorName; >>> + delegatorData.entityEcaHandler = this.entityEcaHandler; >>> + delegatorData.sequencer = this.sequencer; >>> + delegatorData.crypto = this.crypto; >>> + return delegatorData; >>> + } >>> +} >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:keywords = "Date Rev Author URL Id" >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java (added) >>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java Sun Aug 9 18:04:26 2009 >>> @@ -0,0 +1,44 @@ >>> +/* >>> + * Licensed to the Apache Software Foundation (ASF) under one >>> + * or more contributor license agreements. See the NOTICE file >>> + * distributed with this work for additional information >>> + * regarding copyright ownership. The ASF licenses this file >>> + * to you 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. >>> + */ >>> +package org.ofbiz.entity; >>> + >>> +import org.ofbiz.base.util.Debug; >>> + >>> +/** GenericDelegator Factory Class. */ >>> +public class DelegatorFactory { >>> + >>> + public static final String module = >>> DelegatorFactory.class.getName(); >>> + >>> + public static GenericDelegator getGenericDelegator(String >>> delegatorName) { >>> + if (delegatorName == null) { >>> + delegatorName = "default"; >>> + Debug.logWarning(new Exception("Location where >>> getting delegator with null name"), "Got a getGenericDelegator >>> call with a null delegatorName, assuming default for the name.", >>> module); >>> + } >>> + DelegatorData delegatorData = null; >>> + try { >>> + delegatorData = >>> DelegatorData.getInstance(delegatorName); >>> + } catch (GenericEntityException e) { >>> + Debug.logError(e, "Could not create delegator with >>> name \"" + delegatorName + "\": ", module); >>> + } >>> + if (delegatorData != null) { >>> + return new DelegatorImpl(delegatorData); >>> + } >>> + return null; >>> + } >>> +} >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:keywords = "Date Rev Author URL Id" >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> smime.p7s (3K) Download Attachment |
I don't see it as a battleground. The changes I made have benefit
outside the work David is doing in the branch. -Adrian Scott Gray wrote: > I would repository not be a battle ground for conflicting designs, if > David started the work first then that work should be discussed fully > before just dumping code into the trunk that conflicts with what he's > already done in the branch (even if it is in your opinion cleaner). > > Regards > Scott > > On 11/08/2009, at 10:42 AM, Adrian Crum wrote: > >> I checked out the branch and examined it. After looking over your >> ideas, I saw a way to make incremental changes to the trunk - negating >> the need for a branch. >> >> The GenericDelegator refactor was done for two reasons: >> >> 1. To eliminate the hundreds of references to a concrete class, that >> have caused inconvenience in the past. >> 2. Eliminate thread local variables and the cumbersome pushing and >> popping of the GenericDelegator state. >> >> How it relates to the ExecutionContext is, we have the ability to keep >> an instance in the GenericDelegator without having to create more >> thread local variables and have even more things to push/pop. >> >> It's a cleaner design. >> >> -Adrian >> >> David E Jones wrote: >>> Adrian, >>> What is all of this, and how does it relate to what I've been working >>> on in the executioncontext20090716 branch? >>> It seems like this will: >>> 1. cause some inconvenience now, while more comprehensive changes are >>> being made in the executioncontext20090716 branch >>> 2. make it a LOT more difficult (perhaps impossible) to merge the >>> executioncontext20090716 branch >>> What is your plan with this? >>> It would make life a lot easier for all of us if you would do some >>> research on what I've already done in the executioncontext20090716 >>> branch before continuing with this. >>> -David >>> On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: >>>> Author: adrianc >>>> Date: Sun Aug 9 18:04:26 2009 >>>> New Revision: 802567 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >>>> Log: >>>> Refactored GenericDelegator: >>>> >>>> 1. Converted GenericDelegator to an interface. We already have >>>> DelegatorInterface, but it isn't being used anywhere. Removed >>>> DelegatorInterface.java. >>>> >>>> 2. Extracted the static, cached data from the GenericDelegator >>>> implementation and put it in its own class - DelegatorData. The >>>> GenericDelegator implementation holds a reference to the >>>> DelegatorData instance. This makes it possible to have per-thread >>>> instances of GenericDelegator. >>>> >>>> 3. Replaced the ThreadLocal variables with regular variables. >>>> ThreadLocal variables are no longer needed. Client code doesn't need >>>> to be concerned with pushing and popping the GenericDelegator state. >>>> >>>> This commit paves the way for the forthcoming ExecutionContext. >>>> >>>> User modifications will have to replace >>>> GenericDelegator.getGenericDelegator(...) with >>>> DelegatorFactory.getGenericDelegator(...). Also, replace the push >>>> code with the new setXxx methods, and remove the pop code. If >>>> modifications used DelegatorInterface, replace that with >>>> GenericDelegator. >>>> >>>> Aside from those changes, this commit is backwards compatible. >>>> >>>> Added: >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> (with props) >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> (with props) >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java >>>> (with props) >>>> Removed: >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java >>>> >>>> Modified: >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> >>>> >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java >>>> >>>> >>>> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/XuiContainer.java >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/WebDavServlet.java >>>> >>>> >>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java >>>> >>>> >>>> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/AuditEntityObject.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/InstanceEntityObject.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/AbstractRequester.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java >>>> >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -28,6 +28,7 @@ >>>> import org.ofbiz.base.util.Debug; >>>> import org.ofbiz.base.util.UtilValidate; >>>> import org.ofbiz.webapp.stats.VisitHandler; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -58,7 +59,7 @@ >>>> String delegatorName = (String) >>>> session.getAttribute("delegatorName"); >>>> GenericDelegator delegator = null; >>>> if (UtilValidate.isNotEmpty(delegatorName)) { >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> if (delegator == null) { >>>> Debug.logError("Could not find delegator with >>>> delegatorName in session, not saving abandoned cart info.", module); >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -21,6 +21,7 @@ >>>> import javolution.util.FastList; >>>> import javolution.util.FastMap; >>>> import org.ofbiz.base.util.*; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericPK; >>>> @@ -275,7 +276,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (delegator == null) { >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -41,6 +41,7 @@ >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericPK; >>>> @@ -2406,7 +2407,7 @@ >>>> if (UtilValidate.isEmpty(delegatorName)) { >>>> throw new IllegalStateException("Bad delegator name"); >>>> } >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -35,6 +35,7 @@ >>>> import org.ofbiz.base.util.UtilFormatOut; >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -500,7 +501,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -32,6 +32,7 @@ >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -76,7 +77,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -34,6 +34,7 @@ >>>> import org.ofbiz.base.util.UtilNumber; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -102,7 +103,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -36,6 +36,7 @@ >>>> import org.ofbiz.base.container.ContainerException; >>>> import org.ofbiz.base.container.ContainerConfig.Container.Property; >>>> import org.ofbiz.base.util.*; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> >>>> import org.apache.catalina.Cluster; >>>> @@ -168,7 +169,7 @@ >>>> //int debug = ContainerConfig.getPropertyValue(cc, "debug", 0); >>>> >>>> // grab some global context settings >>>> - this.delegator = >>>> GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>> "delegator-name", "default")); >>>> + this.delegator = >>>> DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>> "delegator-name", "default")); >>>> this.contextReloadable = ContainerConfig.getPropertyValue(cc, >>>> "apps-context-reloadable", false); >>>> this.crossContext = ContainerConfig.getPropertyValue(cc, >>>> "apps-cross-context", true); >>>> this.distribute = ContainerConfig.getPropertyValue(cc, >>>> "apps-distributable", true); >>>> >>>> Added: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> (added) >>>> +++ >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -0,0 +1,110 @@ >>>> +/* >>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>> + * or more contributor license agreements. See the NOTICE file >>>> + * distributed with this work for additional information >>>> + * regarding copyright ownership. The ASF licenses this file >>>> + * to you 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. >>>> + */ >>>> +package org.ofbiz.entity; >>>> + >>>> +import java.util.Map; >>>> + >>>> +import javolution.util.FastMap; >>>> + >>>> +import org.ofbiz.base.util.Debug; >>>> +import org.ofbiz.entity.cache.Cache; >>>> +import org.ofbiz.entity.config.DelegatorInfo; >>>> +import org.ofbiz.entity.config.EntityConfigUtil; >>>> +import org.ofbiz.entity.eca.EntityEcaHandler; >>>> +import org.ofbiz.entity.model.ModelGroupReader; >>>> +import org.ofbiz.entity.model.ModelReader; >>>> +import org.ofbiz.entity.util.DistributedCacheClear; >>>> +import org.ofbiz.entity.util.EntityCrypto; >>>> +import org.ofbiz.entity.util.SequenceUtil; >>>> + >>>> +/** Data source for the DelegatorImpl Class. */ >>>> +public class DelegatorData implements Cloneable { >>>> + >>>> + public static final String module = DelegatorData.class.getName(); >>>> + /** >>>> + * the delegatorDataCache will now be a HashMap, allowing >>>> reload of >>>> + * definitions, but the delegator will always be the same >>>> object for the >>>> + * given name >>>> + */ >>>> + protected static final Map<String, DelegatorData> >>>> delegatorDataCache = FastMap.newInstance(); >>>> + >>>> + /** >>>> + * keeps a list of field key sets used in the by and cache, a >>>> Set (of Sets >>>> + * of fieldNames) for each entityName >>>> + */ >>>> + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); >>>> + protected Cache cache = null; >>>> + protected EntityCrypto crypto = null; >>>> + protected DelegatorInfo delegatorInfo = null; >>>> + protected String delegatorName = null; >>>> + protected DistributedCacheClear distributedCacheClear = null; >>>> + protected EntityEcaHandler<?> entityEcaHandler = null; >>>> + protected ModelGroupReader modelGroupReader = null; >>>> + protected ModelReader modelReader = null; >>>> + protected String originalDelegatorName = null; >>>> + protected SequenceUtil sequencer = null; >>>> + protected boolean initialized = false; >>>> + >>>> + public static synchronized DelegatorData getInstance(String >>>> delegatorName) throws GenericEntityException { >>>> + if (delegatorName == null) { >>>> + delegatorName = "default"; >>>> + Debug.logWarning(new Exception("Location where getting >>>> delegator with null name"), "Got a getGenericDelegator call with a >>>> null delegatorName, assuming \"default\" for the name.", module); >>>> + } >>>> + DelegatorData delegatorData = >>>> delegatorDataCache.get(delegatorName); >>>> + if (delegatorData == null) { >>>> + if (Debug.infoOn()) { >>>> + Debug.logInfo("Creating new delegator data instance >>>> [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", >>>> module); >>>> + } >>>> + delegatorData = new DelegatorData(delegatorName); >>>> + delegatorDataCache.put(delegatorName, delegatorData); >>>> + } >>>> + return delegatorData; >>>> + } >>>> + >>>> + /** Only allow creation through the factory method */ >>>> + protected DelegatorData() { >>>> + } >>>> + >>>> + /** Only allow creation through the factory method */ >>>> + protected DelegatorData(String delegatorName) throws >>>> GenericEntityException { >>>> + this.delegatorName = delegatorName; >>>> + this.originalDelegatorName = delegatorName; >>>> + this.modelReader = ModelReader.getModelReader(delegatorName); >>>> + this.modelGroupReader = >>>> ModelGroupReader.getModelGroupReader(delegatorName); >>>> + this.cache = new Cache(delegatorName); >>>> + this.delegatorInfo = >>>> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >>>> + } >>>> + >>>> + @Override >>>> + protected Object clone() { >>>> + DelegatorData delegatorData = new DelegatorData(); >>>> + delegatorData.modelReader = this.modelReader; >>>> + delegatorData.modelGroupReader = this.modelGroupReader; >>>> + delegatorData.delegatorName = this.delegatorName; >>>> + delegatorData.delegatorInfo = this.delegatorInfo; >>>> + delegatorData.cache = this.cache; >>>> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >>>> + delegatorData.distributedCacheClear = >>>> this.distributedCacheClear; >>>> + delegatorData.originalDelegatorName = >>>> this.originalDelegatorName; >>>> + delegatorData.entityEcaHandler = this.entityEcaHandler; >>>> + delegatorData.sequencer = this.sequencer; >>>> + delegatorData.crypto = this.crypto; >>>> + return delegatorData; >>>> + } >>>> +} >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:keywords = "Date Rev Author URL Id" >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:mime-type = text/plain >>>> >>>> Added: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> (added) >>>> +++ >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -0,0 +1,44 @@ >>>> +/* >>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>> + * or more contributor license agreements. See the NOTICE file >>>> + * distributed with this work for additional information >>>> + * regarding copyright ownership. The ASF licenses this file >>>> + * to you 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. >>>> + */ >>>> +package org.ofbiz.entity; >>>> + >>>> +import org.ofbiz.base.util.Debug; >>>> + >>>> +/** GenericDelegator Factory Class. */ >>>> +public class DelegatorFactory { >>>> + >>>> + public static final String module = >>>> DelegatorFactory.class.getName(); >>>> + >>>> + public static GenericDelegator getGenericDelegator(String >>>> delegatorName) { >>>> + if (delegatorName == null) { >>>> + delegatorName = "default"; >>>> + Debug.logWarning(new Exception("Location where getting >>>> delegator with null name"), "Got a getGenericDelegator call with a >>>> null delegatorName, assuming default for the name.", module); >>>> + } >>>> + DelegatorData delegatorData = null; >>>> + try { >>>> + delegatorData = DelegatorData.getInstance(delegatorName); >>>> + } catch (GenericEntityException e) { >>>> + Debug.logError(e, "Could not create delegator with name >>>> \"" + delegatorName + "\": ", module); >>>> + } >>>> + if (delegatorData != null) { >>>> + return new DelegatorImpl(delegatorData); >>>> + } >>>> + return null; >>>> + } >>>> +} >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:keywords = "Date Rev Author URL Id" >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:mime-type = text/plain >>>> >>>> > |
In reply to this post by Adrian Crum
Yes, that's why I did a similar thing in the branch. Stepping back a little... please keep in mind that the interface will not be able to stay in the entity component. Part of the point of making these interfaces is so that we can have a ExecutionContext that knows certain things about a number of framework components without actually depending on those components at compile time. Instead with the interfaces in the execution context component all of the other components can depend on and share that. Without that pattern it will be impossible to implement the execution context. As part of that, I'd rather do them all together rather than separately otherwise (like I mentioned before) merging the branch will become difficult. In fact, even with the changes you've already added to the trunk the merge is already a HUGE mess... (ie just updating the branch against the trunk). -David On Aug 10, 2009, at 4:42 PM, Adrian Crum wrote: > I checked out the branch and examined it. After looking over your > ideas, I saw a way to make incremental changes to the trunk - > negating the need for a branch. > > The GenericDelegator refactor was done for two reasons: > > 1. To eliminate the hundreds of references to a concrete class, that > have caused inconvenience in the past. > 2. Eliminate thread local variables and the cumbersome pushing and > popping of the GenericDelegator state. > > How it relates to the ExecutionContext is, we have the ability to > keep an instance in the GenericDelegator without having to create > more thread local variables and have even more things to push/pop. > > It's a cleaner design. > > -Adrian > > David E Jones wrote: >> Adrian, >> What is all of this, and how does it relate to what I've been >> working on in the executioncontext20090716 branch? >> It seems like this will: >> 1. cause some inconvenience now, while more comprehensive changes >> are being made in the executioncontext20090716 branch >> 2. make it a LOT more difficult (perhaps impossible) to merge the >> executioncontext20090716 branch >> What is your plan with this? >> It would make life a lot easier for all of us if you would do some >> research on what I've already done in the executioncontext20090716 >> branch before continuing with this. >> -David >> On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: >>> Author: adrianc >>> Date: Sun Aug 9 18:04:26 2009 >>> New Revision: 802567 >>> >>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >>> Log: >>> Refactored GenericDelegator: >>> >>> 1. Converted GenericDelegator to an interface. We already have >>> DelegatorInterface, but it isn't being used anywhere. Removed >>> DelegatorInterface.java. >>> >>> 2. Extracted the static, cached data from the GenericDelegator >>> implementation and put it in its own class - DelegatorData. The >>> GenericDelegator implementation holds a reference to the >>> DelegatorData instance. This makes it possible to have per-thread >>> instances of GenericDelegator. >>> >>> 3. Replaced the ThreadLocal variables with regular variables. >>> ThreadLocal variables are no longer needed. Client code doesn't >>> need to be concerned with pushing and popping the GenericDelegator >>> state. >>> >>> This commit paves the way for the forthcoming ExecutionContext. >>> >>> User modifications will have to replace >>> GenericDelegator.getGenericDelegator(...) with >>> DelegatorFactory.getGenericDelegator(...). Also, replace the push >>> code with the new setXxx methods, and remove the pop code. If >>> modifications used DelegatorInterface, replace that with >>> GenericDelegator. >>> >>> Aside from those changes, this commit is backwards compatible. >>> >>> Added: >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java (with props) >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java (with props) >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorImpl.java (with props) >>> Removed: >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorInterface.java >>> Modified: >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> CartEventListener.java >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> ShoppingCart.java >>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>> ShoppingCartItem.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ >>> PackingSession.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java >>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java >>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ >>> CatalinaContainer.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> GenericDelegator.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> GenericEntity.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/ >>> AbstractCache.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/ >>> EntityExpr.java >>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ >>> ListFinder.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/ >>> EntityDataLoadContainer.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>> synchronization/EntitySyncContext.java >>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>> synchronization/EntitySyncServices.java >>> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/ >>> XuiContainer.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/EntityCount.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/EntityData.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/FindByAnd.java >>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>> entityops/FindByPrimaryKey.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/ >>> ServiceDispatcher.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/ >>> JavaMailContainer.java >>> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ >>> RmiServiceContainer.java >>> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ >>> ModelTestSuite.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> ContextFilter.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> ControlServlet.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>> RequestHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> CoreEvents.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> ServiceStreamHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>> XmlRpcEventHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>> ServerHitBin.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>> VisitHandler.java >>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/ >>> WebDavServlet.java >>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ >>> WebslingerContextMapper.java >>> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/ >>> WebToolsServices.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/ >>> AuditEntityObject.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/ >>> SharkContainer.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/ >>> InstanceEntityObject.java >>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/ >>> AbstractRequester.java >>> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/ >>> WebPosSession.java >>> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/ >>> definition/XpdlReader.java >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/CartEventListener.java Sun Aug 9 18:04:26 2009 >>> @@ -28,6 +28,7 @@ >>> import org.ofbiz.base.util.Debug; >>> import org.ofbiz.base.util.UtilValidate; >>> import org.ofbiz.webapp.stats.VisitHandler; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -58,7 +59,7 @@ >>> String delegatorName = (String) >>> session.getAttribute("delegatorName"); >>> GenericDelegator delegator = null; >>> if (UtilValidate.isNotEmpty(delegatorName)) { >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> if (delegator == null) { >>> Debug.logError("Could not find delegator with >>> delegatorName in session, not saving abandoned cart info.", module); >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCart.java Sun Aug 9 18:04:26 2009 >>> @@ -21,6 +21,7 @@ >>> import javolution.util.FastList; >>> import javolution.util.FastMap; >>> import org.ofbiz.base.util.*; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericPK; >>> @@ -275,7 +276,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (delegator == null) { >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java (original) >>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>> shoppingcart/ShoppingCartItem.java Sun Aug 9 18:04:26 2009 >>> @@ -41,6 +41,7 @@ >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericPK; >>> @@ -2406,7 +2407,7 @@ >>> if (UtilValidate.isEmpty(delegatorName)) { >>> throw new IllegalStateException("Bad delegator >>> name"); >>> } >>> - delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> packing/PackingSession.java Sun Aug 9 18:04:26 2009 >>> @@ -35,6 +35,7 @@ >>> import org.ofbiz.base.util.UtilFormatOut; >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -500,7 +501,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> verify/VerifyPickSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>> VerifyPickSession.java Sun Aug 9 18:04:26 2009 >>> @@ -32,6 +32,7 @@ >>> import org.ofbiz.base.util.UtilMisc; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -76,7 +77,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java (original) >>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>> weightPackage/WeightPackageSession.java Sun Aug 9 18:04:26 2009 >>> @@ -34,6 +34,7 @@ >>> import org.ofbiz.base.util.UtilNumber; >>> import org.ofbiz.base.util.UtilProperties; >>> import org.ofbiz.base.util.UtilValidate; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> import org.ofbiz.entity.GenericEntityException; >>> import org.ofbiz.entity.GenericValue; >>> @@ -102,7 +103,7 @@ >>> >>> public GenericDelegator getDelegator() { >>> if (_delegator == null) { >>> - _delegator = >>> GenericDelegator.getGenericDelegator(delegatorName); >>> + _delegator = >>> DelegatorFactory.getGenericDelegator(delegatorName); >>> } >>> return _delegator; >>> } >>> >>> Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java (original) >>> +++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>> container/CatalinaContainer.java Sun Aug 9 18:04:26 2009 >>> @@ -36,6 +36,7 @@ >>> import org.ofbiz.base.container.ContainerException; >>> import org.ofbiz.base.container.ContainerConfig.Container.Property; >>> import org.ofbiz.base.util.*; >>> +import org.ofbiz.entity.DelegatorFactory; >>> import org.ofbiz.entity.GenericDelegator; >>> >>> import org.apache.catalina.Cluster; >>> @@ -168,7 +169,7 @@ >>> //int debug = ContainerConfig.getPropertyValue(cc, "debug", >>> 0); >>> >>> // grab some global context settings >>> - this.delegator = >>> GenericDelegator >>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>> "delegator-name", "default")); >>> + this.delegator = >>> DelegatorFactory >>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>> "delegator-name", "default")); >>> this.contextReloadable = >>> ContainerConfig.getPropertyValue(cc, "apps-context-reloadable", >>> false); >>> this.crossContext = ContainerConfig.getPropertyValue(cc, >>> "apps-cross-context", true); >>> this.distribute = ContainerConfig.getPropertyValue(cc, >>> "apps-distributable", true); >>> >>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java (added) >>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java Sun Aug 9 18:04:26 2009 >>> @@ -0,0 +1,110 @@ >>> +/* >>> + * Licensed to the Apache Software Foundation (ASF) under one >>> + * or more contributor license agreements. See the NOTICE file >>> + * distributed with this work for additional information >>> + * regarding copyright ownership. The ASF licenses this file >>> + * to you 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. >>> + */ >>> +package org.ofbiz.entity; >>> + >>> +import java.util.Map; >>> + >>> +import javolution.util.FastMap; >>> + >>> +import org.ofbiz.base.util.Debug; >>> +import org.ofbiz.entity.cache.Cache; >>> +import org.ofbiz.entity.config.DelegatorInfo; >>> +import org.ofbiz.entity.config.EntityConfigUtil; >>> +import org.ofbiz.entity.eca.EntityEcaHandler; >>> +import org.ofbiz.entity.model.ModelGroupReader; >>> +import org.ofbiz.entity.model.ModelReader; >>> +import org.ofbiz.entity.util.DistributedCacheClear; >>> +import org.ofbiz.entity.util.EntityCrypto; >>> +import org.ofbiz.entity.util.SequenceUtil; >>> + >>> +/** Data source for the DelegatorImpl Class. */ >>> +public class DelegatorData implements Cloneable { >>> + >>> + public static final String module = >>> DelegatorData.class.getName(); >>> + /** >>> + * the delegatorDataCache will now be a HashMap, allowing >>> reload of >>> + * definitions, but the delegator will always be the same >>> object for the >>> + * given name >>> + */ >>> + protected static final Map<String, DelegatorData> >>> delegatorDataCache = FastMap.newInstance(); >>> + >>> + /** >>> + * keeps a list of field key sets used in the by and cache, a >>> Set (of Sets >>> + * of fieldNames) for each entityName >>> + */ >>> + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); >>> + protected Cache cache = null; >>> + protected EntityCrypto crypto = null; >>> + protected DelegatorInfo delegatorInfo = null; >>> + protected String delegatorName = null; >>> + protected DistributedCacheClear distributedCacheClear = null; >>> + protected EntityEcaHandler<?> entityEcaHandler = null; >>> + protected ModelGroupReader modelGroupReader = null; >>> + protected ModelReader modelReader = null; >>> + protected String originalDelegatorName = null; >>> + protected SequenceUtil sequencer = null; >>> + protected boolean initialized = false; >>> + >>> + public static synchronized DelegatorData getInstance(String >>> delegatorName) throws GenericEntityException { >>> + if (delegatorName == null) { >>> + delegatorName = "default"; >>> + Debug.logWarning(new Exception("Location where >>> getting delegator with null name"), "Got a getGenericDelegator >>> call with a null delegatorName, assuming \"default\" for the >>> name.", module); >>> + } >>> + DelegatorData delegatorData = >>> delegatorDataCache.get(delegatorName); >>> + if (delegatorData == null) { >>> + if (Debug.infoOn()) { >>> + Debug.logInfo("Creating new delegator data >>> instance [" + delegatorName + "] (" + >>> Thread.currentThread().getName() + ")", module); >>> + } >>> + delegatorData = new DelegatorData(delegatorName); >>> + delegatorDataCache.put(delegatorName, delegatorData); >>> + } >>> + return delegatorData; >>> + } >>> + >>> + /** Only allow creation through the factory method */ >>> + protected DelegatorData() { >>> + } >>> + >>> + /** Only allow creation through the factory method */ >>> + protected DelegatorData(String delegatorName) throws >>> GenericEntityException { >>> + this.delegatorName = delegatorName; >>> + this.originalDelegatorName = delegatorName; >>> + this.modelReader = >>> ModelReader.getModelReader(delegatorName); >>> + this.modelGroupReader = >>> ModelGroupReader.getModelGroupReader(delegatorName); >>> + this.cache = new Cache(delegatorName); >>> + this.delegatorInfo = >>> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >>> + } >>> + >>> + @Override >>> + protected Object clone() { >>> + DelegatorData delegatorData = new DelegatorData(); >>> + delegatorData.modelReader = this.modelReader; >>> + delegatorData.modelGroupReader = this.modelGroupReader; >>> + delegatorData.delegatorName = this.delegatorName; >>> + delegatorData.delegatorInfo = this.delegatorInfo; >>> + delegatorData.cache = this.cache; >>> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >>> + delegatorData.distributedCacheClear = >>> this.distributedCacheClear; >>> + delegatorData.originalDelegatorName = >>> this.originalDelegatorName; >>> + delegatorData.entityEcaHandler = this.entityEcaHandler; >>> + delegatorData.sequencer = this.sequencer; >>> + delegatorData.crypto = this.crypto; >>> + return delegatorData; >>> + } >>> +} >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:keywords = "Date Rev Author URL Id" >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorData.java >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java (added) >>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java Sun Aug 9 18:04:26 2009 >>> @@ -0,0 +1,44 @@ >>> +/* >>> + * Licensed to the Apache Software Foundation (ASF) under one >>> + * or more contributor license agreements. See the NOTICE file >>> + * distributed with this work for additional information >>> + * regarding copyright ownership. The ASF licenses this file >>> + * to you 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. >>> + */ >>> +package org.ofbiz.entity; >>> + >>> +import org.ofbiz.base.util.Debug; >>> + >>> +/** GenericDelegator Factory Class. */ >>> +public class DelegatorFactory { >>> + >>> + public static final String module = >>> DelegatorFactory.class.getName(); >>> + >>> + public static GenericDelegator getGenericDelegator(String >>> delegatorName) { >>> + if (delegatorName == null) { >>> + delegatorName = "default"; >>> + Debug.logWarning(new Exception("Location where >>> getting delegator with null name"), "Got a getGenericDelegator >>> call with a null delegatorName, assuming default for the name.", >>> module); >>> + } >>> + DelegatorData delegatorData = null; >>> + try { >>> + delegatorData = >>> DelegatorData.getInstance(delegatorName); >>> + } catch (GenericEntityException e) { >>> + Debug.logError(e, "Could not create delegator with >>> name \"" + delegatorName + "\": ", module); >>> + } >>> + if (delegatorData != null) { >>> + return new DelegatorImpl(delegatorData); >>> + } >>> + return null; >>> + } >>> +} >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:keywords = "Date Rev Author URL Id" >>> >>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>> DelegatorFactory.java >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> |
In my implementation, I put the ExecutionContext in framework/base.
I'll work on updating the branch - I caused the problem, so I'll fix it. -Adrian David E Jones wrote: > > Yes, that's why I did a similar thing in the branch. > > Stepping back a little... please keep in mind that the interface will > not be able to stay in the entity component. Part of the point of making > these interfaces is so that we can have a ExecutionContext that knows > certain things about a number of framework components without actually > depending on those components at compile time. Instead with the > interfaces in the execution context component all of the other > components can depend on and share that. > > Without that pattern it will be impossible to implement the execution > context. As part of that, I'd rather do them all together rather than > separately otherwise (like I mentioned before) merging the branch will > become difficult. In fact, even with the changes you've already added to > the trunk the merge is already a HUGE mess... (ie just updating the > branch against the trunk). > > -David > > > On Aug 10, 2009, at 4:42 PM, Adrian Crum wrote: > >> I checked out the branch and examined it. After looking over your >> ideas, I saw a way to make incremental changes to the trunk - negating >> the need for a branch. >> >> The GenericDelegator refactor was done for two reasons: >> >> 1. To eliminate the hundreds of references to a concrete class, that >> have caused inconvenience in the past. >> 2. Eliminate thread local variables and the cumbersome pushing and >> popping of the GenericDelegator state. >> >> How it relates to the ExecutionContext is, we have the ability to keep >> an instance in the GenericDelegator without having to create more >> thread local variables and have even more things to push/pop. >> >> It's a cleaner design. >> >> -Adrian >> >> David E Jones wrote: >>> Adrian, >>> What is all of this, and how does it relate to what I've been working >>> on in the executioncontext20090716 branch? >>> It seems like this will: >>> 1. cause some inconvenience now, while more comprehensive changes are >>> being made in the executioncontext20090716 branch >>> 2. make it a LOT more difficult (perhaps impossible) to merge the >>> executioncontext20090716 branch >>> What is your plan with this? >>> It would make life a lot easier for all of us if you would do some >>> research on what I've already done in the executioncontext20090716 >>> branch before continuing with this. >>> -David >>> On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: >>>> Author: adrianc >>>> Date: Sun Aug 9 18:04:26 2009 >>>> New Revision: 802567 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >>>> Log: >>>> Refactored GenericDelegator: >>>> >>>> 1. Converted GenericDelegator to an interface. We already have >>>> DelegatorInterface, but it isn't being used anywhere. Removed >>>> DelegatorInterface.java. >>>> >>>> 2. Extracted the static, cached data from the GenericDelegator >>>> implementation and put it in its own class - DelegatorData. The >>>> GenericDelegator implementation holds a reference to the >>>> DelegatorData instance. This makes it possible to have per-thread >>>> instances of GenericDelegator. >>>> >>>> 3. Replaced the ThreadLocal variables with regular variables. >>>> ThreadLocal variables are no longer needed. Client code doesn't need >>>> to be concerned with pushing and popping the GenericDelegator state. >>>> >>>> This commit paves the way for the forthcoming ExecutionContext. >>>> >>>> User modifications will have to replace >>>> GenericDelegator.getGenericDelegator(...) with >>>> DelegatorFactory.getGenericDelegator(...). Also, replace the push >>>> code with the new setXxx methods, and remove the pop code. If >>>> modifications used DelegatorInterface, replace that with >>>> GenericDelegator. >>>> >>>> Aside from those changes, this commit is backwards compatible. >>>> >>>> Added: >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> (with props) >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> (with props) >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java >>>> (with props) >>>> Removed: >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java >>>> >>>> Modified: >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> >>>> >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> >>>> >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> >>>> >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java >>>> >>>> >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java >>>> >>>> >>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java >>>> >>>> >>>> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/XuiContainer.java >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java >>>> >>>> >>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java >>>> >>>> >>>> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java >>>> >>>> >>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/WebDavServlet.java >>>> >>>> >>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java >>>> >>>> >>>> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/AuditEntityObject.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/InstanceEntityObject.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/AbstractRequester.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java >>>> >>>> >>>> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java >>>> >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -28,6 +28,7 @@ >>>> import org.ofbiz.base.util.Debug; >>>> import org.ofbiz.base.util.UtilValidate; >>>> import org.ofbiz.webapp.stats.VisitHandler; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -58,7 +59,7 @@ >>>> String delegatorName = (String) >>>> session.getAttribute("delegatorName"); >>>> GenericDelegator delegator = null; >>>> if (UtilValidate.isNotEmpty(delegatorName)) { >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> if (delegator == null) { >>>> Debug.logError("Could not find delegator with >>>> delegatorName in session, not saving abandoned cart info.", module); >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -21,6 +21,7 @@ >>>> import javolution.util.FastList; >>>> import javolution.util.FastMap; >>>> import org.ofbiz.base.util.*; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericPK; >>>> @@ -275,7 +276,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (delegator == null) { >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -41,6 +41,7 @@ >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericPK; >>>> @@ -2406,7 +2407,7 @@ >>>> if (UtilValidate.isEmpty(delegatorName)) { >>>> throw new IllegalStateException("Bad delegator name"); >>>> } >>>> - delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -35,6 +35,7 @@ >>>> import org.ofbiz.base.util.UtilFormatOut; >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -500,7 +501,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -32,6 +32,7 @@ >>>> import org.ofbiz.base.util.UtilMisc; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -76,7 +77,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -34,6 +34,7 @@ >>>> import org.ofbiz.base.util.UtilNumber; >>>> import org.ofbiz.base.util.UtilProperties; >>>> import org.ofbiz.base.util.UtilValidate; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> import org.ofbiz.entity.GenericEntityException; >>>> import org.ofbiz.entity.GenericValue; >>>> @@ -102,7 +103,7 @@ >>>> >>>> public GenericDelegator getDelegator() { >>>> if (_delegator == null) { >>>> - _delegator = >>>> GenericDelegator.getGenericDelegator(delegatorName); >>>> + _delegator = >>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>> } >>>> return _delegator; >>>> } >>>> >>>> Modified: >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> (original) >>>> +++ >>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -36,6 +36,7 @@ >>>> import org.ofbiz.base.container.ContainerException; >>>> import org.ofbiz.base.container.ContainerConfig.Container.Property; >>>> import org.ofbiz.base.util.*; >>>> +import org.ofbiz.entity.DelegatorFactory; >>>> import org.ofbiz.entity.GenericDelegator; >>>> >>>> import org.apache.catalina.Cluster; >>>> @@ -168,7 +169,7 @@ >>>> //int debug = ContainerConfig.getPropertyValue(cc, "debug", 0); >>>> >>>> // grab some global context settings >>>> - this.delegator = >>>> GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>> "delegator-name", "default")); >>>> + this.delegator = >>>> DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>> "delegator-name", "default")); >>>> this.contextReloadable = ContainerConfig.getPropertyValue(cc, >>>> "apps-context-reloadable", false); >>>> this.crossContext = ContainerConfig.getPropertyValue(cc, >>>> "apps-cross-context", true); >>>> this.distribute = ContainerConfig.getPropertyValue(cc, >>>> "apps-distributable", true); >>>> >>>> Added: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> (added) >>>> +++ >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -0,0 +1,110 @@ >>>> +/* >>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>> + * or more contributor license agreements. See the NOTICE file >>>> + * distributed with this work for additional information >>>> + * regarding copyright ownership. The ASF licenses this file >>>> + * to you 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. >>>> + */ >>>> +package org.ofbiz.entity; >>>> + >>>> +import java.util.Map; >>>> + >>>> +import javolution.util.FastMap; >>>> + >>>> +import org.ofbiz.base.util.Debug; >>>> +import org.ofbiz.entity.cache.Cache; >>>> +import org.ofbiz.entity.config.DelegatorInfo; >>>> +import org.ofbiz.entity.config.EntityConfigUtil; >>>> +import org.ofbiz.entity.eca.EntityEcaHandler; >>>> +import org.ofbiz.entity.model.ModelGroupReader; >>>> +import org.ofbiz.entity.model.ModelReader; >>>> +import org.ofbiz.entity.util.DistributedCacheClear; >>>> +import org.ofbiz.entity.util.EntityCrypto; >>>> +import org.ofbiz.entity.util.SequenceUtil; >>>> + >>>> +/** Data source for the DelegatorImpl Class. */ >>>> +public class DelegatorData implements Cloneable { >>>> + >>>> + public static final String module = DelegatorData.class.getName(); >>>> + /** >>>> + * the delegatorDataCache will now be a HashMap, allowing >>>> reload of >>>> + * definitions, but the delegator will always be the same >>>> object for the >>>> + * given name >>>> + */ >>>> + protected static final Map<String, DelegatorData> >>>> delegatorDataCache = FastMap.newInstance(); >>>> + >>>> + /** >>>> + * keeps a list of field key sets used in the by and cache, a >>>> Set (of Sets >>>> + * of fieldNames) for each entityName >>>> + */ >>>> + protected Map<?, ?> andCacheFieldSets = FastMap.newInstance(); >>>> + protected Cache cache = null; >>>> + protected EntityCrypto crypto = null; >>>> + protected DelegatorInfo delegatorInfo = null; >>>> + protected String delegatorName = null; >>>> + protected DistributedCacheClear distributedCacheClear = null; >>>> + protected EntityEcaHandler<?> entityEcaHandler = null; >>>> + protected ModelGroupReader modelGroupReader = null; >>>> + protected ModelReader modelReader = null; >>>> + protected String originalDelegatorName = null; >>>> + protected SequenceUtil sequencer = null; >>>> + protected boolean initialized = false; >>>> + >>>> + public static synchronized DelegatorData getInstance(String >>>> delegatorName) throws GenericEntityException { >>>> + if (delegatorName == null) { >>>> + delegatorName = "default"; >>>> + Debug.logWarning(new Exception("Location where getting >>>> delegator with null name"), "Got a getGenericDelegator call with a >>>> null delegatorName, assuming \"default\" for the name.", module); >>>> + } >>>> + DelegatorData delegatorData = >>>> delegatorDataCache.get(delegatorName); >>>> + if (delegatorData == null) { >>>> + if (Debug.infoOn()) { >>>> + Debug.logInfo("Creating new delegator data instance >>>> [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", >>>> module); >>>> + } >>>> + delegatorData = new DelegatorData(delegatorName); >>>> + delegatorDataCache.put(delegatorName, delegatorData); >>>> + } >>>> + return delegatorData; >>>> + } >>>> + >>>> + /** Only allow creation through the factory method */ >>>> + protected DelegatorData() { >>>> + } >>>> + >>>> + /** Only allow creation through the factory method */ >>>> + protected DelegatorData(String delegatorName) throws >>>> GenericEntityException { >>>> + this.delegatorName = delegatorName; >>>> + this.originalDelegatorName = delegatorName; >>>> + this.modelReader = ModelReader.getModelReader(delegatorName); >>>> + this.modelGroupReader = >>>> ModelGroupReader.getModelGroupReader(delegatorName); >>>> + this.cache = new Cache(delegatorName); >>>> + this.delegatorInfo = >>>> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >>>> + } >>>> + >>>> + @Override >>>> + protected Object clone() { >>>> + DelegatorData delegatorData = new DelegatorData(); >>>> + delegatorData.modelReader = this.modelReader; >>>> + delegatorData.modelGroupReader = this.modelGroupReader; >>>> + delegatorData.delegatorName = this.delegatorName; >>>> + delegatorData.delegatorInfo = this.delegatorInfo; >>>> + delegatorData.cache = this.cache; >>>> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >>>> + delegatorData.distributedCacheClear = >>>> this.distributedCacheClear; >>>> + delegatorData.originalDelegatorName = >>>> this.originalDelegatorName; >>>> + delegatorData.entityEcaHandler = this.entityEcaHandler; >>>> + delegatorData.sequencer = this.sequencer; >>>> + delegatorData.crypto = this.crypto; >>>> + return delegatorData; >>>> + } >>>> +} >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:keywords = "Date Rev Author URL Id" >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:mime-type = text/plain >>>> >>>> Added: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> URL: >>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >>>> >>>> ============================================================================== >>>> >>>> --- >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> (added) >>>> +++ >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> Sun Aug 9 18:04:26 2009 >>>> @@ -0,0 +1,44 @@ >>>> +/* >>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>> + * or more contributor license agreements. See the NOTICE file >>>> + * distributed with this work for additional information >>>> + * regarding copyright ownership. The ASF licenses this file >>>> + * to you 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. >>>> + */ >>>> +package org.ofbiz.entity; >>>> + >>>> +import org.ofbiz.base.util.Debug; >>>> + >>>> +/** GenericDelegator Factory Class. */ >>>> +public class DelegatorFactory { >>>> + >>>> + public static final String module = >>>> DelegatorFactory.class.getName(); >>>> + >>>> + public static GenericDelegator getGenericDelegator(String >>>> delegatorName) { >>>> + if (delegatorName == null) { >>>> + delegatorName = "default"; >>>> + Debug.logWarning(new Exception("Location where getting >>>> delegator with null name"), "Got a getGenericDelegator call with a >>>> null delegatorName, assuming default for the name.", module); >>>> + } >>>> + DelegatorData delegatorData = null; >>>> + try { >>>> + delegatorData = DelegatorData.getInstance(delegatorName); >>>> + } catch (GenericEntityException e) { >>>> + Debug.logError(e, "Could not create delegator with name >>>> \"" + delegatorName + "\": ", module); >>>> + } >>>> + if (delegatorData != null) { >>>> + return new DelegatorImpl(delegatorData); >>>> + } >>>> + return null; >>>> + } >>>> +} >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:keywords = "Date Rev Author URL Id" >>>> >>>> Propchange: >>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java >>>> ------------------------------------------------------------------------------ >>>> >>>> svn:mime-type = text/plain >>>> >>>> > > |
If the ExecutionContext interface is in base and the GenericDelegator interface is in entity and the ExecutionContext needs to use the GenericDelegator interface, how will that work? -David On Aug 10, 2009, at 5:19 PM, Adrian Crum wrote: > In my implementation, I put the ExecutionContext in framework/base. > > I'll work on updating the branch - I caused the problem, so I'll fix > it. > > -Adrian > > David E Jones wrote: >> Yes, that's why I did a similar thing in the branch. >> Stepping back a little... please keep in mind that the interface >> will not be able to stay in the entity component. Part of the point >> of making these interfaces is so that we can have a >> ExecutionContext that knows certain things about a number of >> framework components without actually depending on those components >> at compile time. Instead with the interfaces in the execution >> context component all of the other components can depend on and >> share that. >> Without that pattern it will be impossible to implement the >> execution context. As part of that, I'd rather do them all together >> rather than separately otherwise (like I mentioned before) merging >> the branch will become difficult. In fact, even with the changes >> you've already added to the trunk the merge is already a HUGE >> mess... (ie just updating the branch against the trunk). >> -David >> On Aug 10, 2009, at 4:42 PM, Adrian Crum wrote: >>> I checked out the branch and examined it. After looking over your >>> ideas, I saw a way to make incremental changes to the trunk - >>> negating the need for a branch. >>> >>> The GenericDelegator refactor was done for two reasons: >>> >>> 1. To eliminate the hundreds of references to a concrete class, >>> that have caused inconvenience in the past. >>> 2. Eliminate thread local variables and the cumbersome pushing and >>> popping of the GenericDelegator state. >>> >>> How it relates to the ExecutionContext is, we have the ability to >>> keep an instance in the GenericDelegator without having to create >>> more thread local variables and have even more things to push/pop. >>> >>> It's a cleaner design. >>> >>> -Adrian >>> >>> David E Jones wrote: >>>> Adrian, >>>> What is all of this, and how does it relate to what I've been >>>> working on in the executioncontext20090716 branch? >>>> It seems like this will: >>>> 1. cause some inconvenience now, while more comprehensive changes >>>> are being made in the executioncontext20090716 branch >>>> 2. make it a LOT more difficult (perhaps impossible) to merge the >>>> executioncontext20090716 branch >>>> What is your plan with this? >>>> It would make life a lot easier for all of us if you would do >>>> some research on what I've already done in the >>>> executioncontext20090716 branch before continuing with this. >>>> -David >>>> On Aug 9, 2009, at 12:04 PM, [hidden email] wrote: >>>>> Author: adrianc >>>>> Date: Sun Aug 9 18:04:26 2009 >>>>> New Revision: 802567 >>>>> >>>>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev >>>>> Log: >>>>> Refactored GenericDelegator: >>>>> >>>>> 1. Converted GenericDelegator to an interface. We already have >>>>> DelegatorInterface, but it isn't being used anywhere. Removed >>>>> DelegatorInterface.java. >>>>> >>>>> 2. Extracted the static, cached data from the GenericDelegator >>>>> implementation and put it in its own class - DelegatorData. The >>>>> GenericDelegator implementation holds a reference to the >>>>> DelegatorData instance. This makes it possible to have per- >>>>> thread instances of GenericDelegator. >>>>> >>>>> 3. Replaced the ThreadLocal variables with regular variables. >>>>> ThreadLocal variables are no longer needed. Client code doesn't >>>>> need to be concerned with pushing and popping the >>>>> GenericDelegator state. >>>>> >>>>> This commit paves the way for the forthcoming ExecutionContext. >>>>> >>>>> User modifications will have to replace >>>>> GenericDelegator.getGenericDelegator(...) with >>>>> DelegatorFactory.getGenericDelegator(...). Also, replace the >>>>> push code with the new setXxx methods, and remove the pop code. >>>>> If modifications used DelegatorInterface, replace that with >>>>> GenericDelegator. >>>>> >>>>> Aside from those changes, this commit is backwards compatible. >>>>> >>>>> Added: >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java (with props) >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java (with props) >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorImpl.java (with props) >>>>> Removed: >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorInterface.java >>>>> Modified: >>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>>>> CartEventListener.java >>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>>>> ShoppingCart.java >>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ >>>>> ShoppingCartItem.java >>>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/ >>>>> PackingSession.java >>>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/ >>>>> VerifyPickSession.java >>>>> ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> weightPackage/WeightPackageSession.java >>>>> ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/ >>>>> CatalinaContainer.java >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> GenericDelegator.java >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> GenericEntity.java >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/ >>>>> AbstractCache.java >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/ >>>>> EntityExpr.java >>>>> ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ >>>>> ListFinder.java >>>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/ >>>>> EntityDataLoadContainer.java >>>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>>>> synchronization/EntitySyncContext.java >>>>> ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/ >>>>> synchronization/EntitySyncServices.java >>>>> ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/ >>>>> XuiContainer.java >>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>>>> entityops/EntityCount.java >>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>>>> entityops/EntityData.java >>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>>>> entityops/FindByAnd.java >>>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ >>>>> entityops/FindByPrimaryKey.java >>>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/ >>>>> ServiceDispatcher.java >>>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/ >>>>> JavaMailContainer.java >>>>> ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/ >>>>> RmiServiceContainer.java >>>>> ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ >>>>> ModelTestSuite.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>>>> ContextFilter.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>>>> ControlServlet.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ >>>>> RequestHandler.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>>>> CoreEvents.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>>>> ServiceStreamHandler.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ >>>>> XmlRpcEventHandler.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>>>> ServerHitBin.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ >>>>> VisitHandler.java >>>>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/ >>>>> WebDavServlet.java >>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ >>>>> WebslingerContextMapper.java >>>>> ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/ >>>>> WebToolsServices.java >>>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/ >>>>> AuditEntityObject.java >>>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/ >>>>> SharkContainer.java >>>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/ >>>>> InstanceEntityObject.java >>>>> ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/ >>>>> AbstractRequester.java >>>>> ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/ >>>>> WebPosSession.java >>>>> ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/ >>>>> definition/XpdlReader.java >>>>> >>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/CartEventListener.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/CartEventListener.java (original) >>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/CartEventListener.java Sun Aug 9 18:04:26 2009 >>>>> @@ -28,6 +28,7 @@ >>>>> import org.ofbiz.base.util.Debug; >>>>> import org.ofbiz.base.util.UtilValidate; >>>>> import org.ofbiz.webapp.stats.VisitHandler; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericValue; >>>>> @@ -58,7 +59,7 @@ >>>>> String delegatorName = (String) >>>>> session.getAttribute("delegatorName"); >>>>> GenericDelegator delegator = null; >>>>> if (UtilValidate.isNotEmpty(delegatorName)) { >>>>> - delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> if (delegator == null) { >>>>> Debug.logError("Could not find delegator with >>>>> delegatorName in session, not saving abandoned cart info.", >>>>> module); >>>>> >>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCart.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCart.java (original) >>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCart.java Sun Aug 9 18:04:26 2009 >>>>> @@ -21,6 +21,7 @@ >>>>> import javolution.util.FastList; >>>>> import javolution.util.FastMap; >>>>> import org.ofbiz.base.util.*; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericPK; >>>>> @@ -275,7 +276,7 @@ >>>>> >>>>> public GenericDelegator getDelegator() { >>>>> if (delegator == null) { >>>>> - delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> return delegator; >>>>> } >>>>> >>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCartItem.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCartItem.java (original) >>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ >>>>> shoppingcart/ShoppingCartItem.java Sun Aug 9 18:04:26 2009 >>>>> @@ -41,6 +41,7 @@ >>>>> import org.ofbiz.base.util.UtilMisc; >>>>> import org.ofbiz.base.util.UtilProperties; >>>>> import org.ofbiz.base.util.UtilValidate; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericPK; >>>>> @@ -2406,7 +2407,7 @@ >>>>> if (UtilValidate.isEmpty(delegatorName)) { >>>>> throw new IllegalStateException("Bad delegator >>>>> name"); >>>>> } >>>>> - delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> return delegator; >>>>> } >>>>> >>>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/ >>>>> shipment/packing/PackingSession.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> packing/PackingSession.java (original) >>>>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> packing/PackingSession.java Sun Aug 9 18:04:26 2009 >>>>> @@ -35,6 +35,7 @@ >>>>> import org.ofbiz.base.util.UtilFormatOut; >>>>> import org.ofbiz.base.util.UtilMisc; >>>>> import org.ofbiz.base.util.UtilValidate; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericValue; >>>>> @@ -500,7 +501,7 @@ >>>>> >>>>> public GenericDelegator getDelegator() { >>>>> if (_delegator == null) { >>>>> - _delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + _delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> return _delegator; >>>>> } >>>>> >>>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/ >>>>> shipment/verify/VerifyPickSession.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> verify/VerifyPickSession.java (original) >>>>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> verify/VerifyPickSession.java Sun Aug 9 18:04:26 2009 >>>>> @@ -32,6 +32,7 @@ >>>>> import org.ofbiz.base.util.UtilMisc; >>>>> import org.ofbiz.base.util.UtilProperties; >>>>> import org.ofbiz.base.util.UtilValidate; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericValue; >>>>> @@ -76,7 +77,7 @@ >>>>> >>>>> public GenericDelegator getDelegator() { >>>>> if (_delegator == null) { >>>>> - _delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + _delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> return _delegator; >>>>> } >>>>> >>>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/ >>>>> shipment/weightPackage/WeightPackageSession.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> weightPackage/WeightPackageSession.java (original) >>>>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/ >>>>> weightPackage/WeightPackageSession.java Sun Aug 9 18:04:26 2009 >>>>> @@ -34,6 +34,7 @@ >>>>> import org.ofbiz.base.util.UtilNumber; >>>>> import org.ofbiz.base.util.UtilProperties; >>>>> import org.ofbiz.base.util.UtilValidate; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> import org.ofbiz.entity.GenericEntityException; >>>>> import org.ofbiz.entity.GenericValue; >>>>> @@ -102,7 +103,7 @@ >>>>> >>>>> public GenericDelegator getDelegator() { >>>>> if (_delegator == null) { >>>>> - _delegator = >>>>> GenericDelegator.getGenericDelegator(delegatorName); >>>>> + _delegator = >>>>> DelegatorFactory.getGenericDelegator(delegatorName); >>>>> } >>>>> return _delegator; >>>>> } >>>>> >>>>> Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>>>> container/CatalinaContainer.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>>>> container/CatalinaContainer.java (original) >>>>> +++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/ >>>>> container/CatalinaContainer.java Sun Aug 9 18:04:26 2009 >>>>> @@ -36,6 +36,7 @@ >>>>> import org.ofbiz.base.container.ContainerException; >>>>> import >>>>> org.ofbiz.base.container.ContainerConfig.Container.Property; >>>>> import org.ofbiz.base.util.*; >>>>> +import org.ofbiz.entity.DelegatorFactory; >>>>> import org.ofbiz.entity.GenericDelegator; >>>>> >>>>> import org.apache.catalina.Cluster; >>>>> @@ -168,7 +169,7 @@ >>>>> //int debug = ContainerConfig.getPropertyValue(cc, >>>>> "debug", 0); >>>>> >>>>> // grab some global context settings >>>>> - this.delegator = >>>>> GenericDelegator >>>>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>>> "delegator-name", "default")); >>>>> + this.delegator = >>>>> DelegatorFactory >>>>> .getGenericDelegator(ContainerConfig.getPropertyValue(cc, >>>>> "delegator-name", "default")); >>>>> this.contextReloadable = >>>>> ContainerConfig.getPropertyValue(cc, "apps-context-reloadable", >>>>> false); >>>>> this.crossContext = ContainerConfig.getPropertyValue(cc, >>>>> "apps-cross-context", true); >>>>> this.distribute = ContainerConfig.getPropertyValue(cc, >>>>> "apps-distributable", true); >>>>> >>>>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java (added) >>>>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java Sun Aug 9 18:04:26 2009 >>>>> @@ -0,0 +1,110 @@ >>>>> +/* >>>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>>> + * or more contributor license agreements. See the NOTICE file >>>>> + * distributed with this work for additional information >>>>> + * regarding copyright ownership. The ASF licenses this file >>>>> + * to you 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. >>>>> + */ >>>>> +package org.ofbiz.entity; >>>>> + >>>>> +import java.util.Map; >>>>> + >>>>> +import javolution.util.FastMap; >>>>> + >>>>> +import org.ofbiz.base.util.Debug; >>>>> +import org.ofbiz.entity.cache.Cache; >>>>> +import org.ofbiz.entity.config.DelegatorInfo; >>>>> +import org.ofbiz.entity.config.EntityConfigUtil; >>>>> +import org.ofbiz.entity.eca.EntityEcaHandler; >>>>> +import org.ofbiz.entity.model.ModelGroupReader; >>>>> +import org.ofbiz.entity.model.ModelReader; >>>>> +import org.ofbiz.entity.util.DistributedCacheClear; >>>>> +import org.ofbiz.entity.util.EntityCrypto; >>>>> +import org.ofbiz.entity.util.SequenceUtil; >>>>> + >>>>> +/** Data source for the DelegatorImpl Class. */ >>>>> +public class DelegatorData implements Cloneable { >>>>> + >>>>> + public static final String module = >>>>> DelegatorData.class.getName(); >>>>> + /** >>>>> + * the delegatorDataCache will now be a HashMap, allowing >>>>> reload of >>>>> + * definitions, but the delegator will always be the same >>>>> object for the >>>>> + * given name >>>>> + */ >>>>> + protected static final Map<String, DelegatorData> >>>>> delegatorDataCache = FastMap.newInstance(); >>>>> + >>>>> + /** >>>>> + * keeps a list of field key sets used in the by and cache, >>>>> a Set (of Sets >>>>> + * of fieldNames) for each entityName >>>>> + */ >>>>> + protected Map<?, ?> andCacheFieldSets = >>>>> FastMap.newInstance(); >>>>> + protected Cache cache = null; >>>>> + protected EntityCrypto crypto = null; >>>>> + protected DelegatorInfo delegatorInfo = null; >>>>> + protected String delegatorName = null; >>>>> + protected DistributedCacheClear distributedCacheClear = null; >>>>> + protected EntityEcaHandler<?> entityEcaHandler = null; >>>>> + protected ModelGroupReader modelGroupReader = null; >>>>> + protected ModelReader modelReader = null; >>>>> + protected String originalDelegatorName = null; >>>>> + protected SequenceUtil sequencer = null; >>>>> + protected boolean initialized = false; >>>>> + >>>>> + public static synchronized DelegatorData getInstance(String >>>>> delegatorName) throws GenericEntityException { >>>>> + if (delegatorName == null) { >>>>> + delegatorName = "default"; >>>>> + Debug.logWarning(new Exception("Location where >>>>> getting delegator with null name"), "Got a getGenericDelegator >>>>> call with a null delegatorName, assuming \"default\" for the >>>>> name.", module); >>>>> + } >>>>> + DelegatorData delegatorData = >>>>> delegatorDataCache.get(delegatorName); >>>>> + if (delegatorData == null) { >>>>> + if (Debug.infoOn()) { >>>>> + Debug.logInfo("Creating new delegator data >>>>> instance [" + delegatorName + "] (" + >>>>> Thread.currentThread().getName() + ")", module); >>>>> + } >>>>> + delegatorData = new DelegatorData(delegatorName); >>>>> + delegatorDataCache.put(delegatorName, delegatorData); >>>>> + } >>>>> + return delegatorData; >>>>> + } >>>>> + >>>>> + /** Only allow creation through the factory method */ >>>>> + protected DelegatorData() { >>>>> + } >>>>> + >>>>> + /** Only allow creation through the factory method */ >>>>> + protected DelegatorData(String delegatorName) throws >>>>> GenericEntityException { >>>>> + this.delegatorName = delegatorName; >>>>> + this.originalDelegatorName = delegatorName; >>>>> + this.modelReader = >>>>> ModelReader.getModelReader(delegatorName); >>>>> + this.modelGroupReader = >>>>> ModelGroupReader.getModelGroupReader(delegatorName); >>>>> + this.cache = new Cache(delegatorName); >>>>> + this.delegatorInfo = >>>>> EntityConfigUtil.getDelegatorInfo(this.delegatorName); >>>>> + } >>>>> + >>>>> + @Override >>>>> + protected Object clone() { >>>>> + DelegatorData delegatorData = new DelegatorData(); >>>>> + delegatorData.modelReader = this.modelReader; >>>>> + delegatorData.modelGroupReader = this.modelGroupReader; >>>>> + delegatorData.delegatorName = this.delegatorName; >>>>> + delegatorData.delegatorInfo = this.delegatorInfo; >>>>> + delegatorData.cache = this.cache; >>>>> + delegatorData.andCacheFieldSets = this.andCacheFieldSets; >>>>> + delegatorData.distributedCacheClear = >>>>> this.distributedCacheClear; >>>>> + delegatorData.originalDelegatorName = >>>>> this.originalDelegatorName; >>>>> + delegatorData.entityEcaHandler = this.entityEcaHandler; >>>>> + delegatorData.sequencer = this.sequencer; >>>>> + delegatorData.crypto = this.crypto; >>>>> + return delegatorData; >>>>> + } >>>>> +} >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:eol-style = native >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:keywords = "Date Rev Author URL Id" >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorData.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:mime-type = text/plain >>>>> >>>>> Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ================================================================== >>>>> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java (added) >>>>> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java Sun Aug 9 18:04:26 2009 >>>>> @@ -0,0 +1,44 @@ >>>>> +/* >>>>> + * Licensed to the Apache Software Foundation (ASF) under one >>>>> + * or more contributor license agreements. See the NOTICE file >>>>> + * distributed with this work for additional information >>>>> + * regarding copyright ownership. The ASF licenses this file >>>>> + * to you 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. >>>>> + */ >>>>> +package org.ofbiz.entity; >>>>> + >>>>> +import org.ofbiz.base.util.Debug; >>>>> + >>>>> +/** GenericDelegator Factory Class. */ >>>>> +public class DelegatorFactory { >>>>> + >>>>> + public static final String module = >>>>> DelegatorFactory.class.getName(); >>>>> + >>>>> + public static GenericDelegator getGenericDelegator(String >>>>> delegatorName) { >>>>> + if (delegatorName == null) { >>>>> + delegatorName = "default"; >>>>> + Debug.logWarning(new Exception("Location where >>>>> getting delegator with null name"), "Got a getGenericDelegator >>>>> call with a null delegatorName, assuming default for the name.", >>>>> module); >>>>> + } >>>>> + DelegatorData delegatorData = null; >>>>> + try { >>>>> + delegatorData = >>>>> DelegatorData.getInstance(delegatorName); >>>>> + } catch (GenericEntityException e) { >>>>> + Debug.logError(e, "Could not create delegator with >>>>> name \"" + delegatorName + "\": ", module); >>>>> + } >>>>> + if (delegatorData != null) { >>>>> + return new DelegatorImpl(delegatorData); >>>>> + } >>>>> + return null; >>>>> + } >>>>> +} >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:eol-style = native >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:keywords = "Date Rev Author URL Id" >>>>> >>>>> Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/ >>>>> DelegatorFactory.java >>>>> ------------------------------------------------------------------------------ >>>>> svn:mime-type = text/plain >>>>> >>>>> |
lol - while i was driving home I realized that statement would cause confusion. The basic part of keeping track of the execution path is in framework/base. Other components extend it to add the higher level artifacts.
Let me fix the branch. Then I'll port my implementation over to it and commit it. Then you can try it out. It's working quite well. -Adrian --- On Mon, 8/10/09, David E Jones <[hidden email]> wrote: > From: David E Jones <[hidden email]> > Subject: Re: svn commit: r802567 [1/5] - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/product/src/org/ofbiz/shipment/packing/ applications/product/src/org/ofbiz/shipment/verify/ applications/product/src/org/ofbiz/shipment/weigh... > To: [hidden email] > Date: Monday, August 10, 2009, 4:41 PM > > If the ExecutionContext interface is in base and the > GenericDelegator interface is in entity and the > ExecutionContext needs to use the GenericDelegator > interface, how will that work? > > -David > > > On Aug 10, 2009, at 5:19 PM, Adrian Crum wrote: > > > In my implementation, I put the ExecutionContext in > framework/base. > > > > I'll work on updating the branch - I caused the > problem, so I'll fix it. > > > > -Adrian > > > > David E Jones wrote: > >> Yes, that's why I did a similar thing in the > branch. > >> Stepping back a little... please keep in mind that > the interface will not be able to stay in the entity > component. Part of the point of making these interfaces is > so that we can have a ExecutionContext that knows certain > things about a number of framework components without > actually depending on those components at compile time. > Instead with the interfaces in the execution context > component all of the other components can depend on and > share that. > >> Without that pattern it will be impossible to > implement the execution context. As part of that, I'd rather > do them all together rather than separately otherwise (like > I mentioned before) merging the branch will become > difficult. In fact, even with the changes you've already > added to the trunk the merge is already a HUGE mess... (ie > just updating the branch against the trunk). > >> -David > >> On Aug 10, 2009, at 4:42 PM, Adrian Crum wrote: > >>> I checked out the branch and examined it. > After looking over your ideas, I saw a way to make > incremental changes to the trunk - negating the need for a > branch. > >>> > >>> The GenericDelegator refactor was done for two > reasons: > >>> > >>> 1. To eliminate the hundreds of references to > a concrete class, that have caused inconvenience in the > past. > >>> 2. Eliminate thread local variables and the > cumbersome pushing and popping of the GenericDelegator > state. > >>> > >>> How it relates to the ExecutionContext is, we > have the ability to keep an instance in the GenericDelegator > without having to create more thread local variables and > have even more things to push/pop. > >>> > >>> It's a cleaner design. > >>> > >>> -Adrian > >>> > >>> David E Jones wrote: > >>>> Adrian, > >>>> What is all of this, and how does it > relate to what I've been working on in the > executioncontext20090716 branch? > >>>> It seems like this will: > >>>> 1. cause some inconvenience now, while > more comprehensive changes are being made in the > executioncontext20090716 branch > >>>> 2. make it a LOT more difficult (perhaps > impossible) to merge the executioncontext20090716 branch > >>>> What is your plan with this? > >>>> It would make life a lot easier for all of > us if you would do some research on what I've already done > in the executioncontext20090716 branch before continuing > with this. > >>>> -David > >>>> On Aug 9, 2009, at 12:04 PM, [hidden email] > wrote: > >>>>> Author: adrianc > >>>>> Date: Sun Aug 9 18:04:26 2009 > >>>>> New Revision: 802567 > >>>>> > >>>>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev > >>>>> Log: > >>>>> Refactored GenericDelegator: > >>>>> > >>>>> 1. Converted GenericDelegator to an > interface. We already have DelegatorInterface, but it isn't > being used anywhere. Removed DelegatorInterface.java. > >>>>> > >>>>> 2. Extracted the static, cached data > from the GenericDelegator implementation and put it in its > own class - DelegatorData. The GenericDelegator > implementation holds a reference to the DelegatorData > instance. This makes it possible to have per-thread > instances of GenericDelegator. > >>>>> > >>>>> 3. Replaced the ThreadLocal variables > with regular variables. ThreadLocal variables are no longer > needed. Client code doesn't need to be concerned with > pushing and popping the GenericDelegator state. > >>>>> > >>>>> This commit paves the way for the > forthcoming ExecutionContext. > >>>>> > >>>>> User modifications will have to > replace GenericDelegator.getGenericDelegator(...) with > DelegatorFactory.getGenericDelegator(...). Also, replace the > push code with the new setXxx methods, and remove the pop > code. If modifications used DelegatorInterface, replace that > with GenericDelegator. > >>>>> > >>>>> Aside from those changes, this commit > is backwards compatible. > >>>>> > >>>>> Added: > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java (with > props) > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (with > props) > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java (with > props) > >>>>> Removed: > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java > >>>>> Modified: > >>>>> > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > >>>>> > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > >>>>> > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > >>>>> > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > >>>>> > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > >>>>> > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > >>>>> > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java > >>>>> > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java > >>>>> > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java > >>>>> > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java > >>>>> > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java > >>>>> > ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/XuiContainer.java > >>>>> > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java > >>>>> > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java > >>>>> > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java > >>>>> > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java > >>>>> > ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java > >>>>> > ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java > >>>>> > ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java > >>>>> > ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java > >>>>> > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/WebDavServlet.java > >>>>> > ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java > >>>>> > ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java > >>>>> > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/AuditEntityObject.java > >>>>> > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java > >>>>> > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/InstanceEntityObject.java > >>>>> > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/AbstractRequester.java > >>>>> > ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java > >>>>> > ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > (original) > >>>>> +++ > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -28,6 +28,7 @@ > >>>>> import org.ofbiz.base.util.Debug; > >>>>> import > org.ofbiz.base.util.UtilValidate; > >>>>> import > org.ofbiz.webapp.stats.VisitHandler; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericValue; > >>>>> @@ -58,7 +59,7 @@ > >>>>> String > delegatorName = (String) > session.getAttribute("delegatorName"); > >>>>> > GenericDelegator delegator = null; > >>>>> if > (UtilValidate.isNotEmpty(delegatorName)) { > >>>>> - > delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> if > (delegator == null) { > >>>>> > Debug.logError("Could not find delegator > with delegatorName in session, not saving abandoned cart > info.", module); > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > (original) > >>>>> +++ > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -21,6 +21,7 @@ > >>>>> import javolution.util.FastList; > >>>>> import javolution.util.FastMap; > >>>>> import org.ofbiz.base.util.*; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericPK; > >>>>> @@ -275,7 +276,7 @@ > >>>>> > >>>>> public > GenericDelegator getDelegator() { > >>>>> if > (delegator == null) { > >>>>> - > delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> return > delegator; > >>>>> } > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > (original) > >>>>> +++ > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -41,6 +41,7 @@ > >>>>> import org.ofbiz.base.util.UtilMisc; > >>>>> import > org.ofbiz.base.util.UtilProperties; > >>>>> import > org.ofbiz.base.util.UtilValidate; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericPK; > >>>>> @@ -2406,7 +2407,7 @@ > >>>>> > if (UtilValidate.isEmpty(delegatorName)) > { > >>>>> > throw new > IllegalStateException("Bad delegator name"); > >>>>> > } > >>>>> - > delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> return > delegator; > >>>>> } > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > (original) > >>>>> +++ > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -35,6 +35,7 @@ > >>>>> import > org.ofbiz.base.util.UtilFormatOut; > >>>>> import org.ofbiz.base.util.UtilMisc; > >>>>> import > org.ofbiz.base.util.UtilValidate; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericValue; > >>>>> @@ -500,7 +501,7 @@ > >>>>> > >>>>> public > GenericDelegator getDelegator() { > >>>>> if > (_delegator == null) { > >>>>> - > _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> return > _delegator; > >>>>> } > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > (original) > >>>>> +++ > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -32,6 +32,7 @@ > >>>>> import org.ofbiz.base.util.UtilMisc; > >>>>> import > org.ofbiz.base.util.UtilProperties; > >>>>> import > org.ofbiz.base.util.UtilValidate; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericValue; > >>>>> @@ -76,7 +77,7 @@ > >>>>> > >>>>> public > GenericDelegator getDelegator() { > >>>>> if > (_delegator == null) { > >>>>> - > _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> return > _delegator; > >>>>> } > >>>>> > >>>>> Modified: > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > (original) > >>>>> +++ > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -34,6 +34,7 @@ > >>>>> import > org.ofbiz.base.util.UtilNumber; > >>>>> import > org.ofbiz.base.util.UtilProperties; > >>>>> import > org.ofbiz.base.util.UtilValidate; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> import > org.ofbiz.entity.GenericEntityException; > >>>>> import org.ofbiz.entity.GenericValue; > >>>>> @@ -102,7 +103,7 @@ > >>>>> > >>>>> public > GenericDelegator getDelegator() { > >>>>> if > (_delegator == null) { > >>>>> - > _delegator = > GenericDelegator.getGenericDelegator(delegatorName); > >>>>> + > _delegator = > DelegatorFactory.getGenericDelegator(delegatorName); > >>>>> } > >>>>> return > _delegator; > >>>>> } > >>>>> > >>>>> Modified: > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > (original) > >>>>> +++ > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -36,6 +36,7 @@ > >>>>> import > org.ofbiz.base.container.ContainerException; > >>>>> import > org.ofbiz.base.container.ContainerConfig.Container.Property; > >>>>> import org.ofbiz.base.util.*; > >>>>> +import > org.ofbiz.entity.DelegatorFactory; > >>>>> import > org.ofbiz.entity.GenericDelegator; > >>>>> > >>>>> import org.apache.catalina.Cluster; > >>>>> @@ -168,7 +169,7 @@ > >>>>> //int > debug = ContainerConfig.getPropertyValue(cc, "debug", 0); > >>>>> > >>>>> // grab > some global context settings > >>>>> - > this.delegator = > GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, > "delegator-name", "default")); > >>>>> + > this.delegator = > DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, > "delegator-name", "default")); > >>>>> > this.contextReloadable = > ContainerConfig.getPropertyValue(cc, > "apps-context-reloadable", false); > >>>>> > this.crossContext = > ContainerConfig.getPropertyValue(cc, "apps-cross-context", > true); > >>>>> > this.distribute = > ContainerConfig.getPropertyValue(cc, "apps-distributable", > true); > >>>>> > >>>>> Added: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > (added) > >>>>> +++ > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -0,0 +1,110 @@ > >>>>> +/* > >>>>> + * Licensed to the Apache Software > Foundation (ASF) under one > >>>>> + * or more contributor license > agreements. See the NOTICE file > >>>>> + * distributed with this work for > additional information > >>>>> + * regarding copyright > ownership. The ASF licenses this file > >>>>> + * to you 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. > >>>>> + */ > >>>>> +package org.ofbiz.entity; > >>>>> + > >>>>> +import java.util.Map; > >>>>> + > >>>>> +import javolution.util.FastMap; > >>>>> + > >>>>> +import org.ofbiz.base.util.Debug; > >>>>> +import org.ofbiz.entity.cache.Cache; > >>>>> +import > org.ofbiz.entity.config.DelegatorInfo; > >>>>> +import > org.ofbiz.entity.config.EntityConfigUtil; > >>>>> +import > org.ofbiz.entity.eca.EntityEcaHandler; > >>>>> +import > org.ofbiz.entity.model.ModelGroupReader; > >>>>> +import > org.ofbiz.entity.model.ModelReader; > >>>>> +import > org.ofbiz.entity.util.DistributedCacheClear; > >>>>> +import > org.ofbiz.entity.util.EntityCrypto; > >>>>> +import > org.ofbiz.entity.util.SequenceUtil; > >>>>> + > >>>>> +/** Data source for the DelegatorImpl > Class. */ > >>>>> +public class DelegatorData implements > Cloneable { > >>>>> + > >>>>> + public static final > String module = DelegatorData.class.getName(); > >>>>> + /** > >>>>> + * the > delegatorDataCache will now be a HashMap, allowing reload > of > >>>>> + * > definitions, but the delegator will always be the same > object for the > >>>>> + * given > name > >>>>> + */ > >>>>> + protected static final > Map<String, DelegatorData> delegatorDataCache = > FastMap.newInstance(); > >>>>> + > >>>>> + /** > >>>>> + * keeps a > list of field key sets used in the by and cache, a Set (of > Sets > >>>>> + * of > fieldNames) for each entityName > >>>>> + */ > >>>>> + protected Map<?, > ?> andCacheFieldSets = FastMap.newInstance(); > >>>>> + protected Cache cache = > null; > >>>>> + protected EntityCrypto > crypto = null; > >>>>> + protected DelegatorInfo > delegatorInfo = null; > >>>>> + protected String > delegatorName = null; > >>>>> + protected > DistributedCacheClear distributedCacheClear = null; > >>>>> + protected > EntityEcaHandler<?> entityEcaHandler = null; > >>>>> + protected > ModelGroupReader modelGroupReader = null; > >>>>> + protected ModelReader > modelReader = null; > >>>>> + protected String > originalDelegatorName = null; > >>>>> + protected SequenceUtil > sequencer = null; > >>>>> + protected boolean > initialized = false; > >>>>> + > >>>>> + public static > synchronized DelegatorData getInstance(String delegatorName) > throws GenericEntityException { > >>>>> + if > (delegatorName == null) { > >>>>> + > delegatorName = "default"; > >>>>> + > Debug.logWarning(new Exception("Location where > getting delegator with null name"), "Got a > getGenericDelegator call with a null delegatorName, assuming > \"default\" for the name.", module); > >>>>> + } > >>>>> + > DelegatorData delegatorData = > delegatorDataCache.get(delegatorName); > >>>>> + if > (delegatorData == null) { > >>>>> + > if (Debug.infoOn()) { > >>>>> + > Debug.logInfo("Creating new delegator > data instance [" + delegatorName + "] (" + > Thread.currentThread().getName() + ")", module); > >>>>> + > } > >>>>> + > delegatorData = new DelegatorData(delegatorName); > >>>>> + > delegatorDataCache.put(delegatorName, > delegatorData); > >>>>> + } > >>>>> + return > delegatorData; > >>>>> + } > >>>>> + > >>>>> + /** Only allow creation > through the factory method */ > >>>>> + protected > DelegatorData() { > >>>>> + } > >>>>> + > >>>>> + /** Only allow creation > through the factory method */ > >>>>> + protected > DelegatorData(String delegatorName) throws > GenericEntityException { > >>>>> + > this.delegatorName = delegatorName; > >>>>> + > this.originalDelegatorName = delegatorName; > >>>>> + > this.modelReader = > ModelReader.getModelReader(delegatorName); > >>>>> + > this.modelGroupReader = > ModelGroupReader.getModelGroupReader(delegatorName); > >>>>> + > this.cache = new Cache(delegatorName); > >>>>> + > this.delegatorInfo = > EntityConfigUtil.getDelegatorInfo(this.delegatorName); > >>>>> + } > >>>>> + > >>>>> + @Override > >>>>> + protected Object > clone() { > >>>>> + > DelegatorData delegatorData = new DelegatorData(); > >>>>> + > delegatorData.modelReader = this.modelReader; > >>>>> + > delegatorData.modelGroupReader = this.modelGroupReader; > >>>>> + > delegatorData.delegatorName = this.delegatorName; > >>>>> + > delegatorData.delegatorInfo = this.delegatorInfo; > >>>>> + > delegatorData.cache = this.cache; > >>>>> + > delegatorData.andCacheFieldSets = this.andCacheFieldSets; > >>>>> + > delegatorData.distributedCacheClear = > this.distributedCacheClear; > >>>>> + > delegatorData.originalDelegatorName = > this.originalDelegatorName; > >>>>> + > delegatorData.entityEcaHandler = this.entityEcaHandler; > >>>>> + > delegatorData.sequencer = this.sequencer; > >>>>> + > delegatorData.crypto = this.crypto; > >>>>> + return > delegatorData; > >>>>> + } > >>>>> +} > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:eol-style = native > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:keywords = "Date Rev Author > URL Id" > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:mime-type = text/plain > >>>>> > >>>>> Added: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto > >>>>> > ============================================================================== > >>>>> --- > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > (added) > >>>>> +++ > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > Sun Aug 9 18:04:26 2009 > >>>>> @@ -0,0 +1,44 @@ > >>>>> +/* > >>>>> + * Licensed to the Apache Software > Foundation (ASF) under one > >>>>> + * or more contributor license > agreements. See the NOTICE file > >>>>> + * distributed with this work for > additional information > >>>>> + * regarding copyright > ownership. The ASF licenses this file > >>>>> + * to you 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. > >>>>> + */ > >>>>> +package org.ofbiz.entity; > >>>>> + > >>>>> +import org.ofbiz.base.util.Debug; > >>>>> + > >>>>> +/** GenericDelegator Factory Class. > */ > >>>>> +public class DelegatorFactory { > >>>>> + > >>>>> + public static final > String module = DelegatorFactory.class.getName(); > >>>>> + > >>>>> + public static > GenericDelegator getGenericDelegator(String delegatorName) > { > >>>>> + if > (delegatorName == null) { > >>>>> + > delegatorName = "default"; > >>>>> + > Debug.logWarning(new Exception("Location where > getting delegator with null name"), "Got a > getGenericDelegator call with a null delegatorName, assuming > default for the name.", module); > >>>>> + } > >>>>> + > DelegatorData delegatorData = null; > >>>>> + try { > >>>>> + > delegatorData = > DelegatorData.getInstance(delegatorName); > >>>>> + } catch > (GenericEntityException e) { > >>>>> + > Debug.logError(e, "Could not create delegator with > name \"" + delegatorName + "\": ", module); > >>>>> + } > >>>>> + if > (delegatorData != null) { > >>>>> + > return new DelegatorImpl(delegatorData); > >>>>> + } > >>>>> + return > null; > >>>>> + } > >>>>> +} > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:eol-style = native > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:keywords = "Date Rev Author > URL Id" > >>>>> > >>>>> Propchange: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > >>>>> > ------------------------------------------------------------------------------ > >>>>> svn:mime-type = text/plain > >>>>> > >>>>> > > |
David,
I think I figured out where the confusion comes from - we have different ideas of the ExecutionContext role. I see it as a means to keep track of the execution path, plus a container for frequently used objects. I believe you see it doing much more than that. I updated my local copy of the branch with my changes from the trunk, but there isn't much I can do to test it - since nothing will compile. I'm at an impasse. I believe the ExecutionContext (and ultimately the security-aware artifacts) can be introduced into the project small steps at a time - with each step being backwards compatible. I can see from the branch your approach is to rewrite everything. Please accept this in the spirit it is intended. I have collaborated with you in the past, and it has always been enjoyable and rewarding. I'm not trying to be argumentative or adversarial. I only want to help. But I don't like the direction you're taking with this. Here's what I suggest: let's create a new branch, and introduce changes that can be compiled and tested. In other words, the branch is always functional. I know you're busy, but please try to communicate more. A lot of what you have in mind is in your head. I can't see inside your head. Keep in mind that we have a design document we can use to share ideas and agree on designs. I have my local copy of the trunk 50% there as far as the security-aware artifacts are concerned. I'd really like to get it into the project. What do you think? -Adrian --- On Mon, 8/10/09, Adrian Crum <[hidden email]> wrote: > From: Adrian Crum <[hidden email]> > Subject: Re: svn commit: r802567 [1/5] - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/product/src/org/ofbiz/shipment/packing/ applications/product/src/org/ofbiz/shipment/verify/ applications/product/src/org/ofbiz/shipment/weigh... > To: [hidden email] > Date: Monday, August 10, 2009, 5:15 PM > lol - while i was driving home I > realized that statement would cause confusion. The basic > part of keeping track of the execution path is in > framework/base. Other components extend it to add the higher > level artifacts. > > Let me fix the branch. Then I'll port my implementation > over to it and commit it. Then you can try it out. It's > working quite well. > > -Adrian > > --- On Mon, 8/10/09, David E Jones <[hidden email]> > wrote: > > > From: David E Jones <[hidden email]> > > Subject: Re: svn commit: r802567 [1/5] - in > /ofbiz/trunk: > applications/order/src/org/ofbiz/order/shoppingcart/ > applications/product/src/org/ofbiz/shipment/packing/ > applications/product/src/org/ofbiz/shipment/verify/ > applications/product/src/org/ofbiz/shipment/weigh... > > To: [hidden email] > > Date: Monday, August 10, 2009, 4:41 PM > > > > If the ExecutionContext interface is in base and the > > GenericDelegator interface is in entity and the > > ExecutionContext needs to use the GenericDelegator > > interface, how will that work? > > > > -David > > > > > > On Aug 10, 2009, at 5:19 PM, Adrian Crum wrote: > > > > > In my implementation, I put the ExecutionContext > in > > framework/base. > > > > > > I'll work on updating the branch - I caused the > > problem, so I'll fix it. > > > > > > -Adrian > > > > > > David E Jones wrote: > > >> Yes, that's why I did a similar thing in the > > branch. > > >> Stepping back a little... please keep in mind > that > > the interface will not be able to stay in the entity > > component. Part of the point of making these > interfaces is > > so that we can have a ExecutionContext that knows > certain > > things about a number of framework components without > > actually depending on those components at compile > time. > > Instead with the interfaces in the execution context > > component all of the other components can depend on > and > > share that. > > >> Without that pattern it will be impossible > to > > implement the execution context. As part of that, I'd > rather > > do them all together rather than separately otherwise > (like > > I mentioned before) merging the branch will become > > difficult. In fact, even with the changes you've > already > > added to the trunk the merge is already a HUGE mess... > (ie > > just updating the branch against the trunk). > > >> -David > > >> On Aug 10, 2009, at 4:42 PM, Adrian Crum > wrote: > > >>> I checked out the branch and examined > it. > > After looking over your ideas, I saw a way to make > > incremental changes to the trunk - negating the need > for a > > branch. > > >>> > > >>> The GenericDelegator refactor was done > for two > > reasons: > > >>> > > >>> 1. To eliminate the hundreds of > references to > > a concrete class, that have caused inconvenience in > the > > past. > > >>> 2. Eliminate thread local variables and > the > > cumbersome pushing and popping of the > GenericDelegator > > state. > > >>> > > >>> How it relates to the ExecutionContext > is, we > > have the ability to keep an instance in the > GenericDelegator > > without having to create more thread local variables > and > > have even more things to push/pop. > > >>> > > >>> It's a cleaner design. > > >>> > > >>> -Adrian > > >>> > > >>> David E Jones wrote: > > >>>> Adrian, > > >>>> What is all of this, and how does it > > relate to what I've been working on in the > > executioncontext20090716 branch? > > >>>> It seems like this will: > > >>>> 1. cause some inconvenience now, > while > > more comprehensive changes are being made in the > > executioncontext20090716 branch > > >>>> 2. make it a LOT more difficult > (perhaps > > impossible) to merge the executioncontext20090716 > branch > > >>>> What is your plan with this? > > >>>> It would make life a lot easier for > all of > > us if you would do some research on what I've already > done > > in the executioncontext20090716 branch before > continuing > > with this. > > >>>> -David > > >>>> On Aug 9, 2009, at 12:04 PM, [hidden email] > > wrote: > > >>>>> Author: adrianc > > >>>>> Date: Sun Aug 9 18:04:26 2009 > > >>>>> New Revision: 802567 > > >>>>> > > >>>>> URL: http://svn.apache.org/viewvc?rev=802567&view=rev > > >>>>> Log: > > >>>>> Refactored GenericDelegator: > > >>>>> > > >>>>> 1. Converted GenericDelegator to > an > > interface. We already have DelegatorInterface, but it > isn't > > being used anywhere. Removed DelegatorInterface.java. > > >>>>> > > >>>>> 2. Extracted the static, cached > data > > from the GenericDelegator implementation and put it in > its > > own class - DelegatorData. The GenericDelegator > > implementation holds a reference to the DelegatorData > > instance. This makes it possible to have per-thread > > instances of GenericDelegator. > > >>>>> > > >>>>> 3. Replaced the ThreadLocal > variables > > with regular variables. ThreadLocal variables are no > longer > > needed. Client code doesn't need to be concerned with > > pushing and popping the GenericDelegator state. > > >>>>> > > >>>>> This commit paves the way for > the > > forthcoming ExecutionContext. > > >>>>> > > >>>>> User modifications will have to > > replace GenericDelegator.getGenericDelegator(...) > with > > DelegatorFactory.getGenericDelegator(...). Also, > replace the > > push code with the new setXxx methods, and remove the > pop > > code. If modifications used DelegatorInterface, > replace that > > with GenericDelegator. > > >>>>> > > >>>>> Aside from those changes, this > commit > > is backwards compatible. > > >>>>> > > >>>>> Added: > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java (with > > props) > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (with > > props) > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java (with > > props) > > >>>>> Removed: > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java > > >>>>> Modified: > > >>>>> > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > > >>>>> > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > > >>>>> > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > > >>>>> > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > > >>>>> > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > > >>>>> > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > > >>>>> > > > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java > > >>>>> > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java > > >>>>> > > > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java > > >>>>> > > > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java > > >>>>> > > > ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java > > >>>>> > > > ofbiz/trunk/framework/guiapp/src/org/ofbiz/guiapp/xui/XuiContainer.java > > >>>>> > > > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java > > >>>>> > > > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java > > >>>>> > > > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java > > >>>>> > > > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java > > >>>>> > > > ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java > > >>>>> > > > ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java > > >>>>> > > > ofbiz/trunk/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java > > >>>>> > > > ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java > > >>>>> > > > ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/webdav/WebDavServlet.java > > >>>>> > > > ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java > > >>>>> > > > ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java > > >>>>> > > > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/audit/AuditEntityObject.java > > >>>>> > > > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java > > >>>>> > > > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/instance/InstanceEntityObject.java > > >>>>> > > > ofbiz/trunk/specialpurpose/shark/src/org/ofbiz/shark/requester/AbstractRequester.java > > >>>>> > > > ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java > > >>>>> > > > ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -28,6 +28,7 @@ > > >>>>> import > org.ofbiz.base.util.Debug; > > >>>>> import > > org.ofbiz.base.util.UtilValidate; > > >>>>> import > > org.ofbiz.webapp.stats.VisitHandler; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericValue; > > >>>>> @@ -58,7 +59,7 @@ > > >>>>> String > > delegatorName = (String) > > session.getAttribute("delegatorName"); > > >>>>> > > GenericDelegator delegator = null; > > >>>>> if > > (UtilValidate.isNotEmpty(delegatorName)) { > > >>>>> - > > delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> if > > (delegator == null) { > > >>>>> > > Debug.logError("Could not find delegator > > with delegatorName in session, not saving abandoned > cart > > info.", module); > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -21,6 +21,7 @@ > > >>>>> import javolution.util.FastList; > > >>>>> import javolution.util.FastMap; > > >>>>> import org.ofbiz.base.util.*; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericPK; > > >>>>> @@ -275,7 +276,7 @@ > > >>>>> > > >>>>> public > > GenericDelegator getDelegator() { > > >>>>> if > > (delegator == null) { > > >>>>> - > > delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> return > > delegator; > > >>>>> } > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -41,6 +41,7 @@ > > >>>>> import > org.ofbiz.base.util.UtilMisc; > > >>>>> import > > org.ofbiz.base.util.UtilProperties; > > >>>>> import > > org.ofbiz.base.util.UtilValidate; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericPK; > > >>>>> @@ -2406,7 +2407,7 @@ > > >>>>> > > if (UtilValidate.isEmpty(delegatorName)) > > { > > >>>>> > > throw new > > IllegalStateException("Bad delegator name"); > > >>>>> > > } > > >>>>> - > > delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> return > > delegator; > > >>>>> } > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -35,6 +35,7 @@ > > >>>>> import > > org.ofbiz.base.util.UtilFormatOut; > > >>>>> import > org.ofbiz.base.util.UtilMisc; > > >>>>> import > > org.ofbiz.base.util.UtilValidate; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericValue; > > >>>>> @@ -500,7 +501,7 @@ > > >>>>> > > >>>>> public > > GenericDelegator getDelegator() { > > >>>>> if > > (_delegator == null) { > > >>>>> - > > _delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > _delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> return > > _delegator; > > >>>>> } > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -32,6 +32,7 @@ > > >>>>> import > org.ofbiz.base.util.UtilMisc; > > >>>>> import > > org.ofbiz.base.util.UtilProperties; > > >>>>> import > > org.ofbiz.base.util.UtilValidate; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericValue; > > >>>>> @@ -76,7 +77,7 @@ > > >>>>> > > >>>>> public > > GenericDelegator getDelegator() { > > >>>>> if > > (_delegator == null) { > > >>>>> - > > _delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > _delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> return > > _delegator; > > >>>>> } > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/applications/product/src/org/ofbiz/shipment/weightPackage/WeightPackageSession.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -34,6 +34,7 @@ > > >>>>> import > > org.ofbiz.base.util.UtilNumber; > > >>>>> import > > org.ofbiz.base.util.UtilProperties; > > >>>>> import > > org.ofbiz.base.util.UtilValidate; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> import > > org.ofbiz.entity.GenericEntityException; > > >>>>> import > org.ofbiz.entity.GenericValue; > > >>>>> @@ -102,7 +103,7 @@ > > >>>>> > > >>>>> public > > GenericDelegator getDelegator() { > > >>>>> if > > (_delegator == null) { > > >>>>> - > > _delegator = > > GenericDelegator.getGenericDelegator(delegatorName); > > >>>>> + > > _delegator = > > DelegatorFactory.getGenericDelegator(delegatorName); > > >>>>> } > > >>>>> return > > _delegator; > > >>>>> } > > >>>>> > > >>>>> Modified: > > > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=802567&r1=802566&r2=802567&view=diff > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > > (original) > > >>>>> +++ > > > ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -36,6 +36,7 @@ > > >>>>> import > > org.ofbiz.base.container.ContainerException; > > >>>>> import > > > org.ofbiz.base.container.ContainerConfig.Container.Property; > > >>>>> import org.ofbiz.base.util.*; > > >>>>> +import > > org.ofbiz.entity.DelegatorFactory; > > >>>>> import > > org.ofbiz.entity.GenericDelegator; > > >>>>> > > >>>>> import > org.apache.catalina.Cluster; > > >>>>> @@ -168,7 +169,7 @@ > > >>>>> //int > > debug = ContainerConfig.getPropertyValue(cc, "debug", > 0); > > >>>>> > > >>>>> // grab > > some global context settings > > >>>>> - > > this.delegator = > > > GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, > > "delegator-name", "default")); > > >>>>> + > > this.delegator = > > > DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, > > "delegator-name", "default")); > > >>>>> > > this.contextReloadable = > > ContainerConfig.getPropertyValue(cc, > > "apps-context-reloadable", false); > > >>>>> > > this.crossContext = > > ContainerConfig.getPropertyValue(cc, > "apps-cross-context", > > true); > > >>>>> > > this.distribute = > > ContainerConfig.getPropertyValue(cc, > "apps-distributable", > > true); > > >>>>> > > >>>>> Added: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java?rev=802567&view=auto > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > (added) > > >>>>> +++ > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -0,0 +1,110 @@ > > >>>>> +/* > > >>>>> + * Licensed to the Apache > Software > > Foundation (ASF) under one > > >>>>> + * or more contributor license > > agreements. See the NOTICE file > > >>>>> + * distributed with this work > for > > additional information > > >>>>> + * regarding copyright > > ownership. The ASF licenses this file > > >>>>> + * to you 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. > > >>>>> + */ > > >>>>> +package org.ofbiz.entity; > > >>>>> + > > >>>>> +import java.util.Map; > > >>>>> + > > >>>>> +import javolution.util.FastMap; > > >>>>> + > > >>>>> +import > org.ofbiz.base.util.Debug; > > >>>>> +import > org.ofbiz.entity.cache.Cache; > > >>>>> +import > > org.ofbiz.entity.config.DelegatorInfo; > > >>>>> +import > > org.ofbiz.entity.config.EntityConfigUtil; > > >>>>> +import > > org.ofbiz.entity.eca.EntityEcaHandler; > > >>>>> +import > > org.ofbiz.entity.model.ModelGroupReader; > > >>>>> +import > > org.ofbiz.entity.model.ModelReader; > > >>>>> +import > > org.ofbiz.entity.util.DistributedCacheClear; > > >>>>> +import > > org.ofbiz.entity.util.EntityCrypto; > > >>>>> +import > > org.ofbiz.entity.util.SequenceUtil; > > >>>>> + > > >>>>> +/** Data source for the > DelegatorImpl > > Class. */ > > >>>>> +public class DelegatorData > implements > > Cloneable { > > >>>>> + > > >>>>> + public static final > > String module = DelegatorData.class.getName(); > > >>>>> + /** > > >>>>> + * the > > delegatorDataCache will now be a HashMap, allowing > reload > > of > > >>>>> + * > > definitions, but the delegator will always be the > same > > object for the > > >>>>> + * given > > name > > >>>>> + */ > > >>>>> + protected static final > > Map<String, DelegatorData> delegatorDataCache = > > FastMap.newInstance(); > > >>>>> + > > >>>>> + /** > > >>>>> + * keeps a > > list of field key sets used in the by and cache, a Set > (of > > Sets > > >>>>> + * of > > fieldNames) for each entityName > > >>>>> + */ > > >>>>> + protected Map<?, > > ?> andCacheFieldSets = FastMap.newInstance(); > > >>>>> + protected Cache cache = > > null; > > >>>>> + protected EntityCrypto > > crypto = null; > > >>>>> + protected DelegatorInfo > > delegatorInfo = null; > > >>>>> + protected String > > delegatorName = null; > > >>>>> + protected > > DistributedCacheClear distributedCacheClear = null; > > >>>>> + protected > > EntityEcaHandler<?> entityEcaHandler = null; > > >>>>> + protected > > ModelGroupReader modelGroupReader = null; > > >>>>> + protected ModelReader > > modelReader = null; > > >>>>> + protected String > > originalDelegatorName = null; > > >>>>> + protected SequenceUtil > > sequencer = null; > > >>>>> + protected boolean > > initialized = false; > > >>>>> + > > >>>>> + public static > > synchronized DelegatorData getInstance(String > delegatorName) > > throws GenericEntityException { > > >>>>> + if > > (delegatorName == null) { > > >>>>> + > > delegatorName = "default"; > > >>>>> + > > Debug.logWarning(new Exception("Location where > > getting delegator with null name"), "Got a > > getGenericDelegator call with a null delegatorName, > assuming > > \"default\" for the name.", module); > > >>>>> + } > > >>>>> + > > DelegatorData delegatorData = > > delegatorDataCache.get(delegatorName); > > >>>>> + if > > (delegatorData == null) { > > >>>>> + > > if (Debug.infoOn()) { > > >>>>> + > > Debug.logInfo("Creating new delegator > > data instance [" + delegatorName + "] (" + > > Thread.currentThread().getName() + ")", module); > > >>>>> + > > } > > >>>>> + > > delegatorData = new DelegatorData(delegatorName); > > >>>>> + > > delegatorDataCache.put(delegatorName, > > delegatorData); > > >>>>> + } > > >>>>> + return > > delegatorData; > > >>>>> + } > > >>>>> + > > >>>>> + /** Only allow creation > > through the factory method */ > > >>>>> + protected > > DelegatorData() { > > >>>>> + } > > >>>>> + > > >>>>> + /** Only allow creation > > through the factory method */ > > >>>>> + protected > > DelegatorData(String delegatorName) throws > > GenericEntityException { > > >>>>> + > > this.delegatorName = delegatorName; > > >>>>> + > > this.originalDelegatorName = delegatorName; > > >>>>> + > > this.modelReader = > > ModelReader.getModelReader(delegatorName); > > >>>>> + > > this.modelGroupReader = > > ModelGroupReader.getModelGroupReader(delegatorName); > > >>>>> + > > this.cache = new Cache(delegatorName); > > >>>>> + > > this.delegatorInfo = > > > EntityConfigUtil.getDelegatorInfo(this.delegatorName); > > >>>>> + } > > >>>>> + > > >>>>> + @Override > > >>>>> + protected Object > > clone() { > > >>>>> + > > DelegatorData delegatorData = new DelegatorData(); > > >>>>> + > > delegatorData.modelReader = this.modelReader; > > >>>>> + > > delegatorData.modelGroupReader = > this.modelGroupReader; > > >>>>> + > > delegatorData.delegatorName = this.delegatorName; > > >>>>> + > > delegatorData.delegatorInfo = this.delegatorInfo; > > >>>>> + > > delegatorData.cache = this.cache; > > >>>>> + > > delegatorData.andCacheFieldSets = > this.andCacheFieldSets; > > >>>>> + > > delegatorData.distributedCacheClear = > > this.distributedCacheClear; > > >>>>> + > > delegatorData.originalDelegatorName = > > this.originalDelegatorName; > > >>>>> + > > delegatorData.entityEcaHandler = > this.entityEcaHandler; > > >>>>> + > > delegatorData.sequencer = this.sequencer; > > >>>>> + > > delegatorData.crypto = this.crypto; > > >>>>> + return > > delegatorData; > > >>>>> + } > > >>>>> +} > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:eol-style = native > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:keywords = "Date Rev > Author > > URL Id" > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorData.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:mime-type = text/plain > > >>>>> > > >>>>> Added: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=802567&view=auto > > >>>>> > > > ============================================================================== > > >>>>> --- > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > (added) > > >>>>> +++ > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > Sun Aug 9 18:04:26 2009 > > >>>>> @@ -0,0 +1,44 @@ > > >>>>> +/* > > >>>>> + * Licensed to the Apache > Software > > Foundation (ASF) under one > > >>>>> + * or more contributor license > > agreements. See the NOTICE file > > >>>>> + * distributed with this work > for > > additional information > > >>>>> + * regarding copyright > > ownership. The ASF licenses this file > > >>>>> + * to you 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. > > >>>>> + */ > > >>>>> +package org.ofbiz.entity; > > >>>>> + > > >>>>> +import > org.ofbiz.base.util.Debug; > > >>>>> + > > >>>>> +/** GenericDelegator Factory > Class. > > */ > > >>>>> +public class DelegatorFactory { > > >>>>> + > > >>>>> + public static final > > String module = DelegatorFactory.class.getName(); > > >>>>> + > > >>>>> + public static > > GenericDelegator getGenericDelegator(String > delegatorName) > > { > > >>>>> + if > > (delegatorName == null) { > > >>>>> + > > delegatorName = "default"; > > >>>>> + > > Debug.logWarning(new Exception("Location where > > getting delegator with null name"), "Got a > > getGenericDelegator call with a null delegatorName, > assuming > > default for the name.", module); > > >>>>> + } > > >>>>> + > > DelegatorData delegatorData = null; > > >>>>> + try { > > >>>>> + > > delegatorData = > > DelegatorData.getInstance(delegatorName); > > >>>>> + } catch > > (GenericEntityException e) { > > >>>>> + > > Debug.logError(e, "Could not create delegator with > > name \"" + delegatorName + "\": ", module); > > >>>>> + } > > >>>>> + if > > (delegatorData != null) { > > >>>>> + > > return new DelegatorImpl(delegatorData); > > >>>>> + } > > >>>>> + return > > null; > > >>>>> + } > > >>>>> +} > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:eol-style = native > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:keywords = "Date Rev > Author > > URL Id" > > >>>>> > > >>>>> Propchange: > > > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java > > >>>>> > > > ------------------------------------------------------------------------------ > > >>>>> svn:mime-type = text/plain > > >>>>> > > >>>>> > > > > > > > > |
Free forum by Nabble | Edit this page |