diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-30 04:39:55 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-30 04:39:55 +0000 |
commit | 563383415f9efeb2ff9420f0097989e5b79a6257 (patch) | |
tree | 541c21b1ad15cfae8f057a70197b0e564dde3904 /branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java | |
parent | b61cf23bd501dfde37fbef4056a7b1148ae92268 (diff) |
Fix for TUSCANY-3000
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@770058 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java')
5 files changed, 65 insertions, 61 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java index 695dea3343..eefe82f1d9 100644 --- a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java +++ b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.implementation.java.injection;
@@ -26,6 +26,8 @@ import java.util.StringTokenizer; import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
import org.apache.tuscany.sca.databinding.Mediator;
@@ -55,7 +57,11 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { public JavaPropertyValueObjectFactory(Mediator mediator) {
this.mediator = mediator;
}
-
+
+ public JavaPropertyValueObjectFactory(ExtensionPointRegistry registry) {
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
public ObjectFactory createValueFactory(Property property, Object propertyValue, JavaElementImpl javaElement) {
isSimpleType = isSimpleType(property);
Document doc = (Document)propertyValue;
@@ -131,7 +137,7 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { }
}
- }
+ }
private boolean isSimpleType(Property property) {
if (property.getXSDType() != null) {
@@ -227,10 +233,10 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { try {
return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
+ throw new ObjectCreationException("Failed to create instance for property "
+ property.getName() + " with value " + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
+ throw new ObjectCreationException("Failed to create instance for property "
+ property.getName() + " with value " + propertyValue, ex);
}
} else {
@@ -253,12 +259,12 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { try {
values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
+ throw new ObjectCreationException("Failed to create instance for property "
+ + property.getName() + " with value " + aValue
+ " from value list of " + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
+ throw new ObjectCreationException("Failed to create instance for property "
+ + property.getName() + " with value " + aValue
+ " from value list of " + propertyValue, ex);
}
}
@@ -272,7 +278,7 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { }
}
}
-
+
public class ArrayObjectFactoryImpl extends ObjectFactoryImplBase {
public ArrayObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class javaType) {
super(property, propertyValues, isSimpleType, javaType);
@@ -287,11 +293,11 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { try {
Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
+ throw new ObjectCreationException("Failed to create instance for property "
+ property.getName() + " with value " + aValue
+ " from value list of " + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
+ throw new ObjectCreationException("Failed to create instance for property "
+ property.getName() + " with value " + aValue
+ " from value list of " + propertyValue, ex);
}
@@ -310,11 +316,11 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory { /**
* This method will create an instance of the value for the specified Property.
- *
+ *
* @param property The Property from which to retrieve the property value
* @param type The type of the property value being retrieved from the Property
* @param <B> Type type of the property value being looked up
- *
+ *
* @return the value for the Property
*/
public <B> B createPropertyValue(ComponentProperty property, Class<B> type)
diff --git a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java index e585b3d46f..29e02da648 100644 --- a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java +++ b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.invocation; @@ -37,6 +37,7 @@ import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.context.ComponentContextFactory; +import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; import org.apache.tuscany.sca.core.context.ComponentContextImpl; import org.apache.tuscany.sca.core.context.InstanceWrapper; @@ -68,7 +69,7 @@ import org.osoa.sca.annotations.ConversationID; /** * The runtime instantiation of Java component implementations - * + * * @version $Rev$ $Date$ */ public class JavaComponentContextProvider { @@ -81,7 +82,7 @@ public class JavaComponentContextProvider { public JavaComponentContextProvider(RuntimeComponent component, JavaInstanceFactoryProvider configuration, DataBindingExtensionPoint dataBindingExtensionPoint, - JavaPropertyValueObjectFactory propertyValueObjectFactory, + PropertyValueFactory propertyValueObjectFactory, ComponentContextFactory componentContextFactory, RequestContextFactory requestContextFactory) { super(); @@ -94,7 +95,7 @@ public class JavaComponentContextProvider { // } this.component = component; this.dataBindingRegistry = dataBindingExtensionPoint; - this.propertyValueFactory = propertyValueObjectFactory; + this.propertyValueFactory = (JavaPropertyValueObjectFactory) propertyValueObjectFactory; } InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException { @@ -132,7 +133,7 @@ public class JavaComponentContextProvider { ObjectFactory<?> propertyObjectFactory = createPropertyValueFactory(configuredProperty, configuredProperty.getValue(), element); instanceFactoryProvider.setObjectFactory(element, propertyObjectFactory); - + JavaConstructorImpl constructor = instanceFactoryProvider.getImplementation().getConstructor(); for(JavaElementImpl p: constructor.getParameters()){ if(element.getName().equals(p.getName())) { @@ -265,7 +266,7 @@ public class JavaComponentContextProvider { } // We need to set the PropertyValueFactory on the ComponentContextImpl - // so the ComponentContext can "de-marshal" the property type to a value + // so the ComponentContext can "de-marshal" the property type to a value // when the getProperty() method is called ComponentContextImpl ccImpl = (ComponentContextImpl)component.getComponentContext(); ccImpl.setPropertyValueFactory(propertyValueFactory); diff --git a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java index e9eea607c9..10825ca4b6 100644 --- a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java +++ b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.invocation; @@ -24,6 +24,7 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.ComponentContextFactory; +import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; import org.apache.tuscany.sca.core.context.InstanceWrapper; import org.apache.tuscany.sca.core.factory.ObjectFactory; @@ -33,7 +34,6 @@ import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider; import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl; -import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory; import org.apache.tuscany.sca.implementation.java.injection.RequestContextObjectFactory; import org.apache.tuscany.sca.implementation.java.injection.ResourceHost; import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory; @@ -55,12 +55,12 @@ public class JavaImplementationProvider implements ScopedImplementationProvider private JavaImplementation implementation; private JavaComponentContextProvider componentContextProvider; private RequestContextFactory requestContextFactory; - + public JavaImplementationProvider(RuntimeComponent component, JavaImplementation implementation, ProxyFactory proxyService, DataBindingExtensionPoint dataBindingRegistry, - JavaPropertyValueObjectFactory propertyValueObjectFactory, + PropertyValueFactory propertyValueObjectFactory, ComponentContextFactory componentContextFactory, RequestContextFactory requestContextFactory, List<PolicyHandlerTuple> policyHandlerClassNames) { @@ -68,16 +68,16 @@ public class JavaImplementationProvider implements ScopedImplementationProvider this.implementation = implementation; this.requestContextFactory = requestContextFactory; this.implementation.setPolicyHandlerClassNames(policyHandlerClassNames); - + try { JavaInstanceFactoryProvider configuration = new JavaInstanceFactoryProvider(implementation); configuration.setProxyFactory(proxyService); componentContextProvider = - new JavaComponentContextProvider(component, - configuration, + new JavaComponentContextProvider(component, + configuration, dataBindingRegistry, propertyValueObjectFactory, - componentContextFactory, + componentContextFactory, requestContextFactory); Scope scope = getScope(); @@ -110,9 +110,9 @@ public class JavaImplementationProvider implements ScopedImplementationProvider } catch (Exception e) { throw new IllegalStateException(e); } - + } - + private void handleResources(JavaImplementation componentType, ProxyFactory proxyService) { for (JavaResourceImpl resource : componentType.getResources().values()) { String name = resource.getName(); @@ -169,7 +169,7 @@ public class JavaImplementationProvider implements ScopedImplementationProvider } } } - + public boolean supportsOneWayInvocation() { return false; } diff --git a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java index 9b78439012..a97d21e1e5 100644 --- a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java +++ b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.invocation; @@ -22,11 +22,11 @@ package org.apache.tuscany.sca.implementation.java.invocation; import java.util.List; import org.apache.tuscany.sca.context.ComponentContextFactory; +import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory; import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; @@ -36,7 +36,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; * @version $Rev$ $Date$ */ public class JavaImplementationProviderFactory implements ImplementationProviderFactory<JavaImplementation> { - private JavaPropertyValueObjectFactory propertyValueObjectFactory; + private PropertyValueFactory propertyValueObjectFactory; private DataBindingExtensionPoint dataBindingRegistry; private ProxyFactory proxyService; private ComponentContextFactory componentContextFactory; @@ -45,7 +45,7 @@ public class JavaImplementationProviderFactory implements ImplementationProvider public JavaImplementationProviderFactory(ProxyFactory proxyService, DataBindingExtensionPoint dataBindingRegistry, - JavaPropertyValueObjectFactory propertyValueObjectFactory, + PropertyValueFactory propertyValueObjectFactory, ComponentContextFactory componentContextFactory, RequestContextFactory requestContextFactory, List<PolicyHandlerTuple> policyHandlerClassNames) { @@ -60,12 +60,12 @@ public class JavaImplementationProviderFactory implements ImplementationProvider public ImplementationProvider createImplementationProvider(RuntimeComponent component, JavaImplementation implementation) { - return new JavaImplementationProvider(component, - implementation, - proxyService, + return new JavaImplementationProvider(component, + implementation, + proxyService, dataBindingRegistry, - propertyValueObjectFactory, - componentContextFactory, + propertyValueObjectFactory, + componentContextFactory, requestContextFactory, policyHandlerClassNames); } diff --git a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java index 31c91e2d6c..baf942ccd9 100644 --- a/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java +++ b/branches/sca-java-1.x/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java @@ -6,25 +6,25 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.module; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import org.apache.tuscany.sca.context.ComponentContextFactory; 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.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; @@ -35,9 +35,7 @@ import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; -import org.apache.tuscany.sca.databinding.TransformerExtensionPoint; -import org.apache.tuscany.sca.databinding.impl.MediatorImpl; -import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory; +import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.implementation.java.invocation.JavaCallbackRuntimeWireProcessor; import org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationProviderFactory; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; @@ -62,7 +60,7 @@ public class JavaRuntimeModuleActivator implements ModuleActivator { ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); MessageFactory messageFactory = factories.getFactory(MessageFactory.class); - + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); InterfaceContractMapper interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); @@ -76,9 +74,8 @@ public class JavaRuntimeModuleActivator implements ModuleActivator { JavaInterfaceFactory javaFactory = factories.getFactory(JavaInterfaceFactory.class); DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class); - TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); - MediatorImpl mediator = new MediatorImpl(dataBindings, transformers); - JavaPropertyValueObjectFactory factory = new JavaPropertyValueObjectFactory(mediator); + Mediator mediator = utilities.getUtility(Mediator.class); + PropertyValueFactory factory = utilities.getUtility(PropertyValueFactory.class); ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class); ComponentContextFactory componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class); @@ -86,9 +83,9 @@ public class JavaRuntimeModuleActivator implements ModuleActivator { List<PolicyHandlerTuple> policyHandlerClassNames = null; policyHandlerClassNames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames(); - + ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactories); - + JavaImplementationProviderFactory javaImplementationProviderFactory = new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory, componentContextFactory, requestContextFactory, policyHandlerClassNames); |