diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-06 09:10:54 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-06 09:10:54 +0000 |
commit | 168cd98fee1fe54e434795027dff44657ebfb937 (patch) | |
tree | 22dd34ece2655359ee02703154cc3c59e70eba95 /sca-java-2.x/trunk/modules/core | |
parent | 27e7df7cfb7e9d33348dc32652a65d373fd146f9 (diff) |
Minor performance enhacement - look up all the factories once instead of each time
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1078430 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core')
2 files changed, 46 insertions, 22 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java index 2de52bebb2..d2528784fd 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java @@ -19,10 +19,20 @@ package org.apache.tuscany.sca.core.context; +import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.context.ComponentContextFactory; import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; +import org.apache.tuscany.sca.context.PropertyValueFactory; +import org.apache.tuscany.sca.context.RequestContextFactory; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.core.context.impl.ComponentContextImpl; +import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.runtime.CompositeActivator; +import org.apache.tuscany.sca.runtime.EndpointReferenceBinder; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.oasisopen.sca.ComponentContext; @@ -31,13 +41,32 @@ import org.oasisopen.sca.ComponentContext; */ public class DefaultComponentContextFactory implements ComponentContextFactory { private final ExtensionPointRegistry registry; + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaInterfaceFactory; + private CompositeActivator compositeActivator; + private RequestContextFactory requestContextFactory; + private PropertyValueFactory propertyFactory; + private EndpointReferenceBinder eprBinder; + private ExtensibleProxyFactory proxyFactory; public DefaultComponentContextFactory(ExtensionPointRegistry registry) { this.registry = registry; + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + this.assemblyFactory = factories.getFactory(AssemblyFactory.class); + this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); + this.compositeActivator = utilities.getUtility(CompositeActivator.class); + this.requestContextFactory = + registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class); + this.propertyFactory = factories.getFactory(PropertyValueFactory.class); + this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); + this.proxyFactory = ExtensibleProxyFactory.getInstance(registry); } public ComponentContext createComponentContext(CompositeContext compositeContext, RuntimeComponent component) { - return new ComponentContextImpl(registry, compositeContext, component); + return new ComponentContextImpl(registry, assemblyFactory, javaInterfaceFactory, compositeActivator, + requestContextFactory, propertyFactory, eprBinder, proxyFactory, + compositeContext, component); } } diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java index d9cb512501..f0053e2ce0 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java @@ -35,13 +35,9 @@ import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.CompositeContext; -import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -80,26 +76,25 @@ public class ComponentContextImpl implements RuntimeComponentContext { private final ExtensionPointRegistry registry; public ComponentContextImpl(ExtensionPointRegistry registry, + AssemblyFactory assemblyFactory, + JavaInterfaceFactory javaInterfaceFactory, + CompositeActivator compositeActivator, + RequestContextFactory requestContextFactory, + PropertyValueFactory propertyFactory, + EndpointReferenceBinder eprBinder, + ProxyFactory proxyFactory, CompositeContext compositeContext, RuntimeComponent component) { - this.component = component; - FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); - this.assemblyFactory = factories.getFactory(AssemblyFactory.class); - this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); - - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - this.compositeContext = compositeContext; - - this.compositeActivator = utilities.getUtility(CompositeActivator.class); - - this.requestContextFactory = - registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class); - this.proxyFactory = ExtensibleProxyFactory.getInstance(registry); - this.propertyFactory = factories.getFactory(PropertyValueFactory.class); - - this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class); - this.registry = registry; + this.assemblyFactory = assemblyFactory; + this.javaInterfaceFactory = javaInterfaceFactory; + this.compositeActivator = compositeActivator; + this.requestContextFactory = requestContextFactory; + this.propertyFactory = propertyFactory; + this.eprBinder = eprBinder; + this.proxyFactory = proxyFactory; + this.compositeContext = compositeContext; + this.component = component; } public String getURI() { |