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/08/18 22:50:59 UTC
svn commit: r432722 [1/2] - in
/incubator/tuscany/java/sca/containers/container.spring/src:
main/java/org/apache/tuscany/container/spring/config/
main/java/org/apache/tuscany/container/spring/impl/
main/java/org/apache/tuscany/container/spring/model/ m...
Author: jmarino
Date: Fri Aug 18 13:50:57 2006
New Revision: 432722
URL: http://svn.apache.org/viewvc?rev=432722&view=rev
Log:
commit patch for Andy Piper, TUSCANY-643
Added:
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/intercept/
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java (with props)
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java (with props)
Modified:
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
incubator/tuscany/java/sca/containers/container.spring/src/main/resources/META-INF/spring.handlers
incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java
incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
Modified: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java?rev=432722&r1=432721&r2=432722&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java (original)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java Fri Aug 18 13:50:57 2006
@@ -22,6 +22,7 @@
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
@@ -35,18 +36,18 @@
private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
- private SCANamespaceHandler handler;
+ private ScaNamespaceHandler handler;
public SCANamespaceHandlerResolver(ClassLoader classLoader, CompositeComponentType componentType) {
super(classLoader);
- handler = new SCANamespaceHandler(componentType);
+ handler = new ScaNamespaceHandler(/*componentType*/);
}
public SCANamespaceHandlerResolver(String handlerMappingsLocation,
ClassLoader classLoader,
CompositeComponentType componentType) {
super(classLoader, handlerMappingsLocation);
- handler = new SCANamespaceHandler(componentType);
+ handler = new ScaNamespaceHandler(/*componentType*/);
}
public NamespaceHandler resolve(String namespaceUri) {
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tuscany.container.spring.config;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.sca.ScaAdapterAware;
+import org.springframework.sca.ScaAdapterPostProcessor;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.container.spring.impl.SpringScaAdapter;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class ScaApplicationContext extends AbstractXmlApplicationContext
+{
+ private Resource appXml;
+ private CompositeComponentType componentType;
+
+ public ScaApplicationContext(Resource appXml, CompositeComponentType componentType) {
+ this(null, appXml, componentType);
+ }
+
+ public ScaApplicationContext(ApplicationContext parent, Resource appXml, CompositeComponentType componentType) {
+ super(parent);
+ this.appXml = appXml;
+ this.componentType = componentType;
+ refresh();
+ }
+
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
+ // beanDefinitionReader.setEntityResolver(null);
+ beanDefinitionReader.setNamespaceHandlerResolver(new SCANamespaceHandlerResolver(getClassLoader(), componentType));
+ }
+
+ protected Resource[] getConfigResources() {
+ return new Resource[] { appXml };
+ }
+
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ super.postProcessBeanFactory(beanFactory);
+ beanFactory.addBeanPostProcessor(new ScaAdapterPostProcessor(new SpringScaAdapter(componentType)));
+ beanFactory.ignoreDependencyInterface(ScaAdapterAware.class);
+ }
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Modified: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java?rev=432722&r1=432721&r2=432722&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java (original)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java Fri Aug 18 13:50:57 2006
@@ -18,23 +18,19 @@
*/
package org.apache.tuscany.container.spring.impl;
-import org.osoa.sca.annotations.Constructor;
-
+import org.apache.tuscany.container.spring.config.ScaApplicationContext;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
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.container.spring.config.SCAService;
-import org.apache.tuscany.container.spring.config.ScaServiceBeanDefinitionParser;
-import org.apache.tuscany.container.spring.model.SpringComponentType;
-import org.apache.tuscany.container.spring.model.SpringImplementation;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.GenericApplicationContext;
+import org.osoa.sca.annotations.Constructor;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
import org.springframework.core.io.Resource;
+import org.springframework.sca.ScaServiceExporter;
/**
* Loads a component type for a Spring <code>ApplicationContext</code>. The implementation creates a new instance of a
@@ -43,63 +39,64 @@
* @version $$Rev$$ $$Date$$
*/
-public class SpringComponentTypeLoader extends ComponentTypeLoaderExtension<SpringImplementation> {
-
- @Constructor
- public SpringComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry) {
- super(loaderRegistry);
+public class SpringComponentTypeLoader extends ComponentTypeLoaderExtension<SpringImplementation>
+{
+ public static final String SERVICE_BEAN_SUFFIX = ".SCAService";
+
+ @Constructor
+ public SpringComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry) {
+ super(loaderRegistry);
+ }
+
+ @Override
+ protected Class<SpringImplementation> getImplementationClass() {
+ return SpringImplementation.class;
+ }
+
+ /**
+ * Responsible for loading the Spring composite component type. The the application context is instantiated here as
+ * it is needed to derive component type information. Since the component type is loaded per SCDL entry (i.e.
+ * composite use) one application context instance will be created per Spring composite instance.
+ */
+ @SuppressWarnings("unchecked")
+ public void load(CompositeComponent<?> parent,
+ SpringImplementation implementation,
+ DeploymentContext deploymentContext) 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;
}
-
- @Override
- protected Class<SpringImplementation> getImplementationClass() {
- return SpringImplementation.class;
- }
-
- /**
- * Responsible for loading the Spring composite component type. The the application context is instantiated here as
- * it is needed to derive component type information. Since the component type is loaded per SCDL entry (i.e.
- * composite use) one application context instance will be created per Spring composite instance.
- */
- @SuppressWarnings("unchecked")
- public void load(CompositeComponent<?> parent,
- SpringImplementation implementation,
- DeploymentContext deploymentContext) 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;
- }
- Resource resource = implementation.getApplicationResource();
- DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
- XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
- reader.loadBeanDefinitions(resource);
- GenericApplicationContext ctx = new GenericApplicationContext(beanFactory);
- ctx.refresh();
- SpringComponentType componentType = new SpringComponentType(ctx);
-
- // If there are <sca:service> elements, they define (and limit) the services exposed
- // in the componentType.
- String [] serviceBeanNames = ctx.getBeanNamesForType(SCAService.class);
- for (String serviceBeanName : serviceBeanNames) {
- int nSuffix = serviceBeanName.indexOf(ScaServiceBeanDefinitionParser.SERVICE_BEAN_SUFFIX);
- if (nSuffix == -1) {
- continue;
- }
-
- String serviceName = serviceBeanName.substring(0, nSuffix);
- SCAService serviceBean = (SCAService) ctx.getBean(serviceName);
- String serviceTypeName = serviceBean.getType();
- try {
- Class serviceInterface = Class.forName(serviceTypeName, true, deploymentContext.getClassLoader());
- componentType.addServiceType(serviceName, serviceInterface);
- //ServiceDefinition service = createService(serviceInterface);
- //componentType.getServices().put(serviceName, service);
- } catch (ClassNotFoundException e) {
- throw new LoaderException(e);
- }
- }
- // if no service tags are specified, expose all beans
- componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
- implementation.setComponentType(componentType);
+ Resource resource = implementation.getApplicationResource();
+ SpringComponentType componentType = new SpringComponentType();
+ // REVIEW andyp -- pass in deploymentContext.getClassLoader()?
+ AbstractRefreshableApplicationContext ctx = new ScaApplicationContext(resource, componentType);
+ componentType.setApplicationContext(ctx); // FIXME andyp@bea.com -- don't do this!
+
+ // If there are <sca:service> elements, they define (and limit) the services exposed
+ // in the componentType.
+ String [] serviceBeanNames = ctx.getBeanNamesForType(ScaServiceExporter.class);
+ for (String serviceBeanName : serviceBeanNames) {
+ int nSuffix = serviceBeanName.indexOf(SERVICE_BEAN_SUFFIX);
+ if (nSuffix == -1) {
+ continue;
+ }
+
+ String serviceName = serviceBeanName.substring(0, nSuffix);
+ ScaServiceExporter serviceBean = (ScaServiceExporter) ctx.getBean(serviceName);
+ // REVIEW andyp -- use the class directly?
+ String serviceTypeName = serviceBean.getServiceType().getName();
+ try {
+ Class serviceInterface = Class.forName(serviceTypeName, true, deploymentContext.getClassLoader());
+ componentType.addServiceType(serviceName, serviceInterface);
+ //ServiceDefinition service = createService(serviceInterface);
+ //componentType.getServices().put(serviceName, service);
+ } catch (ClassNotFoundException e) {
+ throw new LoaderException(e);
+ }
}
+ // if no service tags are specified, expose all beans
+ componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
+ implementation.setComponentType(componentType);
+ }
}
Modified: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java?rev=432722&r1=432721&r2=432722&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java (original)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java Fri Aug 18 13:50:57 2006
@@ -38,6 +38,8 @@
import org.apache.tuscany.container.spring.model.SpringImplementation;
import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
/**
* Creates a {@link org.apache.tuscany.container.spring.impl.SpringCompositeComponent} from an assembly model
@@ -52,7 +54,7 @@
DeploymentContext deploymentContext) throws BuilderConfigException {
String name = componentDefinition.getName();
SpringImplementation implementation = componentDefinition.getImplementation();
- ConfigurableApplicationContext applicationContext = implementation.getComponentType().getApplicationContext();
+ AbstractApplicationContext applicationContext = implementation.getComponentType().getApplicationContext();
SpringCompositeComponent<?> component = new SpringCompositeComponent(name, applicationContext, parent, null);
CompositeComponentType<BoundServiceDefinition<? extends Binding>,
BoundReferenceDefinition<? extends Binding>,
Modified: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java?rev=432722&r1=432721&r2=432722&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java (original)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java Fri Aug 18 13:50:57 2006
@@ -43,6 +43,7 @@
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.NoSuchMessageException;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.core.io.Resource;
/**
@@ -52,7 +53,7 @@
*/
public class SpringCompositeComponent<T> extends CompositeComponentExtension<T> {
private static final String[] EMPTY_ARRAY = new String[0];
- private ConfigurableApplicationContext springContext;
+ private AbstractApplicationContext springContext;
/**
* Creates a new composite
@@ -63,7 +64,7 @@
* @param propertyValues the values of this composite's Properties
*/
public SpringCompositeComponent(String name,
- ConfigurableApplicationContext springContext,
+ AbstractApplicationContext springContext,
CompositeComponent parent,
Map<String, Document> propertyValues) {
super(name, parent, propertyValues);
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.springframework.sca.ScaAdapter;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class SpringScaAdapter implements ScaAdapter
+{
+ private final CompositeComponentType componentType;
+
+ public SpringScaAdapter(CompositeComponentType componentType) {
+ this.componentType = componentType;
+ }
+
+ public Object getServiceReference(String referenceName, Class referenceType, String moduleName, String defaultServiceName) {
+ return null;
+ }
+
+ public Object getPropertyReference(String propertyName, Class propertyType, String moduleName) {
+ return null;
+ }
+
+ public void publishAsService(Object serviceImplementation, Class serviceInterface, String serviceName, String moduleName) {
+ // componentType.getServices().put(serviceName, serviceImplementation);
+ }
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Modified: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java?rev=432722&r1=432721&r2=432722&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java (original)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java Fri Aug 18 13:50:57 2006
@@ -25,8 +25,7 @@
import org.apache.tuscany.spi.model.Property;
import org.apache.tuscany.spi.model.ReferenceDefinition;
import org.apache.tuscany.spi.model.ServiceDefinition;
-
-import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
/**
* Component type information for a Spring composite component implementation type. A component type is associated with
@@ -36,57 +35,67 @@
*/
public class SpringComponentType<S extends ServiceDefinition,
R extends ReferenceDefinition,
- P extends Property<?>> extends CompositeComponentType<S, R, P> {
+ P extends Property<?>> extends CompositeComponentType<S, R, P>
+{
- private GenericApplicationContext applicationContext;
- private Map<String, Class<?>> serviceTypes = new HashMap<String, Class<?>>();
- private boolean exposeAllBeans;
-
- public SpringComponentType(GenericApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- /**
- * Returns the application context for the component type
- */
- public GenericApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
- /**
- * Returns a collection of service types defined by <code>sca:service</code> elements in a Spring configuration.
- * Service types define beans that can be targets of services defined in the SCDL Spring composite declaration. For
- * each service type, there must be a corresponding service definition as part of the Spring composite declaration
- * per the SCA specification.
- */
- public Map<String, Class<?>> getServiceTypes() {
- return serviceTypes;
- }
-
- /**
- * Adds a service type to the component declaration defined by <code>sca:service</code> elements in a Spring
- * configuration.
- *
- * @param name the name of the service
- * @param type the interface type of the target bean
- */
- public void addServiceType(String name, Class<?> type) {
- this.serviceTypes.put(name, type);
- }
-
- /**
- * Returns true if all beans in the Spring application context may be service targets or false if service types are
- * defined
- */
- public boolean isExposeAllBeans() {
- return exposeAllBeans;
- }
-
- /**
- * Sets if all beans in the Spring application context may be service targets or false if service types are defined
- */
- public void setExposeAllBeans(boolean exposeAllBeans) {
- this.exposeAllBeans = exposeAllBeans;
- }
+ private AbstractApplicationContext applicationContext;
+ private Map<String, Class<?>> serviceTypes = new HashMap<String, Class<?>>();
+ private boolean exposeAllBeans;
+
+ public SpringComponentType(AbstractApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ public SpringComponentType() {
+ }
+
+ // FIXME andyp@bea.com -- this is a component type it should NOT contain bean instances!
+
+ /**
+ * Returns the application context for the component type
+ */
+ public AbstractApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public void setApplicationContext(AbstractApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ /**
+ * Returns a collection of service types defined by <code>sca:service</code> elements in a Spring configuration.
+ * Service types define beans that can be targets of services defined in the SCDL Spring composite declaration. For
+ * each service type, there must be a corresponding service definition as part of the Spring composite declaration
+ * per the SCA specification.
+ */
+ public Map<String, Class<?>> getServiceTypes() {
+ return serviceTypes;
+ }
+
+ /**
+ * Adds a service type to the component declaration defined by <code>sca:service</code> elements in a Spring
+ * configuration.
+ *
+ * @param name the name of the service
+ * @param type the interface type of the target bean
+ */
+ public void addServiceType(String name, Class<?> type) {
+ this.serviceTypes.put(name, type);
+ }
+
+ /**
+ * Returns true if all beans in the Spring application context may be service targets or false if service types are
+ * defined
+ */
+ public boolean isExposeAllBeans() {
+ return exposeAllBeans;
+ }
+
+ /**
+ * Sets if all beans in the Spring application context may be service targets or false if service types are defined
+ */
+ public void setExposeAllBeans(boolean exposeAllBeans) {
+ this.exposeAllBeans = exposeAllBeans;
+ }
}
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 11-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+/**
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class DefaultScaAdapter implements ScaAdapter {
+
+ /* (non-Javadoc)
+ * @see org.springframework.sca.ScaAdapter#getServiceReference(java.lang.String, java.lang.Class, java.lang.String, java.lang.String)
+ */
+ public Object getServiceReference(String referenceName,
+ Class referenceType, String moduleName, String defaultServiceName) {
+ // TODO
+ return new Object();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.sca.ScaAdapter#getPropertyReference(java.lang.String, java.lang.Class, java.lang.String)
+ */
+ public Object getPropertyReference(String propertyName, Class propertyType,
+ String moduleName) {
+ // TODO
+ return new Object();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.sca.ScaAdapter#publishAsService(java.lang.Object, java.lang.Class, java.lang.String, java.lang.String)
+ */
+ public void publishAsService(Object serviceImplementation,
+ Class serviceInterface, String serviceName, String moduleName) {
+ // TODO
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 11-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+/**
+ * Encapsulates interaction with an SCA runtime
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public interface ScaAdapter {
+
+ Object getServiceReference(
+ String referenceName,
+ Class referenceType,
+ String moduleName,
+ String defaultServiceName);
+
+ Object getPropertyReference(
+ String propertyName,
+ Class propertyType,
+ String moduleName);
+
+ void publishAsService(
+ Object serviceImplementation,
+ Class serviceInterface,
+ String serviceName,
+ String moduleName);
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,18 @@
+package org.springframework.sca;
+
+/**
+
+/**
+ * Interface that enables beans to find the ScaAdapter they are
+ * defined with.
+ *
+ * Note that in most circumstances there is no need for a bean to
+ * implement this interface.
+ *
+ * @author Andy Piper
+ * @since 2.1
+ */
+public interface ScaAdapterAware
+{
+ void setScaAdapter(ScaAdapter adapter);
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class ScaAdapterPostProcessor implements BeanPostProcessor
+{
+ private ScaAdapter scaAdapter;
+
+ public ScaAdapterPostProcessor(ScaAdapter adapter) {
+ this.scaAdapter = adapter;
+ }
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ if (bean instanceof ScaAdapterAware) {
+ if (this.scaAdapter == null) {
+ throw new IllegalStateException("Cannot satisfy ScaAdapterAware for bean '" +
+ beanName + "' without ScaAdapater");
+ }
+ ((ScaAdapterAware) bean).setScaAdapter(scaAdapter);
+ }
+ return bean;
+ }
+
+ public Object postProcessAfterInitialization(Object object, String string) throws BeansException {
+ return object;
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return scaAdapter;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Bean that represents an Sca composite component.
+ * An instance of this bean is created when the
+ * <sca:composite module-id="xxx"/> element
+ * is declared.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaComposite implements InitializingBean {
+
+ private String component;
+ private ScaAdapter scaAdapter = new DefaultScaAdapter();
+
+ public String getComponent() {
+ return this.component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ this.scaAdapter = scaAdapter;
+ }
+
+ public void setScaAdapterClass(Class adapterClass) {
+ if (!ScaAdapter.class.isAssignableFrom(adapterClass)) {
+ throw new IllegalArgumentException(
+ "Adapter class '" + adapterClass + "' specified for ScaComposite bean " +
+ "does not implement the ScaApapter interface"
+ );
+ }
+ try {
+ this.scaAdapter = (ScaAdapter) adapterClass.newInstance();
+ }
+ catch(Exception ex) {
+ // many exceptions may be thrown by the above, we treat them all
+ // the same
+ throw new IllegalStateException("Unable to create instance of ScaAdapter class '" +
+ adapterClass.getName() + "'",ex);
+ }
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return this.scaAdapter ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.component == null) {
+ throw new IllegalArgumentException("Required property moduleId was not set");
+ }
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca;
+
+import org.springframework.aop.framework.ProxyFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.PropertyValues;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.sca.intercept.OneWayAdvisor;
+import org.springframework.sca.metadata.DeploymentMetadata;
+import org.springframework.sca.metadata.Injection;
+import org.springframework.sca.metadata.NoSuchServiceException;
+import org.springframework.sca.metadata.ServiceMetadata;
+
+/**
+ * Spring bean post processor that looks up service metadata by
+ * name for each bean definition and performs SCA injection.
+ * <p>
+ * Also performs proxying for OneWay.
+ * @author Rod Johnson
+ */
+public class ScaPostProcessor implements InstantiationAwareBeanPostProcessor, ApplicationContextAware {
+
+ private DeploymentMetadata deploymentMetadata;
+
+ private ApplicationContext applicationContext;
+
+ private TaskExecutor taskExecutor;
+
+ private ScaAdapter scaAdapter;
+
+
+ /**
+ * @param taskExecutor The taskExecutor to set.
+ */
+ public void setTaskExecutor(TaskExecutor taskExecutor) {
+ this.taskExecutor = taskExecutor;
+ }
+
+ // TODO would process side files when container starts up
+
+ public void setDeploymentMetadata(DeploymentMetadata deploymentMetadata) {
+ this.deploymentMetadata = deploymentMetadata;
+ }
+
+ /**
+ * @param scaAdapter the ScaAdapter for use to export services if necessary
+ */
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ this.scaAdapter = scaAdapter;
+ }
+
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public Object postProcessBeforeInstantiation(Class beanClass,
+ String beanName) throws BeansException {
+ return null;
+ }
+
+ public boolean postProcessAfterInstantiation(Object bean, String beanName)
+ throws BeansException {
+ try {
+ ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
+ doScaInjection(bean, smd);
+ }
+ catch (NoSuchServiceException ex) {
+ //
+ }
+ return true;
+ }
+
+ public PropertyValues postProcessPropertyValues(PropertyValues propertyValues, Object object, String string) throws BeansException {
+ return propertyValues;
+ }
+
+ protected void doScaInjection(Object bean, ServiceMetadata smd) {
+ for (Injection injection : smd.getInjections()) {
+ injection.apply(applicationContext, bean);
+ }
+ }
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName)
+ throws BeansException {
+ return bean;
+ }
+
+ public Object postProcessAfterInitialization(Object bean, String beanName)
+ throws BeansException {
+ try {
+ ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
+ return createScaProxy(bean, smd);
+ }
+ catch (NoSuchServiceException ex) {
+ return bean;
+ }
+
+ // TODO validate required injections here or earlier
+
+ // TODO publish if necessary, using adapter
+ }
+
+ protected Object createScaProxy(Object bean, ServiceMetadata smd) {
+ ProxyFactory pf = new ProxyFactory(bean);
+ for (Class intf : smd.getServiceInterfaces()) {
+ pf.addInterface(intf);
+ }
+
+// pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
+// pf.addAdvisor(new ExposeBeanNameAdvisor(smd.getServiceName()));
+ // TODO enforce call by value
+
+ if (!smd.getOneWayMethods().isEmpty()) {
+ pf.addAdvisor(new OneWayAdvisor(smd, this.taskExecutor));
+ }
+
+ return pf.getProxy();
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Factory bean that returns a reference to an SCA property
+ * obtained by asking the SCA runtime for the property with
+ * the given name for the given component.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaPropertyProxyFactoryBean implements InitializingBean, FactoryBean {
+
+ /** the type of the property */
+ private Class propertyType;
+
+ /** the name of the property to look up */
+ private String propertyName;
+
+ /**
+ * the SCA component we should present ourselves as when asking for
+ * a service reference
+ */
+ private ScaComposite scaComposite;
+
+ private Object resolvedPropertyVal;
+
+ public void setPropertyType(Class serviceType) {
+ this.propertyType = serviceType;
+ }
+
+ public Class getPropertyType() {
+ return this.propertyType;
+ }
+
+ public void setPropertyName(String name) {
+ this.propertyName = name;
+ }
+
+ public String getPropertyName() {
+ return this.propertyName;
+ }
+
+ public void setScaComposite(ScaComposite scaComposite) {
+ this.scaComposite = scaComposite;
+ }
+
+ public ScaComposite getScaComposite() {
+ return this.scaComposite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.propertyType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.scaComposite == null) {
+ throw new IllegalArgumentException("Required property scaComposite was not set");
+ }
+ if (this.propertyName == null) {
+ throw new IllegalArgumentException("Required property referenceName was not set");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ if (this.resolvedPropertyVal != null) {
+ return this.resolvedPropertyVal;
+ }
+
+ String moduleName = this.scaComposite.getComponent();
+ // TODO: AMC is there any merit in proxying this with a lazy target source?
+ Object propertyVal = this.scaComposite.getScaAdapter().getPropertyReference(this.propertyName, this.propertyType, moduleName);
+ if (!this.propertyType.isAssignableFrom(propertyVal.getClass())) {
+ throw new IllegalStateException("Property value '" + propertyVal.toString() + "'" +
+ " of type '" + propertyVal.getClass().getName() + "' " +
+ " is not of expected type '" + this.propertyType.getName() + "'");
+ }
+ this.resolvedPropertyVal = propertyVal;
+ return this.resolvedPropertyVal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return this.propertyType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Exposes a bean instance to SCA to using the given service name.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaServiceExporter implements InitializingBean, BeanFactoryAware, ScaAdapterAware {
+
+ /** the name of the service we want to advertise */
+ private String serviceName;
+
+ /** the type the service should be published with */
+ private Class serviceType;
+
+ /** the bean to be published */
+ private Object target;
+
+ /** for resolving the bean name */
+ private BeanFactory beanFactory;
+ private ScaAdapter scaAdapter;
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceName() {
+ return this.serviceName;
+ }
+
+ public void setServiceType(Class serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public Class getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setTarget(Object targetBean) {
+ this.target = targetBean;
+ }
+
+ public Object getTarget() {
+ return this.target;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
+ */
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = beanFactory;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.serviceType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.target == null) {
+ throw new IllegalArgumentException("Required property target was not set");
+ }
+ if (this.beanFactory == null) {
+ throw new IllegalArgumentException("Required property beanFactory was not set");
+ }
+ if (this.serviceName == null) {
+ throw new IllegalArgumentException("Required property serviceName was not set");
+ }
+ publishScaService();
+ }
+
+ private void publishScaService() {
+ scaAdapter.publishAsService(target, serviceType, serviceName, null);
+ }
+
+ public void setScaAdapter(ScaAdapter adapter) {
+ this.scaAdapter = adapter;
+ }
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Factory bean that returns a reference to an SCA service
+ * obtained by asking the SCA runtime for the service with
+ * the given name for the given component.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaServiceProxyFactoryBean
+ implements InitializingBean, FactoryBean, ApplicationContextAware, ScaAdapterAware
+{
+
+ /** the public interface type of the service (may be a class...) */
+ private Class serviceType;
+
+ /** the name of the reference to look up */
+ private String referenceName;
+
+ /** the default service name to resolve the reference too */
+ private String defaultServiceName;
+
+ private Object resolvedServiceReference;
+ private ApplicationContext applicationContext;
+ private ScaAdapter scaAdapter;
+
+ public void setServiceType(Class serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public Class getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setReferenceName(String name) {
+ this.referenceName = name;
+ }
+
+ public String getReferenceName() {
+ return this.referenceName;
+ }
+
+ public void setDefaultServiceName(String defaultService) {
+ this.defaultServiceName = defaultService;
+ }
+
+ public String getDefaultServiceName() {
+ return this.defaultServiceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.serviceType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.referenceName == null) {
+ throw new IllegalArgumentException("Required property referenceName was not set");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ if (this.resolvedServiceReference != null) {
+ return this.resolvedServiceReference;
+ }
+
+ // TODO: AMC is there any merit in proxying this with a lazy target source?
+ // should the returned service ref be proxied? Only seems to add value
+ // if SCA gives us any lifecycle events we can subscribe to and take
+ // meaningful action on...
+ // See OsgiServiceProxyFactoryBean for an example of how to do the
+ // proxying if needed.
+ Object scaServiceRef;
+ if (this.applicationContext.getParent() == null) return null;
+
+ if (!this.applicationContext.getParent().containsBean(this.referenceName)) {
+ scaServiceRef = this.applicationContext.getParent().getBean(this.defaultServiceName);
+ }
+ else {
+ scaServiceRef = this.applicationContext.getParent().getBean(this.referenceName);
+ }
+ if (!this.serviceType.isAssignableFrom(scaServiceRef.getClass())) {
+ throw new IllegalStateException("...");
+ }
+ this.resolvedServiceReference = scaServiceRef;
+ return this.resolvedServiceReference;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return this.serviceType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public void setScaAdapter(ScaAdapter adapter) {
+ this.scaAdapter = adapter;
+ }
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+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.ScaComposite;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for <sca:composite> elements
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaCompositeBeanDefinitionParser implements BeanDefinitionParser {
+
+ static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
+ private static final String MODULE_ATTRIBUTE_NAME = "component";
+ private static final String MODULE_ID = "component";
+ private static final String ADAPTER_ATTRIBUTE = "sca-adapter-class";
+ private static final String ADAPTER_CLASS_PROPERTY = "scaAdapterClass";
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry.containsBeanDefinition(SCA_COMPOSITE_BEAN_NAME)) {
+ throw new IllegalArgumentException(
+ "At most one <sca:composite> element can be declared in a bean factory");
+ }
+ BeanDefinition beanDef = createScaCompositeBeanDefinition(element);
+ registry.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createScaCompositeBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaComposite.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(MODULE_ID, element.getAttribute(MODULE_ATTRIBUTE_NAME));
+ if (element.hasAttribute(ADAPTER_ATTRIBUTE)) {
+ props.addPropertyValue(ADAPTER_CLASS_PROPERTY,element.getAttribute(ADAPTER_ATTRIBUTE));
+ }
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.sca.ScaAdapter;
+import org.springframework.sca.ScaComposite;
+
+/**
+ * @author Hal Hildebrand
+ * Date: Apr 11, 2006
+ * Time: 4:33:33 PM
+ */
+public class ScaContextBuilder {
+
+ private String moduleId;
+
+ private ScaAdapter scaAdapter;
+
+ private static final String MODULE_ID = "moduleId";
+
+ private static final String SCA_ADAPTER = "scaAdapter";
+
+ private static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
+
+ public String getModuleId() {
+ return this.moduleId;
+ }
+
+ public void setModuleId(String moduleId) {
+ this.moduleId = moduleId;
+ }
+
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ this.scaAdapter = scaAdapter;
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return this.scaAdapter;
+ }
+
+ public ApplicationContext construct() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ BeanDefinition bd = new RootBeanDefinition(ScaComposite.class, true);
+
+ bd.getPropertyValues().addPropertyValue(new PropertyValue(MODULE_ID, moduleId));
+ bd.getPropertyValues().addPropertyValue(new PropertyValue(SCA_ADAPTER, scaAdapter));
+ parent.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, bd);
+ parent.refresh();
+ return parent;
+ }
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+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
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ init();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
+ */
+ public void init() {
+ registerBeanDefinitionParser("composite", new ScaCompositeBeanDefinitionParser());
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+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.ScaPropertyProxyFactoryBean;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the <sca:property/> element
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ private static final String PROPERTY_NAME_ATTRIBUTE = "name";
+ private static final String PROPERTY_NAME_PROPERTY = "propertyName";
+ private static final String PROPERTY_TYPE_PROPERTY = "propertyType";
+ private static final String TYPE_ATTRIBUTE = "type";
+ private static final String ID_ATTRIBUTE = "id";
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // needs service type, reference name, sca component, and optionally default service name
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ String beanName = element.getAttribute(ID_ATTRIBUTE);
+ BeanDefinition beanDef = createBeanDefinition(element);
+ registry.registerBeanDefinition(beanName, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaPropertyProxyFactoryBean.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(PROPERTY_NAME_PROPERTY, element.getAttribute(PROPERTY_NAME_ATTRIBUTE));
+ props.addPropertyValue(PROPERTY_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+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.ScaServiceProxyFactoryBean;
+import org.w3c.dom.Element;
+
+/**
+ * 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";
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ 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;
+ }
+
+ 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/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java?rev=432722&view=auto
==============================================================================
--- incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java (added)
+++ incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+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;
+import org.w3c.dom.Element;
+
+/**
+ * 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";
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ 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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.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
Re: svn commit: r432722 [1/2] - in /incubator/tuscany/java/sca/containers/container.spring/src: main/java/org/apache/tuscany/container/spring/config/ main/java/org/apache/tuscany/container/spring/impl/ main/java/org/apache/tuscany/container/spring/model/ m
Posted by Jim Marino <jm...@myromatours.com>.
That must have been in the patch - good catch and I'll fix it.
Jim
On Aug 19, 2006, at 9:16 AM, Raymond Feng wrote:
> Hi, Jim.
>
> It seems that you use a wrong property setting for "svn:keywords"
> which should be "Rev Date" instead of "Rev,Date". Please see
> Jeremy's post.
>
> Thanks,
> Raymond
>
> ----- Original Message ----- From: <jm...@apache.org>
> To: <tu...@ws.apache.org>
> Sent: Friday, August 18, 2006 1:50 PM
> Subject: svn commit: r432722 [1/2] - in /incubator/tuscany/java/sca/
> containers/container.spring/src: main/java/org/apache/tuscany/
> container/spring/config/ main/java/org/apache/tuscany/container/
> spring/impl/ main/java/org/apache/tuscany/container/spring/model/ m...
>
>
>> Author: jmarino
>> Date: Fri Aug 18 13:50:57 2006
>> New Revision: 432722
>>
>> URL: http://svn.apache.org/viewvc?rev=432722&view=rev
>> Log:
>> commit patch for Andy Piper, TUSCANY-643
>>
>> Added:
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/DefaultScaAdapter.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaAdapter.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaAdapterAware.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaAdapterPostProcessor.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaComposite.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaPostProcessor.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
>> (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaServiceExporter.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/ScaServiceProxyFactoryBean.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/ScaContextBuilder.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/ScaNamespaceHandler.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/intercept/
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/intercept/OneWayAdvisor.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/
>> AnnotationServiceMetadata.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/
>> BeanFactoryDeploymentMetadata.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/DeploymentMetadata.java
>> (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/FieldInjection.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/Injection.java (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/MethodInjection.java (with
>> props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/NoSuchServiceException.java
>> (with props)
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/springframework/sca/metadata/ServiceMetadata.java (with
>> props)
>> Modified:
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/config/
>> SCANamespaceHandlerResolver.java
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/impl/
>> SpringComponentTypeLoader.java
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeBuilder.java
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeComponent.java
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> java/org/apache/tuscany/container/spring/model/
>> SpringComponentType.java
>> incubator/tuscany/java/sca/containers/container.spring/src/main/
>> resources/META-INF/spring.handlers
>> incubator/tuscany/java/sca/containers/container.spring/src/test/
>> java/org/apache/tuscany/container/spring/
>> SpringConfigSchemaTestCase.java
>> incubator/tuscany/java/sca/containers/container.spring/src/test/
>> java/org/apache/tuscany/container/spring/impl/
>> ReferenceInvocationTestCase.java
>> incubator/tuscany/java/sca/containers/container.spring/src/test/
>> java/org/apache/tuscany/container/spring/impl/
>> ServiceInvocationTestCase.java
>>
>> Modified: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/config/
>> SCANamespaceHandlerResolver.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/config/SCANamespaceHandlerResolver.java?
>> rev=432722&r1=432721&r2=432722&view=diff
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/config/
>> SCANamespaceHandlerResolver.java (original)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/config/
>> SCANamespaceHandlerResolver.java Fri Aug 18 13:50:57 2006
>> @@ -22,6 +22,7 @@
>>
>> 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
>> @@ -35,18 +36,18 @@
>>
>> private static final String SCA_NAMESPACE = "http://
>> www.springframework.org/schema/sca";
>>
>> - private SCANamespaceHandler handler;
>> + private ScaNamespaceHandler handler;
>>
>> public SCANamespaceHandlerResolver(ClassLoader classLoader,
>> CompositeComponentType componentType) {
>> super(classLoader);
>> - handler = new SCANamespaceHandler(componentType);
>> + handler = new ScaNamespaceHandler(/*componentType*/);
>> }
>>
>> public SCANamespaceHandlerResolver(String
>> handlerMappingsLocation,
>> ClassLoader classLoader,
>> CompositeComponentType
>> componentType) {
>> super(classLoader, handlerMappingsLocation);
>> - handler = new SCANamespaceHandler(componentType);
>> + handler = new ScaNamespaceHandler(/*componentType*/);
>> }
>>
>> public NamespaceHandler resolve(String namespaceUri) {
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/config/ScaApplicationContext.java?
>> rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,64 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + */
>> +package org.apache.tuscany.container.spring.config;
>> +
>> +import
>> org.springframework.context.support.AbstractXmlApplicationContext;
>> +import org.springframework.context.ApplicationContext;
>> +import org.springframework.core.io.Resource;
>> +import
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
>> +import
>> org.springframework.beans.factory.config.ConfigurableListableBeanFact
>> ory;
>> +import org.springframework.beans.BeansException;
>> +import org.springframework.sca.ScaAdapterAware;
>> +import org.springframework.sca.ScaAdapterPostProcessor;
>> +import org.apache.tuscany.spi.model.CompositeComponentType;
>> +import org.apache.tuscany.container.spring.impl.SpringScaAdapter;
>> +
>> +/**
>> + * @author Andy Piper
>> + * @since 2.1
>> + */
>> +public class ScaApplicationContext extends
>> AbstractXmlApplicationContext
>> +{
>> + private Resource appXml;
>> + private CompositeComponentType componentType;
>> +
>> + public ScaApplicationContext(Resource appXml,
>> CompositeComponentType componentType) {
>> + this(null, appXml, componentType);
>> + }
>> +
>> + public ScaApplicationContext(ApplicationContext parent,
>> Resource appXml, CompositeComponentType componentType) {
>> + super(parent);
>> + this.appXml = appXml;
>> + this.componentType = componentType;
>> + refresh();
>> + }
>> +
>> + protected void initBeanDefinitionReader(XmlBeanDefinitionReader
>> beanDefinitionReader) {
>> + // beanDefinitionReader.setEntityResolver(null);
>> + beanDefinitionReader.setNamespaceHandlerResolver(new
>> SCANamespaceHandlerResolver(getClassLoader(), componentType));
>> + }
>> +
>> + protected Resource[] getConfigResources() {
>> + return new Resource[] { appXml };
>> + }
>> +
>> + protected void postProcessBeanFactory
>> (ConfigurableListableBeanFactory beanFactory) throws BeansException {
>> + super.postProcessBeanFactory(beanFactory);
>> + beanFactory.addBeanPostProcessor(new ScaAdapterPostProcessor
>> (new SpringScaAdapter(componentType)));
>> + beanFactory.ignoreDependencyInterface(ScaAdapterAware.class);
>> + }
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/config/
>> ScaApplicationContext.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Modified: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/impl/
>> SpringComponentTypeLoader.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/impl/SpringComponentTypeLoader.java?
>> rev=432722&r1=432721&r2=432722&view=diff
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringComponentTypeLoader.java (original)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringComponentTypeLoader.java Fri Aug 18 13:50:57 2006
>> @@ -18,23 +18,19 @@
>> */
>> package org.apache.tuscany.container.spring.impl;
>>
>> -import org.osoa.sca.annotations.Constructor;
>> -
>> +import
>> org.apache.tuscany.container.spring.config.ScaApplicationContext;
>> +import
>> org.apache.tuscany.container.spring.model.SpringComponentType;
>> +import
>> org.apache.tuscany.container.spring.model.SpringImplementation;
>> 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.container.spring.config.SCAService;
>> -import
>> org.apache.tuscany.container.spring.config.ScaServiceBeanDefinitionPa
>> rser;
>> -import
>> org.apache.tuscany.container.spring.model.SpringComponentType;
>> -import
>> org.apache.tuscany.container.spring.model.SpringImplementation;
>> -import
>> org.springframework.beans.factory.support.DefaultListableBeanFactory;
>> -import
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
>> -import
>> org.springframework.context.support.GenericApplicationContext;
>> +import org.osoa.sca.annotations.Constructor;
>> +import
>> org.springframework.context.support.AbstractRefreshableApplicationCon
>> text;
>> import org.springframework.core.io.Resource;
>> +import org.springframework.sca.ScaServiceExporter;
>>
>> /**
>> * Loads a component type for a Spring <code>ApplicationContext</
>> code>. The implementation creates a new instance of a
>> @@ -43,63 +39,64 @@
>> * @version $$Rev$$ $$Date$$
>> */
>>
>> -public class SpringComponentTypeLoader extends
>> ComponentTypeLoaderExtension<SpringImplementation> {
>> -
>> - @Constructor
>> - public SpringComponentTypeLoader(@Autowire LoaderRegistry
>> loaderRegistry) {
>> - super(loaderRegistry);
>> +public class SpringComponentTypeLoader extends
>> ComponentTypeLoaderExtension<SpringImplementation>
>> +{
>> + public static final String SERVICE_BEAN_SUFFIX = ".SCAService";
>> +
>> + @Constructor
>> + public SpringComponentTypeLoader(@Autowire LoaderRegistry
>> loaderRegistry) {
>> + super(loaderRegistry);
>> + }
>> +
>> + @Override
>> + protected Class<SpringImplementation> getImplementationClass() {
>> + return SpringImplementation.class;
>> + }
>> +
>> + /**
>> + * Responsible for loading the Spring composite component type.
>> The the application context is instantiated here as
>> + * it is needed to derive component type information. Since the
>> component type is loaded per SCDL entry (i.e.
>> + * composite use) one application context instance will be
>> created per Spring composite instance.
>> + */
>> + @SuppressWarnings("unchecked")
>> + public void load(CompositeComponent<?> parent,
>> + SpringImplementation implementation,
>> + DeploymentContext deploymentContext) 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;
>> }
>> -
>> - @Override
>> - protected Class<SpringImplementation> getImplementationClass() {
>> - return SpringImplementation.class;
>> - }
>> -
>> - /**
>> - * Responsible for loading the Spring composite component
>> type. The the application context is instantiated here as
>> - * it is needed to derive component type information. Since
>> the component type is loaded per SCDL entry (i.e.
>> - * composite use) one application context instance will be
>> created per Spring composite instance.
>> - */
>> - @SuppressWarnings("unchecked")
>> - public void load(CompositeComponent<?> parent,
>> - SpringImplementation implementation,
>> - DeploymentContext deploymentContext) 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;
>> - }
>> - Resource resource = implementation.getApplicationResource();
>> - DefaultListableBeanFactory beanFactory = new
>> DefaultListableBeanFactory();
>> - XmlBeanDefinitionReader reader = new
>> XmlBeanDefinitionReader(beanFactory);
>> - reader.loadBeanDefinitions(resource);
>> - GenericApplicationContext ctx = new
>> GenericApplicationContext(beanFactory);
>> - ctx.refresh();
>> - SpringComponentType componentType = new
>> SpringComponentType(ctx);
>> -
>> - // If there are <sca:service> elements, they define (and
>> limit) the services exposed
>> - // in the componentType.
>> - String [] serviceBeanNames = ctx.getBeanNamesForType
>> (SCAService.class);
>> - for (String serviceBeanName : serviceBeanNames) {
>> - int nSuffix = serviceBeanName.indexOf
>> (ScaServiceBeanDefinitionParser.SERVICE_BEAN_SUFFIX);
>> - if (nSuffix == -1) {
>> - continue;
>> - }
>> -
>> - String serviceName = serviceBeanName.substring(0,
>> nSuffix);
>> - SCAService serviceBean = (SCAService) ctx.getBean
>> (serviceName);
>> - String serviceTypeName = serviceBean.getType();
>> - try {
>> - Class serviceInterface = Class.forName
>> (serviceTypeName, true, deploymentContext.getClassLoader());
>> - componentType.addServiceType(serviceName,
>> serviceInterface);
>> - //ServiceDefinition service = createService
>> (serviceInterface);
>> - //componentType.getServices().put(serviceName,
>> service);
>> - } catch (ClassNotFoundException e) {
>> - throw new LoaderException(e);
>> - }
>> - }
>> - // if no service tags are specified, expose all beans
>> - componentType.setExposeAllBeans(componentType.getServiceTypes
>> ().isEmpty());
>> - implementation.setComponentType(componentType);
>> + Resource resource = implementation.getApplicationResource();
>> + SpringComponentType componentType = new SpringComponentType();
>> + // REVIEW andyp -- pass in deploymentContext.getClassLoader()?
>> + AbstractRefreshableApplicationContext ctx = new
>> ScaApplicationContext(resource, componentType);
>> + componentType.setApplicationContext(ctx); // FIXME
>> andyp@bea.com -- don't do this!
>> +
>> + // If there are <sca:service> elements, they define (and
>> limit) the services exposed
>> + // in the componentType.
>> + String [] serviceBeanNames = ctx.getBeanNamesForType
>> (ScaServiceExporter.class);
>> + for (String serviceBeanName : serviceBeanNames) {
>> + int nSuffix = serviceBeanName.indexOf(SERVICE_BEAN_SUFFIX);
>> + if (nSuffix == -1) {
>> + continue;
>> + }
>> +
>> + String serviceName = serviceBeanName.substring(0, nSuffix);
>> + ScaServiceExporter serviceBean = (ScaServiceExporter)
>> ctx.getBean(serviceName);
>> + // REVIEW andyp -- use the class directly?
>> + String serviceTypeName = serviceBean.getServiceType
>> ().getName();
>> + try {
>> + Class serviceInterface = Class.forName(serviceTypeName,
>> true, deploymentContext.getClassLoader());
>> + componentType.addServiceType(serviceName, serviceInterface);
>> + //ServiceDefinition service = createService
>> (serviceInterface);
>> + //componentType.getServices().put(serviceName, service);
>> + } catch (ClassNotFoundException e) {
>> + throw new LoaderException(e);
>> + }
>> }
>> + // if no service tags are specified, expose all beans
>> + componentType.setExposeAllBeans(componentType.getServiceTypes
>> ().isEmpty());
>> + implementation.setComponentType(componentType);
>> + }
>> }
>>
>> Modified: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeBuilder.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/impl/SpringCompositeBuilder.java?
>> rev=432722&r1=432721&r2=432722&view=diff
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeBuilder.java (original)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeBuilder.java Fri Aug 18 13:50:57 2006
>> @@ -38,6 +38,8 @@
>>
>> import
>> org.apache.tuscany.container.spring.model.SpringImplementation;
>> import org.springframework.context.ConfigurableApplicationContext;
>> +import org.springframework.context.ApplicationContext;
>> +import
>> org.springframework.context.support.AbstractApplicationContext;
>>
>> /**
>> * Creates a {@link
>> org.apache.tuscany.container.spring.impl.SpringCompositeComponent}
>> from an assembly model
>> @@ -52,7 +54,7 @@
>> DeploymentContext deploymentContext)
>> throws BuilderConfigException {
>> String name = componentDefinition.getName();
>> SpringImplementation implementation =
>> componentDefinition.getImplementation();
>> - ConfigurableApplicationContext applicationContext =
>> implementation.getComponentType().getApplicationContext();
>> + AbstractApplicationContext applicationContext =
>> implementation.getComponentType().getApplicationContext();
>> SpringCompositeComponent<?> component = new
>> SpringCompositeComponent(name, applicationContext, parent, null);
>> CompositeComponentType<BoundServiceDefinition<? extends
>> Binding>,
>> BoundReferenceDefinition<? extends Binding>,
>>
>> Modified: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeComponent.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/impl/SpringCompositeComponent.java?
>> rev=432722&r1=432721&r2=432722&view=diff
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeComponent.java (original)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringCompositeComponent.java Fri Aug 18 13:50:57 2006
>> @@ -43,6 +43,7 @@
>> import org.springframework.context.ConfigurableApplicationContext;
>> import org.springframework.context.MessageSourceResolvable;
>> import org.springframework.context.NoSuchMessageException;
>> +import
>> org.springframework.context.support.AbstractApplicationContext;
>> import org.springframework.core.io.Resource;
>>
>> /**
>> @@ -52,7 +53,7 @@
>> */
>> public class SpringCompositeComponent<T> extends
>> CompositeComponentExtension<T> {
>> private static final String[] EMPTY_ARRAY = new String[0];
>> - private ConfigurableApplicationContext springContext;
>> + private AbstractApplicationContext springContext;
>>
>> /**
>> * Creates a new composite
>> @@ -63,7 +64,7 @@
>> * @param propertyValues the values of this composite's
>> Properties
>> */
>> public SpringCompositeComponent(String name,
>> -
>> ConfigurableApplicationContext springContext,
>> + AbstractApplicationContext
>> springContext,
>> CompositeComponent parent,
>> Map<String, Document>
>> propertyValues) {
>> super(name, parent, propertyValues);
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/impl/SpringScaAdapter.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,45 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + */
>> +package org.apache.tuscany.container.spring.impl;
>> +
>> +import org.springframework.sca.ScaAdapter;
>> +import org.apache.tuscany.spi.model.CompositeComponentType;
>> +
>> +/**
>> + * @author Andy Piper
>> + * @since 2.1
>> + */
>> +public class SpringScaAdapter implements ScaAdapter
>> +{
>> + private final CompositeComponentType componentType;
>> +
>> + public SpringScaAdapter(CompositeComponentType componentType) {
>> + this.componentType = componentType;
>> + }
>> +
>> + public Object getServiceReference(String referenceName, Class
>> referenceType, String moduleName, String defaultServiceName) {
>> + return null;
>> + }
>> +
>> + public Object getPropertyReference(String propertyName, Class
>> propertyType, String moduleName) {
>> + return null;
>> + }
>> +
>> + public void publishAsService(Object serviceImplementation,
>> Class serviceInterface, String serviceName, String moduleName) {
>> + // componentType.getServices().put(serviceName,
>> serviceImplementation);
>> + }
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/impl/
>> SpringScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Modified: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/apache/tuscany/container/spring/model/
>> SpringComponentType.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/apache/tuscany/
>> container/spring/model/SpringComponentType.java?
>> rev=432722&r1=432721&r2=432722&view=diff
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/model/
>> SpringComponentType.java (original)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/apache/tuscany/container/spring/model/
>> SpringComponentType.java Fri Aug 18 13:50:57 2006
>> @@ -25,8 +25,7 @@
>> import org.apache.tuscany.spi.model.Property;
>> import org.apache.tuscany.spi.model.ReferenceDefinition;
>> import org.apache.tuscany.spi.model.ServiceDefinition;
>> -
>> -import
>> org.springframework.context.support.GenericApplicationContext;
>> +import
>> org.springframework.context.support.AbstractApplicationContext;
>>
>> /**
>> * Component type information for a Spring composite component
>> implementation type. A component type is associated with
>> @@ -36,57 +35,67 @@
>> */
>> public class SpringComponentType<S extends ServiceDefinition,
>> R extends ReferenceDefinition,
>> - P extends Property<?>> extends CompositeComponentType<S, R, P> {
>> + P extends Property<?>> extends CompositeComponentType<S, R, P>
>> +{
>>
>> - private GenericApplicationContext applicationContext;
>> - private Map<String, Class<?>> serviceTypes = new
>> HashMap<String, Class<?>>();
>> - private boolean exposeAllBeans;
>> -
>> - public SpringComponentType(GenericApplicationContext
>> applicationContext) {
>> - this.applicationContext = applicationContext;
>> - }
>> -
>> - /**
>> - * Returns the application context for the component type
>> - */
>> - public GenericApplicationContext getApplicationContext() {
>> - return applicationContext;
>> - }
>> -
>> - /**
>> - * Returns a collection of service types defined by
>> <code>sca:service</code> elements in a Spring configuration.
>> - * Service types define beans that can be targets of services
>> defined in the SCDL Spring composite declaration. For
>> - * each service type, there must be a corresponding service
>> definition as part of the Spring composite declaration
>> - * per the SCA specification.
>> - */
>> - public Map<String, Class<?>> getServiceTypes() {
>> - return serviceTypes;
>> - }
>> -
>> - /**
>> - * Adds a service type to the component declaration defined
>> by <code>sca:service</code> elements in a Spring
>> - * configuration.
>> - *
>> - * @param name the name of the service
>> - * @param type the interface type of the target bean
>> - */
>> - public void addServiceType(String name, Class<?> type) {
>> - this.serviceTypes.put(name, type);
>> - }
>> -
>> - /**
>> - * Returns true if all beans in the Spring application
>> context may be service targets or false if service types are
>> - * defined
>> - */
>> - public boolean isExposeAllBeans() {
>> - return exposeAllBeans;
>> - }
>> -
>> - /**
>> - * Sets if all beans in the Spring application context may be
>> service targets or false if service types are defined
>> - */
>> - public void setExposeAllBeans(boolean exposeAllBeans) {
>> - this.exposeAllBeans = exposeAllBeans;
>> - }
>> + private AbstractApplicationContext applicationContext;
>> + private Map<String, Class<?>> serviceTypes = new
>> HashMap<String, Class<?>>();
>> + private boolean exposeAllBeans;
>> +
>> + public SpringComponentType(AbstractApplicationContext
>> applicationContext) {
>> + this.applicationContext = applicationContext;
>> + }
>> +
>> + public SpringComponentType() {
>> + }
>> +
>> + // FIXME andyp@bea.com -- this is a component type it should
>> NOT contain bean instances!
>> +
>> + /**
>> + * Returns the application context for the component type
>> + */
>> + public AbstractApplicationContext getApplicationContext() {
>> + return applicationContext;
>> + }
>> +
>> + public void setApplicationContext(AbstractApplicationContext
>> applicationContext) {
>> + this.applicationContext = applicationContext;
>> + }
>> +
>> + /**
>> + * Returns a collection of service types defined by
>> <code>sca:service</code> elements in a Spring configuration.
>> + * Service types define beans that can be targets of services
>> defined in the SCDL Spring composite declaration. For
>> + * each service type, there must be a corresponding service
>> definition as part of the Spring composite declaration
>> + * per the SCA specification.
>> + */
>> + public Map<String, Class<?>> getServiceTypes() {
>> + return serviceTypes;
>> + }
>> +
>> + /**
>> + * Adds a service type to the component declaration defined by
>> <code>sca:service</code> elements in a Spring
>> + * configuration.
>> + *
>> + * @param name the name of the service
>> + * @param type the interface type of the target bean
>> + */
>> + public void addServiceType(String name, Class<?> type) {
>> + this.serviceTypes.put(name, type);
>> + }
>> +
>> + /**
>> + * Returns true if all beans in the Spring application context
>> may be service targets or false if service types are
>> + * defined
>> + */
>> + public boolean isExposeAllBeans() {
>> + return exposeAllBeans;
>> + }
>> +
>> + /**
>> + * Sets if all beans in the Spring application context may be
>> service targets or false if service types are defined
>> + */
>> + public void setExposeAllBeans(boolean exposeAllBeans) {
>> + this.exposeAllBeans = exposeAllBeans;
>> + }
>>
>> }
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/DefaultScaAdapter.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> DefaultScaAdapter.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/DefaultScaAdapter.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/DefaultScaAdapter.java Fri Aug
>> 18 13:50:57 2006
>> @@ -0,0 +1,52 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 11-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +/**
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class DefaultScaAdapter implements ScaAdapter {
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.sca.ScaAdapter#getServiceReference
>> (java.lang.String, java.lang.Class, java.lang.String,
>> java.lang.String)
>> + */
>> + public Object getServiceReference(String referenceName,
>> + Class referenceType, String moduleName, String
>> defaultServiceName) {
>> + // TODO
>> + return new Object();
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.sca.ScaAdapter#getPropertyReference
>> (java.lang.String, java.lang.Class, java.lang.String)
>> + */
>> + public Object getPropertyReference(String propertyName, Class
>> propertyType,
>> + String moduleName) {
>> + // TODO
>> + return new Object();
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.sca.ScaAdapter#publishAsService
>> (java.lang.Object, java.lang.Class, java.lang.String,
>> java.lang.String)
>> + */
>> + public void publishAsService(Object serviceImplementation,
>> + Class serviceInterface, String serviceName, String moduleName) {
>> + // TODO
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/DefaultScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/DefaultScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapter.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaAdapter.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapter.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapter.java Fri Aug 18
>> 13:50:57 2006
>> @@ -0,0 +1,45 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 11-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +/**
>> + * Encapsulates interaction with an SCA runtime
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public interface ScaAdapter {
>> +
>> + Object getServiceReference(
>> + String referenceName,
>> + Class referenceType,
>> + String moduleName,
>> + String defaultServiceName);
>> +
>> + Object getPropertyReference(
>> + String propertyName,
>> + Class propertyType,
>> + String moduleName);
>> +
>> + void publishAsService(
>> + Object serviceImplementation,
>> + Class serviceInterface,
>> + String serviceName,
>> + String moduleName);
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterAware.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaAdapterAware.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterAware.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterAware.java Fri Aug 18
>> 13:50:57 2006
>> @@ -0,0 +1,18 @@
>> +package org.springframework.sca;
>> +
>> +/**
>> +
>> +/**
>> + * Interface that enables beans to find the ScaAdapter they are
>> + * defined with.
>> + *
>> + * Note that in most circumstances there is no need for a bean to
>> + * implement this interface.
>> + *
>> + * @author Andy Piper
>> + * @since 2.1
>> + */
>> +public interface ScaAdapterAware
>> +{
>> + void setScaAdapter(ScaAdapter adapter);
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapterAware.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapterAware.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterPostProcessor.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaAdapterPostProcessor.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterPostProcessor.java
>> (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaAdapterPostProcessor.java Fri
>> Aug 18 13:50:57 2006
>> @@ -0,0 +1,53 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + */
>> +package org.springframework.sca;
>> +
>> +import org.springframework.beans.BeansException;
>> +import org.springframework.beans.factory.config.BeanPostProcessor;
>> +
>> +/**
>> + * @author Andy Piper
>> + * @since 2.1
>> + */
>> +public class ScaAdapterPostProcessor implements BeanPostProcessor
>> +{
>> + private ScaAdapter scaAdapter;
>> +
>> + public ScaAdapterPostProcessor(ScaAdapter adapter) {
>> + this.scaAdapter = adapter;
>> + }
>> +
>> + public Object postProcessBeforeInitialization(Object bean,
>> String beanName) throws BeansException {
>> + if (bean instanceof ScaAdapterAware) {
>> + if (this.scaAdapter == null) {
>> + throw new IllegalStateException("Cannot satisfy
>> ScaAdapterAware for bean '" +
>> + beanName + "' without ScaAdapater");
>> + }
>> + ((ScaAdapterAware) bean).setScaAdapter(scaAdapter);
>> + }
>> + return bean;
>> + }
>> +
>> + public Object postProcessAfterInitialization(Object object,
>> String string) throws BeansException {
>> + return object;
>> + }
>> +
>> + public ScaAdapter getScaAdapter() {
>> + return scaAdapter;
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaComposite.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaComposite.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaComposite.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaComposite.java Fri Aug 18
>> 13:50:57 2006
>> @@ -0,0 +1,80 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +import org.springframework.beans.factory.InitializingBean;
>> +
>> +/**
>> + * Bean that represents an Sca composite component.
>> + * An instance of this bean is created when the
>> + * <sca:composite module-id="xxx"/> element
>> + * is declared.
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaComposite implements InitializingBean {
>> +
>> + private String component;
>> + private ScaAdapter scaAdapter = new DefaultScaAdapter();
>> +
>> + public String getComponent() {
>> + return this.component;
>> + }
>> +
>> + public void setComponent(String component) {
>> + this.component = component;
>> + }
>> +
>> + public void setScaAdapter(ScaAdapter scaAdapter) {
>> + this.scaAdapter = scaAdapter;
>> + }
>> +
>> + public void setScaAdapterClass(Class adapterClass) {
>> + if (!ScaAdapter.class.isAssignableFrom(adapterClass)) {
>> + throw new IllegalArgumentException(
>> + "Adapter class '" + adapterClass + "' specified for ScaComposite
>> bean " +
>> + "does not implement the ScaApapter interface"
>> + );
>> + }
>> + try {
>> + this.scaAdapter = (ScaAdapter) adapterClass.newInstance();
>> + }
>> + catch(Exception ex) {
>> + // many exceptions may be thrown by the above, we treat them all
>> + // the same
>> + throw new IllegalStateException("Unable to create instance of
>> ScaAdapter class '" +
>> + adapterClass.getName() + "'",ex);
>> + }
>> + }
>> +
>> + public ScaAdapter getScaAdapter() {
>> + return this.scaAdapter ;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.InitializingBean#afterPropertiesSet
>> ()
>> + */
>> + public void afterPropertiesSet() throws Exception {
>> + if (this.component == null) {
>> + throw new IllegalArgumentException("Required property moduleId
>> was not set");
>> + }
>> + }
>> +
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaComposite.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaComposite.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPostProcessor.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaPostProcessor.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPostProcessor.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPostProcessor.java Fri Aug 18
>> 13:50:57 2006
>> @@ -0,0 +1,140 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + */
>> +
>> +package org.springframework.sca;
>> +
>> +import org.springframework.aop.framework.ProxyFactory;
>> +import org.springframework.beans.BeansException;
>> +import org.springframework.beans.PropertyValues;
>> +import
>> org.springframework.beans.factory.config.InstantiationAwareBeanPostPr
>> ocessor;
>> +import org.springframework.context.ApplicationContext;
>> +import org.springframework.context.ApplicationContextAware;
>> +import org.springframework.core.task.TaskExecutor;
>> +import org.springframework.sca.intercept.OneWayAdvisor;
>> +import org.springframework.sca.metadata.DeploymentMetadata;
>> +import org.springframework.sca.metadata.Injection;
>> +import org.springframework.sca.metadata.NoSuchServiceException;
>> +import org.springframework.sca.metadata.ServiceMetadata;
>> +
>> +/**
>> + * Spring bean post processor that looks up service metadata by
>> + * name for each bean definition and performs SCA injection.
>> + * <p>
>> + * Also performs proxying for OneWay.
>> + * @author Rod Johnson
>> + */
>> +public class ScaPostProcessor implements
>> InstantiationAwareBeanPostProcessor, ApplicationContextAware {
>> +
>> + private DeploymentMetadata deploymentMetadata;
>> +
>> + private ApplicationContext applicationContext;
>> +
>> + private TaskExecutor taskExecutor;
>> +
>> + private ScaAdapter scaAdapter;
>> +
>> +
>> + /**
>> + * @param taskExecutor The taskExecutor to set.
>> + */
>> + public void setTaskExecutor(TaskExecutor taskExecutor) {
>> + this.taskExecutor = taskExecutor;
>> + }
>> +
>> + // TODO would process side files when container starts up
>> +
>> + public void setDeploymentMetadata(DeploymentMetadata
>> deploymentMetadata) {
>> + this.deploymentMetadata = deploymentMetadata;
>> + }
>> +
>> + /**
>> + * @param scaAdapter the ScaAdapter for use to export services if
>> necessary
>> + */
>> + public void setScaAdapter(ScaAdapter scaAdapter) {
>> + this.scaAdapter = scaAdapter;
>> + }
>> +
>> +
>> + public void setApplicationContext(ApplicationContext
>> applicationContext) throws BeansException {
>> + this.applicationContext = applicationContext;
>> + }
>> +
>> + public Object postProcessBeforeInstantiation(Class beanClass,
>> + String beanName) throws BeansException {
>> + return null;
>> + }
>> +
>> + public boolean postProcessAfterInstantiation(Object bean, String
>> beanName)
>> + throws BeansException {
>> + try {
>> + ServiceMetadata smd = deploymentMetadata.getServiceMetadata
>> (beanName);
>> + doScaInjection(bean, smd);
>> + }
>> + catch (NoSuchServiceException ex) {
>> + //
>> + }
>> + return true;
>> + }
>> +
>> + public PropertyValues postProcessPropertyValues(PropertyValues
>> propertyValues, Object object, String string) throws BeansException {
>> + return propertyValues;
>> + }
>> +
>> + protected void doScaInjection(Object bean, ServiceMetadata smd) {
>> + for (Injection injection : smd.getInjections()) {
>> + injection.apply(applicationContext, bean);
>> + }
>> + }
>> +
>> + public Object postProcessBeforeInitialization(Object bean,
>> String beanName)
>> + throws BeansException {
>> + return bean;
>> + }
>> +
>> + public Object postProcessAfterInitialization(Object bean, String
>> beanName)
>> + throws BeansException {
>> + try {
>> + ServiceMetadata smd = deploymentMetadata.getServiceMetadata
>> (beanName);
>> + return createScaProxy(bean, smd);
>> + }
>> + catch (NoSuchServiceException ex) {
>> + return bean;
>> + }
>> +
>> + // TODO validate required injections here or earlier
>> +
>> + // TODO publish if necessary, using adapter
>> + }
>> +
>> + protected Object createScaProxy(Object bean, ServiceMetadata smd) {
>> + ProxyFactory pf = new ProxyFactory(bean);
>> + for (Class intf : smd.getServiceInterfaces()) {
>> + pf.addInterface(intf);
>> + }
>> +
>> +// pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
>> +// pf.addAdvisor(new ExposeBeanNameAdvisor(smd.getServiceName()));
>> + // TODO enforce call by value
>> +
>> + if (!smd.getOneWayMethods().isEmpty()) {
>> + pf.addAdvisor(new OneWayAdvisor(smd, this.taskExecutor));
>> + }
>> +
>> + return pf.getProxy();
>> + }
>> +
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaPostProcessor.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaPostProcessor.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaPropertyProxyFactoryBean.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
>> (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
>> Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,120 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +import org.springframework.beans.factory.FactoryBean;
>> +import org.springframework.beans.factory.InitializingBean;
>> +
>> +/**
>> + * Factory bean that returns a reference to an SCA property
>> + * obtained by asking the SCA runtime for the property with
>> + * the given name for the given component.
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaPropertyProxyFactoryBean implements
>> InitializingBean, FactoryBean {
>> +
>> + /** the type of the property */
>> + private Class propertyType;
>> +
>> + /** the name of the property to look up */
>> + private String propertyName;
>> +
>> + /**
>> + * the SCA component we should present ourselves as when asking for
>> + * a service reference
>> + */
>> + private ScaComposite scaComposite;
>> +
>> + private Object resolvedPropertyVal;
>> +
>> + public void setPropertyType(Class serviceType) {
>> + this.propertyType = serviceType;
>> + }
>> +
>> + public Class getPropertyType() {
>> + return this.propertyType;
>> + }
>> +
>> + public void setPropertyName(String name) {
>> + this.propertyName = name;
>> + }
>> +
>> + public String getPropertyName() {
>> + return this.propertyName;
>> + }
>> +
>> + public void setScaComposite(ScaComposite scaComposite) {
>> + this.scaComposite = scaComposite;
>> + }
>> +
>> + public ScaComposite getScaComposite() {
>> + return this.scaComposite;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.InitializingBean#afterPropertiesSet
>> ()
>> + */
>> + public void afterPropertiesSet() throws Exception {
>> + if (this.propertyType == null) {
>> + throw new IllegalArgumentException("Required property
>> serviceType was not set");
>> + }
>> + if (this.scaComposite == null) {
>> + throw new IllegalArgumentException("Required property
>> scaComposite was not set");
>> + }
>> + if (this.propertyName == null) {
>> + throw new IllegalArgumentException("Required property
>> referenceName was not set");
>> + }
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.beans.factory.FactoryBean#getObject()
>> + */
>> + public Object getObject() throws Exception {
>> + if (this.resolvedPropertyVal != null) {
>> + return this.resolvedPropertyVal;
>> + }
>> +
>> + String moduleName = this.scaComposite.getComponent();
>> + // TODO: AMC is there any merit in proxying this with a lazy
>> target source?
>> + Object propertyVal = this.scaComposite.getScaAdapter
>> ().getPropertyReference(this.propertyName, this.propertyType,
>> moduleName);
>> + if (!this.propertyType.isAssignableFrom(propertyVal.getClass())) {
>> + throw new IllegalStateException("Property value '" +
>> propertyVal.toString() + "'" +
>> + " of type '" + propertyVal.getClass().getName() + "' " +
>> + " is not of expected type '" + this.propertyType.getName() + "'");
>> + }
>> + this.resolvedPropertyVal = propertyVal;
>> + return this.resolvedPropertyVal;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.FactoryBean#getObjectType()
>> + */
>> + public Class getObjectType() {
>> + return this.propertyType;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.beans.factory.FactoryBean#isSingleton()
>> + */
>> + public boolean isSingleton() {
>> + return true;
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/
>> ScaPropertyProxyFactoryBean.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/
>> ScaPropertyProxyFactoryBean.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceExporter.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaServiceExporter.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceExporter.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceExporter.java Fri Aug
>> 18 13:50:57 2006
>> @@ -0,0 +1,103 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +import org.springframework.beans.BeansException;
>> +import org.springframework.beans.factory.BeanFactory;
>> +import org.springframework.beans.factory.BeanFactoryAware;
>> +import org.springframework.beans.factory.InitializingBean;
>> +
>> +/**
>> + * Exposes a bean instance to SCA to using the given service name.
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaServiceExporter implements InitializingBean,
>> BeanFactoryAware, ScaAdapterAware {
>> +
>> + /** the name of the service we want to advertise */
>> + private String serviceName;
>> +
>> + /** the type the service should be published with */
>> + private Class serviceType;
>> +
>> + /** the bean to be published */
>> + private Object target;
>> +
>> + /** for resolving the bean name */
>> + private BeanFactory beanFactory;
>> + private ScaAdapter scaAdapter;
>> +
>> + public void setServiceName(String serviceName) {
>> + this.serviceName = serviceName;
>> + }
>> +
>> + public String getServiceName() {
>> + return this.serviceName;
>> + }
>> +
>> + public void setServiceType(Class serviceType) {
>> + this.serviceType = serviceType;
>> + }
>> +
>> + public Class getServiceType() {
>> + return this.serviceType;
>> + }
>> +
>> + public void setTarget(Object targetBean) {
>> + this.target = targetBean;
>> + }
>> +
>> + public Object getTarget() {
>> + return this.target;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.BeanFactoryAware#setBeanFactory
>> (org.springframework.beans.factory.BeanFactory)
>> + */
>> + public void setBeanFactory(BeanFactory beanFactory) throws
>> BeansException {
>> + this.beanFactory = beanFactory;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.InitializingBean#afterPropertiesSet
>> ()
>> + */
>> + public void afterPropertiesSet() throws Exception {
>> + if (this.serviceType == null) {
>> + throw new IllegalArgumentException("Required property
>> serviceType was not set");
>> + }
>> + if (this.target == null) {
>> + throw new IllegalArgumentException("Required property target was
>> not set");
>> + }
>> + if (this.beanFactory == null) {
>> + throw new IllegalArgumentException("Required property
>> beanFactory was not set");
>> + }
>> + if (this.serviceName == null) {
>> + throw new IllegalArgumentException("Required property
>> serviceName was not set");
>> + }
>> + publishScaService();
>> + }
>> +
>> + private void publishScaService() {
>> + scaAdapter.publishAsService(target, serviceType, serviceName,
>> null);
>> + }
>> +
>> + public void setScaAdapter(ScaAdapter adapter) {
>> + this.scaAdapter = adapter;
>> + }
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaServiceExporter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaServiceExporter.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> ScaServiceProxyFactoryBean.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
>> (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
>> Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,138 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca;
>> +
>> +import org.springframework.beans.factory.FactoryBean;
>> +import org.springframework.beans.factory.InitializingBean;
>> +import org.springframework.beans.BeansException;
>> +import org.springframework.context.ApplicationContextAware;
>> +import org.springframework.context.ApplicationContext;
>> +
>> +/**
>> + * Factory bean that returns a reference to an SCA service
>> + * obtained by asking the SCA runtime for the service with
>> + * the given name for the given component.
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaServiceProxyFactoryBean
>> + implements InitializingBean, FactoryBean,
>> ApplicationContextAware, ScaAdapterAware
>> +{
>> +
>> + /** the public interface type of the service (may be a
>> class...) */
>> + private Class serviceType;
>> +
>> + /** the name of the reference to look up */
>> + private String referenceName;
>> +
>> + /** the default service name to resolve the reference too */
>> + private String defaultServiceName;
>> +
>> + private Object resolvedServiceReference;
>> + private ApplicationContext applicationContext;
>> + private ScaAdapter scaAdapter;
>> +
>> + public void setServiceType(Class serviceType) {
>> + this.serviceType = serviceType;
>> + }
>> +
>> + public Class getServiceType() {
>> + return this.serviceType;
>> + }
>> +
>> + public void setReferenceName(String name) {
>> + this.referenceName = name;
>> + }
>> +
>> + public String getReferenceName() {
>> + return this.referenceName;
>> + }
>> +
>> + public void setDefaultServiceName(String defaultService) {
>> + this.defaultServiceName = defaultService;
>> + }
>> +
>> + public String getDefaultServiceName() {
>> + return this.defaultServiceName;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.InitializingBean#afterPropertiesSet
>> ()
>> + */
>> + public void afterPropertiesSet() throws Exception {
>> + if (this.serviceType == null) {
>> + throw new IllegalArgumentException("Required property
>> serviceType was not set");
>> + }
>> + if (this.referenceName == null) {
>> + throw new IllegalArgumentException("Required property
>> referenceName was not set");
>> + }
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see org.springframework.beans.factory.FactoryBean#getObject()
>> + */
>> + public Object getObject() throws Exception {
>> + if (this.resolvedServiceReference != null) {
>> + return this.resolvedServiceReference;
>> + }
>> +
>> + // TODO: AMC is there any merit in proxying this with a lazy
>> target source?
>> + // should the returned service ref be proxied? Only
>> seems to add value
>> + // if SCA gives us any lifecycle events we can
>> subscribe to and take
>> + // meaningful action on...
>> + // See OsgiServiceProxyFactoryBean for an example of
>> how to do the
>> + // proxying if needed.
>> + Object scaServiceRef;
>> + if (this.applicationContext.getParent() == null) return null;
>> +
>> + if (!this.applicationContext.getParent().containsBean
>> (this.referenceName)) {
>> + scaServiceRef = this.applicationContext.getParent().getBean
>> (this.defaultServiceName);
>> + }
>> + else {
>> + scaServiceRef = this.applicationContext.getParent().getBean
>> (this.referenceName);
>> + }
>> + if (!this.serviceType.isAssignableFrom(scaServiceRef.getClass
>> ())) {
>> + throw new IllegalStateException("...");
>> + }
>> + this.resolvedServiceReference = scaServiceRef;
>> + return this.resolvedServiceReference;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.FactoryBean#getObjectType()
>> + */
>> + public Class getObjectType() {
>> + return this.serviceType;
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.FactoryBean#isSingleton()
>> + */
>> + public boolean isSingleton() {
>> + return true;
>> + }
>> +
>> + public void setApplicationContext(ApplicationContext
>> applicationContext) throws BeansException {
>> + this.applicationContext = applicationContext;
>> + }
>> +
>> + public void setScaAdapter(ScaAdapter adapter) {
>> + this.scaAdapter = adapter;
>> + }
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaCompositeBeanDefinitionParser.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,69 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +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.ScaComposite;
>> +import org.w3c.dom.Element;
>> +
>> +/**
>> + * Parser for <sca:composite> elements
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaCompositeBeanDefinitionParser implements
>> BeanDefinitionParser {
>> +
>> + static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
>> + private static final String MODULE_ATTRIBUTE_NAME = "component";
>> + private static final String MODULE_ID = "component";
>> + private static final String ADAPTER_ATTRIBUTE = "sca-adapter-
>> class";
>> + private static final String ADAPTER_CLASS_PROPERTY =
>> "scaAdapterClass";
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.xml.BeanDefinitionParser#parse
>> (org.w3c.dom.Element,
>> org.springframework.beans.factory.xml.ParserContext)
>> + */
>> + public BeanDefinition parse(Element element, ParserContext
>> parserContext) {
>> + BeanDefinitionRegistry registry = parserContext.getRegistry();
>> + if (registry.containsBeanDefinition(SCA_COMPOSITE_BEAN_NAME)) {
>> + throw new IllegalArgumentException(
>> + "At most one <sca:composite> element can be declared in a bean
>> factory");
>> + }
>> + BeanDefinition beanDef = createScaCompositeBeanDefinition(element);
>> + registry.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, beanDef);
>> + return beanDef;
>> + }
>> +
>> + private BeanDefinition createScaCompositeBeanDefinition(Element
>> element) {
>> + RootBeanDefinition beanDefinition = new RootBeanDefinition();
>> + beanDefinition.setBeanClass(ScaComposite.class);
>> + MutablePropertyValues props = new MutablePropertyValues();
>> + props.addPropertyValue(MODULE_ID, element.getAttribute
>> (MODULE_ATTRIBUTE_NAME));
>> + if (element.hasAttribute(ADAPTER_ATTRIBUTE)) {
>> + props.addPropertyValue
>> (ADAPTER_CLASS_PROPERTY,element.getAttribute(ADAPTER_ATTRIBUTE));
>> + }
>> + beanDefinition.setPropertyValues(props);
>> + return beanDefinition;
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaCompositeBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaContextBuilder.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaContextBuilder.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaContextBuilder.java
>> (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaContextBuilder.java
>> Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,72 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +import org.springframework.beans.PropertyValue;
>> +import org.springframework.beans.factory.config.BeanDefinition;
>> +import org.springframework.beans.factory.support.RootBeanDefinition;
>> +import org.springframework.context.ApplicationContext;
>> +import org.springframework.context.ConfigurableApplicationContext;
>> +import
>> org.springframework.context.support.GenericApplicationContext;
>> +import org.springframework.sca.ScaAdapter;
>> +import org.springframework.sca.ScaComposite;
>> +
>> +/**
>> + * @author Hal Hildebrand
>> + * Date: Apr 11, 2006
>> + * Time: 4:33:33 PM
>> + */
>> +public class ScaContextBuilder {
>> +
>> + private String moduleId;
>> +
>> + private ScaAdapter scaAdapter;
>> +
>> + private static final String MODULE_ID = "moduleId";
>> +
>> + private static final String SCA_ADAPTER = "scaAdapter";
>> +
>> + private static final String SCA_COMPOSITE_BEAN_NAME =
>> "scaComposite";
>> +
>> + public String getModuleId() {
>> + return this.moduleId;
>> + }
>> +
>> + public void setModuleId(String moduleId) {
>> + this.moduleId = moduleId;
>> + }
>> +
>> + public void setScaAdapter(ScaAdapter scaAdapter) {
>> + this.scaAdapter = scaAdapter;
>> + }
>> +
>> + public ScaAdapter getScaAdapter() {
>> + return this.scaAdapter;
>> + }
>> +
>> + public ApplicationContext construct() {
>> + GenericApplicationContext parent = new
>> GenericApplicationContext();
>> + BeanDefinition bd = new RootBeanDefinition
>> (ScaComposite.class, true);
>> +
>> + bd.getPropertyValues().addPropertyValue(new PropertyValue
>> (MODULE_ID, moduleId));
>> + bd.getPropertyValues().addPropertyValue(new PropertyValue
>> (SCA_ADAPTER, scaAdapter));
>> + parent.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, bd);
>> + parent.refresh();
>> + return parent;
>> + }
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/ScaContextBuilder.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/ScaContextBuilder.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaNamespaceHandler.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaNamespaceHandler.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaNamespaceHandler.java
>> (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/ScaNamespaceHandler.java
>> Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,50 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +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
>> + */
>> +public class ScaNamespaceHandler extends NamespaceHandlerSupport {
>> +
>> + public ScaNamespaceHandler() {
>> + init();
>> + }
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.xml.NamespaceHandler#init()
>> + */
>> + public void init() {
>> + registerBeanDefinitionParser("composite", new
>> ScaCompositeBeanDefinitionParser());
>> + registerBeanDefinitionParser("reference", new
>> ScaReferenceBeanDefinitionParser());
>> + registerBeanDefinitionParser("property", new
>> ScaPropertyBeanDefinitionParser());
>> + registerBeanDefinitionParser("service", new
>> ScaServiceBeanDefinitionParser());
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaPropertyBeanDefinitionParser.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,66 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +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.ScaPropertyProxyFactoryBean;
>> +import org.w3c.dom.Element;
>> +
>> +/**
>> + * Parser for the <sca:property/> element
>> + *
>> + * @author Adrian Colyer
>> + * @since 2.0
>> + */
>> +public class ScaPropertyBeanDefinitionParser implements
>> BeanDefinitionParser {
>> +
>> + private static final String PROPERTY_NAME_ATTRIBUTE = "name";
>> + private static final String PROPERTY_NAME_PROPERTY =
>> "propertyName";
>> + private static final String PROPERTY_TYPE_PROPERTY =
>> "propertyType";
>> + private static final String TYPE_ATTRIBUTE = "type";
>> + private static final String ID_ATTRIBUTE = "id";
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.xml.BeanDefinitionParser#parse
>> (org.w3c.dom.Element,
>> org.springframework.beans.factory.xml.ParserContext)
>> + */
>> + public BeanDefinition parse(Element element, ParserContext
>> parserContext) {
>> + // needs service type, reference name, sca component, and
>> optionally default service name
>> + BeanDefinitionRegistry registry = parserContext.getRegistry();
>> + String beanName = element.getAttribute(ID_ATTRIBUTE);
>> + BeanDefinition beanDef = createBeanDefinition(element);
>> + registry.registerBeanDefinition(beanName, beanDef);
>> + return beanDef;
>> + }
>> +
>> + private BeanDefinition createBeanDefinition(Element element) {
>> + RootBeanDefinition beanDefinition = new RootBeanDefinition();
>> + beanDefinition.setBeanClass(ScaPropertyProxyFactoryBean.class);
>> + MutablePropertyValues props = new MutablePropertyValues();
>> + props.addPropertyValue(PROPERTY_NAME_PROPERTY,
>> element.getAttribute(PROPERTY_NAME_ATTRIBUTE));
>> + props.addPropertyValue(PROPERTY_TYPE_PROPERTY,
>> element.getAttribute(TYPE_ATTRIBUTE));
>> + beanDefinition.setPropertyValues(props);
>> + return beanDefinition;
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaPropertyBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaReferenceBeanDefinitionParser.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,69 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +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.ScaServiceProxyFactoryBean;
>> +import org.w3c.dom.Element;
>> +
>> +/**
>> + * 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";
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.xml.BeanDefinitionParser#parse
>> (org.w3c.dom.Element,
>> org.springframework.beans.factory.xml.ParserContext)
>> + */
>> + 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;
>> + }
>> +
>> + 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/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaReferenceBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:keywords = Rev,Date
>>
>> Added: incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.java
>> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/
>> containers/container.spring/src/main/java/org/springframework/sca/
>> config/ScaServiceBeanDefinitionParser.java?rev=432722&view=auto
>> =====================================================================
>> =========
>> --- incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.java (added)
>> +++ incubator/tuscany/java/sca/containers/container.spring/src/
>> main/java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.java Fri Aug 18 13:50:57 2006
>> @@ -0,0 +1,67 @@
>> +/*
>> + * Copyright 2002-2006 the original author or authors.
>> + *
>> + * Licensed under the Apache License, Version 2.0 (the "License");
>> + * you may not use this file except in compliance with the License.
>> + * You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> software
>> + * distributed under the License is distributed on an "AS IS" BASIS,
>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
>> or implied.
>> + * See the License for the specific language governing
>> permissions and
>> + * limitations under the License.
>> + *
>> + * Created on 10-Apr-2006 by Adrian Colyer
>> + */
>> +package org.springframework.sca.config;
>> +
>> +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;
>> +import org.w3c.dom.Element;
>> +
>> +/**
>> + * 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";
>> +
>> + /* (non-Javadoc)
>> + * @see
>> org.springframework.beans.factory.xml.BeanDefinitionParser#parse
>> (org.w3c.dom.Element,
>> org.springframework.beans.factory.xml.ParserContext)
>> + */
>> + 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;
>> + }
>> +
>> +}
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.java
>> ---------------------------------------------------------------------
>> ---------
>> svn:eol-style = native
>>
>> Propchange: incubator/tuscany/java/sca/containers/container.spring/
>> src/main/java/org/springframework/sca/config/
>> ScaServiceBeanDefinitionParser.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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org
Re: svn commit: r432722 [1/2] - in /incubator/tuscany/java/sca/containers/container.spring/src: main/java/org/apache/tuscany/container/spring/config/ main/java/org/apache/tuscany/container/spring/impl/ main/java/org/apache/tuscany/container/spring/model/ m
Posted by Raymond Feng <en...@gmail.com>.
Hi, Jim.
It seems that you use a wrong property setting for "svn:keywords" which
should be "Rev Date" instead of "Rev,Date". Please see Jeremy's post.
Thanks,
Raymond
----- Original Message -----
From: <jm...@apache.org>
To: <tu...@ws.apache.org>
Sent: Friday, August 18, 2006 1:50 PM
Subject: svn commit: r432722 [1/2] - in
/incubator/tuscany/java/sca/containers/container.spring/src:
main/java/org/apache/tuscany/container/spring/config/
main/java/org/apache/tuscany/container/spring/impl/
main/java/org/apache/tuscany/container/spring/model/ m...
> Author: jmarino
> Date: Fri Aug 18 13:50:57 2006
> New Revision: 432722
>
> URL: http://svn.apache.org/viewvc?rev=432722&view=rev
> Log:
> commit patch for Andy Piper, TUSCANY-643
>
> Added:
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/intercept/
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java
> (with props)
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java
> (with props)
> Modified:
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/main/resources/META-INF/spring.handlers
>
> incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java
>
> incubator/tuscany/java/sca/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
>
> Modified:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java?rev=432722&r1=432721&r2=432722&view=diff
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
> (original)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
> Fri Aug 18 13:50:57 2006
> @@ -22,6 +22,7 @@
>
> 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
> @@ -35,18 +36,18 @@
>
> private static final String SCA_NAMESPACE =
> "http://www.springframework.org/schema/sca";
>
> - private SCANamespaceHandler handler;
> + private ScaNamespaceHandler handler;
>
> public SCANamespaceHandlerResolver(ClassLoader classLoader,
> CompositeComponentType componentType) {
> super(classLoader);
> - handler = new SCANamespaceHandler(componentType);
> + handler = new ScaNamespaceHandler(/*componentType*/);
> }
>
> public SCANamespaceHandlerResolver(String handlerMappingsLocation,
> ClassLoader classLoader,
> CompositeComponentType
> componentType) {
> super(classLoader, handlerMappingsLocation);
> - handler = new SCANamespaceHandler(componentType);
> + handler = new ScaNamespaceHandler(/*componentType*/);
> }
>
> public NamespaceHandler resolve(String namespaceUri) {
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + */
> +package org.apache.tuscany.container.spring.config;
> +
> +import org.springframework.context.support.AbstractXmlApplicationContext;
> +import org.springframework.context.ApplicationContext;
> +import org.springframework.core.io.Resource;
> +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
> +import
> org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
> +import org.springframework.beans.BeansException;
> +import org.springframework.sca.ScaAdapterAware;
> +import org.springframework.sca.ScaAdapterPostProcessor;
> +import org.apache.tuscany.spi.model.CompositeComponentType;
> +import org.apache.tuscany.container.spring.impl.SpringScaAdapter;
> +
> +/**
> + * @author Andy Piper
> + * @since 2.1
> + */
> +public class ScaApplicationContext extends AbstractXmlApplicationContext
> +{
> + private Resource appXml;
> + private CompositeComponentType componentType;
> +
> + public ScaApplicationContext(Resource appXml, CompositeComponentType
> componentType) {
> + this(null, appXml, componentType);
> + }
> +
> + public ScaApplicationContext(ApplicationContext parent, Resource
> appXml, CompositeComponentType componentType) {
> + super(parent);
> + this.appXml = appXml;
> + this.componentType = componentType;
> + refresh();
> + }
> +
> + protected void initBeanDefinitionReader(XmlBeanDefinitionReader
> beanDefinitionReader) {
> + // beanDefinitionReader.setEntityResolver(null);
> + beanDefinitionReader.setNamespaceHandlerResolver(new
> SCANamespaceHandlerResolver(getClassLoader(), componentType));
> + }
> +
> + protected Resource[] getConfigResources() {
> + return new Resource[] { appXml };
> + }
> +
> + protected void postProcessBeanFactory(ConfigurableListableBeanFactory
> beanFactory) throws BeansException {
> + super.postProcessBeanFactory(beanFactory);
> + beanFactory.addBeanPostProcessor(new ScaAdapterPostProcessor(new
> SpringScaAdapter(componentType)));
> + beanFactory.ignoreDependencyInterface(ScaAdapterAware.class);
> + }
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Modified:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java?rev=432722&r1=432721&r2=432722&view=diff
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
> (original)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
> Fri Aug 18 13:50:57 2006
> @@ -18,23 +18,19 @@
> */
> package org.apache.tuscany.container.spring.impl;
>
> -import org.osoa.sca.annotations.Constructor;
> -
> +import org.apache.tuscany.container.spring.config.ScaApplicationContext;
> +import org.apache.tuscany.container.spring.model.SpringComponentType;
> +import org.apache.tuscany.container.spring.model.SpringImplementation;
> 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.container.spring.config.SCAService;
> -import
> org.apache.tuscany.container.spring.config.ScaServiceBeanDefinitionParser;
> -import org.apache.tuscany.container.spring.model.SpringComponentType;
> -import org.apache.tuscany.container.spring.model.SpringImplementation;
> -import
> org.springframework.beans.factory.support.DefaultListableBeanFactory;
> -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
> -import org.springframework.context.support.GenericApplicationContext;
> +import org.osoa.sca.annotations.Constructor;
> +import
> org.springframework.context.support.AbstractRefreshableApplicationContext;
> import org.springframework.core.io.Resource;
> +import org.springframework.sca.ScaServiceExporter;
>
> /**
> * Loads a component type for a Spring <code>ApplicationContext</code>.
> The implementation creates a new instance of a
> @@ -43,63 +39,64 @@
> * @version $$Rev$$ $$Date$$
> */
>
> -public class SpringComponentTypeLoader extends
> ComponentTypeLoaderExtension<SpringImplementation> {
> -
> - @Constructor
> - public SpringComponentTypeLoader(@Autowire LoaderRegistry
> loaderRegistry) {
> - super(loaderRegistry);
> +public class SpringComponentTypeLoader extends
> ComponentTypeLoaderExtension<SpringImplementation>
> +{
> + public static final String SERVICE_BEAN_SUFFIX = ".SCAService";
> +
> + @Constructor
> + public SpringComponentTypeLoader(@Autowire LoaderRegistry
> loaderRegistry) {
> + super(loaderRegistry);
> + }
> +
> + @Override
> + protected Class<SpringImplementation> getImplementationClass() {
> + return SpringImplementation.class;
> + }
> +
> + /**
> + * Responsible for loading the Spring composite component type. The the
> application context is instantiated here as
> + * it is needed to derive component type information. Since the
> component type is loaded per SCDL entry (i.e.
> + * composite use) one application context instance will be created per
> Spring composite instance.
> + */
> + @SuppressWarnings("unchecked")
> + public void load(CompositeComponent<?> parent,
> + SpringImplementation implementation,
> + DeploymentContext deploymentContext) 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;
> }
> -
> - @Override
> - protected Class<SpringImplementation> getImplementationClass() {
> - return SpringImplementation.class;
> - }
> -
> - /**
> - * Responsible for loading the Spring composite component type. The
> the application context is instantiated here as
> - * it is needed to derive component type information. Since the
> component type is loaded per SCDL entry (i.e.
> - * composite use) one application context instance will be created
> per Spring composite instance.
> - */
> - @SuppressWarnings("unchecked")
> - public void load(CompositeComponent<?> parent,
> - SpringImplementation implementation,
> - DeploymentContext deploymentContext) 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;
> - }
> - Resource resource = implementation.getApplicationResource();
> - DefaultListableBeanFactory beanFactory = new
> DefaultListableBeanFactory();
> - XmlBeanDefinitionReader reader = new
> XmlBeanDefinitionReader(beanFactory);
> - reader.loadBeanDefinitions(resource);
> - GenericApplicationContext ctx = new
> GenericApplicationContext(beanFactory);
> - ctx.refresh();
> - SpringComponentType componentType = new SpringComponentType(ctx);
> -
> - // If there are <sca:service> elements, they define (and limit)
> the services exposed
> - // in the componentType.
> - String [] serviceBeanNames =
> ctx.getBeanNamesForType(SCAService.class);
> - for (String serviceBeanName : serviceBeanNames) {
> - int nSuffix =
> serviceBeanName.indexOf(ScaServiceBeanDefinitionParser.SERVICE_BEAN_SUFFIX);
> - if (nSuffix == -1) {
> - continue;
> - }
> -
> - String serviceName = serviceBeanName.substring(0, nSuffix);
> - SCAService serviceBean = (SCAService)
> ctx.getBean(serviceName);
> - String serviceTypeName = serviceBean.getType();
> - try {
> - Class serviceInterface = Class.forName(serviceTypeName,
> true, deploymentContext.getClassLoader());
> - componentType.addServiceType(serviceName,
> serviceInterface);
> - //ServiceDefinition service =
> createService(serviceInterface);
> - //componentType.getServices().put(serviceName, service);
> - } catch (ClassNotFoundException e) {
> - throw new LoaderException(e);
> - }
> - }
> - // if no service tags are specified, expose all beans
> -
> componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
> - implementation.setComponentType(componentType);
> + Resource resource = implementation.getApplicationResource();
> + SpringComponentType componentType = new SpringComponentType();
> + // REVIEW andyp -- pass in deploymentContext.getClassLoader()?
> + AbstractRefreshableApplicationContext ctx = new
> ScaApplicationContext(resource, componentType);
> + componentType.setApplicationContext(ctx); // FIXME andyp@bea.com --
> don't do this!
> +
> + // If there are <sca:service> elements, they define (and limit) the
> services exposed
> + // in the componentType.
> + String [] serviceBeanNames =
> ctx.getBeanNamesForType(ScaServiceExporter.class);
> + for (String serviceBeanName : serviceBeanNames) {
> + int nSuffix = serviceBeanName.indexOf(SERVICE_BEAN_SUFFIX);
> + if (nSuffix == -1) {
> + continue;
> + }
> +
> + String serviceName = serviceBeanName.substring(0, nSuffix);
> + ScaServiceExporter serviceBean = (ScaServiceExporter)
> ctx.getBean(serviceName);
> + // REVIEW andyp -- use the class directly?
> + String serviceTypeName = serviceBean.getServiceType().getName();
> + try {
> + Class serviceInterface = Class.forName(serviceTypeName, true,
> deploymentContext.getClassLoader());
> + componentType.addServiceType(serviceName, serviceInterface);
> + //ServiceDefinition service = createService(serviceInterface);
> + //componentType.getServices().put(serviceName, service);
> + } catch (ClassNotFoundException e) {
> + throw new LoaderException(e);
> + }
> }
> + // if no service tags are specified, expose all beans
> +
> componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
> + implementation.setComponentType(componentType);
> + }
> }
>
> Modified:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java?rev=432722&r1=432721&r2=432722&view=diff
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
> (original)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
> Fri Aug 18 13:50:57 2006
> @@ -38,6 +38,8 @@
>
> import org.apache.tuscany.container.spring.model.SpringImplementation;
> import org.springframework.context.ConfigurableApplicationContext;
> +import org.springframework.context.ApplicationContext;
> +import org.springframework.context.support.AbstractApplicationContext;
>
> /**
> * Creates a {@link
> org.apache.tuscany.container.spring.impl.SpringCompositeComponent} from an
> assembly model
> @@ -52,7 +54,7 @@
> DeploymentContext deploymentContext) throws
> BuilderConfigException {
> String name = componentDefinition.getName();
> SpringImplementation implementation =
> componentDefinition.getImplementation();
> - ConfigurableApplicationContext applicationContext =
> implementation.getComponentType().getApplicationContext();
> + AbstractApplicationContext applicationContext =
> implementation.getComponentType().getApplicationContext();
> SpringCompositeComponent<?> component = new
> SpringCompositeComponent(name, applicationContext, parent, null);
> CompositeComponentType<BoundServiceDefinition<? extends Binding>,
> BoundReferenceDefinition<? extends Binding>,
>
> Modified:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java?rev=432722&r1=432721&r2=432722&view=diff
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
> (original)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
> Fri Aug 18 13:50:57 2006
> @@ -43,6 +43,7 @@
> import org.springframework.context.ConfigurableApplicationContext;
> import org.springframework.context.MessageSourceResolvable;
> import org.springframework.context.NoSuchMessageException;
> +import org.springframework.context.support.AbstractApplicationContext;
> import org.springframework.core.io.Resource;
>
> /**
> @@ -52,7 +53,7 @@
> */
> public class SpringCompositeComponent<T> extends
> CompositeComponentExtension<T> {
> private static final String[] EMPTY_ARRAY = new String[0];
> - private ConfigurableApplicationContext springContext;
> + private AbstractApplicationContext springContext;
>
> /**
> * Creates a new composite
> @@ -63,7 +64,7 @@
> * @param propertyValues the values of this composite's Properties
> */
> public SpringCompositeComponent(String name,
> - ConfigurableApplicationContext
> springContext,
> + AbstractApplicationContext
> springContext,
> CompositeComponent parent,
> Map<String, Document> propertyValues)
> {
> super(name, parent, propertyValues);
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,45 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + */
> +package org.apache.tuscany.container.spring.impl;
> +
> +import org.springframework.sca.ScaAdapter;
> +import org.apache.tuscany.spi.model.CompositeComponentType;
> +
> +/**
> + * @author Andy Piper
> + * @since 2.1
> + */
> +public class SpringScaAdapter implements ScaAdapter
> +{
> + private final CompositeComponentType componentType;
> +
> + public SpringScaAdapter(CompositeComponentType componentType) {
> + this.componentType = componentType;
> + }
> +
> + public Object getServiceReference(String referenceName, Class
> referenceType, String moduleName, String defaultServiceName) {
> + return null;
> + }
> +
> + public Object getPropertyReference(String propertyName, Class
> propertyType, String moduleName) {
> + return null;
> + }
> +
> + public void publishAsService(Object serviceImplementation, Class
> serviceInterface, String serviceName, String moduleName) {
> + // componentType.getServices().put(serviceName,
> serviceImplementation);
> + }
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Modified:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java?rev=432722&r1=432721&r2=432722&view=diff
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
> (original)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
> Fri Aug 18 13:50:57 2006
> @@ -25,8 +25,7 @@
> import org.apache.tuscany.spi.model.Property;
> import org.apache.tuscany.spi.model.ReferenceDefinition;
> import org.apache.tuscany.spi.model.ServiceDefinition;
> -
> -import org.springframework.context.support.GenericApplicationContext;
> +import org.springframework.context.support.AbstractApplicationContext;
>
> /**
> * Component type information for a Spring composite component
> implementation type. A component type is associated with
> @@ -36,57 +35,67 @@
> */
> public class SpringComponentType<S extends ServiceDefinition,
> R extends ReferenceDefinition,
> - P extends Property<?>> extends CompositeComponentType<S, R, P> {
> + P extends Property<?>> extends CompositeComponentType<S, R, P>
> +{
>
> - private GenericApplicationContext applicationContext;
> - private Map<String, Class<?>> serviceTypes = new HashMap<String,
> Class<?>>();
> - private boolean exposeAllBeans;
> -
> - public SpringComponentType(GenericApplicationContext
> applicationContext) {
> - this.applicationContext = applicationContext;
> - }
> -
> - /**
> - * Returns the application context for the component type
> - */
> - public GenericApplicationContext getApplicationContext() {
> - return applicationContext;
> - }
> -
> - /**
> - * Returns a collection of service types defined by
> <code>sca:service</code> elements in a Spring configuration.
> - * Service types define beans that can be targets of services defined
> in the SCDL Spring composite declaration. For
> - * each service type, there must be a corresponding service
> definition as part of the Spring composite declaration
> - * per the SCA specification.
> - */
> - public Map<String, Class<?>> getServiceTypes() {
> - return serviceTypes;
> - }
> -
> - /**
> - * Adds a service type to the component declaration defined by
> <code>sca:service</code> elements in a Spring
> - * configuration.
> - *
> - * @param name the name of the service
> - * @param type the interface type of the target bean
> - */
> - public void addServiceType(String name, Class<?> type) {
> - this.serviceTypes.put(name, type);
> - }
> -
> - /**
> - * Returns true if all beans in the Spring application context may be
> service targets or false if service types are
> - * defined
> - */
> - public boolean isExposeAllBeans() {
> - return exposeAllBeans;
> - }
> -
> - /**
> - * Sets if all beans in the Spring application context may be service
> targets or false if service types are defined
> - */
> - public void setExposeAllBeans(boolean exposeAllBeans) {
> - this.exposeAllBeans = exposeAllBeans;
> - }
> + private AbstractApplicationContext applicationContext;
> + private Map<String, Class<?>> serviceTypes = new HashMap<String,
> Class<?>>();
> + private boolean exposeAllBeans;
> +
> + public SpringComponentType(AbstractApplicationContext
> applicationContext) {
> + this.applicationContext = applicationContext;
> + }
> +
> + public SpringComponentType() {
> + }
> +
> + // FIXME andyp@bea.com -- this is a component type it should NOT
> contain bean instances!
> +
> + /**
> + * Returns the application context for the component type
> + */
> + public AbstractApplicationContext getApplicationContext() {
> + return applicationContext;
> + }
> +
> + public void setApplicationContext(AbstractApplicationContext
> applicationContext) {
> + this.applicationContext = applicationContext;
> + }
> +
> + /**
> + * Returns a collection of service types defined by
> <code>sca:service</code> elements in a Spring configuration.
> + * Service types define beans that can be targets of services defined
> in the SCDL Spring composite declaration. For
> + * each service type, there must be a corresponding service definition
> as part of the Spring composite declaration
> + * per the SCA specification.
> + */
> + public Map<String, Class<?>> getServiceTypes() {
> + return serviceTypes;
> + }
> +
> + /**
> + * Adds a service type to the component declaration defined by
> <code>sca:service</code> elements in a Spring
> + * configuration.
> + *
> + * @param name the name of the service
> + * @param type the interface type of the target bean
> + */
> + public void addServiceType(String name, Class<?> type) {
> + this.serviceTypes.put(name, type);
> + }
> +
> + /**
> + * Returns true if all beans in the Spring application context may be
> service targets or false if service types are
> + * defined
> + */
> + public boolean isExposeAllBeans() {
> + return exposeAllBeans;
> + }
> +
> + /**
> + * Sets if all beans in the Spring application context may be service
> targets or false if service types are defined
> + */
> + public void setExposeAllBeans(boolean exposeAllBeans) {
> + this.exposeAllBeans = exposeAllBeans;
> + }
>
> }
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,52 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 11-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +/**
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class DefaultScaAdapter implements ScaAdapter {
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.sca.ScaAdapter#getServiceReference(java.lang.String,
> java.lang.Class, java.lang.String, java.lang.String)
> + */
> + public Object getServiceReference(String referenceName,
> + Class referenceType, String moduleName, String defaultServiceName) {
> + // TODO
> + return new Object();
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.sca.ScaAdapter#getPropertyReference(java.lang.String,
> java.lang.Class, java.lang.String)
> + */
> + public Object getPropertyReference(String propertyName, Class
> propertyType,
> + String moduleName) {
> + // TODO
> + return new Object();
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.sca.ScaAdapter#publishAsService(java.lang.Object,
> java.lang.Class, java.lang.String, java.lang.String)
> + */
> + public void publishAsService(Object serviceImplementation,
> + Class serviceInterface, String serviceName, String moduleName) {
> + // TODO
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,45 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 11-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +/**
> + * Encapsulates interaction with an SCA runtime
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public interface ScaAdapter {
> +
> + Object getServiceReference(
> + String referenceName,
> + Class referenceType,
> + String moduleName,
> + String defaultServiceName);
> +
> + Object getPropertyReference(
> + String propertyName,
> + Class propertyType,
> + String moduleName);
> +
> + void publishAsService(
> + Object serviceImplementation,
> + Class serviceInterface,
> + String serviceName,
> + String moduleName);
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,18 @@
> +package org.springframework.sca;
> +
> +/**
> +
> +/**
> + * Interface that enables beans to find the ScaAdapter they are
> + * defined with.
> + *
> + * Note that in most circumstances there is no need for a bean to
> + * implement this interface.
> + *
> + * @author Andy Piper
> + * @since 2.1
> + */
> +public interface ScaAdapterAware
> +{
> + void setScaAdapter(ScaAdapter adapter);
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,53 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + */
> +package org.springframework.sca;
> +
> +import org.springframework.beans.BeansException;
> +import org.springframework.beans.factory.config.BeanPostProcessor;
> +
> +/**
> + * @author Andy Piper
> + * @since 2.1
> + */
> +public class ScaAdapterPostProcessor implements BeanPostProcessor
> +{
> + private ScaAdapter scaAdapter;
> +
> + public ScaAdapterPostProcessor(ScaAdapter adapter) {
> + this.scaAdapter = adapter;
> + }
> +
> + public Object postProcessBeforeInitialization(Object bean, String
> beanName) throws BeansException {
> + if (bean instanceof ScaAdapterAware) {
> + if (this.scaAdapter == null) {
> + throw new IllegalStateException("Cannot satisfy ScaAdapterAware
> for bean '" +
> + beanName + "' without ScaAdapater");
> + }
> + ((ScaAdapterAware) bean).setScaAdapter(scaAdapter);
> + }
> + return bean;
> + }
> +
> + public Object postProcessAfterInitialization(Object object, String
> string) throws BeansException {
> + return object;
> + }
> +
> + public ScaAdapter getScaAdapter() {
> + return scaAdapter;
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,80 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +import org.springframework.beans.factory.InitializingBean;
> +
> +/**
> + * Bean that represents an Sca composite component.
> + * An instance of this bean is created when the
> + * <sca:composite module-id="xxx"/> element
> + * is declared.
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaComposite implements InitializingBean {
> +
> + private String component;
> + private ScaAdapter scaAdapter = new DefaultScaAdapter();
> +
> + public String getComponent() {
> + return this.component;
> + }
> +
> + public void setComponent(String component) {
> + this.component = component;
> + }
> +
> + public void setScaAdapter(ScaAdapter scaAdapter) {
> + this.scaAdapter = scaAdapter;
> + }
> +
> + public void setScaAdapterClass(Class adapterClass) {
> + if (!ScaAdapter.class.isAssignableFrom(adapterClass)) {
> + throw new IllegalArgumentException(
> + "Adapter class '" + adapterClass + "' specified for ScaComposite bean "
> +
> + "does not implement the ScaApapter interface"
> + );
> + }
> + try {
> + this.scaAdapter = (ScaAdapter) adapterClass.newInstance();
> + }
> + catch(Exception ex) {
> + // many exceptions may be thrown by the above, we treat them all
> + // the same
> + throw new IllegalStateException("Unable to create instance of ScaAdapter
> class '" +
> + adapterClass.getName() + "'",ex);
> + }
> + }
> +
> + public ScaAdapter getScaAdapter() {
> + return this.scaAdapter ;
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
> + */
> + public void afterPropertiesSet() throws Exception {
> + if (this.component == null) {
> + throw new IllegalArgumentException("Required property moduleId was not
> set");
> + }
> + }
> +
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,140 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +package org.springframework.sca;
> +
> +import org.springframework.aop.framework.ProxyFactory;
> +import org.springframework.beans.BeansException;
> +import org.springframework.beans.PropertyValues;
> +import
> org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
> +import org.springframework.context.ApplicationContext;
> +import org.springframework.context.ApplicationContextAware;
> +import org.springframework.core.task.TaskExecutor;
> +import org.springframework.sca.intercept.OneWayAdvisor;
> +import org.springframework.sca.metadata.DeploymentMetadata;
> +import org.springframework.sca.metadata.Injection;
> +import org.springframework.sca.metadata.NoSuchServiceException;
> +import org.springframework.sca.metadata.ServiceMetadata;
> +
> +/**
> + * Spring bean post processor that looks up service metadata by
> + * name for each bean definition and performs SCA injection.
> + * <p>
> + * Also performs proxying for OneWay.
> + * @author Rod Johnson
> + */
> +public class ScaPostProcessor implements
> InstantiationAwareBeanPostProcessor, ApplicationContextAware {
> +
> + private DeploymentMetadata deploymentMetadata;
> +
> + private ApplicationContext applicationContext;
> +
> + private TaskExecutor taskExecutor;
> +
> + private ScaAdapter scaAdapter;
> +
> +
> + /**
> + * @param taskExecutor The taskExecutor to set.
> + */
> + public void setTaskExecutor(TaskExecutor taskExecutor) {
> + this.taskExecutor = taskExecutor;
> + }
> +
> + // TODO would process side files when container starts up
> +
> + public void setDeploymentMetadata(DeploymentMetadata deploymentMetadata)
> {
> + this.deploymentMetadata = deploymentMetadata;
> + }
> +
> + /**
> + * @param scaAdapter the ScaAdapter for use to export services if
> necessary
> + */
> + public void setScaAdapter(ScaAdapter scaAdapter) {
> + this.scaAdapter = scaAdapter;
> + }
> +
> +
> + public void setApplicationContext(ApplicationContext applicationContext)
> throws BeansException {
> + this.applicationContext = applicationContext;
> + }
> +
> + public Object postProcessBeforeInstantiation(Class beanClass,
> + String beanName) throws BeansException {
> + return null;
> + }
> +
> + public boolean postProcessAfterInstantiation(Object bean, String
> beanName)
> + throws BeansException {
> + try {
> + ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
> + doScaInjection(bean, smd);
> + }
> + catch (NoSuchServiceException ex) {
> + //
> + }
> + return true;
> + }
> +
> + public PropertyValues postProcessPropertyValues(PropertyValues
> propertyValues, Object object, String string) throws BeansException {
> + return propertyValues;
> + }
> +
> + protected void doScaInjection(Object bean, ServiceMetadata smd) {
> + for (Injection injection : smd.getInjections()) {
> + injection.apply(applicationContext, bean);
> + }
> + }
> +
> + public Object postProcessBeforeInitialization(Object bean, String
> beanName)
> + throws BeansException {
> + return bean;
> + }
> +
> + public Object postProcessAfterInitialization(Object bean, String
> beanName)
> + throws BeansException {
> + try {
> + ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
> + return createScaProxy(bean, smd);
> + }
> + catch (NoSuchServiceException ex) {
> + return bean;
> + }
> +
> + // TODO validate required injections here or earlier
> +
> + // TODO publish if necessary, using adapter
> + }
> +
> + protected Object createScaProxy(Object bean, ServiceMetadata smd) {
> + ProxyFactory pf = new ProxyFactory(bean);
> + for (Class intf : smd.getServiceInterfaces()) {
> + pf.addInterface(intf);
> + }
> +
> +// pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
> +// pf.addAdvisor(new ExposeBeanNameAdvisor(smd.getServiceName()));
> + // TODO enforce call by value
> +
> + if (!smd.getOneWayMethods().isEmpty()) {
> + pf.addAdvisor(new OneWayAdvisor(smd, this.taskExecutor));
> + }
> +
> + return pf.getProxy();
> + }
> +
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,120 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +import org.springframework.beans.factory.FactoryBean;
> +import org.springframework.beans.factory.InitializingBean;
> +
> +/**
> + * Factory bean that returns a reference to an SCA property
> + * obtained by asking the SCA runtime for the property with
> + * the given name for the given component.
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaPropertyProxyFactoryBean implements InitializingBean,
> FactoryBean {
> +
> + /** the type of the property */
> + private Class propertyType;
> +
> + /** the name of the property to look up */
> + private String propertyName;
> +
> + /**
> + * the SCA component we should present ourselves as when asking for
> + * a service reference
> + */
> + private ScaComposite scaComposite;
> +
> + private Object resolvedPropertyVal;
> +
> + public void setPropertyType(Class serviceType) {
> + this.propertyType = serviceType;
> + }
> +
> + public Class getPropertyType() {
> + return this.propertyType;
> + }
> +
> + public void setPropertyName(String name) {
> + this.propertyName = name;
> + }
> +
> + public String getPropertyName() {
> + return this.propertyName;
> + }
> +
> + public void setScaComposite(ScaComposite scaComposite) {
> + this.scaComposite = scaComposite;
> + }
> +
> + public ScaComposite getScaComposite() {
> + return this.scaComposite;
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
> + */
> + public void afterPropertiesSet() throws Exception {
> + if (this.propertyType == null) {
> + throw new IllegalArgumentException("Required property serviceType was
> not set");
> + }
> + if (this.scaComposite == null) {
> + throw new IllegalArgumentException("Required property scaComposite was
> not set");
> + }
> + if (this.propertyName == null) {
> + throw new IllegalArgumentException("Required property referenceName was
> not set");
> + }
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#getObject()
> + */
> + public Object getObject() throws Exception {
> + if (this.resolvedPropertyVal != null) {
> + return this.resolvedPropertyVal;
> + }
> +
> + String moduleName = this.scaComposite.getComponent();
> + // TODO: AMC is there any merit in proxying this with a lazy target
> source?
> + Object propertyVal =
> this.scaComposite.getScaAdapter().getPropertyReference(this.propertyName,
> this.propertyType, moduleName);
> + if (!this.propertyType.isAssignableFrom(propertyVal.getClass())) {
> + throw new IllegalStateException("Property value '" +
> propertyVal.toString() + "'" +
> + " of type '" + propertyVal.getClass().getName() + "' " +
> + " is not of expected type '" + this.propertyType.getName() + "'");
> + }
> + this.resolvedPropertyVal = propertyVal;
> + return this.resolvedPropertyVal;
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#getObjectType()
> + */
> + public Class getObjectType() {
> + return this.propertyType;
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#isSingleton()
> + */
> + public boolean isSingleton() {
> + return true;
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,103 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +import org.springframework.beans.BeansException;
> +import org.springframework.beans.factory.BeanFactory;
> +import org.springframework.beans.factory.BeanFactoryAware;
> +import org.springframework.beans.factory.InitializingBean;
> +
> +/**
> + * Exposes a bean instance to SCA to using the given service name.
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaServiceExporter implements InitializingBean,
> BeanFactoryAware, ScaAdapterAware {
> +
> + /** the name of the service we want to advertise */
> + private String serviceName;
> +
> + /** the type the service should be published with */
> + private Class serviceType;
> +
> + /** the bean to be published */
> + private Object target;
> +
> + /** for resolving the bean name */
> + private BeanFactory beanFactory;
> + private ScaAdapter scaAdapter;
> +
> + public void setServiceName(String serviceName) {
> + this.serviceName = serviceName;
> + }
> +
> + public String getServiceName() {
> + return this.serviceName;
> + }
> +
> + public void setServiceType(Class serviceType) {
> + this.serviceType = serviceType;
> + }
> +
> + public Class getServiceType() {
> + return this.serviceType;
> + }
> +
> + public void setTarget(Object targetBean) {
> + this.target = targetBean;
> + }
> +
> + public Object getTarget() {
> + return this.target;
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
> + */
> + public void setBeanFactory(BeanFactory beanFactory) throws
> BeansException {
> + this.beanFactory = beanFactory;
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
> + */
> + public void afterPropertiesSet() throws Exception {
> + if (this.serviceType == null) {
> + throw new IllegalArgumentException("Required property serviceType was
> not set");
> + }
> + if (this.target == null) {
> + throw new IllegalArgumentException("Required property target was not
> set");
> + }
> + if (this.beanFactory == null) {
> + throw new IllegalArgumentException("Required property beanFactory was
> not set");
> + }
> + if (this.serviceName == null) {
> + throw new IllegalArgumentException("Required property serviceName was
> not set");
> + }
> + publishScaService();
> + }
> +
> + private void publishScaService() {
> + scaAdapter.publishAsService(target, serviceType, serviceName, null);
> + }
> +
> + public void setScaAdapter(ScaAdapter adapter) {
> + this.scaAdapter = adapter;
> + }
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,138 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca;
> +
> +import org.springframework.beans.factory.FactoryBean;
> +import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.beans.BeansException;
> +import org.springframework.context.ApplicationContextAware;
> +import org.springframework.context.ApplicationContext;
> +
> +/**
> + * Factory bean that returns a reference to an SCA service
> + * obtained by asking the SCA runtime for the service with
> + * the given name for the given component.
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaServiceProxyFactoryBean
> + implements InitializingBean, FactoryBean, ApplicationContextAware,
> ScaAdapterAware
> +{
> +
> + /** the public interface type of the service (may be a class...) */
> + private Class serviceType;
> +
> + /** the name of the reference to look up */
> + private String referenceName;
> +
> + /** the default service name to resolve the reference too */
> + private String defaultServiceName;
> +
> + private Object resolvedServiceReference;
> + private ApplicationContext applicationContext;
> + private ScaAdapter scaAdapter;
> +
> + public void setServiceType(Class serviceType) {
> + this.serviceType = serviceType;
> + }
> +
> + public Class getServiceType() {
> + return this.serviceType;
> + }
> +
> + public void setReferenceName(String name) {
> + this.referenceName = name;
> + }
> +
> + public String getReferenceName() {
> + return this.referenceName;
> + }
> +
> + public void setDefaultServiceName(String defaultService) {
> + this.defaultServiceName = defaultService;
> + }
> +
> + public String getDefaultServiceName() {
> + return this.defaultServiceName;
> + }
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
> + */
> + public void afterPropertiesSet() throws Exception {
> + if (this.serviceType == null) {
> + throw new IllegalArgumentException("Required property serviceType
> was not set");
> + }
> + if (this.referenceName == null) {
> + throw new IllegalArgumentException("Required property referenceName
> was not set");
> + }
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#getObject()
> + */
> + public Object getObject() throws Exception {
> + if (this.resolvedServiceReference != null) {
> + return this.resolvedServiceReference;
> + }
> +
> + // TODO: AMC is there any merit in proxying this with a lazy target
> source?
> + // should the returned service ref be proxied? Only seems to
> add value
> + // if SCA gives us any lifecycle events we can subscribe to and
> take
> + // meaningful action on...
> + // See OsgiServiceProxyFactoryBean for an example of how to do
> the
> + // proxying if needed.
> + Object scaServiceRef;
> + if (this.applicationContext.getParent() == null) return null;
> +
> + if
> (!this.applicationContext.getParent().containsBean(this.referenceName)) {
> + scaServiceRef =
> this.applicationContext.getParent().getBean(this.defaultServiceName);
> + }
> + else {
> + scaServiceRef =
> this.applicationContext.getParent().getBean(this.referenceName);
> + }
> + if (!this.serviceType.isAssignableFrom(scaServiceRef.getClass())) {
> + throw new IllegalStateException("...");
> + }
> + this.resolvedServiceReference = scaServiceRef;
> + return this.resolvedServiceReference;
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#getObjectType()
> + */
> + public Class getObjectType() {
> + return this.serviceType;
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.FactoryBean#isSingleton()
> + */
> + public boolean isSingleton() {
> + return true;
> + }
> +
> + public void setApplicationContext(ApplicationContext
> applicationContext) throws BeansException {
> + this.applicationContext = applicationContext;
> + }
> +
> + public void setScaAdapter(ScaAdapter adapter) {
> + this.scaAdapter = adapter;
> + }
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +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.ScaComposite;
> +import org.w3c.dom.Element;
> +
> +/**
> + * Parser for <sca:composite> elements
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaCompositeBeanDefinitionParser implements
> BeanDefinitionParser {
> +
> + static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
> + private static final String MODULE_ATTRIBUTE_NAME = "component";
> + private static final String MODULE_ID = "component";
> + private static final String ADAPTER_ATTRIBUTE = "sca-adapter-class";
> + private static final String ADAPTER_CLASS_PROPERTY = "scaAdapterClass";
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
> org.springframework.beans.factory.xml.ParserContext)
> + */
> + public BeanDefinition parse(Element element, ParserContext
> parserContext) {
> + BeanDefinitionRegistry registry = parserContext.getRegistry();
> + if (registry.containsBeanDefinition(SCA_COMPOSITE_BEAN_NAME)) {
> + throw new IllegalArgumentException(
> + "At most one <sca:composite> element can be declared in a bean
> factory");
> + }
> + BeanDefinition beanDef = createScaCompositeBeanDefinition(element);
> + registry.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, beanDef);
> + return beanDef;
> + }
> +
> + private BeanDefinition createScaCompositeBeanDefinition(Element element)
> {
> + RootBeanDefinition beanDefinition = new RootBeanDefinition();
> + beanDefinition.setBeanClass(ScaComposite.class);
> + MutablePropertyValues props = new MutablePropertyValues();
> + props.addPropertyValue(MODULE_ID,
> element.getAttribute(MODULE_ATTRIBUTE_NAME));
> + if (element.hasAttribute(ADAPTER_ATTRIBUTE)) {
> +
> props.addPropertyValue(ADAPTER_CLASS_PROPERTY,element.getAttribute(ADAPTER_ATTRIBUTE));
> + }
> + beanDefinition.setPropertyValues(props);
> + return beanDefinition;
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,72 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +import org.springframework.beans.PropertyValue;
> +import org.springframework.beans.factory.config.BeanDefinition;
> +import org.springframework.beans.factory.support.RootBeanDefinition;
> +import org.springframework.context.ApplicationContext;
> +import org.springframework.context.ConfigurableApplicationContext;
> +import org.springframework.context.support.GenericApplicationContext;
> +import org.springframework.sca.ScaAdapter;
> +import org.springframework.sca.ScaComposite;
> +
> +/**
> + * @author Hal Hildebrand
> + * Date: Apr 11, 2006
> + * Time: 4:33:33 PM
> + */
> +public class ScaContextBuilder {
> +
> + private String moduleId;
> +
> + private ScaAdapter scaAdapter;
> +
> + private static final String MODULE_ID = "moduleId";
> +
> + private static final String SCA_ADAPTER = "scaAdapter";
> +
> + private static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
> +
> + public String getModuleId() {
> + return this.moduleId;
> + }
> +
> + public void setModuleId(String moduleId) {
> + this.moduleId = moduleId;
> + }
> +
> + public void setScaAdapter(ScaAdapter scaAdapter) {
> + this.scaAdapter = scaAdapter;
> + }
> +
> + public ScaAdapter getScaAdapter() {
> + return this.scaAdapter;
> + }
> +
> + public ApplicationContext construct() {
> + GenericApplicationContext parent = new
> GenericApplicationContext();
> + BeanDefinition bd = new RootBeanDefinition(ScaComposite.class,
> true);
> +
> + bd.getPropertyValues().addPropertyValue(new
> PropertyValue(MODULE_ID, moduleId));
> + bd.getPropertyValues().addPropertyValue(new
> PropertyValue(SCA_ADAPTER, scaAdapter));
> + parent.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, bd);
> + parent.refresh();
> + return parent;
> + }
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,50 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +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
> + */
> +public class ScaNamespaceHandler extends NamespaceHandlerSupport {
> +
> + public ScaNamespaceHandler() {
> + init();
> + }
> +
> + /* (non-Javadoc)
> + * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
> + */
> + public void init() {
> + registerBeanDefinitionParser("composite", new
> ScaCompositeBeanDefinitionParser());
> + registerBeanDefinitionParser("reference", new
> ScaReferenceBeanDefinitionParser());
> + registerBeanDefinitionParser("property", new
> ScaPropertyBeanDefinitionParser());
> + registerBeanDefinitionParser("service", new
> ScaServiceBeanDefinitionParser());
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,66 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +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.ScaPropertyProxyFactoryBean;
> +import org.w3c.dom.Element;
> +
> +/**
> + * Parser for the <sca:property/> element
> + *
> + * @author Adrian Colyer
> + * @since 2.0
> + */
> +public class ScaPropertyBeanDefinitionParser implements
> BeanDefinitionParser {
> +
> + private static final String PROPERTY_NAME_ATTRIBUTE = "name";
> + private static final String PROPERTY_NAME_PROPERTY = "propertyName";
> + private static final String PROPERTY_TYPE_PROPERTY = "propertyType";
> + private static final String TYPE_ATTRIBUTE = "type";
> + private static final String ID_ATTRIBUTE = "id";
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
> org.springframework.beans.factory.xml.ParserContext)
> + */
> + public BeanDefinition parse(Element element, ParserContext
> parserContext) {
> + // needs service type, reference name, sca component, and optionally
> default service name
> + BeanDefinitionRegistry registry = parserContext.getRegistry();
> + String beanName = element.getAttribute(ID_ATTRIBUTE);
> + BeanDefinition beanDef = createBeanDefinition(element);
> + registry.registerBeanDefinition(beanName, beanDef);
> + return beanDef;
> + }
> +
> + private BeanDefinition createBeanDefinition(Element element) {
> + RootBeanDefinition beanDefinition = new RootBeanDefinition();
> + beanDefinition.setBeanClass(ScaPropertyProxyFactoryBean.class);
> + MutablePropertyValues props = new MutablePropertyValues();
> + props.addPropertyValue(PROPERTY_NAME_PROPERTY,
> element.getAttribute(PROPERTY_NAME_ATTRIBUTE));
> + props.addPropertyValue(PROPERTY_TYPE_PROPERTY,
> element.getAttribute(TYPE_ATTRIBUTE));
> + beanDefinition.setPropertyValues(props);
> + return beanDefinition;
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +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.ScaServiceProxyFactoryBean;
> +import org.w3c.dom.Element;
> +
> +/**
> + * 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";
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
> org.springframework.beans.factory.xml.ParserContext)
> + */
> + 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;
> + }
> +
> + 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/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev,Date
>
> Added:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java?rev=432722&view=auto
> ==============================================================================
> ---
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
> (added)
> +++
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
> Fri Aug 18 13:50:57 2006
> @@ -0,0 +1,67 @@
> +/*
> + * Copyright 2002-2006 the original author or authors.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * Created on 10-Apr-2006 by Adrian Colyer
> + */
> +package org.springframework.sca.config;
> +
> +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;
> +import org.w3c.dom.Element;
> +
> +/**
> + * 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";
> +
> + /* (non-Javadoc)
> + * @see
> org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
> org.springframework.beans.factory.xml.ParserContext)
> + */
> + 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;
> + }
> +
> +}
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange:
> incubator/tuscany/java/sca/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org