You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/11 04:55:07 UTC
svn commit: r527378 [3/9] - in /incubator/tuscany/java/sca/modules:
assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/
assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/
assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/...
Added: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java (added)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.bean.impl;
+
+import org.apache.tuscany.implementation.java.JavaImplementation;
+import org.apache.tuscany.interfacedef.java.JavaFactory;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceContractImpl;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA Java assembly model factory that creates SCA
+ * Java assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaFactory implements JavaFactory {
+
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanJavaFactory(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ return new BeanJavaImplementationImpl(beanRegistry);
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new BeanJavaInterfaceImpl();
+ }
+
+ public JavaInterfaceContract createJavaInterfaceContract() {
+ return new JavaInterfaceContractImpl();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java (added)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.bean.impl;
+
+import org.apache.tuscany.implementation.java.JavaImplementation;
+import org.apache.tuscany.implementation.java.JavaImplementationFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA Java assembly model factory that creates SCA
+ * Java assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaImplementationFactory implements JavaImplementationFactory {
+
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanJavaImplementationFactory(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ return new BeanJavaImplementationImpl(beanRegistry);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java (added)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.bean.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.assembly.ConstrainingType;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.Reference;
+import org.apache.tuscany.assembly.Service;
+import org.apache.tuscany.implementation.java.JavaImplementation;
+import org.apache.tuscany.policy.Intent;
+import org.apache.tuscany.policy.PolicySet;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+
+/**
+ * An implementation of the SCA assembly JavaImplementation interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaImplementationImpl extends RootBeanDefinition implements JavaImplementation {
+ private static final long serialVersionUID = 1L;
+
+ private List<Service> services = new ArrayList<Service>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ConstrainingType constrainingType;
+ private List<Object> extensions = new ArrayList<Object>();
+ private boolean unresolved;
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+
+ // Register this bean definition in the bean registry
+ //TODO find a better name for bean definitions representing component types
+ String name = String.valueOf(System.identityHashCode(this));
+ this.beanRegistry.registerBeanDefinition(name, this);
+ }
+
+ public Class<?> getJavaClass() {
+ return super.getBeanClass();
+ }
+
+ public String getName() {
+ return super.getBeanClassName();
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ super.setBeanClass(javaClass);
+ }
+
+ public void setName(String className) {
+ super.setBeanClassName(className);
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ //TODO use a better list implementation
+ private List<Property> properties = new ArrayList<Property>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a property
+ public boolean add(Property property) {
+
+ // Add corresponding bean property value
+ getPropertyValues().addPropertyValue(property.getName(), property.getValue());
+
+ return super.add(property);
+ }
+ };
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ //TODO use a better list implementation
+ private List<Reference> references = new ArrayList<Reference>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a reference
+ public boolean add(Reference reference) {
+
+ // Add corresponding bean property value
+ String target;
+ if (!reference.getTargets().isEmpty()) {
+ //TODO handle multiplicity
+ target = reference.getTargets().get(0).getName();
+ int i = target.indexOf('/');
+ if (i != -1)
+ target = target.substring(0, i);
+ } else {
+ target = null;
+ }
+ getPropertyValues().addPropertyValue(reference.getName(), target);
+
+ return super.add(reference);
+ }
+ };
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaImplementationImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.bean.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.policy.Intent;
+
+/**
+ * An alternate implementation of the SCA Java assembly model JavaInterface
+ * interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaInterfaceImpl implements JavaInterface {
+
+ private String className;
+ private Class<?> javaClass;
+ private Class<?> callbackClass;
+ private boolean conversational;
+ private boolean remotable;
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Operation> operations = new ArrayList<Operation>();
+ private boolean unresolved = false;
+
+ public String getName() {
+ if (isUnresolved())
+ return className;
+ else
+ return javaClass.getName();
+ }
+
+ public void setName(String className) {
+ if (!isUnresolved())
+ throw new IllegalStateException();
+ this.className = className;
+ }
+
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ public Class<?> getCallbackClass() {
+ return callbackClass;
+ }
+
+ public void setCallbackClass(Class<?> callbackClass) {
+ this.callbackClass = callbackClass;
+ }
+
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ public void setRemotable(boolean local) {
+ this.remotable = local;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/implementation/java/bean/impl/BeanJavaInterfaceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/application/context/TestRuntimeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/application/context/TestRuntimeContext.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/application/context/TestRuntimeContext.java (original)
+++ incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/application/context/TestRuntimeContext.java Tue Apr 10 19:55:00 2007
@@ -21,10 +21,10 @@
import java.io.InputStream;
import org.apache.tuscany.assembly.Composite;
-import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
-import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
-import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
-import org.apache.tuscany.bean.context.CompositeApplicationContext;
+import org.apache.tuscany.assembly.xml.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.ConstrainingTypeProcessor;
+import org.apache.tuscany.core.bean.context.CompositeApplicationContext;
import org.apache.tuscany.implementation.java.xml.JavaImplementationProcessor;
import org.apache.tuscany.interfacedef.java.xml.JavaInterfaceProcessor;
import org.apache.tuscany.services.spi.contribution.ContributionException;
Modified: incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/model/variant/VariantRuntimeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/model/variant/VariantRuntimeContext.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/model/variant/VariantRuntimeContext.java (original)
+++ incubator/tuscany/java/sca/modules/core-spring/src/test/java/test/model/variant/VariantRuntimeContext.java Tue Apr 10 19:55:00 2007
@@ -22,15 +22,15 @@
import org.apache.tuscany.assembly.AssemblyFactory;
import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.bean.impl.BeanAssemblyFactory;
import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
-import org.apache.tuscany.assembly.xml.impl.ComponentTypeProcessor;
-import org.apache.tuscany.assembly.xml.impl.CompositeProcessor;
-import org.apache.tuscany.assembly.xml.impl.ConstrainingTypeProcessor;
-import org.apache.tuscany.bean.impl.BeanAssemblyFactory;
+import org.apache.tuscany.assembly.xml.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.ConstrainingTypeProcessor;
import org.apache.tuscany.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.implementation.java.bean.impl.BeanJavaImplementationFactory;
import org.apache.tuscany.implementation.java.xml.JavaImplementationProcessor;
import org.apache.tuscany.interfacedef.java.xml.JavaInterfaceProcessor;
-import org.apache.tuscany.java.bean.impl.BeanJavaImplementationFactory;
import org.apache.tuscany.policy.PolicyFactory;
import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
import org.apache.tuscany.services.spi.contribution.ContributionException;
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java Tue Apr 10 19:55:00 2007
@@ -74,7 +74,7 @@
* of the implementation class. Otherwise, if the resource
* "META-INF/services/org.apache.tuscany.api.SCARuntime" can be loaded from
* the supplied classloader. Otherwise, it will use
- * "org.apache.tuscany.runtime.embedded.DefaultSCARuntime" as the default.
+ * "org.apache.tuscany.host.embedded.DefaultSCARuntime" as the default.
* The named class is loaded from the supplied classloader and instantiated
* using its default (no-arg) constructor.
*
@@ -94,7 +94,7 @@
className = getServiceName(classLoader, name);
}
if (className == null) {
- className = "org.apache.tuscany.runtime.embedded.DefaultSCARuntime";
+ className = "org.apache.tuscany.host.embedded.DefaultSCARuntime";
}
Class cls = Class.forName(className, true, classLoader);
return (SCARuntime)cls.newInstance(); // NOPMD lresende
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.embedded;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * Default implementation of SCARuntime.
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class DefaultSCARuntime extends SCARuntime {
+
+ protected SimpleRuntime runtime;
+
+ protected void startup(URL system, URL[] exts, URL applicationSCDL, String compositePath) throws Exception {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ List<URL> extensions = exts == null ? null : Arrays.asList(exts);
+ URI contributionURI = URI.create("/default");
+ SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(cl, system, extensions, contributionURI,
+ applicationSCDL, compositePath);
+ runtime = new SimpleRuntimeImpl(runtimeInfo);
+
+ try {
+ runtime.start();
+ } catch (Exception e) {
+ throw e;
+ }
+
+ }
+
+ protected void shutdown() throws Exception {
+ runtime.destroy();
+ }
+
+ @Override
+ protected ComponentContext getContext(String componentName) {
+ return runtime.getComponentContext(URI.create(componentName));
+ }
+
+ @Override
+ public Object getSystemService(String serviceName) {
+ try {
+ return runtime.getSystemService(Object.class, serviceName);
+ } catch (TargetResolutionException e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/DefaultSCARuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.embedded;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+/**
+ * Class for tunneling a WorkContext through the invocation of a user class.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class PojoWorkContextTunnel {
+ private static final ThreadLocal<WorkContext> CONTEXT = new ThreadLocal<WorkContext>();
+
+ private PojoWorkContextTunnel() {
+ }
+
+ /**
+ * Set the WorkContext for the current thread.
+ * The current work context is returned and must be restored after the invocation is complete.
+ * Typical usage would be:
+ * <pre>
+ * WorkContext old = PojoWorkContextTunnel.setThreadWorkContext(newContext);
+ * try {
+ * ... invoke user code ...
+ * } finally {
+ * PojoWorkContextTunnel.setThreadWorkContext(old);
+ * }
+ * </pre>
+ * @param context
+ * @return the current work context for the thread; this must be restored after the invocation is made
+ */
+ public static WorkContext setThreadWorkContext(WorkContext context) {
+ WorkContext old = CONTEXT.get();
+ CONTEXT.set(context);
+ return old;
+ }
+
+ /**
+ * Returns the WorkContext for the current thread.
+ *
+ * @return the WorkContext for the current thread
+ */
+ public static WorkContext getThreadWorkContext() {
+ return CONTEXT.get();
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/PojoWorkContextTunnel.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.host.embedded;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+
+/**
+ * A simple runtime to host both Tuscany and application code on the same classpath
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SimpleRuntime extends TuscanyRuntime<SimpleRuntimeInfo> {
+ /**
+ * Start the embedded Tuscany
+ * @return
+ * @throws Exception
+ */
+ Component start() throws Exception;
+
+ /**
+ * Look up system services by name
+ * @param <T>
+ * @param type
+ * @param name
+ * @return
+ * @throws TargetResolutionException
+ */
+ <T> T getSystemService(Class<T> type, String name) throws TargetResolutionException;
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.embedded;
+
+import static org.apache.tuscany.host.embedded.SimpleRuntimeInfo.DEFAULT_COMPOSITE;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collection;
+
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.xml.ComponentTypeProcessor;
+import org.apache.tuscany.assembly.xml.CompositeDocumentProcessor;
+import org.apache.tuscany.assembly.xml.CompositeProcessor;
+import org.apache.tuscany.assembly.xml.ConstrainingTypeProcessor;
+import org.apache.tuscany.core.bootstrap.ExtensionPointRegistryImpl;
+import org.apache.tuscany.core.component.SimpleWorkContext;
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.host.runtime.InitializationException;
+import org.apache.tuscany.services.contribution.ContributionPackageProcessorRegistryImpl;
+import org.apache.tuscany.services.contribution.ContributionRepositoryImpl;
+import org.apache.tuscany.services.contribution.ContributionServiceImpl;
+import org.apache.tuscany.services.contribution.PackageTypeDescriberImpl;
+import org.apache.tuscany.services.contribution.model.Contribution;
+import org.apache.tuscany.services.contribution.model.DeployedArtifact;
+import org.apache.tuscany.services.contribution.processor.FolderContributionProcessor;
+import org.apache.tuscany.services.contribution.processor.JarContributionProcessor;
+import org.apache.tuscany.services.contribution.util.FileHelper;
+import org.apache.tuscany.services.spi.contribution.ArtifactResolverRegistry;
+import org.apache.tuscany.services.spi.contribution.ContributionPackageProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.ContributionRepository;
+import org.apache.tuscany.services.spi.contribution.ContributionService;
+import org.apache.tuscany.services.spi.contribution.DefaultArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.DefaultStAXArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.DefaultURLArtifactProcessorRegistry;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.bootstrap.ExtensionPointRegistry;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.component.WorkContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeImpl extends AbstractRuntime<SimpleRuntimeInfo> implements SimpleRuntime {
+ private ScopeContainer<URI> container;
+
+ public SimpleRuntimeImpl(SimpleRuntimeInfo runtimeInfo) {
+ super(SimpleRuntimeInfo.class);
+ ClassLoader hostClassLoader = runtimeInfo.getClassLoader();
+ setHostClassLoader(hostClassLoader);
+ setApplicationScdl(runtimeInfo.getApplicationSCDL());
+ setSystemScdl(runtimeInfo.getSystemSCDL());
+ setRuntimeInfo(runtimeInfo);
+ }
+
+ public void initialize() throws InitializationException {
+ }
+
+ private static URL getContributionLocation(URL applicationSCDL, String compositePath) {
+ URL root = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ try {
+ String scdlUrl = applicationSCDL.toExternalForm();
+ String protocol = applicationSCDL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (scdlUrl.endsWith(compositePath)) {
+ String location = scdlUrl.substring(0, scdlUrl.lastIndexOf(compositePath));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = scdlUrl.substring(4, scdlUrl.lastIndexOf("!/"));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ } catch (MalformedURLException mfe) {
+ throw new IllegalArgumentException(mfe);
+ }
+
+ return root;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component start() throws Exception {
+ ExtensionPointRegistry extensionRegistry = new ExtensionPointRegistryImpl();
+ ContributionRepository repository = new ContributionRepositoryImpl("target");
+ DefaultStAXArtifactProcessorRegistry registry = new DefaultStAXArtifactProcessorRegistry();
+ registry.addArtifactProcessor(new CompositeProcessor(registry));
+ registry.addArtifactProcessor(new ComponentTypeProcessor(registry));
+ registry.addArtifactProcessor(new ConstrainingTypeProcessor(registry));
+
+ extensionRegistry.addExtensionPoint(StAXArtifactProcessorRegistry.class, registry);
+
+ DefaultURLArtifactProcessorRegistry artifactRegistry = new DefaultURLArtifactProcessorRegistry();
+ CompositeDocumentProcessor compositeProcessor = new CompositeDocumentProcessor(registry);
+
+ artifactRegistry.addArtifactProcessor(compositeProcessor);
+
+ PackageTypeDescriberImpl describer = new PackageTypeDescriberImpl();
+ ContributionPackageProcessorRegistry pkgRegistry = new ContributionPackageProcessorRegistryImpl(describer);
+ new JarContributionProcessor(pkgRegistry);
+ new FolderContributionProcessor(pkgRegistry);
+
+ DefaultArtifactResolver artifactResolver = new DefaultArtifactResolver();
+
+ ContributionService contributionService =
+ new ContributionServiceImpl(repository, pkgRegistry, artifactRegistry, artifactResolver);
+
+ extensionRegistry.addExtensionPoint(ContributionService.class, contributionService);
+ initialize(extensionRegistry, contributionService);
+
+ ScopeRegistry scopeRegistry = getScopeRegistry();
+ container = scopeRegistry.getScopeContainer(Scope.COMPOSITE);
+
+ URI uri = URI.create("sca://default/");
+ URL root = getContributionLocation(getApplicationScdl(), runtimeInfo.getCompositePath());
+ contributionService.contribute(uri, root, false);
+ Contribution contribution = contributionService.getContribution(uri);
+
+ // FIXME: Need to getDeployables() as list of Composites
+ DeployedArtifact artifact = contribution.getArtifact(URI.create(uri + runtimeInfo.getCompositePath()));
+ Composite composite = (Composite)artifact.getModelObject();
+
+ Collection<Component> components = getDeployer().deploy(composite);
+ for (Component component : components) {
+ component.start();
+ }
+ container.startContext(DEFAULT_COMPOSITE, DEFAULT_COMPOSITE);
+ getWorkContext().setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE);
+ WorkContext workContext = new SimpleWorkContext();
+ workContext.setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE);
+ PojoWorkContextTunnel.setThreadWorkContext(workContext);
+ tuscanySystem = getComponentManager().getComponent(URI.create("/" + composite.getName().getLocalPart()));
+ return tuscanySystem;
+ }
+
+ @SuppressWarnings("deprecation")
+ public <T> T getSystemService(Class<T> type, String name) throws TargetResolutionException {
+ SCAObject child = getComponentManager().getComponent(URI.create(name));
+ if (child == null) {
+ return null;
+ }
+ AtomicComponent service = (AtomicComponent)child;
+ return type.cast(service.getTargetInstance());
+ }
+
+ @Override
+ public void destroy() {
+ container.stopContext(DEFAULT_COMPOSITE);
+ getWorkContext().setIdentifier(Scope.COMPOSITE, null);
+ super.destroy();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.host.embedded;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface SimpleRuntimeInfo extends RuntimeInfo {
+ URI DEFAULT_COMPOSITE = ComponentNames.TUSCANY_APPLICATION_ROOT.resolve("default");
+
+ String DEFAULT_SYSTEM_SCDL = "META-INF/tuscany/default-system.composite";
+ String SYSTEM_SCDL = "system.composite";
+ String EXTENSION_SCDL = "META-INF/sca/extension.composite";
+ String SERVICE_SCDL = "META-INF/sca/service.composite";
+ String META_APPLICATION_SCDL = "META-INF/sca/application.composite";
+ String APPLICATION_SCDL = "application.composite";
+
+ ClassLoader getClassLoader();
+
+ String getCompositePath();
+
+ URL getSystemSCDL();
+
+ URL getApplicationSCDL();
+
+ List<URL> getExtensionSCDLs();
+
+ URL getContributionRoot();
+
+ URI getContributionURI();
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.host.embedded;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.tuscany.host.AbstractRuntimeInfo;
+import org.apache.tuscany.services.contribution.util.FileHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeInfoImpl extends AbstractRuntimeInfo implements SimpleRuntimeInfo {
+ private ClassLoader classLoader;
+ private String compositePath;
+
+ private List<URL> extensions;
+ private URL applicationSCDL;
+ private URL systemSCDL;
+
+ private URL contributionURL;
+ private URI contributionURI;
+
+ /**
+ * @param classLoader
+ * @param compositePath
+ * @param extensions
+ * @param applicationSCDL
+ * @param systemSCDL
+ */
+ public SimpleRuntimeInfoImpl(ClassLoader classLoader,
+ URL systemSCDL,
+ List<URL> extensions,
+ URI contributionURI,
+ URL applicationSCDL,
+ String compositePath) {
+ this(classLoader, compositePath);
+ this.extensions = extensions;
+ this.applicationSCDL = applicationSCDL;
+ this.systemSCDL = systemSCDL;
+ this.contributionURI = contributionURI;
+ }
+
+ public SimpleRuntimeInfoImpl(ClassLoader classLoader, String compositePath) {
+ // super(domain, applicationRootDirectory, baseUrl, online, runtimeId);
+ super(URI.create("sca://domain/local"), null, null, false, "simple");
+ if (classLoader != null) {
+ this.classLoader = classLoader;
+ } else {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ this.compositePath = compositePath != null ? compositePath : APPLICATION_SCDL;
+ getApplicationSCDL();
+ this.contributionURI = URI.create("/default");
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public String getCompositePath() {
+ return compositePath;
+ }
+
+ public final URL getApplicationSCDL() {
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(compositePath);
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(APPLICATION_SCDL);
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(META_APPLICATION_SCDL);
+ if (applicationSCDL != null) {
+ compositePath = META_APPLICATION_SCDL;
+ }
+ } else {
+ if (compositePath == null) {
+ compositePath = APPLICATION_SCDL;
+ }
+ }
+ if (applicationSCDL == null) {
+ throw new IllegalArgumentException("application SCDL not found: " + APPLICATION_SCDL);
+ }
+ }
+ }
+ return applicationSCDL;
+ }
+
+ public URL getContributionRoot() {
+ if (contributionURL == null) {
+ contributionURL = getContributionLocation(getApplicationSCDL(), compositePath);
+ }
+ return contributionURL;
+ }
+
+ public List<URL> getExtensionSCDLs() {
+ if (extensions == null) {
+ try {
+ List<URL> extensionURLs = new ArrayList<URL>();
+ Enumeration<URL> urls = classLoader.getResources(SERVICE_SCDL);
+ extensionURLs.addAll(Collections.list(urls));
+ urls = classLoader.getResources(EXTENSION_SCDL);
+ extensionURLs.addAll(Collections.list(urls));
+ if (extensions != null) {
+ for (URL ext : extensions) {
+ if (!extensionURLs.contains(ext)) {
+ extensionURLs.add(ext);
+ }
+ }
+ }
+ extensions = extensionURLs;
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return extensions;
+ }
+
+ public URL getSystemSCDL() {
+ if (systemSCDL == null) {
+ systemSCDL = classLoader.getResource(SYSTEM_SCDL);
+ if (systemSCDL == null) {
+ systemSCDL = classLoader.getResource(DEFAULT_SYSTEM_SCDL);
+ }
+ }
+ return systemSCDL;
+ }
+
+ private static URL getContributionLocation(URL applicationSCDL, String compositePath) {
+ URL root = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ try {
+ String scdlUrl = applicationSCDL.toExternalForm();
+ String protocol = applicationSCDL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (scdlUrl.endsWith(compositePath)) {
+ String location = scdlUrl.substring(0, scdlUrl.lastIndexOf(compositePath));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = scdlUrl.substring(4, scdlUrl.lastIndexOf("!/"));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ } catch (MalformedURLException mfe) {
+ throw new IllegalArgumentException(mfe);
+ }
+
+ return root;
+ }
+
+ public URI getContributionURI() {
+ return contributionURI;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SimpleRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.host.embedded;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.embedded.SimpleRuntime;
+import org.apache.tuscany.host.embedded.SimpleRuntimeImpl;
+import org.apache.tuscany.host.embedded.SimpleRuntimeInfo;
+import org.apache.tuscany.host.embedded.SimpleRuntimeInfoImpl;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeImplTestCase extends TestCase {
+ private SimpleRuntime runtime;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(getClass().getClassLoader(), "crud.composite");
+ runtime = new SimpleRuntimeImpl(runtimeInfo);
+ runtime.start();
+ }
+
+ public void testStart() throws Exception {
+ ComponentContext context = runtime.getComponentContext(URI.create("CRUDServiceComponent"));
+ assertNotNull(context);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ runtime.destroy();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SimpleRuntimeImplTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java Tue Apr 10 19:55:00 2007
@@ -46,7 +46,7 @@
import org.apache.tuscany.core.injection.ObjectCallbackException;
import org.apache.tuscany.implementation.java.impl.JavaElement;
import org.apache.tuscany.implementation.java.impl.Parameter;
-import org.apache.tuscany.implementation.java.processor.JavaIntrospectionHelper;
+import org.apache.tuscany.implementation.java.introspect.impl.JavaIntrospectionHelper;
import org.apache.tuscany.interfacedef.java.JavaInterface;
import org.apache.tuscany.spi.CoreRuntimeException;
import org.apache.tuscany.spi.ObjectCreationException;
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java Tue Apr 10 19:55:00 2007
@@ -42,7 +42,7 @@
import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
import org.apache.tuscany.implementation.java.impl.JavaElement;
import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
-import org.apache.tuscany.implementation.java.processor.JavaIntrospectionHelper;
+import org.apache.tuscany.implementation.java.introspect.impl.JavaIntrospectionHelper;
import org.apache.tuscany.spi.ObjectFactory;
import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.wire.ProxyService;
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/java/bootstrap/RuntimeJavaModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/java/bootstrap/RuntimeJavaModuleActivator.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/java/bootstrap/RuntimeJavaModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/core/implementation/java/bootstrap/RuntimeJavaModuleActivator.java Tue Apr 10 19:55:00 2007
@@ -25,25 +25,25 @@
import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
import org.apache.tuscany.core.wire.jdk.JDKProxyService;
import org.apache.tuscany.implementation.java.JavaImplementation;
-import org.apache.tuscany.implementation.java.introspection.ImplementationProcessorExtension;
-import org.apache.tuscany.implementation.java.introspection.IntrospectionRegistry;
-import org.apache.tuscany.implementation.java.introspection.impl.IntrospectionRegistryImpl;
-import org.apache.tuscany.implementation.java.processor.AllowsPassByReferenceProcessor;
-import org.apache.tuscany.implementation.java.processor.ConstructorProcessor;
-import org.apache.tuscany.implementation.java.processor.ContextProcessor;
-import org.apache.tuscany.implementation.java.processor.ConversationProcessor;
-import org.apache.tuscany.implementation.java.processor.DestroyProcessor;
-import org.apache.tuscany.implementation.java.processor.EagerInitProcessor;
-import org.apache.tuscany.implementation.java.processor.HeuristicPojoProcessor;
-import org.apache.tuscany.implementation.java.processor.InitProcessor;
-import org.apache.tuscany.implementation.java.processor.PropertyProcessor;
-import org.apache.tuscany.implementation.java.processor.ReferenceProcessor;
-import org.apache.tuscany.implementation.java.processor.ResourceProcessor;
-import org.apache.tuscany.implementation.java.processor.ScopeProcessor;
-import org.apache.tuscany.implementation.java.processor.ServiceProcessor;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.DefaultJavaClassIntrospector;
+import org.apache.tuscany.implementation.java.introspect.JavaClassIntrospectorExtensionPoint;
+import org.apache.tuscany.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ConstructorProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ContextProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ConversationProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.DestroyProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.EagerInitProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.HeuristicPojoProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.InitProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.PropertyProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ReferenceProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ResourceProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ScopeProcessor;
+import org.apache.tuscany.implementation.java.introspect.impl.ServiceProcessor;
import org.apache.tuscany.implementation.java.xml.JavaImplementationProcessor;
-import org.apache.tuscany.interfacedef.java.introspection.JavaInterfaceProcessorRegistry;
-import org.apache.tuscany.interfacedef.java.introspection.impl.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.interfacedef.java.introspect.DefaultJavaInterfaceIntrospector;
+import org.apache.tuscany.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
import org.apache.tuscany.spi.bootstrap.ExtensionPointRegistry;
import org.apache.tuscany.spi.bootstrap.ModuleActivator;
@@ -60,8 +60,8 @@
public Map<Class, Object> getExtensionPoints() {
Map<Class, Object> map = new HashMap<Class, Object>();
map.put(ProxyService.class, new JDKProxyService());
- map.put(IntrospectionRegistry.class, new IntrospectionRegistryImpl());
- map.put(JavaInterfaceProcessorRegistry.class, new JavaInterfaceProcessorRegistryImpl());
+ map.put(JavaClassIntrospectorExtensionPoint.class, new DefaultJavaClassIntrospector());
+ map.put(JavaInterfaceIntrospectorExtensionPoint.class, new DefaultJavaInterfaceIntrospector());
return map;
}
@@ -69,11 +69,11 @@
* @see org.apache.tuscany.spi.bootstrap.ModuleActivator#start(org.apache.tuscany.spi.bootstrap.ExtensionPointRegistry)
*/
public void start(ExtensionPointRegistry registry) {
- JavaInterfaceProcessorRegistry javaInterfaceProcessorRegistry = registry
- .getExtensionPoint(JavaInterfaceProcessorRegistry.class);
+ JavaInterfaceIntrospectorExtensionPoint javaInterfaceProcessorRegistry = registry
+ .getExtensionPoint(JavaInterfaceIntrospectorExtensionPoint.class);
- IntrospectionRegistry introspectionRegistry = registry.getExtensionPoint(IntrospectionRegistry.class);
- ImplementationProcessorExtension[] extensions = new ImplementationProcessorExtension[] {new ConstructorProcessor(),
+ JavaClassIntrospectorExtensionPoint introspectionRegistry = registry.getExtensionPoint(JavaClassIntrospectorExtensionPoint.class);
+ BaseJavaClassIntrospectorExtension[] extensions = new BaseJavaClassIntrospectorExtension[] {new ConstructorProcessor(),
new AllowsPassByReferenceProcessor(),
new ContextProcessor(),
new ConversationProcessor(),
@@ -88,10 +88,10 @@
new HeuristicPojoProcessor()
};
- for (ImplementationProcessorExtension e : extensions) {
+ for (BaseJavaClassIntrospectorExtension e : extensions) {
e.setRegistry(introspectionRegistry);
- e.setInterfaceProcessorRegistry(javaInterfaceProcessorRegistry);
- introspectionRegistry.registerProcessor(e);
+ e.setInterfaceVisitorExtensionPoint(javaInterfaceProcessorRegistry);
+ introspectionRegistry.addExtension(e);
}
StAXArtifactProcessorRegistry artifactProcessorRegistry = registry
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerProxyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerProxyTestCase.java?view=diff&rev=527378&r1=527377&r2=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerProxyTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerProxyTestCase.java Tue Apr 10 19:55:00 2007
@@ -30,8 +30,8 @@
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceContractImpl;
-import org.apache.tuscany.interfacedef.java.introspection.JavaInterfaceProcessorRegistry;
-import org.apache.tuscany.interfacedef.java.introspection.impl.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.interfacedef.java.introspect.DefaultJavaInterfaceIntrospector;
+import org.apache.tuscany.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
import org.apache.tuscany.spi.wire.InvocationChain;
import org.apache.tuscany.spi.wire.MessageImpl;
import org.apache.tuscany.spi.wire.TargetInvoker;
@@ -42,7 +42,7 @@
* @version $Rev$ $Date$
*/
public class JDKInvocationHandlerProxyTestCase extends TestCase {
- private JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ private JavaInterfaceIntrospectorExtensionPoint registry = new DefaultJavaInterfaceIntrospector();
private Method clientHello;
/**
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * A convenience class for annotation processors which alleviates the need to
+ * implement unused callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public abstract class BaseJavaClassIntrospectorExtension implements JavaClassIntrospectorExtension {
+ protected AssemblyFactory factory;
+ protected JavaClassIntrospectorExtensionPoint registry;
+ protected JavaInterfaceIntrospectorExtensionPoint interfaceIntrospector;
+
+ public BaseJavaClassIntrospectorExtension() {
+ super();
+ this.factory = new DefaultAssemblyFactory();
+ }
+
+ /**
+ * @param registry
+ */
+ public BaseJavaClassIntrospectorExtension(JavaClassIntrospectorExtensionPoint registry) {
+ super();
+ this.registry = registry;
+ this.factory = new DefaultAssemblyFactory();
+ }
+
+ @Reference
+ public void setRegistry(JavaClassIntrospectorExtensionPoint registry) {
+ this.registry = registry;
+ }
+
+ @Reference
+ public void setInterfaceVisitorExtensionPoint(JavaInterfaceIntrospectorExtensionPoint interfaceIntrospectorExtensionPoint) {
+ this.interfaceIntrospector = interfaceIntrospectorExtensionPoint;
+ }
+
+ @Init
+ public void init() {
+ registry.addExtension(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ registry.removeExtension(this);
+ }
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitSuperClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitConstructor(Constructor<T> constructor, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitField(Field field, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitEnd(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitConstructorParameter(Parameter parameter, JavaImplementationDefinition type) throws ProcessingException {
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/BaseJavaClassIntrospectorExtension.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.implementation.java.introspect.impl.JavaIntrospectionHelper;
+
+/**
+ * Default implementation of the <code>IntrospectionRegistry</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultJavaClassIntrospector implements JavaClassIntrospectorExtensionPoint {
+
+ private List<JavaClassIntrospectorExtension> processors = new ArrayList<JavaClassIntrospectorExtension>();
+
+ public DefaultJavaClassIntrospector() {
+ }
+
+ public void addExtension(JavaClassIntrospectorExtension processor) {
+ processors.add(processor);
+ }
+
+ public void removeExtension(JavaClassIntrospectorExtension processor) {
+ processors.remove(processor);
+ }
+
+ /**
+ * JSR-250 PFD recommends the following guidelines for how annotations
+ * interact with inheritance in order to keep the resulting complexity in
+ * control:
+ * <ol>
+ * <li>Class-level annotations only affect the class they annotate and
+ * their members, that is, its methods and fields. They never affect a
+ * member declared by a superclass, even if it is not hidden or overridden
+ * by the class in question.
+ * <li>In addition to affecting the annotated class, class-level
+ * annotations may act as a shorthand for member-level annotations. If a
+ * member carries a specific member-level annotation, any annotations of the
+ * same type implied by a class-level annotation are ignored. In other
+ * words, explicit member-level annotations have priority over member-level
+ * annotations implied by a class-level annotation.
+ * <li>The interfaces implemented by a class never contribute annotations
+ * to the class itself or any of its members.
+ * <li>Members inherited from a superclass and which are not hidden or
+ * overridden maintain the annotations they had in the class that declared
+ * them, including member-level annotations implied by class-level ones.
+ * <li>Member-level annotations on a hidden or overridden member are always
+ * ignored.
+ * </ol>
+ */
+ public JavaImplementationDefinition introspect(Class<?> clazz, JavaImplementationDefinition type)
+ throws ProcessingException {
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitClass(clazz, type);
+ }
+
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitConstructor(constructor, type);
+ // Assuming the visitClass or visitConstructor will populate the
+ // type.getConstructors
+ ConstructorDefinition<?> definition = type.getConstructors().get(constructor);
+ if (definition != null) {
+ for (Parameter p : definition.getParameters()) {
+ processor.visitConstructorParameter(p, type);
+ }
+ }
+ }
+ }
+
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz);
+ for (Method method : methods) {
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitMethod(method, type);
+ }
+ }
+
+ Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz);
+ for (Field field : fields) {
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitField(field, type);
+ }
+ }
+
+ Class superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ visitSuperClass(superClass, type);
+ }
+
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitEnd(clazz, type);
+ }
+ return type;
+ }
+
+ private void visitSuperClass(Class<?> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ if (!Object.class.equals(clazz)) {
+ for (JavaClassIntrospectorExtension processor : processors) {
+ processor.visitSuperClass(clazz, type);
+ }
+ clazz = clazz.getSuperclass();
+ if (clazz != null) {
+ visitSuperClass(clazz, type);
+ }
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DefaultJavaClassIntrospector.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+/**
+ * Thrown when an implementation has more than one property injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicatePropertyException extends ProcessingException {
+ private static final long serialVersionUID = 5536415875694904037L;
+
+ public DuplicatePropertyException(String message) {
+ super(message);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/DuplicatePropertyException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import java.lang.reflect.Member;
+
+/**
+ * Denotes an illegal property definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalPropertyException extends ProcessingException {
+ private static final long serialVersionUID = -2836849110706758494L;
+
+ public IllegalPropertyException(String message) {
+ super(message);
+ }
+
+ public IllegalPropertyException(String message, Member member) {
+ super(message, member);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/IllegalPropertyException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+
+/**
+ * Implementations are responsible for walking a component implementation class,
+ * adding additional component type information as appropriate
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaClassIntrospector {
+
+ /**
+ * Walks the given component implementation class
+ *
+ * @param clazz the component implementation class
+ * @param type the component type associated with the implementation class
+ * @return the updated component type
+ * @throws ProcessingException if an error is encountered evaluating the
+ * implementation class
+ */
+ JavaImplementationDefinition introspect(Class<?> clazz, JavaImplementationDefinition type) throws ProcessingException;
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospector.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