summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config')
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java57
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java44
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java59
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java46
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidMetaDataException.java35
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java45
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidSetterException.java39
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java446
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MetaDataException.java37
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingInterfaceException.java39
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java35
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java75
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/SidefileLoadException.java50
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java164
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java139
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/StAXModuleComponentConfigurationLoaderImpl.java91
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ComponentNameProcessor.java51
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ContextProcessor.java50
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DefaultProcessor.java112
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DestroyProcessor.java47
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ImplementationProcessorSupport.java107
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/InitProcessor.java43
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorHelper.java59
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorUtils.java65
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyProcessor.java104
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyReferenceValidator.java80
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ReferenceProcessor.java119
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ScopeProcessor.java74
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ServiceProcessor.java129
29 files changed, 0 insertions, 2441 deletions
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java
deleted file mode 100644
index 9f9c125a5e..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.core.extension.config.ImplementationProcessor;
-
-/**
- * Interface for implementations that are able create SCA definitions by inspecting Java classes.
- *
- * @version $Rev$ $Date$
- */
-public interface ComponentTypeIntrospector {
-
- /**
- * Create a componentType definition by introspecting a Java Class.
- *
- * @param implClass the class to inspect
- * @return a componentType definition
- * @throws ConfigurationLoadException if the Class does not define a valid component type
- */
- ComponentType introspect(Class<?> implClass) throws ConfigurationLoadException;
-
- /**
- * Completes the given componentType definition by introspecting a Java Class.
- *
- * @param implClass the class to inspect
- * @return a componentType definition
- * @throws ConfigurationLoadException if the Class does not define a valid component type
- */
- ComponentType introspect(Class<?> implClass, ComponentType compType) throws ConfigurationLoadException;
-
- /**
- * Registers an annotation processor
- */
- void registerProcessor(ImplementationProcessor processor);
-
- /**
- * De-registers an annotation processor
- */
- void unregisterProcessor(ImplementationProcessor processor);
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java
deleted file mode 100644
index de0e4a3733..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import org.apache.tuscany.common.TuscanyException;
-
-
-/**
- * Base class for exceptions that pertain to configuration.
- *
- * @version $Rev$ $Date$
- */
-public abstract class ConfigurationException extends TuscanyException {
- private static final long serialVersionUID = 7441469809266868036L;
-
- public ConfigurationException() {
- }
-
- public ConfigurationException(String message) {
- super(message);
- }
-
- public ConfigurationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConfigurationException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java
deleted file mode 100644
index 2a9e325b0b..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-/**
- * Exception indicating that there was a problem loading a configuration resource.
- *
- * @version $Rev$ $Date$
- */
-public class ConfigurationLoadException extends ConfigurationException {
- private static final long serialVersionUID = -2310798146091959144L;
-
- private String resourceURI;
-
- public ConfigurationLoadException() {
- }
-
- public ConfigurationLoadException(String message) {
- super(message);
- }
-
- public ConfigurationLoadException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConfigurationLoadException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Returns the location of the resource that was being loaded.
- * @return the location of the resource that was being loaded
- */
- public String getResourceURI() {
- return resourceURI;
- }
-
- /**
- * Sets the location of the resource that was being loaded.
- * @param resourceURI the location of the resource that was being loaded
- */
- public void setResourceURI(String resourceURI) {
- this.resourceURI = resourceURI;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java
deleted file mode 100644
index cc5f2999fe..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import org.apache.tuscany.model.assembly.Implementation;
-
-import javax.xml.namespace.QName;
-
-/**
- * Cache of introspected implementations.
- *
- * @version $Rev$ $Date$
- */
-public interface ImplementationCache {
- /**
- * Return an implementation from a given namespace.
- *
- * @param type the namespace that defines the type of implementation
- * @param name the name of an implementation in that namespace
- * @return the implementation or null if it is not present in the cache
- */
- Implementation get(QName type, String name);
-
- /**
- * Add an implementation to the cache
- *
- * @param type the namespace that defines the type of implementation
- * @param name the name of an implementation in that namespace
- * @param implementation the introspected implementation
- */
- void put(QName type, String name, Implementation implementation);
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidMetaDataException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidMetaDataException.java
deleted file mode 100644
index 71b2329044..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidMetaDataException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-/**
- * Denotes an validation error processing component metadata
- * @version $$Rev$$ $$Date$$
- */
-public class InvalidMetaDataException extends MetaDataException {
- public InvalidMetaDataException() {
- }
-
- public InvalidMetaDataException(String message) {
- super(message);
- }
-
- public InvalidMetaDataException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidMetaDataException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java
deleted file mode 100644
index a355d884a5..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import javax.xml.namespace.QName;
-
-/**
- * Configuration exception that indicates the actual root element in an XML file was not the one expected.
- *
- * @version $Rev$ $Date$
- */
-public class InvalidRootElementException extends ConfigurationLoadException {
- private static final long serialVersionUID = 2376629433948140418L;
-
- private final QName expected;
- private final QName actual;
-
- public InvalidRootElementException(QName expected, QName actual) {
- super("Invalid root element, expected [" + expected + "], was [" + actual + ']');
- this.expected = expected;
- this.actual = actual;
- }
-
- public QName getExpected() {
- return expected;
- }
-
- public QName getActual() {
- return actual;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidSetterException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidSetterException.java
deleted file mode 100644
index ed4e53645f..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidSetterException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * 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.core.config;
-
-/**
- * @version $Rev$ $Date$
- */
-public class InvalidSetterException extends ConfigurationLoadException {
- private static final long serialVersionUID = -3298236203808038211L;
-
- public InvalidSetterException() {
- }
-
- public InvalidSetterException(String message) {
- super(message);
- }
-
- public InvalidSetterException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidSetterException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java
deleted file mode 100644
index 9d74633519..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Implements various reflection-related operations
- *
- * @version $Rev$ $Date$
- */
-public class JavaIntrospectionHelper {
-
- private static final Class[] EMPTY_CLASS_ARRY = new Class[0];
-
- /**
- * Hide the constructor
- */
- private JavaIntrospectionHelper() {
- }
-
- /**
- * Returns a collection of public, private, protected, or default fields declared by a class or one of its
- * supertypes
- */
- public static Set<Field> getAllFields(Class pClass) {
- return getAllFields(pClass, new HashSet<Field>());
- }
-
- /**
- * Recursively evaluates the type hierachy to return all fields on a given type
- */
- private static Set<Field> getAllFields(Class pClass, Set<Field> fields) {
- if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
- return fields;
- }
- fields = getAllFields(pClass.getSuperclass(), fields);
- Field[] declaredFields = pClass.getDeclaredFields();
- for (Field field : declaredFields) {
- field.setAccessible(true); // ignore Java accessibility
- fields.add(field);
- }
- return fields;
- }
-
- /**
- * Returns a collection of public, and protected fields declared by a class or one of its
- * supertypes
- */
- public static Set<Field> getAllPublicAndProtectedFields(Class clazz) {
- return getAllPublicAndProtectedFields(clazz, new HashSet<Field>());
- }
-
- /**
- * Recursively evaluates the type hierachy to return all fields that are public or protected
- */
- private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field> fields) {
- if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
- return fields;
- }
- fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields);
- Field[] declaredFields = clazz.getDeclaredFields();
-// fields = new HashSet<Field>();
-// Field[] declaredFields = clazz.getFields();
- for (Field field : declaredFields) {
- int modifiers = field.getModifiers();
- if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(modifiers)){
- field.setAccessible(true); // ignore Java accessibility
- fields.add(field);
- }
- }
- return fields;
- }
-
- /**
- * Returns a collection of public, private, protected, or default methods declared by a class or one of
- * its supertypes. Note that overriden methods will not be returned in the collection (i.e. only the
- * method override will be). <p/> This method can potentially be expensive as reflection information is
- * not cached. It is assumed that this method will be used during a configuration phase.
- */
- public static Set<Method> getAllUniqueMethods(Class clazz) {
- return getAllUniqueMethods(clazz, new HashSet<Method>());
- }
-
- /**
- * Recursively evaluates the type hierarchy to return all unique methods
- */
- private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method> methods) {
- if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
- return methods;
- }
- // we first evaluate methods of the subclass and then move to the parent
- Method[] declaredMethods = pClass.getDeclaredMethods();
- for (Method declaredMethod : declaredMethods) {
- if (methods.size() == 0) {
- methods.add(declaredMethod);
- } else {
- List<Method> temp = new ArrayList<Method>();
- boolean matched = false;
- for (Method method : methods) {
- // only add if not already in the set from a supclass (i.e. the
- // method is not overrided)
- if (exactMethodMatch(declaredMethod, method)) {
- matched = true;
- break;
- }
- }
- if (!matched) {
- // TODO ignore Java accessibility
- declaredMethod.setAccessible(true);
- temp.add(declaredMethod);
-
- }
- methods.addAll(temp);
- temp.clear();
- }
- }
- // evaluate class hierarchy - this is done last to track inherited methods
- methods = getAllUniqueMethods(pClass.getSuperclass(), methods);
- return methods;
- }
-
- /**
- * Finds the closest matching field with the given name, that is, a field of the exact specified type or,
- * alternately, of a supertype.
- *
- * @param name the name of the field
- * @param type the field type
- * @param fields the collection of fields to search
- * @return the matching field or null if not found
- */
- public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
- Field candidate = null;
- for (Field field : fields) {
- if (field.getName().equals(name)) {
- if (field.getType().equals(type)) {
- return field; // exact match
- } else if (field.getType().isAssignableFrom(type)
- || (field.getType().isPrimitive() && primitiveAssignable(field.getType(), type))) {
- // We could have the situation where a field parameter is a primitive and the demarshalled value is
- // an object counterpart (e.g. Integer and int)
- // @spec issue
- // either an interface or super class, so keep a reference until
- // we know there are no closer types
- candidate = field;
- }
- }
- }
- if (candidate != null) {
- return candidate;
- } else {
- return null;
- }
- }
-
- /**
- * Finds the closest matching method with the given name, that is, a method taking the exact parameter
- * types or, alternately, parameter supertypes.
- *
- * @param name the name of the method
- * @param types the method parameter types
- * @param methods the collection of methods to search
- * @return the matching method or null if not found
- */
- public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
- if (types == null) {
- types = EMPTY_CLASS_ARRY;
- }
- Method candidate = null;
- for (Method method : methods) {
- if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
- Class[] params = method.getParameterTypes();
- boolean disqualify = false;
- boolean exactMatch = true;
- for (int i = 0; i < params.length; i++) {
- if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
- // no match
- disqualify = true;
- exactMatch = false;
- break;
- } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
- // not exact match
- exactMatch = false;
- }
- }
- if (disqualify) {
- continue;
- } else if (exactMatch) {
- return method;
- } else {
- candidate = method;
- }
- }
- }
- if (candidate != null) {
- return candidate;
- } else {
- return null;
- }
- }
-
- /**
- * Searches a collection of fields for one that matches by name and has a multiplicity type. i.e. a List
- * or Array of interfaces
- *
- * @return a matching field or null
- */
- public static Field findMultiplicityFieldByName(String name, Set<Field> fields) {
- for (Field candidate : fields) {
- if (candidate.getName().equals(name)
- && (List.class.isAssignableFrom(candidate.getType()) || (candidate.getType().isArray()
- && candidate.getType().getComponentType() != null && candidate.getType().getComponentType()
- .isInterface()))) {
- return candidate;
- }
- }
- return null;
- }
-
- /**
- * Searches a collection of method for one that matches by name and has single parameter of a multiplicity
- * type. i.e. a List or Array of interfaces
- *
- * @return a matching method or null
- */
- public static Method findMultiplicityMethodByName(String name, Set<Method> methods) {
- for (Method candidate : methods) {
- if (candidate.getName().equals(name)
- && candidate.getParameterTypes().length == 1
- && (List.class.isAssignableFrom(candidate.getParameterTypes()[0]) || (candidate.getParameterTypes()[0]
- .isArray()
- && candidate.getParameterTypes()[0].getComponentType() != null && candidate.getParameterTypes()[0]
- .getComponentType().isInterface()))) {
- return candidate;
- }
- }
- return null;
- }
-
- /**
- * Returns a field or method defined in the given class or its superclasses matching a literal name and
- * parameter types <p/> This method can potentially be expensive as reflection information is not cached.
- * It is assumed that this method will be used during a configuration phase.
- *
- * @param clazz the class to introspect
- * @param propertName the literal name of the property (i.e. JavaBean conventions are not applied)
- * @param paramTypes the parameter types for a method or null for fields or methods with no parameters
- * @return the field, method or null
- */
- public static AccessibleObject getBeanProperty(Class clazz, String propertName, Class[] paramTypes) {
-
- Set<Method> methods = getAllUniqueMethods(clazz);
- for (Method method : methods) {
- if (method.getName().equals(propertName)) {
- Class[] types = method.getParameterTypes();
- if (types.length == 0 && paramTypes == null) {
- return method;
- } else if (types.length != 0 && paramTypes == null) {
- break;
- } else if (types.length == paramTypes.length) {
- for (int n = 0; n < types.length - 1; n++) {
- if (!types[n].equals(paramTypes[n]) || !types[n].isAssignableFrom(paramTypes[n])) {
- break;
- }
- }
- return method;
- }
- }
- }
-
- Set<Field> fields = getAllFields(clazz);
- for (Field field : fields) {
- if (field.getName().equals(propertName)) {
- return field;
- }
- }
- return null;
- }
-
- /**
- * Determines if two methods "match" - that is, they have the same method names and exact parameter types
- * (one is not a supertype of the other)
- */
- public static boolean exactMethodMatch(Method method1, Method method2) {
- if (!method1.getName().equals(method2.getName())) {
- return false;
- }
- Class[] types1 = method1.getParameterTypes();
- Class[] types2 = method2.getParameterTypes();
- if (types1.length == 0 && types2.length == 0) {
- return true;
- } else if (types1.length == types2.length) {
- for (int n = 0; n < types1.length; n++) {
- if (!types1[n].equals(types2[n])) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
- return clazz.getConstructor((Class[]) null);
- }
-
- /**
- * Loads a class corresponding to the class name using the current context class loader.
- *
- * @throws ClassNotFoundException if the class was not found on the classpath
- */
- public static Class loadClass(String pName) throws ClassNotFoundException {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return Class.forName(pName, true, loader);
- }
-
- /**
- * Returns the simple name of a class - i.e. the class name devoid of its package qualifier
- *
- * @param implClass
- */
- public static String getBaseName(Class<?> implClass) {
- String baseName = implClass.getName();
- int lastDot = baseName.lastIndexOf('.');
- if (lastDot != -1) {
- baseName = baseName.substring(lastDot + 1);
- }
- return baseName;
- }
-
- public static boolean isImmutable(Class clazz) {
- return (String.class == clazz || clazz.isPrimitive() || Number.class.isAssignableFrom(clazz)
- || Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz) || Byte.class
- .isAssignableFrom(clazz));
- }
-
- /**
- * Takes a property name and converts it to a getter method name according to JavaBean conventions. For
- * example, property <code>foo<code> is returned as <code>getFoo</code>
- */
- public static String toGetter(String name) {
- return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
- }
-
- /**
- * Takes a setter or getter method name and converts it to a property name according to JavaBean
- * conventions. For example, <code>setFoo(var)</code> is returned as property <code>foo<code>
- */
- public static String toPropertyName(String name) {
- return Character.toLowerCase(name.charAt(3)) + name.substring(4);
- }
-
- /**
- * Takes a property name and converts it to a setter method name according to JavaBean conventions. For
- * example, the property <code>foo<code> is returned as <code>setFoo(var)</code>
- */
- public static String toSetter(String name) {
- return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
- }
-
- /**
- * Compares a two types, assuming one is a primitive, to determine if the other is its object counterpart
- */
- private static boolean primitiveAssignable(Class memberType, Class param) {
- if (memberType == Integer.class) {
- return (param == Integer.TYPE);
- } else if (memberType == Double.class) {
- return (param == Double.TYPE);
- } else if (memberType == Float.class) {
- return (param == Float.TYPE);
- } else if (memberType == Short.class) {
- return (param == Short.TYPE);
- } else if (memberType == Character.class) {
- return (param == Character.TYPE);
- } else if (memberType == Boolean.class) {
- return (param == Boolean.TYPE);
- } else if (memberType == Byte.class) {
- return (param == Byte.TYPE);
- } else if (param == Integer.class) {
- return (memberType == Integer.TYPE);
- } else if (param == Double.class) {
- return (memberType == Double.TYPE);
- } else if (param == Float.class) {
- return (memberType == Float.TYPE);
- } else if (param == Short.class) {
- return (memberType == Short.TYPE);
- } else if (param == Character.class) {
- return (memberType == Character.TYPE);
- } else if (param == Boolean.class) {
- return (memberType == Boolean.TYPE);
- } else if (param == Byte.class) {
- return (memberType == Byte.TYPE);
- } else {
- return false;
- }
- }
-
- /**
- * Returns the generic types represented in the given type. Usage as follows:
- * <p/>
- * <code> // to return the generic type of a field: JavaIntrospectionHelper.getGenerics(field.getGenericType());
- * <p/>
- * // to return the generic types for the first parameter of a method: JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];);
- * <p/>
- * </code>
- *
- * @return the generic types in order of declaration or an empty array if the type is not genericized
- */
- public static List<? extends Type> getGenerics(Type genericType) {
- List<Type> classes = new ArrayList<Type>();
- if (genericType instanceof ParameterizedType) {
- ParameterizedType ptype = (ParameterizedType) genericType;
- // get the type arguments
- Type[] targs = ptype.getActualTypeArguments();
- for (Type targ : targs) {
- classes.add(targ);
- }
- }
- return classes;
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MetaDataException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MetaDataException.java
deleted file mode 100644
index 30840a6e15..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MetaDataException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-/**
- * Denotes an error processing component metadata
- *
- * @version $$Rev$$ $$Date$$
- */
-public class MetaDataException extends ConfigurationLoadException{
-
- public MetaDataException() {
- }
-
- public MetaDataException(String message) {
- super(message);
- }
-
- public MetaDataException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public MetaDataException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingInterfaceException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingInterfaceException.java
deleted file mode 100644
index 6164b6a011..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingInterfaceException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * 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.core.config;
-
-/**
- * Exception indicating that the interface referenced in an assembly file could not be found.
- *
- * @version $Rev$ $Date$
- */
-public class MissingInterfaceException extends ConfigurationLoadException {
- public MissingInterfaceException() {
- }
-
- public MissingInterfaceException(String message) {
- super(message);
- }
-
- public MissingInterfaceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public MissingInterfaceException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java
deleted file mode 100644
index 8260dbc8ae..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-/**
- * Exception that indicates an expected resource could not be found.
- *
- * @version $Rev$ $Date$
- */
-public class MissingResourceException extends ConfigurationLoadException {
- /**
- * Constructor that indicates which resource could not be found.
- * The supplied parameter is also returned as the message.
- *
- * @param resource the resource that could not be found
- */
- public MissingResourceException(String resource) {
- super(resource);
- setResourceURI(resource);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java
deleted file mode 100644
index 15857441b1..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config;
-
-import org.apache.tuscany.model.assembly.ModuleComponent;
-
-import java.net.URL;
-import java.util.Collection;
-
-/**
- * Interface for loading configuration information from some external
- * form into a Tuscany logical model.
- *
- * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
- */
-public interface ModuleComponentConfigurationLoader {
-
- /**
- * Load a SCDL module component.
- *
- * @param name the name of the module component
- * @param uri
- * @return a new module component definition
- * @throws ConfigurationLoadException if there was a problem loading the module component.
- */
- ModuleComponent loadModuleComponent(String name, String uri) throws ConfigurationLoadException;
-
- /**
- * Load a System SCDL module component.
- *
- * @param name the name of the module component
- * @param uri
- * @return a new module component definition
- * @throws ConfigurationLoadException if there was a problem loading the module component.
- */
- ModuleComponent loadSystemModuleComponent(String name, String uri) throws ConfigurationLoadException;
-
- /**
- * Load a SCDL module component.
- *
- * @param name the name of the module component
- * @param uri
- * @param url
- * @return a new module component definition
- * @throws ConfigurationLoadException if there was a problem loading the module component.
- */
- ModuleComponent loadModuleComponent(String name, String uri, URL url) throws ConfigurationLoadException;
-
- /**
- * Load a SCDL module component.
- *
- * @param name the name of the module component
- * @param uri
- * @param url
- * @param urls
- * @return a new module component definition
- * @throws ConfigurationLoadException if there was a problem loading the module component.
- */
- ModuleComponent loadModuleComponent(String name, String uri, URL url, Collection<URL> urls) throws ConfigurationLoadException;
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/SidefileLoadException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/SidefileLoadException.java
deleted file mode 100644
index b432d4ea68..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/SidefileLoadException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * 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.core.config;
-
-/**
- * Exception indicating that there was a problem loading a sidefile.
- *
- * @version $Rev$ $Date$
- */
-public class SidefileLoadException extends ConfigurationLoadException {
- private static final long serialVersionUID = -3530306758412789392L;
- private String sidefileURI;
-
- public SidefileLoadException() {
- }
-
- public SidefileLoadException(String message) {
- super(message);
- }
-
- public SidefileLoadException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public SidefileLoadException(Throwable cause) {
- super(cause);
- }
-
- public String getSidefileURI() {
- return sidefileURI;
- }
-
- public void setSidefileURI(String sidefileURI) {
- this.sidefileURI = sidefileURI;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
deleted file mode 100644
index a77031b8c5..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.core.config.impl;
-
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.processor.ProcessorUtils;
-import org.apache.tuscany.core.system.context.SystemCompositeContextImpl;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.ModuleComponent;
-import org.apache.tuscany.model.assembly.ModuleFragment;
-import org.apache.tuscany.model.assembly.ComponentType;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @version $Rev$ $Date$
- */
-public abstract class AbstractModuleComponentConfigurationLoader implements ModuleComponentConfigurationLoader {
- private static final String SCA_MODULE_FILE_NAME = "sca.module";
- //FIXME can fragments have a variable prefix name?
- private static final String SCA_FRAGMENT_FILE_NAME = "sca.fragment";
- private static final String SYSTEM_MODULE_FILE_NAME = "system.module";
- //FIXME can fragments have a variable prefix name?
- private static final String SYSTEM_FRAGMENT_FILE_NAME = "system.fragment";
-
- protected final AssemblyContext modelContext;
- protected final ResourceLoader resourceLoader;
- protected final AssemblyFactory assemblyFactory;
-
- // JFM HACK
- private ComponentTypeIntrospector introspector;
-
- private ComponentType systemType;
-
- private ComponentType compositeType;
-
- protected ComponentTypeIntrospector getIntrospector(){
- if (introspector == null){
- introspector = ProcessorUtils.createCoreIntrospector(assemblyFactory);
- }
- return introspector;
- }
-
- protected ComponentType getSystemCompositeComponentType() throws ConfigurationLoadException {
- if (systemType == null){
- systemType = getIntrospector().introspect(SystemCompositeContextImpl.class);
- }
- return systemType;
- }
-
- protected ComponentType getCompositeComponentType() throws ConfigurationLoadException {
- if (compositeType == null){
- compositeType = getIntrospector().introspect(CompositeContextImpl.class);
- }
- return compositeType;
- }
- /// JFM HACK
-
- protected AbstractModuleComponentConfigurationLoader(AssemblyContext modelContext) {
- this.modelContext = modelContext;
- resourceLoader = modelContext.getApplicationResourceLoader();
- assemblyFactory = modelContext.getAssemblyFactory();
- }
-
- public ModuleComponent loadSystemModuleComponent(String name, String uri) throws ConfigurationLoadException {
- ModuleComponent mc = loadModuleComponent(SYSTEM_MODULE_FILE_NAME, SYSTEM_FRAGMENT_FILE_NAME, name, uri);
- //JFM HACK - this is completely gross since it overwrites existing component type
- mc.getImplementation().setImplementationClass(SystemCompositeContextImpl.class);
- mc.getImplementation().setComponentType(getSystemCompositeComponentType());
- //END HACK
- return mc;
- }
-
- public ModuleComponent loadModuleComponent(String name, String uri) throws ConfigurationLoadException {
- ModuleComponent mc = loadModuleComponent(SCA_MODULE_FILE_NAME, SCA_FRAGMENT_FILE_NAME, name, uri);
- //JFM HACK
- mc.getImplementation().setImplementationClass(CompositeContextImpl.class);
- mc.getImplementation().setComponentType(getCompositeComponentType());
- //END HACK
- return mc;
- }
-
- protected ModuleComponent loadModuleComponent(String moduleFileName, String fragmentFileName, String name, String uri) throws ConfigurationLoadException {
-
- // Load the sca.module file
- URL moduleUrl;
- moduleUrl = resourceLoader.getResource(moduleFileName);
-
-
- if (moduleUrl == null) {
- throw new ConfigurationLoadException(moduleFileName);
- }
-
- // Load the sca.fragment files
- Iterator<URL> i;
- try {
- i = resourceLoader.getResources(fragmentFileName);
- } catch (IOException e) {
- throw new ConfigurationLoadException(fragmentFileName, e);
- }
- List<URL> moduleFragmentUris=new ArrayList<URL>();
- while (i.hasNext()) {
- URL url=i.next();
- moduleFragmentUris.add(url);
- }
-
- return loadModuleComponent(name, uri, moduleUrl, moduleFragmentUris);
- }
-
- public ModuleComponent loadModuleComponent(String name, String uri, URL url) throws ConfigurationLoadException {
- return loadModuleComponent( name, uri, url, null);
- }
-
- public ModuleComponent loadModuleComponent(String name, String uri, URL moduleUri, Collection<URL> moduleFragmentUris) throws ConfigurationLoadException {
-
- // Load the module file
- Module module=loadModule(moduleUri);
- // Load the sca.fragment files
- if (moduleFragmentUris!=null) {
- for (URL moduleFragmentUri : moduleFragmentUris) {
- ModuleFragment moduleFragment=loadModuleFragment(moduleFragmentUri);
- module.getModuleFragments().add(moduleFragment);
- }
- }
-
- // Create the module component
- ModuleComponent moduleComponent=assemblyFactory.createModuleComponent();
- moduleComponent.setName(name);
- moduleComponent.setURI(uri);
- moduleComponent.setImplementation(module);
- moduleComponent.initialize(modelContext);
-
- return moduleComponent;
- }
-
- public abstract Module loadModule(URL url) throws ConfigurationLoadException;
-
- public abstract ModuleFragment loadModuleFragment(URL url) throws ConfigurationLoadException;
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java
deleted file mode 100644
index fdbb6e0942..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.impl;
-
-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.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.core.config.processor.ProcessorUtils;
-import org.apache.tuscany.core.extension.config.ImplementationProcessor;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.ComponentName;
-
-/**
- * Introspects Java annotation-based metata data
- *
- * @version $Rev$ $Date$
- */
-@org.osoa.sca.annotations.Service(ComponentTypeIntrospector.class)
-public class Java5ComponentTypeIntrospector implements ComponentTypeIntrospector {
-
- private AssemblyFactory factory;
-
- private List<ImplementationProcessor> processors = new ArrayList<ImplementationProcessor>();
-
- public Java5ComponentTypeIntrospector() {
- }
-
- public Java5ComponentTypeIntrospector(AssemblyFactory factory) {
- this.factory = factory;
- }
-
- @Autowire
- public void setFactory(SystemAssemblyFactory factory) {
- this.factory = factory;
- //FIXME JFM HACK
- List<ImplementationProcessor> processors = ProcessorUtils.createCoreProcessors(factory);
- for (ImplementationProcessor processor : processors) {
- this.registerProcessor(processor);
- }
- // END hack
- }
-
- @ComponentName
- protected String name;
-
- @Init(eager = true)
- public void init(){
- }
-
- public void registerProcessor(ImplementationProcessor processor) {
- processors.add(processor);
- }
-
- public void unregisterProcessor(ImplementationProcessor processor) {
- processors.remove(processor);
- }
-
- /**
- * Visits the given implementation type and calls back to {@link org.apache.tuscany.core.extension.config.ImplementationProcessor}s
- * registered with this introspector to build up a {@link ComponentType}
- *
- * @return ComponentType representing the implementation type metadata
- * @throws ConfigurationLoadException if there is an error introspecting the implementation type
- */
- public ComponentType introspect(Class<?> implClass) throws ConfigurationLoadException {
- ComponentType compType = factory.createComponentType();
- return introspect(implClass, compType);
- }
-
- public ComponentType introspect(Class<?> implClass, ComponentType compType) throws ConfigurationLoadException {
- for (ImplementationProcessor processor : processors) {
- processor.visitClass(implClass, compType);
- }
- Constructor[] constructors = implClass.getConstructors();
- for (Constructor constructor : constructors) {
- for (ImplementationProcessor processor : processors) {
- processor.visitConstructor(constructor, compType);
- }
- }
- Method[] methods = implClass.getMethods();
- for (Method method : methods) {
- for (ImplementationProcessor processor : processors) {
- processor.visitMethod(method, compType);
- }
- }
- Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(implClass);
- for (Field field : fields) {
- for (ImplementationProcessor processor : processors) {
- processor.visitField(field, compType);
- }
- }
- Class superClass = implClass.getSuperclass();
- if (superClass != null) {
- visitSuperClass(superClass, compType);
- }
- for (ImplementationProcessor processor : processors) {
- processor.visitEnd(implClass, compType);
- }
- return compType;
- }
-
- private void visitSuperClass(Class<?> superClass, ComponentType compType) throws ConfigurationLoadException {
- if (!Object.class.equals(superClass)) {
- for (ImplementationProcessor processor : processors) {
- processor.visitSuperClass(superClass, compType);
- }
- superClass = superClass.getSuperclass();
- if (superClass != null) {
- visitSuperClass(superClass, compType);
- }
- }
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/StAXModuleComponentConfigurationLoaderImpl.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/StAXModuleComponentConfigurationLoaderImpl.java
deleted file mode 100644
index 3bd6e6361d..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/StAXModuleComponentConfigurationLoaderImpl.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.impl;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.loader.StAXLoaderRegistry;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.ModuleFragment;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * @version $Rev$ $Date$
- */
-public class StAXModuleComponentConfigurationLoaderImpl extends AbstractModuleComponentConfigurationLoader {
- private final XMLInputFactory xmlFactory;
- private final StAXLoaderRegistry registry;
-
- public StAXModuleComponentConfigurationLoaderImpl(AssemblyContext modelContext, XMLInputFactory xmlFactory, StAXLoaderRegistry registry) {
- super(modelContext);
- this.xmlFactory = xmlFactory;
- this.registry = registry;
- }
-
- public Module loadModule(URL url) throws ConfigurationLoadException {
- registry.setContext(modelContext);
- try {
- XMLStreamReader reader = xmlFactory.createXMLStreamReader(url.openStream());
- getDocumentRoot(reader);
- return (Module) registry.load(reader, new LoaderContext(resourceLoader));
- } catch (XMLStreamException e) {
- ConfigurationLoadException ce = new ConfigurationLoadException(e);
- ce.setResourceURI(url.toString());
- throw ce;
- } catch (IOException e) {
- ConfigurationLoadException ce = new ConfigurationLoadException(e);
- ce.setResourceURI(url.toString());
- throw ce;
- } finally {
- registry.setContext(null);
- }
- }
-
- public ModuleFragment loadModuleFragment(URL url) throws ConfigurationLoadException {
- registry.setContext(modelContext);
- try {
- XMLStreamReader reader = xmlFactory.createXMLStreamReader(url.openStream());
- getDocumentRoot(reader);
- return (ModuleFragment) registry.load(reader, new LoaderContext(resourceLoader));
- } catch (XMLStreamException e) {
- ConfigurationLoadException ce = new ConfigurationLoadException(e);
- ce.setResourceURI(url.toString());
- throw ce;
- } catch (IOException e) {
- ConfigurationLoadException ce = new ConfigurationLoadException(e);
- ce.setResourceURI(url.toString());
- throw ce;
- } finally {
- registry.setContext(null);
- }
- }
-
- private static void getDocumentRoot(XMLStreamReader reader) throws XMLStreamException {
- while (true) {
- if (reader.next() == XMLStreamConstants.START_ELEMENT) {
- return;
- }
- }
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ComponentNameProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ComponentNameProcessor.java
deleted file mode 100644
index 0314bcc9bf..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ComponentNameProcessor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.extension.config.extensibility.ComponentNameExtensibilityElement;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.ComponentName;
-
-/**
- * Processes the {@link ComponentName} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ComponentNameProcessor extends ImplementationProcessorSupport {
-
- public ComponentNameProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- ComponentName name = method.getAnnotation(ComponentName.class);
- if (name == null) {
- return;
- }
- type.getExtensibilityElements().add(new ComponentNameExtensibilityElement(method));
- }
-
- public void visitField(Field field, ComponentType type) throws ConfigurationLoadException {
- ComponentName name = field.getAnnotation(ComponentName.class);
- if (name == null) {
- return;
- }
- type.getExtensibilityElements().add(new ComponentNameExtensibilityElement(field));
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ContextProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ContextProcessor.java
deleted file mode 100644
index ff5c3736b7..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ContextProcessor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.extension.config.extensibility.ContextExtensibilityElement;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Context;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Context} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ContextProcessor extends ImplementationProcessorSupport {
-
- public ContextProcessor() {
- }
-
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- Context context = method.getAnnotation(Context.class);
- if (context == null) {
- return;
- }
- type.getExtensibilityElements().add(new ContextExtensibilityElement(method));
- }
-
- public void visitField(Field field, ComponentType type) throws ConfigurationLoadException {
- Context context = field.getAnnotation(Context.class);
- if (context == null) {
- return;
- }
- type.getExtensibilityElements().add(new ContextExtensibilityElement(field));
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DefaultProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DefaultProcessor.java
deleted file mode 100644
index 8445526dc8..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DefaultProcessor.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Property;
-import org.apache.tuscany.model.assembly.Reference;
-
-/**
- * Adds public methods and public/protected fields as properties that are not declared explicitly with an
- * {@link org.osoa.sca.annotations.Property} or {@link org.osoa.sca.annotations.Reference} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class DefaultProcessor extends ImplementationProcessorSupport {
-
- public DefaultProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public DefaultProcessor() {
- }
-
- public void visitEnd(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- // add any public/protected fields and public setter methods as properties
- Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz);
- List<Property> properties = type.getProperties();
- List<Reference> references = type.getReferences();
- boolean contains;
- Method[] methods = clazz.getMethods();
- String name;
- for (Method method : methods) {
- if (Object.class.equals(method.getDeclaringClass()) || method.getParameterTypes().length != 1
- || method.isAnnotationPresent(org.osoa.sca.annotations.Property.class)
- || method.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
- continue;
- }
- contains = containsProperty(properties, method.getName());
- if (contains) {
- continue;
- }
- name = method.getName();
- if (name.length() > 3 && name.startsWith("set")) {
- // follow JavaBeans conventions
- name = JavaIntrospectionHelper.toPropertyName(name);
- }
- contains = containsReference(references, name);
- if (!contains) {
- addProperty(name, method.getParameterTypes()[0], type);
- }
- }
- for (Field field : fields) {
- if (field.isAnnotationPresent(org.osoa.sca.annotations.Property.class)
- || field.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
- continue;
- }
- contains = containsProperty(properties, field.getName());
- if (contains) {
- continue;
- }
- contains = containsReference(references, field.getName());
- if (!contains) {
- addProperty(field.getName(), field.getType(), type);
- }
- }
- }
-
- private boolean containsProperty(List<Property> properties, String name) {
- for (Property prop : properties) {
- if (prop.getName().equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean containsReference(List<Reference> references, String name) {
- for (Reference ref : references) {
- if (ref.getName().equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- private void addProperty(String name, Class<?> propType, ComponentType type) {
- Property property = factory.createProperty();
- property.setName(name);
- property.setRequired(false);
- property.setType(propType);
- type.getProperties().add(property);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DestroyProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DestroyProcessor.java
deleted file mode 100644
index a16845bbf8..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/DestroyProcessor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.extension.config.extensibility.DestroyInvokerExtensibilityElement;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Destroy;
-
-/**
- * Processes a {@link Destroy}
- *
- * @version $$Rev$$ $$Date$$
- */
-public class DestroyProcessor extends ImplementationProcessorSupport {
-
- public DestroyProcessor() {
- }
-
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- Destroy destroy = method.getAnnotation(Destroy.class);
- if (destroy == null) {
- return;
- }
- if (method.getParameterTypes().length != 0) {
- throw new ConfigurationLoadException("Destroy methods cannot take parameters");
- }
- type.getExtensibilityElements().add(new DestroyInvokerExtensibilityElement(method));
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ImplementationProcessorSupport.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ImplementationProcessorSupport.java
deleted file mode 100644
index 175de28a92..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ImplementationProcessorSupport.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.extension.config.ImplementationProcessor;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Scope;
-
-/**
- * A base implementation of an <code>ImplementationProcessor</code>
- *
- * @version $$Rev$$ $$Date$$
- */
-@Scope("MODULE")
-public abstract class ImplementationProcessorSupport implements ImplementationProcessor {
-
- protected ComponentTypeIntrospector introspector;
- protected AssemblyFactory factory;
-
- protected ImplementationProcessorSupport(AssemblyFactory factory) {
- this.factory = factory;
- }
-
- protected ImplementationProcessorSupport() {
- }
-
- @Init(eager = true)
- public void init() throws Exception {
- introspector.registerProcessor(this);
- }
-
- @Autowire
- public void setIntrospector(ComponentTypeIntrospector introspector) {
- this.introspector = introspector;
- }
-
- @Autowire
- public void setFactory(AssemblyFactory factory) {
- this.factory = factory;
-
- }
-
- public void visitClass(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitSuperClass(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitConstructor(Constructor<?> constructor, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitField(Field field, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitInterface(Class clazz, Annotation[] annotations, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitInterfaceMethod(Method method, Annotation[] annotations, ComponentType type) throws ConfigurationLoadException {
-
- }
-
- public void visitEnd(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
-
- }
-
-// /**
-// * Creates a {@link JavaExtensibilityElement} subclasses may update while processing annotations
-// */
-// protected JavaExtensibilityElement getExtensibilityElement(ComponentType type) {
-// JavaExtensibilityElement element = (JavaExtensibilityElement) type.getExtensibilityElements().get(JAVA_ELEMENT);
-// if (element == null) {
-// element = new JavaExtensibilityElementImpl();
-// type.getExtensibilityElements().put(JAVA_ELEMENT, element);
-// }
-// return element;
-// }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/InitProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/InitProcessor.java
deleted file mode 100644
index 9f4a53a651..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/InitProcessor.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.extension.config.extensibility.InitInvokerExtensibilityElement;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Init;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Init} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class InitProcessor extends ImplementationProcessorSupport {
-
- public InitProcessor() {
- }
-
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- Init init = method.getAnnotation(Init.class);
- if (init == null) {
- return;
- }
- if (method.getParameterTypes().length != 0) {
- throw new ConfigurationLoadException("Initialize methods cannot take parameters");
- }
- type.getExtensibilityElements().add(new InitInvokerExtensibilityElement(method, init.eager()));
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorHelper.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorHelper.java
deleted file mode 100644
index d4c6c4a40e..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.util.List;
-
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-
-/**
- * Provides utility functions for {@link org.apache.tuscany.core.extension.config.ImplementationProcessor}s
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ProcessorHelper {
-
- private ProcessorHelper() {
- }
-
- /**
- * Returns the first <code>Service</code> from a collection matching the interface type
- */
- public static Service getService(Class<?> interfaceType, List<Service> services) {
- for (Service service : services) {
- Class serviceInterface = service.getServiceContract().getInterface();
- if (serviceInterface.equals(interfaceType)) {
- return service;
- }
- }
- return null;
- }
-
- /**
- * Returns the scope enum specified by the annotation
- */
- public static Scope getScope(org.osoa.sca.annotations.Scope annotation) {
- if ("MODULE".equalsIgnoreCase(annotation.value())) {
- return Scope.MODULE;
- } else if ("SESSION".equalsIgnoreCase(annotation.value())) {
- return Scope.SESSION;
- } else if ("REQUEST".equalsIgnoreCase(annotation.value())) {
- return Scope.REQUEST;
- } else {
- return Scope.INSTANCE;
- }
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorUtils.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorUtils.java
deleted file mode 100644
index b0400c183f..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ProcessorUtils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.core.extension.config.ImplementationProcessor;
-import org.apache.tuscany.core.system.config.processor.AutowireProcessor;
-import org.apache.tuscany.core.system.config.processor.MonitorProcessor;
-import org.apache.tuscany.core.system.config.processor.ParentContextProcessor;
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector;
-import org.apache.tuscany.core.sdo.helper.SDOHelperProcessor;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-
-/**
- * Temporary class to create bootstrap {@link ImplementationProcessor}s
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ProcessorUtils {
-
- private ProcessorUtils() {
- }
-
- public static List<ImplementationProcessor> createCoreProcessors(AssemblyFactory factory) {
- List<ImplementationProcessor> processors = new ArrayList<ImplementationProcessor>();
- processors.add(new PropertyProcessor(factory));
- processors.add(new ReferenceProcessor(factory));
- processors.add(new ScopeProcessor());
- processors.add(new ServiceProcessor(factory));
- processors.add(new InitProcessor());
- processors.add(new DestroyProcessor());
- processors.add(new ContextProcessor());
- processors.add(new ComponentNameProcessor(factory));
- processors.add(new DefaultProcessor(factory));
- processors.add(new AutowireProcessor());
- processors.add(new MonitorProcessor());
- processors.add(new ParentContextProcessor());
- processors.add(new SDOHelperProcessor());
- return processors;
- }
-
- public static ComponentTypeIntrospector createCoreIntrospector(AssemblyFactory factory){
- ComponentTypeIntrospector introspector = new Java5ComponentTypeIntrospector(factory);
- List<ImplementationProcessor> processors = createCoreProcessors(factory);
- for (ImplementationProcessor processor : processors) {
- introspector.registerProcessor(processor);
- }
- return introspector;
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyProcessor.java
deleted file mode 100644
index 9191b75793..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyProcessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.InvalidSetterException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Property;
-import org.osoa.sca.annotations.Scope;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Property} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-@Scope("MODULE")
-public class PropertyProcessor extends ImplementationProcessorSupport {
-
- public PropertyProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public PropertyProcessor() {
- }
-
- @Override
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- if (method.getDeclaringClass().equals(Object.class)) {
- return;
- }
- org.osoa.sca.annotations.Property annotation = method.getAnnotation(org.osoa.sca.annotations.Property.class);
- if (annotation != null) {
- if (!Modifier.isPublic(method.getModifiers())) {
- InvalidSetterException e = new InvalidSetterException("Property setter method is not public");
- e.setIdentifier(method.toString());
- throw e;
- }
- Class<?>[] params = method.getParameterTypes();
- if (params.length != 1) {
- InvalidSetterException e = new InvalidSetterException("Property setter method must have one parameter");
- e.setIdentifier(method.toString());
- throw e;
- }
- String name = annotation.name();
- if (name.length() == 0) {
- name = method.getName();
- if (name.length() > 3 && name.startsWith("set")) {
- // follow JavaBeans conventions
- name = JavaIntrospectionHelper.toPropertyName(name);
- }
- }
- addProperty(name, method.getParameterTypes()[0], annotation.required(), type);
- }
-
-
- }
-
- @Override
- public void visitField(Field field, ComponentType type) throws ConfigurationLoadException {
- if (field.getDeclaringClass().equals(Object.class)) {
- return;
- }
- int modifiers = field.getModifiers();
- org.osoa.sca.annotations.Property annotation = field.getAnnotation(org.osoa.sca.annotations.Property.class);
- if (annotation != null) {
- if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) {
- InvalidSetterException e = new InvalidSetterException("Property field is not public or protected");
- e.setIdentifier(field.getName());
- throw e;
- }
- String name = annotation.name();
- if (name.length() == 0) {
- name = field.getName();
- }
- addProperty(name, field.getType(), annotation.required(), type);
- }
- }
-
- private void addProperty(String name, Class<?> propType, boolean required, ComponentType type) {
- Property property = factory.createProperty();
- property.setName(name);
- property.setRequired(required);
- property.setType(propType);
- type.getProperties().add(property);
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyReferenceValidator.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyReferenceValidator.java
deleted file mode 100644
index bc8ef02777..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/PropertyReferenceValidator.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-import java.util.Set;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.MetaDataException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-
-/**
- * Validates the use of {@link org.osoa.sca.annotations.Property} and {@link
- * org.osoa.sca.annotations.Reference} annotations beyond native Java syntactic capabilities
- *
- * @version $$Rev$$ $$Date$$
- */
-public class PropertyReferenceValidator extends ImplementationProcessorSupport {
-
- public PropertyReferenceValidator(AssemblyFactory factory) {
- super(factory);
- }
-
- public void visitEnd(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- // validate methods do not contain both @Reference and @Property annotations
- Method[] methods = clazz.getMethods();
- boolean found;
- for (Method method : methods) {
- found = false;
- Annotation[] anotations = method.getAnnotations();
- for (Annotation annotation : anotations) {
- if (Property.class.equals(annotation.annotationType())
- || Reference.class.equals(annotation.annotationType())) {
- if (found) {
- MetaDataException e = new MetaDataException("Method cannot specify both property and reference");
- e.setIdentifier(method.getName());
- throw e;
- }
- found = true;
- }
- }
- }
- // validate fields do not contain both @Reference and @Property annotations
- Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz);
- for (Field field : fields) {
- found = false;
- Annotation[] anotations = field.getAnnotations();
- for (Annotation annotation : anotations) {
- if (Property.class.equals(annotation.annotationType())
- || Reference.class.equals(annotation.annotationType())) {
- if (found) {
- MetaDataException e = new MetaDataException("Field cannot specify both property and reference");
- e.setIdentifier(field.getName());
- throw e;
- }
- found = true;
- }
- }
- }
-
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ReferenceProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ReferenceProcessor.java
deleted file mode 100644
index 007410b500..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ReferenceProcessor.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.InvalidSetterException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Multiplicity;
-import org.apache.tuscany.model.assembly.Reference;
-import org.apache.tuscany.model.assembly.ServiceContract;
-import org.osoa.sca.annotations.Scope;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Reference} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-@Scope("MODULE")
-public class ReferenceProcessor extends ImplementationProcessorSupport {
-
- public ReferenceProcessor() {
- }
-
- public ReferenceProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- @Override
- public void visitMethod(Method method, ComponentType type) throws ConfigurationLoadException {
- if(method.getDeclaringClass().equals(Object.class)){
- return;
- }
- int modifiers = method.getModifiers();
- org.osoa.sca.annotations.Reference annotation = method.getAnnotation(org.osoa.sca.annotations.Reference.class);
- if (annotation != null) {
- if (!Modifier.isPublic(modifiers)) {
- InvalidSetterException e = new InvalidSetterException("Reference setter method is not public");
- e.setIdentifier(method.getName());
- throw e;
- }
- if (!Void.TYPE.equals(method.getReturnType())) {
- InvalidSetterException e = new InvalidSetterException("Refence setter method must return void");
- e.setIdentifier(method.toString());
- throw e;
- }
- Class<?>[] params = method.getParameterTypes();
- if (params.length != 1) {
- InvalidSetterException e = new InvalidSetterException("Reference setter method must have one parameter");
- e.setIdentifier(method.toString());
- throw e;
- }
- String name = annotation.name();
- if (name.length() == 0) {
- name = method.getName();
- if (name.length() > 3 && name.startsWith("set")) {
- // follow JavaBeans conventions
- name = JavaIntrospectionHelper.toPropertyName(name);
- }
- }
- addReference(name, params[0], annotation.required(), type);
- }
- }
-
- @Override
- public void visitField(Field field, ComponentType type) throws ConfigurationLoadException {
- if(field.getDeclaringClass().equals(Object.class)){
- return;
- }
- int modifiers = field.getModifiers();
- org.osoa.sca.annotations.Reference annotation = field.getAnnotation(org.osoa.sca.annotations.Reference.class);
- if (annotation != null) {
- if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) {
- InvalidSetterException e = new InvalidSetterException("Reference field is not public or protected");
- e.setIdentifier(field.getName());
- throw e;
- }
- String name = annotation.name();
- if (name.length() == 0) {
- name = field.getName();
- }
- addReference(name, field.getType(), annotation.required(), type);
- }
- }
-
- private void addReference(String name, Class<?> paramType, boolean required, ComponentType type) {
- Reference reference = factory.createReference();
- reference.setName(name);
- ServiceContract contract = factory.createJavaServiceContract();
- contract.setInterface(paramType);
- reference.setServiceContract(contract);
- boolean many = paramType.isArray() || Collection.class.isAssignableFrom(paramType);
- Multiplicity multiplicity;
- if (required)
- multiplicity = many ? Multiplicity.ONE_N : Multiplicity.ONE_ONE;
- else
- multiplicity = many ? Multiplicity.ZERO_N : Multiplicity.ZERO_ONE;
- reference.setMultiplicity(multiplicity);
- type.getReferences().add(reference);
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ScopeProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ScopeProcessor.java
deleted file mode 100644
index e81430115a..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ScopeProcessor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Scope} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ScopeProcessor extends ImplementationProcessorSupport {
-
- public ScopeProcessor() {
- }
-
- @Override
- public void visitEnd(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- Scope scope = null;
- org.osoa.sca.annotations.Scope annotation = clazz.getAnnotation(org.osoa.sca.annotations.Scope.class);
- if (annotation != null) {
- scope = ProcessorHelper.getScope(annotation);
- } else {
- Class<?> superClass = clazz.getSuperclass();
- if (superClass != null) {
- scope = recurseScope(superClass);
- }
- }
- if (scope == null) {
- scope = Scope.INSTANCE;
- }
- //FIXME hack for now - set scope to implementation scope
- //This will be clean up with spec change
- for (Service service : type.getServices()) {
- Scope serviceScope = service.getServiceContract().getScope();
- if (serviceScope == Scope.INSTANCE || serviceScope == null) {
- service.getServiceContract().setScope(scope);
- }
- }
-
- }
-
- /**
- * Walks the class hierarchy until a scope annotation is found
- */
- private Scope recurseScope(Class<?> superClass) {
- if (Object.class.equals(superClass)) {
- return null;
- }
- org.osoa.sca.annotations.Scope scope = superClass.getAnnotation(org.osoa.sca.annotations.Scope.class);
- if (scope == null) {
- superClass = superClass.getSuperclass();
- if (superClass != null) {
- return recurseScope(superClass);
- }
- }
- return ProcessorHelper.getScope(scope);
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ServiceProcessor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ServiceProcessor.java
deleted file mode 100644
index 2c7ba823f2..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/config/processor/ServiceProcessor.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.core.config.processor;
-
-import java.util.List;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.InvalidMetaDataException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.types.java.JavaServiceContract;
-import org.osoa.sca.annotations.Callback;
-
-/**
- * Processes the {@link org.osoa.sca.annotations.Service} annotation
- *
- * @version $$Rev$$ $$Date$$
- */
-public class ServiceProcessor extends ImplementationProcessorSupport {
-
- public ServiceProcessor() {
- }
-
- public ServiceProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- @Override
- public void visitClass(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- if (!clazz.isInterface()) {
- processImplementation(clazz,type);
- } else {
- processInterface(clazz, type);
- }
- }
-
- private void processImplementation(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- // visiting the base implementation class
- List<org.apache.tuscany.model.assembly.Service> services = type.getServices();
- Class[] interfaces = clazz.getInterfaces();
- org.osoa.sca.annotations.Service serviceAnnotation = clazz.getAnnotation(org.osoa.sca.annotations.Service.class);
- if (interfaces.length == 0) {
- // no interfaces so the class is the service
- addService(services, clazz);
- } else if (serviceAnnotation == null && interfaces.length == 1) {
- // the impl has one interface, assign it to be the service
- addService(services, interfaces[0]);
- } else {
- // visiting the implementation class
- if (serviceAnnotation == null) {
- return;
- }
- Class<?>[] serviceInterfaces = serviceAnnotation.interfaces();
- Class<?> value = serviceAnnotation.value();
- if (serviceInterfaces.length > 0) {
- if (!Void.class.equals(value)) {
- InvalidMetaDataException e = new InvalidMetaDataException("Both interfaces and value specified in @Service on ");
- e.setIdentifier(clazz.getName());
- throw e;
- }
- for (Class<?> intf : interfaces) {
- addService(services, intf);
- }
- } else if (!Void.class.equals(value)) {
- addService(services, value);
- }
- }
- }
-
-
- @Override
- public void visitEnd(Class<?> clazz, ComponentType type) throws ConfigurationLoadException {
- List<Service> services = type.getServices();
- if (services.size() == 0) {
- // no services processed so the class is the service
- addService(services, clazz);
- }
- }
-
- private void processInterface(Class<?> clazz, ComponentType type) {
- List<org.apache.tuscany.model.assembly.Service> services = type.getServices();
- // the interface is a remotable service, add it
- org.osoa.sca.annotations.Remotable remotableAnnotation = clazz.getAnnotation(org.osoa.sca.annotations.Remotable.class);
- if (remotableAnnotation != null) {
- // check to see if service added previously b/c it was specified on @Service
- if (ProcessorHelper.getService(clazz, services) == null) {
- addService(services, clazz);
- }
- }
- }
-
-
- private void addService(List<Service> services, Class<?> serviceClass) {
- //FIXME how do we support specifying remotable?
- JavaServiceContract javaInterface = factory.createJavaServiceContract();
- javaInterface.setInterface(serviceClass);
- org.osoa.sca.annotations.Scope scopeAnnotation = serviceClass.getAnnotation(org.osoa.sca.annotations.Scope.class);
- Scope scope;
- if (scopeAnnotation == null) {
- scope = Scope.INSTANCE;
- } else {
- scope = ProcessorHelper.getScope(scopeAnnotation);
- }
- javaInterface.setScope(scope);
- Callback callback = serviceClass.getAnnotation(Callback.class);
- if (callback != null && !Void.class.equals(callback.value())) {
- javaInterface.setCallbackInterface(callback.value());
- }
- String name = JavaIntrospectionHelper.getBaseName(serviceClass);
- Service service = factory.createService();
- service.setName(name);
- service.setServiceContract(javaInterface);
- services.add(service);
- }
-}