You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/12/09 12:03:35 UTC
svn commit: r484966 [1/2] - in /incubator/tuscany/java/sca:
kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/
kernel/core/src/main/java/org/apache/tuscany/core/injection/
kernel/core/src/test/java/org/apache/tuscany/core/imple...
Author: jmarino
Date: Sat Dec 9 03:03:28 2006
New Revision: 484966
URL: http://svn.apache.org/viewvc?view=rev&rev=484966
Log:
cleanup Spring implementation; fix setting of XML data types on properties raised by Spring integration; minor exception handling cleanup
Added:
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java (contents, props changed)
- copied, changed from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java (contents, props changed)
- copied, changed from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java (contents, props changed)
- copied, changed from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java (contents, props changed)
- copied, changed from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java (contents, props changed)
- copied, changed from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/main/resources/META-INF/sca/default.scdl
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/TestClassResource.java (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/test/resources/META-INF/sca/testReferenceContext.xml (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/test/resources/META-INF/sca/testServiceContext.xml (with props)
incubator/tuscany/java/sca/services/containers/container.spring/src/test/resources/META-INF/tuscany/
incubator/tuscany/java/sca/services/containers/container.spring/src/test/resources/META-INF/tuscany/xsystem.scdl
incubator/tuscany/java/sca/test/src/main/resources/META-INF/sca/
incubator/tuscany/java/sca/test/src/main/resources/META-INF/sca/test.default.scdl
incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/test.binding.system.scdl
Removed:
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringRuntimeInfo.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringServiceContract.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/ScaWebApplicationContext.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/SpringWebappRuntimeInfo.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/intercept/
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/
incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/Bootstrapper.java
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringImplementation.java
incubator/tuscany/java/sca/services/containers/container.spring/src/main/resources/META-INF/sca/spring.system.scdl
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java
incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/integration/BootstrapTestCase.java
incubator/tuscany/java/sca/services/transaction/transaction.geronimo/src/main/java/org/apache/tuscany/transaction/geronimo/jta/GeronimoTransactionManagerService.java
incubator/tuscany/java/sca/services/transaction/transaction.geronimo/src/test/resources/META-INF/sca/empty.scdl
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java Sat Dec 9 03:03:28 2006
@@ -18,12 +18,6 @@
*/
package org.apache.tuscany.core.implementation.processor;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
-
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -38,10 +32,15 @@
import java.util.Map;
import java.util.Set;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
import org.apache.tuscany.spi.deployer.DeploymentContext;
import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.TypeInfo;
import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
@@ -51,8 +50,12 @@
import org.apache.tuscany.spi.implementation.java.PojoComponentType;
import org.apache.tuscany.spi.implementation.java.ProcessingException;
import org.apache.tuscany.spi.model.OverrideOptions;
-import org.osoa.sca.annotations.Remotable;
-import org.osoa.sca.annotations.Service;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
/**
* Heuristically evaluates an un-annotated Java implementation type to determine services, references, and properties
@@ -66,7 +69,7 @@
* @version $Rev$ $Date$
*/
public class HeuristicPojoProcessor extends ImplementationProcessorExtension {
-
+ private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension();
private ImplementationProcessorService implService;
public HeuristicPojoProcessor(@Autowire ImplementationProcessorService service) {
@@ -418,6 +421,11 @@
property.setMember(member);
property.setOverride(OverrideOptions.MAY);
property.setJavaType(paramType);
+ TypeInfo xmlType = typeMapper.getXMLType(paramType);
+ if (xmlType != null) {
+ property.setXmlType(xmlType.getQName());
+ }
+
return property;
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java Sat Dec 9 03:03:28 2006
@@ -30,7 +30,9 @@
import org.osoa.sca.annotations.Resource;
import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.TypeInfo;
import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
@@ -53,6 +55,7 @@
*/
public class ImplementationProcessorServiceImpl implements ImplementationProcessorService {
private JavaInterfaceProcessorRegistry registry;
+ private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension();
public ImplementationProcessorServiceImpl(@Autowire JavaInterfaceProcessorRegistry registry) {
this.registry = registry;
@@ -266,6 +269,7 @@
// the param is marked as a property
Property propAnnot = (Property) annot;
JavaMappedProperty<T> property = new JavaMappedProperty<T>();
+ property.setJavaType(param);
String name = propAnnot.name();
if (name == null || name.length() == 0) {
if (constructorNames.length < pos + 1 || constructorNames[pos] == null
@@ -284,7 +288,15 @@
property.setName(name);
property.setOverride(OverrideOptions.valueOf(propAnnot.override().toUpperCase()));
- property.setXmlType(QName.valueOf(propAnnot.xmlType()));
+ String xmlType = propAnnot.xmlType();
+ if (xmlType != null && xmlType.length() != 0) {
+ property.setXmlType(QName.valueOf(xmlType));
+ } else {
+ TypeInfo typeInfo = typeMapper.getXMLType(property.getJavaType());
+ if (typeInfo != null) {
+ property.setXmlType(typeInfo.getQName());
+ }
+ }
property.setJavaType(param);
type.getProperties().put(name, property);
addName(explicitNames, pos, name);
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java Sat Dec 9 03:03:28 2006
@@ -40,10 +40,15 @@
public void invokeEvent(T instance) throws ObjectCallbackException {
try {
method.invoke(instance, (Object[]) null);
+ } catch (IllegalArgumentException e) {
+ String name = method.getName();
+ throw new ObjectCallbackException("Exception thrown by callback method [" + name + "]", e.getCause());
} catch (IllegalAccessException e) {
- throw new AssertionError("Method is not accessible [" + method + "]");
+ String name = method.getName();
+ throw new AssertionError("Method is not accessible [" + name + "]");
} catch (InvocationTargetException e) {
- throw new ObjectCallbackException("Exception thrown by callback method [" + method + "]", e.getCause());
+ String name = method.getName();
+ throw new ObjectCallbackException("Exception thrown by callback method [" + name + "]", e.getCause());
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java Sat Dec 9 03:03:28 2006
@@ -93,17 +93,29 @@
// create the constructor arg array
for (int i = 0; i < size; i++) {
ObjectFactory<?> objectFactory = initializerFactories[i];
+ if (objectFactory == null) {
+ ObjectCallbackException e =
+ new ObjectCallbackException("Null object factory for constructor parameter [" + i + "]");
+ e.setIdentifier(ctr.getName());
+ throw e;
+ }
initargs[i] = objectFactory.getInstance();
}
try {
ctr.setAccessible(true);
return ctr.newInstance(initargs);
+ } catch (IllegalArgumentException e) {
+ String name = ctr.getName();
+ throw new ObjectCreationException("Exception thrown by constructor [" + name + "]", e);
} catch (InstantiationException e) {
- throw new AssertionError("Class is not instantiable [" + ctr.getDeclaringClass().getName() + "]");
+ String name = ctr.getDeclaringClass().getName();
+ throw new AssertionError("Class is not instantiable [" + name + "]");
} catch (IllegalAccessException e) {
- throw new AssertionError("Constructor is not accessible [" + ctr + "]");
+ String name = ctr.getName();
+ throw new AssertionError("Constructor is not accessible [" + name + "]");
} catch (InvocationTargetException e) {
- throw new ObjectCreationException("Exception thrown by constructor [" + ctr + "]", e);
+ String name = ctr.getName();
+ throw new ObjectCreationException("Exception thrown by constructor [" + name + "]", e);
}
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java Sat Dec 9 03:03:28 2006
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.core.implementation.java;
+import org.apache.tuscany.spi.ObjectFactory;
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.component.ScopeContainer;
@@ -70,6 +71,30 @@
assertEquals("foo", foo.getTest());
}
+ public void testIntPropertyHandling() throws Exception {
+ JavaComponentBuilder builder = new JavaComponentBuilder();
+ builder.setScopeRegistry(registry);
+ PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>> type =
+ new PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>>();
+ JavaMappedProperty<Integer> property = new JavaMappedProperty<Integer>();
+ property.setName("test");
+ property.setDefaultValueFactory(new SingletonObjectFactory<Integer>(1));
+ property.setMember(JavaBuilderPropertyTestCase.FooInt.class.getMethod("setTest", Integer.TYPE));
+ type.add(property);
+ type.setConstructorDefinition(new ConstructorDefinition<FooInt>(FooInt.class.getConstructor((Class[]) null)));
+ type.setImplementationScope(Scope.STATELESS);
+ JavaImplementation impl = new JavaImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(Foo.class);
+ ComponentDefinition<JavaImplementation> definition = new ComponentDefinition<JavaImplementation>(impl);
+ ObjectFactory<Integer> defaultValueFactory = property.getDefaultValueFactory();
+ PropertyValue<Integer> propertyValue = new PropertyValue<Integer>(property.getName(), defaultValueFactory);
+ definition.getPropertyValues().put(property.getName(), propertyValue);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ FooInt foo = (FooInt) component.createInstance();
+ assertEquals(1, foo.getTest());
+ }
+
protected void setUp() throws Exception {
super.setUp();
deploymentContext = EasyMock.createMock(DeploymentContext.class);
@@ -93,6 +118,21 @@
}
public void setTest(String test) {
+ this.test = test;
+ }
+ }
+
+ private static class FooInt {
+ private int test;
+
+ public FooInt() {
+ }
+
+ public int getTest() {
+ return test;
+ }
+
+ public void setTest(int test) {
this.test = test;
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java Sat Dec 9 03:03:28 2006
@@ -27,6 +27,7 @@
import org.osoa.sca.annotations.Remotable;
import org.osoa.sca.annotations.Service;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
@@ -197,6 +198,29 @@
assertNotNull(type.getReferences().get("otherRef"));
}
+ public void testSetDataTypes() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor(int.class);
+ type.setConstructorDefinition(new ConstructorDefinition<PropertyIntTypeOnConstructor>(ctor));
+ processor.visitEnd(null, ProtectedRemotableRefMethodImpl.class, type, null);
+ org.apache.tuscany.spi.model.Property<?> foo = type.getProperties().get("foo");
+ assertEquals(int.class, foo.getJavaType());
+ assertEquals(SimpleTypeMapperExtension.XSD_INT, foo.getXmlType());
+ }
+
+ private static class PropertyIntTypeOnConstructor {
+ private int foo;
+
+ public PropertyIntTypeOnConstructor(@Property(name = "foo") int foo) {
+ this.foo = foo;
+ }
+
+ public int getFoo() {
+ return foo;
+ }
+ }
+
private interface PropertyInterface {
void setString1(String val);
}
@@ -225,8 +249,11 @@
private interface HeuristicServiceInterface {
void fooOperation(String ref);
+
void setInvalid1(); // No parameter
+
void setInvalid2(String str, int i); // More than one parameter
+
String setInvalid3(String str); // return should be void
}
@@ -251,6 +278,7 @@
public void fooOperation(String ref) {
}
+
public void setInvalid1() {
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java Sat Dec 9 03:03:28 2006
@@ -18,12 +18,22 @@
*/
package org.apache.tuscany.core.implementation.processor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Remotable;
import org.osoa.sca.annotations.Scope;
-import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
import org.apache.tuscany.spi.model.InteractionScope;
import org.apache.tuscany.spi.model.ServiceContract;
@@ -55,6 +65,19 @@
assertEquals(InteractionScope.NONCONVERSATIONAL, service.getServiceContract().getInteractionScope());
}
+ public void testProcessParamProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<PropertyClass> ctor = PropertyClass.class.getConstructor(int.class);
+ Annotation[] paramAnnotations = ctor.getParameterAnnotations()[0];
+ List<String> injectionNames = new ArrayList<String>();
+ String[] names = new String[]{"foo"};
+ implService.processParam(int.class, paramAnnotations, names, 0, type, injectionNames);
+ org.apache.tuscany.spi.model.Property<?> property = type.getProperties().get("foo");
+ assertEquals(int.class, property.getJavaType());
+ assertEquals(SimpleTypeMapperExtension.XSD_INT, property.getXmlType());
+ }
+
@Callback(Bar.class)
@Remotable
@@ -69,5 +92,17 @@
public interface Baz {
+ }
+
+ public static class PropertyClass {
+ private int foo;
+
+ public PropertyClass(@Property(name = "foo") int foo) {
+ this.foo = foo;
+ }
+
+ public int getFoo() {
+ return foo;
+ }
}
}
Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java Sat Dec 9 03:03:28 2006
@@ -20,12 +20,21 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.logging.Level;
-
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.xml.stream.XMLInputFactory;
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.event.EventPublisher;
+
import org.apache.tuscany.core.bootstrap.Bootstrapper;
import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
import org.apache.tuscany.core.component.event.HttpRequestEnded;
@@ -40,12 +49,6 @@
import org.apache.tuscany.host.MonitorFactory;
import org.apache.tuscany.host.RuntimeInfo;
import org.apache.tuscany.host.servlet.ServletRequestInjector;
-import org.apache.tuscany.spi.bootstrap.ComponentNames;
-import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.deployer.Deployer;
-import org.apache.tuscany.spi.event.EventPublisher;
-import org.osoa.sca.SCA;
/**
* Bootstrapper for the Tuscany runtime in a web application host. This listener manages one runtime per servlet
@@ -141,8 +144,21 @@
getApplicationScdl(),
getHostClassLoader());
application.start();
-
- context = new CompositeContextImpl(application);
+ CompositeComponent current = application;
+ String path = servletContext.getInitParameter(Constants.CURRENT_COMPOSITE_PATH_PARAM);
+ if (path != null) {
+ StringTokenizer tokenizer = new StringTokenizer(path, "/");
+ while(tokenizer.hasMoreTokens()) {
+ SCAObject o = current.getChild(tokenizer.nextToken());
+ if (!(o instanceof CompositeComponent)){
+ ServletLauncherInitException e = new ServletLauncherInitException("Invalid context path");
+ e.setIdentifier(path);
+ throw e;
+ }
+ current = (CompositeComponent)o;
+ }
+ }
+ context = new CompositeContextImpl(current);
} catch (Exception e) {
throw new ServletLauncherInitException(e);
}
@@ -179,25 +195,25 @@
public void sessionCreated(HttpSessionEvent event) {
HttpSessionStart startSession = new HttpSessionStart(this, event.getSession().getId());
application.publish(startSession);
- ((EventPublisher)requestInjector).publish(startSession);
+ ((EventPublisher) requestInjector).publish(startSession);
}
public void sessionDestroyed(HttpSessionEvent event) {
HttpSessionEnd endSession = new HttpSessionEnd(this, event.getSession().getId());
application.publish(endSession);
- ((EventPublisher)requestInjector).publish(endSession);
+ ((EventPublisher) requestInjector).publish(endSession);
}
-
+
public void httpRequestStarted(Object sessionid) {
HttpRequestStart httpRequestStart = new HttpRequestStart(this, sessionid);
application.publish(httpRequestStart);
- ((EventPublisher)requestInjector).publish(httpRequestStart);
+ ((EventPublisher) requestInjector).publish(httpRequestStart);
}
-
+
public void httpRequestEnded(Object sessionid) {
HttpRequestEnded httpRequestEnded = new HttpRequestEnded(this, sessionid);
application.publish(httpRequestEnded);
- ((EventPublisher)requestInjector).publish(httpRequestEnded);
+ ((EventPublisher) requestInjector).publish(httpRequestEnded);
}
Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java Sat Dec 9 03:03:28 2006
@@ -22,15 +22,12 @@
import javax.servlet.ServletContext;
import junit.framework.TestCase;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
-import org.apache.tuscany.core.monitor.NullMonitorFactory;
-
/**
* @version $Rev$ $Date$
*/
@@ -45,6 +42,7 @@
*/
public void testBootWithDefaults() throws Exception {
expect(context.getResourcePaths("/WEB-INF/tuscany/extensions/")).andReturn(null);
+ expect(context.getInitParameter("tuscany.currentCompositePath")).andReturn(null);
replay(context);
runtime.initialize();
verify(context);
Modified: incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java Sat Dec 9 03:03:28 2006
@@ -52,9 +52,6 @@
*/
static final String ONLINE_PARAM = "tuscany.online";
-
-
-
/**
* Context attribute to which the Tuscany runtime for this servlet context is stored.
*/
Added: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java?view=auto&rev=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java (added)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java Sat Dec 9 03:03:28 2006
@@ -0,0 +1,49 @@
+/*
+ * 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.apache.tuscany.container.spring.context;
+
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.core.io.Resource;
+
+/**
+ * An <code>ApplicationContext</code> specialization that registers namespace handlers for SCA elements
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAApplicationContext extends AbstractXmlApplicationContext {
+ public static final String APP_CONTEXT_PROP = "org.springframework.sca.application.context";
+ private Resource appXml;
+
+ public SCAApplicationContext(ApplicationContext parent, Resource appXml) {
+ super(parent);
+ this.appXml = appXml;
+ refresh();
+ }
+
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
+ ClassLoader cl = getClassLoader();
+ beanDefinitionReader.setNamespaceHandlerResolver(new SCANamespaceHandlerResolver(cl));
+ }
+
+ protected Resource[] getConfigResources() {
+ return new Resource[]{appXml};
+ }
+}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCAApplicationContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java (from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java?view=diff&rev=484966&p1=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java&r1=480767&p2=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java Sat Dec 9 03:03:28 2006
@@ -16,19 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.container.spring.config;
-
-import org.apache.tuscany.spi.model.CompositeComponentType;
+package org.apache.tuscany.container.spring.context;
import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
import org.springframework.beans.factory.xml.NamespaceHandler;
-import org.springframework.sca.config.ScaNamespaceHandler;
/**
- * Overrides the default Spring namespace resolver to automatically register {@link SCANamespaceHandler} instead of
+ * Overrides the default Spring namespace resolver to automatically register {@link ScaNamespaceHandler} instead of
* requiring a value to be supplied in a Spring configuration
- * <p/>
- * TODO: Figure out how to activate this impl
*
* @version $$Rev$$ $$Date$$
*/
@@ -38,14 +33,12 @@
private ScaNamespaceHandler handler;
- public SCANamespaceHandlerResolver(ClassLoader classLoader, CompositeComponentType componentType) {
+ public SCANamespaceHandlerResolver(ClassLoader classLoader) {
super(classLoader);
handler = new ScaNamespaceHandler(/*componentType*/);
}
- public SCANamespaceHandlerResolver(String handlerMappingsLocation,
- ClassLoader classLoader,
- CompositeComponentType componentType) {
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
super(classLoader, handlerMappingsLocation);
handler = new ScaNamespaceHandler(/*componentType*/);
}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/SCANamespaceHandlerResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java (from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java?view=diff&rev=484966&p1=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java&r1=480767&p2=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java Sat Dec 9 03:03:28 2006
@@ -15,29 +15,21 @@
*
* Created on 10-Apr-2006 by Adrian Colyer
*/
-package org.springframework.sca.config;
+package org.apache.tuscany.container.spring.context;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
- * Handler for the <sca:> namespace. Handles: <ul> <li><sca:composite module="xxxxx"/></li>
- * <li><sca:reference name="xxx" type="yyy" default-service="zzz"/></li> <li><sca:property name="xxx"
- * type="yyy"/></li> <li><sca:service name="xxx" type="yyyy" target="zzz"/> </ul>
- *
- * @author Adrian Colyer
- * @since 2.0
+ * Handler for the <sca:> namespace in an application context
*/
public class ScaNamespaceHandler extends NamespaceHandlerSupport {
public ScaNamespaceHandler() {
- // FIXME JFM
init();
}
public final void init() {
- registerBeanDefinitionParser("composite", new ScaCompositeBeanDefinitionParser());
registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
- registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaNamespaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java (from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java?view=diff&rev=484966&p1=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java&r1=480767&p2=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java Sat Dec 9 03:03:28 2006
@@ -15,52 +15,22 @@
*
* Created on 10-Apr-2006 by Adrian Colyer
*/
-package org.springframework.sca.config;
+package org.apache.tuscany.container.spring.context;
import org.w3c.dom.Element;
-import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.sca.ScaServiceProxyFactoryBean;
/**
* Parser for the <sca:reference> element
- *
- * @author Adrian Colyer
- * @since 2.0
*/
public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
- private static final String REFERENCE_NAME_ATTRIBUTE = "name";
- private static final String REFERENCE_NAME_PROPERTY = "referenceName";
- private static final String TYPE_ATTRIBUTE = "type";
- private static final String SERVICE_TYPE_PROPERTY = "serviceType";
- private static final String DEFAULT_SERVICE_ATTRIBUTE = "default";
- private static final String DEFAULT_SERVICE_PROPERTY = "defaultServiceName";
-
public BeanDefinition parse(Element element, ParserContext parserContext) {
- // needs service type, reference name, sca component, and optionally default service name
- BeanDefinitionRegistry registry = parserContext.getRegistry();
- String referenceName = element.getAttribute(REFERENCE_NAME_ATTRIBUTE);
- BeanDefinition beanDef = createBeanDefinition(element);
- registry.registerBeanDefinition(referenceName, beanDef);
- return beanDef;
+ // do nothing, this is handled by Tuscany
+ return null;
}
- private BeanDefinition createBeanDefinition(Element element) {
- RootBeanDefinition beanDefinition = new RootBeanDefinition();
- beanDefinition.setBeanClass(ScaServiceProxyFactoryBean.class);
- MutablePropertyValues props = new MutablePropertyValues();
- props.addPropertyValue(REFERENCE_NAME_PROPERTY, element.getAttribute(REFERENCE_NAME_ATTRIBUTE));
- props.addPropertyValue(SERVICE_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
- if (element.hasAttribute(DEFAULT_SERVICE_ATTRIBUTE)) {
- props.addPropertyValue(DEFAULT_SERVICE_PROPERTY, element.getAttribute(DEFAULT_SERVICE_ATTRIBUTE));
- }
- beanDefinition.setPropertyValues(props);
- return beanDefinition;
- }
}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java (from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java?view=diff&rev=484966&p1=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java&r1=480767&p2=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java Sat Dec 9 03:03:28 2006
@@ -15,51 +15,22 @@
*
* Created on 10-Apr-2006 by Adrian Colyer
*/
-package org.springframework.sca.config;
+package org.apache.tuscany.container.spring.context;
import org.w3c.dom.Element;
-import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.sca.ScaServiceExporter;
/**
* Parser for the <sca:service/> element
- *
- * @author Adrian Colyer
- * @since 2.0
*/
public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
- private static final String SERVICE_NAME_ATTRIBUTE = "name";
- private static final String TYPE_ATTRIBUTE = "type";
- private static final String TARGET_ATTRIBUTE = "target";
- private static final String SERVICE_NAME_PROPERTY = "serviceName";
- private static final String SERVICE_TYPE_PROPERTY = "serviceType";
- private static final String TARGET_PROPERTY = "target";
-
public BeanDefinition parse(Element element, ParserContext parserContext) {
- BeanDefinitionRegistry registry = parserContext.getRegistry();
- String serviceName = element.getAttribute(SERVICE_NAME_ATTRIBUTE);
- BeanDefinition beanDef = createBeanDefinition(element);
- registry.registerBeanDefinition(serviceName, beanDef);
- return beanDef;
- }
-
- private BeanDefinition createBeanDefinition(Element element) {
- RootBeanDefinition beanDefinition = new RootBeanDefinition();
- beanDefinition.setBeanClass(ScaServiceExporter.class);
- MutablePropertyValues props = new MutablePropertyValues();
- props.addPropertyValue(SERVICE_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
- props.addPropertyValue(TARGET_PROPERTY, new RuntimeBeanReference(element.getAttribute(TARGET_ATTRIBUTE)));
- props.addPropertyValue(SERVICE_NAME_PROPERTY, element.getAttribute(SERVICE_NAME_ATTRIBUTE));
- beanDefinition.setPropertyValues(props);
- return beanDefinition;
+ // do nothing, handled by Tuscany
+ return null;
}
}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/context/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java Sat Dec 9 03:03:28 2006
@@ -30,13 +30,13 @@
import org.apache.tuscany.spi.model.BoundReferenceDefinition;
import org.apache.tuscany.spi.model.BoundServiceDefinition;
import org.apache.tuscany.spi.model.ComponentDefinition;
-import org.apache.tuscany.spi.model.CompositeComponentType;
import org.apache.tuscany.spi.model.Property;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
import org.apache.tuscany.container.spring.model.SpringImplementation;
-import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.core.io.Resource;
/**
* Creates a {@link org.apache.tuscany.container.spring.impl.SpringCompositeComponent} from an assembly model
@@ -45,19 +45,17 @@
*/
public class SpringCompositeBuilder extends ComponentBuilderExtension<SpringImplementation> {
+ @SuppressWarnings("unchecked")
public Component build(CompositeComponent parent,
ComponentDefinition<SpringImplementation> componentDefinition,
DeploymentContext deploymentContext) throws BuilderConfigException {
String name = componentDefinition.getName();
SpringImplementation implementation = componentDefinition.getImplementation();
- AbstractApplicationContext applicationContext = implementation.getComponentType().getApplicationContext();
- SpringCompositeComponent component =
- new SpringCompositeComponent(name, applicationContext, parent, connector, null);
- CompositeComponentType<BoundServiceDefinition<? extends Binding>,
- BoundReferenceDefinition<? extends Binding>,
- ? extends Property> componentType = implementation.getComponentType();
+ Resource resource = implementation.getApplicationResource();
+ SpringCompositeComponent component = new SpringCompositeComponent(name, resource, parent, connector, null);
+ SpringComponentType<Property<?>> componentType = implementation.getComponentType();
- // We still need to set the target invoker as opposed to having the connector do it since the
+ // We need to set the target invoker as opposed to having the connector do it since the
// Spring context is "opaque" to the wiring fabric. In other words, the Spring context does not expose
// its beans as SCA components to the connector to wire the services to
for (BoundServiceDefinition<? extends Binding> serviceDefinition : componentType.getServices().values()) {
Modified: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java Sat Dec 9 03:03:28 2006
@@ -35,9 +35,10 @@
import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.container.spring.context.SCAApplicationContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
@@ -59,27 +60,46 @@
public class SpringCompositeComponent extends CompositeComponentExtension {
private static final String[] EMPTY_ARRAY = new String[0];
private AbstractApplicationContext springContext;
+ private Resource resource;
+
+ /**
+ * Creates a new composite
+ *
+ * @param name the name of the SCA composite
+ * @param resource a resource pointing to the application context
+ * @param parent the SCA composite parent
+ * @param connector the connector to use for wiring children
+ * @param propertyValues the values of this composite's Properties
+ */
+ public SpringCompositeComponent(String name,
+ Resource resource,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ super(name, parent, connector, propertyValues);
+ this.resource = resource;
+ }
/**
* Creates a new composite
*
* @param name the name of the SCA composite
- * @param springContext the pre-instantiated Spring applicaiton context
+ * @param context
* @param parent the SCA composite parent
* @param connector the connector to use for wiring children
* @param propertyValues the values of this composite's Properties
*/
public SpringCompositeComponent(String name,
- AbstractApplicationContext springContext,
+ AbstractApplicationContext context,
CompositeComponent parent,
Connector connector,
Map<String, Document> propertyValues) {
super(name, parent, connector, propertyValues);
- SCAApplicationContext scaApplicationContext = new SCAApplicationContext();
+ this.springContext = context;
+ SCAParentApplicationContext scaApplicationContext = new SCAParentApplicationContext();
springContext.setParent(scaApplicationContext);
// REVIEW we need to refresh to pick up the parent but this is not optimal
springContext.refresh();
- this.springContext = springContext;
}
public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) {
@@ -88,7 +108,7 @@
Method method = findMethod(operation, methods);
// FIXME test m == null
// Treat the serviceName as the Spring bean name to look up
- return new SpringInvoker(targetName, method, springContext);
+ return new SpringInvoker(targetName, method, this);
}
public void setScopeContainer(ScopeContainer scopeContainer) {
@@ -108,7 +128,11 @@
for (SCAObject child : children.values()) {
child.start();
}
- springContext.start();
+ if (springContext == null) {
+ SCAParentApplicationContext scaApplicationContext = new SCAParentApplicationContext();
+ springContext = new SCAApplicationContext(scaApplicationContext, resource);
+ springContext.start();
+ }
}
public void stop() {
@@ -125,12 +149,13 @@
* interface since the return types for {@link org.springframework.context.ApplicationContext#getParent()} and
* {@link org.apache.tuscany.spi.component.CompositeComponent#getParent()} clash
*/
- private class SCAApplicationContext implements ApplicationContext {
+ private class SCAParentApplicationContext implements ApplicationContext {
public Object getBean(String name) throws BeansException {
return getBean(name, null);
}
+ @SuppressWarnings("unchecked")
public Object getBean(String name, Class requiredType) throws BeansException {
SCAObject object = children.get(name); // keep cast due to compiler error
if (object == null) {
@@ -157,6 +182,10 @@
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return children.get(name) != null;
+ }
+
+ public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+ throw new UnsupportedOperationException();
}
public Class getType(String name) throws NoSuchBeanDefinitionException {
Modified: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java?view=diff&rev=484966&r1=484965&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java Sat Dec 9 03:03:28 2006
@@ -22,12 +22,12 @@
import java.lang.reflect.Method;
import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
import org.apache.tuscany.spi.wire.InvocationRuntimeException;
import org.apache.tuscany.spi.wire.Message;
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
/**
* Dispatches to an operation on a Spring bean. Since Spring manages bean lifecycle and scope through resolution in the
@@ -36,7 +36,7 @@
* @version $$Rev$$ $$Date$$
*/
public class SpringInvoker implements TargetInvoker {
- private ApplicationContext springContext;
+ private SpringCompositeComponent component;
// default to true since Spring handles resolution
private boolean cacheable = true;
private String beanName;
@@ -44,16 +44,19 @@
// caching is thread-safe since Spring handles resolution
private Object bean;
- public SpringInvoker(String beanName, Method method, ApplicationContext context) {
+ public SpringInvoker(String beanName, Method method, SpringCompositeComponent component) {
this.beanName = beanName;
this.method = method;
- springContext = context;
+ this.component = component;
}
public Object invokeTarget(final Object object, final short sequence) throws InvocationTargetException {
if (bean == null) {
try {
- bean = springContext.getBean(beanName);
+ bean = component.locateService(Object.class, beanName);
+ if (bean == null) {
+ throw new TargetNotFoundException(beanName);
+ }
} catch (BeansException e) {
throw new TargetException(e);
}
Copied: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java (from r480767, incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java?view=diff&rev=484966&p1=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java&r1=480767&p2=incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java&r2=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java Sat Dec 9 03:03:28 2006
@@ -16,11 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.container.spring.impl;
+package org.apache.tuscany.container.spring.loader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
@@ -48,6 +49,7 @@
import org.apache.tuscany.container.spring.model.SpringComponentType;
import org.apache.tuscany.container.spring.model.SpringImplementation;
import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.runtime.webapp.WebappRuntimeInfo;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
@@ -57,9 +59,7 @@
public class SpringImplementationLoader extends LoaderExtension<SpringImplementation> {
private static final QName IMPLEMENTATION_SPRING = new QName("http://www.osoa.org/xmlns/sca/1.0",
"implementation.spring");
-
- private static final String APPLICATION_CONTEXT = "application-context.xml";
-
+ private static final String APPLICATION_CONTEXT = "applicationContext.xml";
private static final QName SERVICE_ELEMENT = new QName(XML_NAMESPACE_1_0, "service");
private static final QName REFERENCE_ELEMENT = new QName(XML_NAMESPACE_1_0, "reference");
@@ -81,15 +81,13 @@
throws XMLStreamException, LoaderException {
String locationAttr = reader.getAttributeValue(null, "location");
- if (locationAttr == null && !contextProvided()) {
+ if (locationAttr == null) {
throw new MissingResourceException("No location supplied");
}
SpringImplementation implementation = new SpringImplementation();
ClassLoader classLoader = deploymentContext.getClassLoader();
- if (!contextProvided()) {
- implementation.setApplicationResource(getApplicationContextResource(locationAttr, classLoader));
- }
+ implementation.setApplicationResource(getApplicationContextResource(locationAttr, classLoader));
registry.loadComponentType(parent, implementation, deploymentContext);
SpringComponentType type = implementation.getComponentType();
while (true) {
@@ -101,7 +99,7 @@
(BoundServiceDefinition) registry.load(parent, null, reader, deploymentContext);
if (!type.isExposeAllBeans()) {
String name = service.getName();
- if (!type.getServiceTypes().containsKey(name)) {
+ if (!type.getServiceDeclarations().containsKey(name)) {
LoaderException e = new LoaderException("No service defined in Spring context for ");
e.setIdentifier(name);
throw e;
@@ -133,7 +131,16 @@
}
if (!locationFile.exists()) {
// FIXME hack
- URL url = cl.getResource(locationAttr);
+ URL url;
+ if (runtimeInfo instanceof WebappRuntimeInfo) {
+ try {
+ url = ((WebappRuntimeInfo) runtimeInfo).getServletContext().getResource(locationAttr);
+ } catch (MalformedURLException e) {
+ throw new LoaderException(e);
+ }
+ } else {
+ url = cl.getResource(locationAttr);
+ }
if (url != null) {
return new UrlResource(url);
}
@@ -188,10 +195,9 @@
throw new MissingResourceException(locationAttr, e);
}
}
- throw new MissingResourceException(APPLICATION_CONTEXT);
- }
- private boolean contextProvided() {
- return runtimeInfo instanceof SpringRuntimeInfo;
+ throw new
+
+ MissingResourceException(APPLICATION_CONTEXT);
}
}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringImplementationLoader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java?view=auto&rev=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java (added)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java Sat Dec 9 03:03:28 2006
@@ -0,0 +1,134 @@
+/*
+ * 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.apache.tuscany.container.spring.loader;
+
+import java.io.IOException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.Property;
+
+import org.apache.tuscany.container.spring.model.ReferenceDeclaration;
+import org.apache.tuscany.container.spring.model.ServiceDeclaration;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.springframework.core.io.Resource;
+
+/**
+ * Introspects a Spring XML configuration file for its component type information. Other loader implementations may
+ * support alternative Spring configuration mechanisms.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringXMLComponentTypeLoader extends ComponentTypeLoaderExtension<SpringImplementation> {
+ private static final String SCA_NS = "http://www.springframework.org/schema/sca";
+ private static final QName SERVICE_ELEMENT = new QName(SCA_NS, "service");
+ private static final QName REFERENCE_ELEMENT = new QName(SCA_NS, "reference");
+ private static final QName BEANS_ELEMENT = new QName("http://www.springframework.org/schema/beans", "beans");
+
+ public SpringXMLComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry) {
+ super(loaderRegistry);
+ }
+
+ @Override
+ protected Class<SpringImplementation> getImplementationClass() {
+ return SpringImplementation.class;
+ }
+
+ public void load(CompositeComponent parent,
+ SpringImplementation implementation,
+ DeploymentContext context) throws LoaderException {
+ if (implementation.getComponentType() != null) {
+ // FIXME hack since the builder registry loads the implementation type and the Spring implementation
+ // loader needs to as well. The second call is done by the builder registry and we just ignore it.
+ return;
+ }
+ SpringComponentType<Property<?>> type = new SpringComponentType<Property<?>>();
+ Resource resource = implementation.getApplicationResource();
+ loadFromXML(type, resource, context);
+ implementation.setComponentType(type);
+ }
+
+ private void loadFromXML(SpringComponentType<Property<?>> type, Resource resource, DeploymentContext context)
+ throws LoaderException {
+ XMLStreamReader reader;
+ try {
+ XMLInputFactory factory = context.getXmlFactory();
+ ClassLoader cl = context.getClassLoader();
+ reader = factory.createXMLStreamReader(resource.getInputStream());
+ boolean exposeAllBeans = true;
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (SERVICE_ELEMENT.equals(qname)) {
+ exposeAllBeans = false;
+ String name = reader.getAttributeValue(SCA_NS, "name");
+ Class<?> serviceType;
+ try {
+ serviceType = cl.loadClass(reader.getAttributeValue(SCA_NS, "type"));
+ } catch (ClassNotFoundException e) {
+ MissingResourceException e2 =
+ new MissingResourceException("Error loading service class", e);
+ e2.setIdentifier(name);
+ throw e2;
+ }
+ String target = reader.getAttributeValue(SCA_NS, "target");
+ type.addServiceDeclaration(new ServiceDeclaration(name, serviceType, target));
+ } else if (REFERENCE_ELEMENT.equals(qname)) {
+ String name = reader.getAttributeValue(SCA_NS, "name");
+ Class<?> serviceType;
+ try {
+ serviceType = cl.loadClass(reader.getAttributeValue(SCA_NS, "type"));
+ } catch (ClassNotFoundException e) {
+ MissingResourceException e2 =
+ new MissingResourceException("Error loading service class", e);
+ e2.setIdentifier(name);
+ throw e2;
+ }
+ type.addReferenceDeclaration(new ReferenceDeclaration(name, serviceType));
+ }
+ break;
+ case END_ELEMENT:
+ if (BEANS_ELEMENT.equals(reader.getName())) {
+ type.setExposeAllBeans(exposeAllBeans);
+ return;
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ throw new LoaderException(e);
+ } catch (XMLStreamException e) {
+ throw new LoaderException(e);
+ }
+
+ }
+}
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/loader/SpringXMLComponentTypeLoader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java?view=auto&rev=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java (added)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java Sat Dec 9 03:03:28 2006
@@ -0,0 +1,43 @@
+/*
+ * 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.apache.tuscany.container.spring.model;
+
+/**
+ * Represents a <code>sca:reference<code> declaration in an application context. Used as component type metadata for a
+ * Spring composite
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceDeclaration {
+ private String name;
+ private Class<?> serviceType;
+
+ public ReferenceDeclaration(String name, Class<?> serviceType) {
+ this.name = name;
+ this.serviceType = serviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<?> getServiceType() {
+ return serviceType;
+ }
+}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ReferenceDeclaration.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java?view=auto&rev=484966
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java (added)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java Sat Dec 9 03:03:28 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.apache.tuscany.container.spring.model;
+
+/**
+ * Represents a <code>sca:service<code> declaration in an application context. Used as component type metadata for a
+ * Spring composite
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceDeclaration {
+ private String name;
+ private Class<?> serviceType;
+ private String target;
+
+ /**
+ * Constructor
+ *
+ * @param name the service name
+ * @param serviceType the service contract type
+ * @param target the name of the target the service is wired to
+ */
+ public ServiceDeclaration(String name, Class<?> serviceType, String target) {
+ this.name = name;
+ this.serviceType = serviceType;
+ this.target = target;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<?> getClazz() {
+ return serviceType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/ServiceDeclaration.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org