summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl')
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java222
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java57
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java87
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java110
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java89
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java67
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java41
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java34
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java36
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java63
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java678
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java67
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java36
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java39
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java42
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java40
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java48
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java37
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java303
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java50
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java274
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java49
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java153
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java68
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java238
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java35
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java33
40 files changed, 0 insertions, 3491 deletions
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
deleted file mode 100644
index b951e17fd2..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.sca.assembly.Property;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
-
-/**
- * Base class for ImplementationProcessors that handle annotations that add
- * Properties.
- *
- * @version $Rev$ $Date$
- */
-public abstract class AbstractPropertyProcessor<A extends Annotation> extends BaseJavaClassVisitor {
- private final Class<A> annotationClass;
-
- protected AbstractPropertyProcessor(ExtensionPointRegistry registry, Class<A> annotationClass) {
- super(registry);
- this.annotationClass = annotationClass;
- }
-
- private static boolean removeProperty(JavaElementImpl prop, JavaImplementation type) {
- if(prop==null) {
- return false;
- }
- List<Property> props = type.getProperties();
- for(int i=0;i<props.size();i++) {
- if(props.get(i).getName().equals(prop.getName())) {
- props.remove(i);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- A annotation = method.getAnnotation(annotationClass);
- if (annotation != null) {
-
- if (!JavaIntrospectionHelper.isSetter(method)) {
- throw new IllegalPropertyException("Annotated method is not a setter: " + method, method);
- }
-
- if(Modifier.isStatic(method.getModifiers())) {
- throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Property");
- }
-
- String name = getName(annotation);
- if (name == null || "".equals(name)) {
- name = method.getName();
- if (name.startsWith("set")) {
- name = JavaIntrospectionHelper.toPropertyName(method.getName());
- }
- }
-
- Map<String, JavaElementImpl> properties = type.getPropertyMembers();
- JavaElementImpl prop = properties.get(name);
- // Setter override field
- if (prop != null && prop.getElementType() != ElementType.FIELD) {
- throw new DuplicatePropertyException(name);
- }
-
- removeProperty(prop, type);
-
- JavaElementImpl element = new JavaElementImpl(method, 0);
- Property property = createProperty(name, element);
-
- // add databinding available as annotations, as extensions
-
- initProperty(property, annotation);
- type.getProperties().add(property);
- properties.put(name, element);
- }
-
- // enforce the constraint that an ordinary method's argument can not be a Property
- Annotation paramsAnnotations[][] = method.getParameterAnnotations();
- for (int i = 0; i < paramsAnnotations.length; i++) {
- Annotation argAnnotations[] = paramsAnnotations[i];
- for (int j = 0; j < argAnnotations.length; j++) {
- if(argAnnotations[j].annotationType() == org.oasisopen.sca.annotation.Property.class) {
- throw new IllegalPropertyException("Argument " + (i+1) + " of method " + method.getName() + " in class " + method.getDeclaringClass() + " can not be a Property");
- }
- }
- }
- }
-
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
-
- A annotation = field.getAnnotation(annotationClass);
- if (annotation == null) {
- return;
- }
-
- if(Modifier.isStatic(field.getModifiers())) {
- throw new IllegalPropertyException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as a Property");
- }
-
- if(Modifier.isFinal(field.getModifiers())) {
- throw new IllegalPropertyException("Final field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as a Property");
- }
-
- String name = getName(annotation);
- if (name == null) {
- name = "";
- }
- if ("".equals(name) || name.equals(field.getType().getName())) {
- name = field.getName();
- }
-
- Map<String, JavaElementImpl> properties = type.getPropertyMembers();
- JavaElementImpl prop = properties.get(name);
- // Setter override field
- if (prop != null && prop.getElementType() == ElementType.FIELD) {
- throw new DuplicatePropertyException(name);
- }
-
- if (prop == null) {
- JavaElementImpl element = new JavaElementImpl(field);
- Property property = createProperty(name, element);
- initProperty(property, annotation);
- type.getProperties().add(property);
- properties.put(name, element);
- }
- }
-
- @Override
- public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
- throws IntrospectionException {
-
- Map<String, JavaElementImpl> properties = type.getPropertyMembers();
- A annotation = parameter.getAnnotation(annotationClass);
- if (annotation != null) {
- String name = getName(annotation);
- if (name == null) {
- name = parameter.getType().getName();
- }
- if (!"".equals(name) && !"".equals(parameter.getName()) && !name.equals(parameter.getName())) {
- throw new InvalidConstructorException("Mismatched property name: " + parameter);
- }
- if ("".equals(name) && "".equals(parameter.getName())) {
- throw new InvalidPropertyException("Missing property name: " + parameter);
- }
- if ("".equals(name)) {
- name = parameter.getName();
- }
-
- if (!getRequired(annotation)) {
- throw new InvalidPropertyException("JCA_90014 Constructor property must not have required=false: " + type.getName());
- }
-
- JavaElementImpl prop = properties.get(name);
- // Setter override field
- if (prop != null && prop.getElementType() != ElementType.FIELD) {
- throw new DuplicatePropertyException(name);
- }
- removeProperty(prop, type);
-
- parameter.setName(name);
- parameter.setClassifer(annotationClass);
- Property property = createProperty(name, parameter);
- initProperty(property, annotation);
- type.getProperties().add(property);
- properties.put(name, parameter);
- }
- }
-
- protected abstract String getName(A annotation);
- protected abstract boolean getRequired(A annotation);
-
- protected abstract void initProperty(Property property, A annotation) throws IntrospectionException;
-
- protected Property createProperty(String name, JavaElementImpl element) throws IntrospectionException {
-
- Property property = assemblyFactory.createProperty();
- property.setName(name);
- Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
- property.setXSDType(JavaXMLMapper.getXMLType(baseType));
-
- Class<?> javaType = element.getType();
- if (javaType.isArray() || Collection.class.isAssignableFrom(javaType)) {
- property.setMany(true);
- }
- return property;
-
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
deleted file mode 100644
index 4aa29d3b91..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.oasisopen.sca.annotation.AllowsPassByReference;
-
-/**
- * Processes {@link AllowsPassByReference} on an implementation
- *
- * @version $Rev$ $Date$
- */
-public class AllowsPassByReferenceProcessor extends BaseJavaClassVisitor {
-
- public AllowsPassByReferenceProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public AllowsPassByReferenceProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
- type.setAllowsPassByReference(clazz.isAnnotationPresent(AllowsPassByReference.class));
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- boolean pbr = method.isAnnotationPresent(AllowsPassByReference.class);
- if (pbr) {
- type.getAllowsPassByReferenceMethods().add(method);
- }
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java
deleted file mode 100644
index c6e6b6e4d6..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when constructor parameters cannot be unambiguously resolved to a property or reference
- *
- * @version $Rev$ $Date$
- */
-public class AmbiguousConstructorException extends IntrospectionException {
- private static final long serialVersionUID = 3662860753837091880L;
-
- public AmbiguousConstructorException(String message) {
- super(message);
- }
-
- public AmbiguousConstructorException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
deleted file mode 100644
index 1813a177b4..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.oasisopen.sca.annotation.ComponentName;
-
-/**
- * Processes {@link @ComponentName} annotations on a component implementation and adds
- * a {@link JavaMappedProperty} to the component type which will be used to
- * inject the appropriate component name.
- *
- * @version $Rev$ $Date$
- */
-public class ComponentNameProcessor extends BaseJavaClassVisitor {
-
- public ComponentNameProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public ComponentNameProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- if (method.getAnnotation(ComponentName.class) == null) {
- return;
- }
- if (method.getParameterTypes().length != 1) {
- throw new IllegalContextException("ComponentName setter must have one parameter", method);
- }
- Class<?> paramType = method.getParameterTypes()[0];
- String name = JavaIntrospectionHelper.toPropertyName(method.getName());
- if (String.class.equals(paramType)) {
- JavaElementImpl element = new JavaElementImpl(method, 0);
- element.setName(name);
- element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- JavaResourceImpl resource = new JavaResourceImpl(element);
- type.getResources().put(resource.getName(), resource);
- } else {
- throw new IllegalContextException(paramType.getName());
- }
- }
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
- if (field.getAnnotation(ComponentName.class) == null) {
- return;
- }
- Class<?> paramType = field.getType();
- if (String.class.equals(paramType)) {
- JavaElementImpl element = new JavaElementImpl(field);
- element.setClassifer(Resource.class);
- JavaResourceImpl resource = new JavaResourceImpl(element);
- type.getResources().put(resource.getName(), resource);
- } else {
- throw new IllegalContextException(paramType.getName());
- }
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
deleted file mode 100644
index 68f0b46f2e..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Constructor;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-
-/**
- * Handles processing of a constructor decorated with
- * {@link org.oasisopen.sca.annotation.Constructor}
- *
- * @version $Rev$ $Date$
- */
-@SuppressWarnings("unchecked")
-public class ConstructorProcessor extends BaseJavaClassVisitor {
-
- public ConstructorProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public ConstructorProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
- Constructor[] ctors = clazz.getConstructors();
- boolean found = false;
- for (Constructor constructor : ctors) {
- JavaConstructorImpl<?> definition = new JavaConstructorImpl(constructor);
- type.getConstructors().put(constructor, definition);
- if (constructor.getAnnotation(org.oasisopen.sca.annotation.Constructor.class) != null) {
- if (found) {
- throw new DuplicateConstructorException("Multiple constructors marked with @Constructor", constructor);
- }
- found = true;
- type.setConstructor(definition);
- }
- }
- }
-
- @Override
- public <T> void visitConstructor(Constructor<T> constructor, JavaImplementation type)
- throws IntrospectionException {
- org.oasisopen.sca.annotation.Constructor annotation = constructor
- .getAnnotation(org.oasisopen.sca.annotation.Constructor.class);
- if (annotation == null) {
- return;
- }
- JavaConstructorImpl<?> definition = type.getConstructor();
- if (definition == null) {
- definition = new JavaConstructorImpl(constructor);
- type.setConstructor(definition);
- }
- JavaParameterImpl[] parameters = definition.getParameters();
- String[] value = annotation.value();
- boolean isDefault = value.length == 0 || (value.length == 1 && "".equals(value[0]));
- if (!isDefault && value.length != parameters.length) {
- throw new InvalidConstructorException("Invalid Number of names in @Constructor");
- }
-
- for (JavaParameterImpl p : parameters) {
- if (!hasAnnotation(p)) {
- throw new InvalidConstructorException("JCA90003 constructor parameters must have @Property or @Reference annotation");
- }
- }
-
- for (int i = 0; i < parameters.length; i++) {
- parameters[i].setName(i < value.length ? value[i] : "");
- }
- type.setConstructor(definition);
- }
-
- private boolean hasAnnotation(JavaParameterImpl p) {
- if (p.getAnnotations() != null && p.getAnnotations().length > 0) {
- return true;
- }
-// TODO: need to verify JCA90003 as it seems like any annotation should be ok not just SCA ref or prop
-// if (p.getAnnotation(Reference.class) != null) {
-// return true;
-// }
-// if (p.getAnnotation(Property.class) != null) {
-// return true;
-// }
- return false;
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
deleted file mode 100644
index 651ecdbd7e..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.oasisopen.sca.ComponentContext;
-import org.oasisopen.sca.RequestContext;
-import org.oasisopen.sca.annotation.Context;
-
-/**
- * Processes {@link @Context} annotations on a component implementation and adds
- * a {@link JavaMappedProperty} to the component type which will be used to
- * inject the appropriate context
- *
- * @version $Rev$ $Date$
- */
-public class ContextProcessor extends BaseJavaClassVisitor {
-
- public ContextProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public ContextProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- if (method.getAnnotation(Context.class) == null) {
- return;
- }
- if (method.getParameterTypes().length != 1) {
- throw new IllegalContextException("Context setter must have one parameter", method);
- }
- Class<?> paramType = method.getParameterTypes()[0];
- String name = JavaIntrospectionHelper.toPropertyName(method.getName());
- if (ComponentContext.class.equals(paramType) || RequestContext.class.equals(paramType)) {
- JavaElementImpl element = new JavaElementImpl(method, 0);
- element.setName(name);
- element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- JavaResourceImpl resource = new JavaResourceImpl(element);
- type.getResources().put(resource.getName(), resource);
- } else {
- throw new UnknownContextTypeException(paramType.getName());
- }
- }
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
- if (field.getAnnotation(Context.class) == null) {
- return;
- }
- Class<?> paramType = field.getType();
- if (ComponentContext.class.equals(paramType) || RequestContext.class.equals(paramType)) {
- JavaElementImpl element = new JavaElementImpl(field);
- element.setClassifer(Resource.class);
- JavaResourceImpl resource = new JavaResourceImpl(element);
- type.getResources().put(resource.getName(), resource);
- } else {
- throw new UnknownContextTypeException(paramType.getName());
- }
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
deleted file mode 100644
index 25f31c5f12..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.oasisopen.sca.annotation.Destroy;
-
-/**
- * Processes the {@link @Destroy} annotation on a component implementation and
- * updates the component type with the decorated destructor method
- *
- * @version $Rev$ $Date$
- */
-public class DestroyProcessor extends BaseJavaClassVisitor {
-
- public DestroyProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public DestroyProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- Destroy annotation = method.getAnnotation(Destroy.class);
- if (annotation == null) {
- return;
- }
- if (method.getParameterTypes().length != 0) {
- throw new IllegalDestructorException("Destructor must not have argments", method);
- }
- if(!method.getReturnType().equals(void.class)) {
- throw new IllegalDestructorException("Destructor must return void.", method);
- }
- if (type.getDestroyMethod() != null) {
- throw new DuplicateDestructorException("More than one destructor found on implementation");
- }
- if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalDestructorException("Destructor must be a public method. Invalid annotation @Destroy found on "+method);
- }
- type.setDestroyMethod(method);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java
deleted file mode 100644
index d6494e3845..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when more than one component implementation constructor is annotated with {@link
- * org.oasisopen.sca.annotation.Constructor}
- *
- * @version $Rev$ $Date$
- */
-public class DuplicateConstructorException extends IntrospectionException {
- private static final long serialVersionUID = -5926763756570552986L;
-
- public DuplicateConstructorException(String message) {
- super(message);
- }
-
- public DuplicateConstructorException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java
deleted file mode 100644
index 8bfae89162..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when an implementation is annotated multiple times with {@link org.oasisopen.sca.annotation.Destroy}
- *
- * @version $Rev$ $Date$
- */
-public class DuplicateDestructorException extends IntrospectionException {
- private static final long serialVersionUID = -7474912510114895203L;
-
- public DuplicateDestructorException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java
deleted file mode 100644
index 38f6478531..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when an implementation is annotated multiple times with {@link @org.oasisopen.sca.annotation.Init}
- *
- * @version $Rev$ $Date$
- */
-public class DuplicateInitException extends IntrospectionException {
- private static final long serialVersionUID = -6282935288115512057L;
-
- public DuplicateInitException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java
deleted file mode 100644
index b9e1923e73..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when an implementation has more than one property injection site with the same name
- *
- * @version $Rev$ $Date$
- */
-public class DuplicatePropertyException extends IntrospectionException {
- private static final long serialVersionUID = 5536415875694904037L;
-
- public DuplicatePropertyException(String message) {
- super(message);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java
deleted file mode 100644
index 300ad6817e..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when an implementation has more than one reference injection site with the same name
- *
- * @version $Rev$ $Date$
- */
-public class DuplicateReferenceException extends IntrospectionException {
- private static final long serialVersionUID = 907910648213477158L;
-
- public DuplicateReferenceException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java
deleted file mode 100644
index 2d177b3f76..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when an implementation has more than one resource injection site with the same name
- *
- * @version $Rev$ $Date$
- */
-public class DuplicateResourceException extends IntrospectionException {
-
- private static final long serialVersionUID = 1619276459330463299L;
-
- public DuplicateResourceException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
deleted file mode 100644
index 9ad7e8f7a9..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.oasisopen.sca.annotation.EagerInit;
-
-/**
- * Handles processing of {@link org.oasisopen.sca.annotation.EagerInit}
- *
- * @version $Rev$ $Date$
- */
-public class EagerInitProcessor extends BaseJavaClassVisitor {
-
- public EagerInitProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public EagerInitProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz,
- JavaImplementation type) throws IntrospectionException {
- super.visitClass(clazz, type);
- EagerInit annotation = clazz.getAnnotation(EagerInit.class);
- if (annotation == null) {
- Class<?> superClass = clazz.getSuperclass();
- while (!Object.class.equals(superClass)) {
- annotation = superClass.getAnnotation(EagerInit.class);
- if (annotation != null) {
- break;
- }
- superClass = superClass.getSuperclass();
- }
- if (annotation == null) {
- return;
- }
- }
- type.setEagerInit(true);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
deleted file mode 100644
index fc7c87a624..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllInterfaces;
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.toPropertyName;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jws.WebService;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
-import org.oasisopen.sca.annotation.Callback;
-import org.oasisopen.sca.annotation.Context;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Remotable;
-
-/**
- * Heuristically evaluates an un-annotated Java implementation type to determine
- * services, references, and properties according to the algorithm described in
- * the SCA Java Client and Implementation Model Specification <p/> TODO
- * Implement: <p/> When no service interface is annotated, need to calculate a
- * single service comprising all public methods that are not reference or
- * property injection sites. If that service can be exactly mapped to an
- * interface implemented by the class then the service interface will be defined
- * in terms of that interface.
- *
- * @version $Rev$ $Date$
- */
-public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
-
- public HeuristicPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
- super(assemblyFactory);
- this.javaInterfaceFactory = javaFactory;
- }
-
- public HeuristicPojoProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
- List<org.apache.tuscany.sca.assembly.Service> services = type.getServices();
- if (services.isEmpty()) {
- // heuristically determine the service
- /**
- * The following is quoted from Java Specification 1.2.1.3. Introspecting services offered by a Java implementation
- * In the cases described below, the services offered by a Java implementation class may be determined
- * through introspection, eliding the need to specify them using @Service. The following algorithm is used
- * to determine how services are introspected from an implementation class:
- *
- * If the interfaces of the SCA services are not specified with the @Service annotation on the
- * implementation class, it is assumed that all implemented interfaces that have been annotated
- * as @Remotable are the service interfaces provided by the component. If none of the implemented
- * interfaces is remotable, then by default the implementation offers a single service whose type
- * is the implementation class.
- */
- Set<Class<?>> interfaces = getAllInterfaces(clazz);
- for (Class<?> i : interfaces) {
- if (i.isAnnotationPresent(Remotable.class) || i.isAnnotationPresent(WebService.class)) {
- addService(type, i);
- }
- }
- if (services.isEmpty()) {
- // class is the interface
- addService(type, clazz);
- }
- }
- Set<Method> methods = getAllUniquePublicProtectedMethods(clazz, false);
- if (!type.getReferenceMembers().isEmpty() || !type.getPropertyMembers().isEmpty()) {
- // references and properties have been explicitly defined
- // if (type.getServices().isEmpty()) {
- // calculateServiceInterface(clazz, type, methods);
- // if (type.getServices().isEmpty()) {
- // throw new ServiceTypeNotFoundException(clazz.getName());
- // }
- // }
- evaluateConstructor(type, clazz);
- return;
- }
- calcPropRefs(methods, services, type, clazz);
- evaluateConstructor(type, clazz);
- }
-
- private void addService(JavaImplementation type, Class<?> clazz) throws IntrospectionException {
- try {
- org.apache.tuscany.sca.assembly.Service service = createService(clazz);
- type.getServices().add(service);
- } catch (InvalidInterfaceException e) {
- throw new IntrospectionException(e);
- }
- }
-
-
- private <T> void calcPropRefs(Set<Method> methods,
- List<org.apache.tuscany.sca.assembly.Service> services,
- JavaImplementation type,
- Class<T> clazz) throws IntrospectionException {
- // heuristically determine the properties references
- // make a first pass through all public methods with one param
- Set<String> setters = new HashSet<String>();
- Set<String> others = new HashSet<String>();
- for (Method method : methods) {
- if (!isPublicSetter(method)) {
- continue;
- }
- if (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
- // Add the property name as others
- others.add(toPropertyName(method.getName()));
- continue;
- }
- if (!isInServiceInterface(method, services)) {
- // Not part of the service interface
- String name = toPropertyName(method.getName());
- setters.add(name);
- // avoid duplicate property or ref names
- if (!type.getPropertyMembers().containsKey(name) && !type.getReferenceMembers().containsKey(name)) {
- Class<?> param = method.getParameterTypes()[0];
- Type genericType = method.getGenericParameterTypes()[0];
- if (isReferenceType(param, genericType)) {
- type.getReferences().add(createReference(name, param));
- type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
- } else {
- type.getProperties().add(createProperty(name, param));
- type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
- }
- }
- }
- }
- // second pass for protected methods with one param
- for (Method method : methods) {
- if (!isProtectedSetter(method)) {
- continue;
- }
- if (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
- // Add the property name as others
- others.add(toPropertyName(method.getName()));
- continue;
- }
- Class<?> param = method.getParameterTypes()[0];
- String name = toPropertyName(method.getName());
- setters.add(name);
- // avoid duplicate property or ref names
- if (isReferenceType(param, method.getGenericParameterTypes()[0])) {
- if (!type.getReferenceMembers().containsKey(name)) {
- type.getReferences().add(createReference(name, param));
- type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
- }
- } else {
- if (!type.getPropertyMembers().containsKey(name)) {
- type.getProperties().add(createProperty(name, param));
- type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
- }
- }
- }
-
- // Public or protected fields unless there is a public or protected
- // setter method
- // for the same name
- Set<Field> fields = getAllPublicAndProtectedFields(clazz, false);
- for (Field field : fields) {
- if (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class)) {
- continue;
- }
- if (setters.contains(field.getName()) || others.contains(field.getName())) {
- continue;
- }
- String name = field.getName();
- Class<?> paramType = field.getType();
- if (isReferenceType(paramType, field.getGenericType())) {
- if (!type.getReferenceMembers().containsKey(name)) {
- type.getReferences().add(createReference(name, paramType));
- type.getReferenceMembers().put(name, new JavaElementImpl(field));
- }
- } else {
- if (!type.getPropertyMembers().containsKey(name)) {
- type.getProperties().add(createProperty(name, paramType));
- type.getPropertyMembers().put(name, new JavaElementImpl(field));
- }
- }
- }
- }
-
- /**
- * Determines the constructor to use based on the component type's
- * references and properties
- *
- * @param type the component type
- * @param clazz the implementation class corresponding to the component type
- * @throws NoConstructorException if no suitable constructor is found
- * @throws AmbiguousConstructorException if the parameters of a constructor
- * cannot be unambiguously mapped to references and properties
- */
- @SuppressWarnings("unchecked")
- private <T> void evaluateConstructor(JavaImplementation type, Class<T> clazz) throws IntrospectionException {
- // determine constructor if one is not annotated
- JavaConstructorImpl<?> definition = type.getConstructor();
- Constructor constructor;
- boolean explict = false;
- if (definition != null && definition.getConstructor()
- .isAnnotationPresent(org.oasisopen.sca.annotation.Constructor.class)) {
- // the constructor was already defined explicitly
- return;
- } else if (definition != null) {
- explict = true;
- constructor = definition.getConstructor();
- } else {
- // no definition, heuristically determine constructor
- Constructor[] constructors = clazz.getConstructors();
- if (constructors.length == 0) {
- throw new NoConstructorException("No public constructor for class");
- } else if (constructors.length == 1) {
- // Only one constructor, take it
- constructor = constructors[0];
- } else {
- Constructor<T> selected = null;
- for (Constructor<T> ctor : constructors) {
- if (allArgsAnnotated(ctor)) {
- selected = ctor;
- for (Constructor<T> ctor2 : constructors) {
- if (selected != ctor2 && allArgsAnnotated(ctor2)) {
- throw new InvalidConstructorException("Multiple annotated constructors");
- }
- }
- }
- }
- if (selected == null) {
- for (Constructor<T> ctor : constructors) {
- if (ctor.getParameterTypes().length == 0) {
- selected = ctor;
- break;
- }
- }
- }
- if (selected == null) {
- throw new NoConstructorException();
- }
- constructor = selected;
- definition = type.getConstructors().get(selected);
- type.setConstructor(definition);
- }
- definition = type.getConstructors().get(constructor);
- type.setConstructor(definition);
- }
- JavaParameterImpl[] parameters = definition.getParameters();
- if (parameters.length == 0) {
- return;
- }
- Map<String, JavaElementImpl> props = type.getPropertyMembers();
- Map<String, JavaElementImpl> refs = type.getReferenceMembers();
- Annotation[][] annotations = constructor.getParameterAnnotations();
- if (!explict) {
- // the constructor wasn't defined by an annotation, so check to see
- // if any of the params have an annotation
- // which we can impute as explicitly defining the constructor, e.g.
- // @Property, @Reference, or @Autowire
- explict = injectionAnnotationsPresent(annotations);
- }
- if (explict) {
- for (int i = 0; i < parameters.length; i++) {
- if (isAnnotated(parameters[i])) {
- continue;
- } else if (!findReferenceOrProperty(parameters[i], props, refs)) {
- throw new AmbiguousConstructorException(parameters[i].toString());
- }
- }
- } else {
- if (!areUnique(parameters)) {
- throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
- }
- if (!calcPropRefUniqueness(props.values(), refs.values())) {
- throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
- }
- if (!(props.isEmpty() && refs.isEmpty())) {
- calcParamNames(parameters, props, refs);
- } else {
- heuristicParamNames(type, parameters);
-
- }
- }
- }
-
- private boolean allArgsAnnotated(Constructor<?> ctor) {
- if (ctor.getParameterTypes().length < 1) {
- return false;
- }
- for (Annotation[] as : ctor.getParameterAnnotations()) {
- if (as.length < 1) {
- return false;
- }
- }
- return true;
- }
-
- private void calcParamNames(JavaParameterImpl[] parameters,
- Map<String, JavaElementImpl> props,
- Map<String, JavaElementImpl> refs) throws AmbiguousConstructorException {
- // the constructor param types must unambiguously match defined
- // reference or property types
- for (JavaParameterImpl param : parameters) {
- if (!findReferenceOrProperty(param, props, refs)) {
- throw new AmbiguousConstructorException(param.getName());
- }
- }
- }
-
- private void heuristicParamNames(JavaImplementation type, JavaParameterImpl[] parameters)
- throws IntrospectionException {
- // heuristically determine refs and props from the parameter types
- for (JavaParameterImpl p : parameters) {
- String name = p.getType().getSimpleName().toLowerCase();
- if (isReferenceType(p.getType(), p.getGenericType())) {
- type.getReferences().add(createReference(name, p.getType()));
- p.setClassifer(Reference.class);
- type.getReferenceMembers().put(name, p);
- } else {
- type.getProperties().add(createProperty(name, p.getType()));
- p.setClassifer(Property.class);
- type.getPropertyMembers().put(name, p);
- }
- p.setName(name);
- }
- }
-
-
-
- /**
- * Returns true if the union of the given collections of properties and
- * references have unique Java types
- */
- private boolean calcPropRefUniqueness(Collection<JavaElementImpl> props, Collection<JavaElementImpl> refs) {
-
- Class<?>[] classes = new Class[props.size() + refs.size()];
- int i = 0;
- for (JavaElementImpl property : props) {
- classes[i] = property.getType();
- i++;
- }
- for (JavaElementImpl reference : refs) {
- classes[i] = reference.getType();
- i++;
- }
- return areUnique(classes);
- }
-
- /**
- * Unambiguously finds the reference or property associated with the given
- * type
- *
- * @return the name of the reference or property if found, null if not
- * @throws AmbiguousConstructorException if the constructor parameter cannot
- * be resolved to a property or reference
- */
- private boolean findReferenceOrProperty(JavaParameterImpl parameter,
- Map<String, JavaElementImpl> props,
- Map<String, JavaElementImpl> refs) throws AmbiguousConstructorException {
-
- boolean found = false;
- if (!"".equals(parameter.getName())) {
- // Match by name
- JavaElementImpl prop = props.get(parameter.getName());
- if (prop != null && prop.getType() == parameter.getType()) {
- parameter.setClassifer(Property.class);
- return true;
- }
- JavaElementImpl ref = refs.get(parameter.getName());
- if (ref != null && ref.getType() == parameter.getType()) {
- parameter.setClassifer(Reference.class);
- return true;
- }
- }
- for (JavaElementImpl property : props.values()) {
- if (property.getType() == parameter.getType()) {
- if (found) {
- throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type",
- (Member)parameter.getAnchor());
- }
- parameter.setClassifer(Property.class);
- parameter.setName(property.getName());
- found = true;
- // do not break since ambiguities must be checked, i.e. more
- // than one prop or ref of the same type
- }
- }
- for (JavaElementImpl reference : refs.values()) {
- if (reference.getType() == parameter.getType()) {
- if (found) {
- throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type",
- (Member)parameter.getAnchor());
- }
- parameter.setClassifer(Reference.class);
- parameter.setName(reference.getName());
- found = true;
- // do not break since ambiguities must be checked, i.e. more
- // than one prop or ref of the same type
- }
- }
- return found;
- }
-
- /**
- * Creates a mapped property.
- *
- * @param name the property name
- * @param paramType the property type
- */
- private org.apache.tuscany.sca.assembly.Property createProperty(String name, Class<?> paramType) {
- org.apache.tuscany.sca.assembly.Property property = assemblyFactory.createProperty();
- property.setName(name);
- property.setXSDType(JavaXMLMapper.getXMLType(paramType));
- return property;
- }
-
- private org.apache.tuscany.sca.assembly.Reference createReference(String name, Class<?> paramType)
- throws IntrospectionException {
- org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
- reference.setName(name);
- JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- reference.setInterfaceContract(interfaceContract);
- try {
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
- reference.getInterfaceContract().setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
- reference.getInterfaceContract().setCallbackInterface(callbackInterface);
- }
- reference.setMultiplicity(Multiplicity.ZERO_ONE);
- } catch (InvalidInterfaceException e1) {
- throw new IntrospectionException(e1);
- }
-
- // FIXME: This part seems to have already been taken care above!!
- try {
- processCallback(paramType, reference);
- } catch (InvalidServiceTypeException e) {
- throw new IntrospectionException(e);
- }
- return reference;
- }
-
- private org.apache.tuscany.sca.assembly.Service createService(Class<?> interfaze) throws InvalidInterfaceException {
- org.apache.tuscany.sca.assembly.Service service = assemblyFactory.createService();
- service.setName(interfaze.getSimpleName());
-
- JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- service.setInterfaceContract(interfaceContract);
-
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
- service.getInterfaceContract().setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
- service.getInterfaceContract().setCallbackInterface(callbackInterface);
- }
-
- Interface javaInterface = service.getInterfaceContract().getInterface();
- javaInterface.setRemotable(interfaze.getAnnotation(Remotable.class) != null);
- service.getInterfaceContract().setInterface(javaInterface);
- return service;
- }
-
- private void processCallback(Class<?> interfaze, Contract contract) throws InvalidServiceTypeException {
- Callback callback = interfaze.getAnnotation(Callback.class);
- if (callback != null && !Void.class.equals(callback.value())) {
- Class<?> callbackClass = callback.value();
- JavaInterface javaInterface;
- try {
- javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass);
- contract.getInterfaceContract().setCallbackInterface(javaInterface);
- } catch (InvalidInterfaceException e) {
- throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze);
- }
- } else if (callback != null && Void.class.equals(callback.value())) {
- throw new InvalidServiceTypeException("No callback interface specified on annotation", interfaze);
- }
- }
-
-
- /**
- * Utility methods
- */
-
-
- /**
- * Verify if the method is a public setter
- * @param method
- * @return
- */
- private static boolean isPublicSetter(Method method) {
- return method.getParameterTypes().length == 1 && Modifier.isPublic(method.getModifiers())
- && method.getName().startsWith("set")
- && method.getReturnType() == void.class;
- }
-
- /**
- * Verify if the method is a protected setter
- * @param method
- * @return
- */
- private static boolean isProtectedSetter(Method method) {
- return method.getParameterTypes().length == 1 && Modifier.isProtected(method.getModifiers())
- && method.getName().startsWith("set")
- && method.getReturnType() == void.class;
- }
-
- /**
- * @param collection
- * @return
- */
- private static boolean areUnique(Class<?>[] collection) {
- Set<Class<?>> set = new HashSet<Class<?>>(Arrays.asList(collection));
- return set.size() == collection.length;
- }
-
- /**
- * Returns true if a given type is reference according to the SCA
- * specification rules for determining reference types The following rules
- * are used to determine whether an unannotated field or setter method is a
- * property or reference:
- * <ol>
- * <li>If its type is simple, then it is a property.
- * <li>If its type is complex, then if the type is an interface marked by
- *
- * @Remotable, then it is a reference; otherwise, it is a property.
- * <li>Otherwise, if the type associated with the member is an
- * array or a java.util.Collection, the basetype is the element
- * type of the array or the parameterized type of the
- * Collection; otherwise the basetype is the member type. If the
- * basetype is an interface with an
- * @Remotable or
- * @Service annotation then the member is defined as a reference. Otherwise,
- * it is defined as a property.
- * </ol>
- * <p>
- * The name of the reference or of the property is derived from the
- * name found on the setter method or on the field.
- */
- private static boolean isReferenceType(Class<?> cls, Type genericType) {
- Class<?> baseType = JavaIntrospectionHelper.getBaseType(cls, genericType);
- return baseType.isInterface() && baseType.isAnnotationPresent(Remotable.class);
- }
-
- /**
- * Returns true if the given operation is defined in the collection of
- * service interfaces
- * @param operation
- * @param services
- * @return
- */
- private static boolean isInServiceInterface(Method operation, List<org.apache.tuscany.sca.assembly.Service> services) {
- for (org.apache.tuscany.sca.assembly.Service service : services) {
- Interface interface1 = service.getInterfaceContract().getInterface();
- if (interface1 instanceof JavaInterface) {
- Class<?> clazz = ((JavaInterface)interface1).getJavaClass();
- if (isMethodMatched(clazz, operation)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Test if the class declares a method which matches the signature of the
- * given method
- *
- * @param clazz
- * @param method
- * @return
- */
- private static boolean isMethodMatched(Class<?> clazz, Method method) {
- if (method.getDeclaringClass() == clazz) {
- return true;
- }
- Method[] methods = clazz.getMethods();
- for (Method m : methods) {
- if (JavaIntrospectionHelper.exactMethodMatch(method, m)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Verify if there is any SCA annotation on the parameter
- * @param parameter
- * @return
- */
- private static boolean isAnnotated(JavaParameterImpl parameter) {
- for (Annotation annotation : parameter.getAnnotations()) {
- Class<? extends Annotation> annotType = annotation.annotationType();
- if (annotType.equals(Property.class) || annotType.equals(Reference.class)
- || annotType.equals(Resource.class)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Verify if the parameters are unique
- * @param parameters
- * @return
- */
- private static boolean areUnique(JavaParameterImpl[] parameters) {
- Set<Class<?>> set = new HashSet<Class<?>>(parameters.length);
- for (JavaParameterImpl p : parameters) {
- if (!set.add(p.getType())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Verify if the annotations are SCA annotation
- * @param annots
- * @return
- */
- private static boolean injectionAnnotationsPresent(Annotation[][] annots) {
- for (Annotation[] annotations : annots) {
- for (Annotation annotation : annotations) {
- Class<? extends Annotation> annotType = annotation.annotationType();
- if (annotType.equals(Property.class) || annotType.equals(Reference.class)
- || annotType.equals(Resource.class)) {
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java
deleted file mode 100644
index badd41fbb9..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal use of {@link org.oasisopen.sca.annotation.Callback} on a reference
- *
- * @version $Rev$ $Date$
- */
-public class IllegalCallbackReferenceException extends IntrospectionException {
- private static final long serialVersionUID = -8932525723147700591L;
-
- public IllegalCallbackReferenceException(String message) {
- super(message);
- }
-
- public IllegalCallbackReferenceException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java
deleted file mode 100644
index fa1e67a336..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal signature for a method decorated with {@link org.oasisopen.sca.annotation.Context}
- *
- * @version $Rev$ $Date$
- */
-public class IllegalContextException extends IntrospectionException {
- private static final long serialVersionUID = -6946383136750117008L;
-
- public IllegalContextException(String message) {
- super(message);
- }
-
- public IllegalContextException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java
deleted file mode 100644
index 0c4c3d5646..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal signature for a method decorated with {@link org.oasisopen.sca.annotation.Destroy}
- *
- * @version $Rev$ $Date$
- */
-public class IllegalDestructorException extends IntrospectionException {
- private static final long serialVersionUID = 365719353107446326L;
-
- public IllegalDestructorException(String message) {
- super(message);
- }
-
- public IllegalDestructorException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java
deleted file mode 100644
index 2956b60b65..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal signature for a method decorated with {@link @org.oasisopen.sca.annotation.Init}
- *
- * @version $Rev$ $Date$
- */
-public class IllegalInitException extends IntrospectionException {
- private static final long serialVersionUID = -3690763271986854701L;
-
- public IllegalInitException(String message) {
- super(message);
- }
-
- public IllegalInitException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java
deleted file mode 100644
index 54f7dfad1e..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal property definition in a component type
- *
- * @version $Rev$ $Date$
- */
-public class IllegalPropertyException extends IntrospectionException {
- private static final long serialVersionUID = -2836849110706758494L;
-
- public IllegalPropertyException(String message) {
- super(message);
- }
-
- public IllegalPropertyException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java
deleted file mode 100644
index 25196c56e5..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal reference definition in a component type
- *
- * @version $Rev$ $Date$
- */
-public class IllegalReferenceException extends IntrospectionException {
- private static final long serialVersionUID = 4612984122225271395L;
-
- public IllegalReferenceException(String message) {
- super(message);
- }
-
- public IllegalReferenceException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java
deleted file mode 100644
index ccfbaf0043..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal resource definition in a component type
- *
- * @version $Rev$ $Date$
- */
-public class IllegalResourceException extends IntrospectionException {
- private static final long serialVersionUID = -1100936539412435579L;
-
- public IllegalResourceException(String message) {
- super(message);
- }
-
- public IllegalResourceException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java
deleted file mode 100644
index e0f90779a1..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an illegal use of the {@link @org.oasisopen.sca.annotation.Service} annotation
- *
- * @version $Rev$ $Date$
- */
-public class IllegalServiceDefinitionException extends IntrospectionException {
- private static final long serialVersionUID = -7151534258405092548L;
-
- public IllegalServiceDefinitionException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
deleted file mode 100644
index 8d67236fe2..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.oasisopen.sca.annotation.Init;
-
-/**
- * Processes the {@link @Init} annotation on a component implementation and
- * updates the component type with the decorated initializer method
- *
- * @version $Rev$ $Date$
- */
-public class InitProcessor extends BaseJavaClassVisitor {
-
- public InitProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public InitProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- Init annotation = method.getAnnotation(Init.class);
- if (annotation == null) {
- return;
- }
- if (method.getParameterTypes().length != 0) {
- throw new IllegalInitException("Initializer must not have argments", method);
- }
- if(!method.getReturnType().equals(void.class)) {
- throw new IllegalInitException("Initializer must return void.", method);
- }
- if (type.getInitMethod() != null) {
- throw new DuplicateInitException("More than one initializer found on implementaton");
- }
- if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalInitException("Initializer must be a public method. Invalid annotation @Init found on "+method);
- }
- type.setInitMethod(method);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java
deleted file mode 100644
index c75dfdaf46..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an invalid constructor definition, e.g. when the number of injection names specified in {@link
- * org.oasisopen.sca.annotation.Constructor} do not match the number of actual constructor parameters
- *
- * @version $Rev$ $Date$
- */
-public class InvalidConstructorException extends IntrospectionException {
- private static final long serialVersionUID = 1411492435210741512L;
-
- public InvalidConstructorException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java
deleted file mode 100644
index 079495e4db..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Raised when an implementation specifies improper conversational metadata
- *
- * @version $Rev$ $Date$
- */
-public class InvalidConversationalImplementationException extends IntrospectionException {
- private static final long serialVersionUID = -5487291552769408149L;
-
- public InvalidConversationalImplementationException(String message) {
- super(message);
- }
-
- public InvalidConversationalImplementationException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java
deleted file mode 100644
index 429b88aa1f..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an invalid usage of {@link org.oasisopen.sca.annotation.Property}
- *
- * @version $Rev$ $Date$
- */
-public class InvalidPropertyException extends IntrospectionException {
- private static final long serialVersionUID = -2682862652069727948L;
-
- public InvalidPropertyException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java
deleted file mode 100644
index fbf3fc9ed3..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an invalid usage of {@link org.oasisopen.sca.annotation.Reference}
- *
- * @version $Rev$ $Date$
- */
-public class InvalidReferenceException extends IntrospectionException {
- private static final long serialVersionUID = -3285246635989254165L;
-
- public InvalidReferenceException(String message) {
- super(message);
- }
-
- public InvalidReferenceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidReferenceException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java
deleted file mode 100644
index debb5cbacc..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Member;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Denotes an invalid usage of {@link @org.apache.tuscany.api.annotation.Resource}
- *
- * @version $Rev$ $Date$
- */
-public class InvalidResourceException extends IntrospectionException {
- private static final long serialVersionUID = 511728001735534934L;
-
- public InvalidResourceException(String message) {
- super(message);
- }
-
- public InvalidResourceException(String message, Member member) {
- super(message, member);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java
deleted file mode 100644
index 230c8c6fdd..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when a service type specified by an {@link org.oasisopen.sca.annotation.Service} annotation is invalid, e.g. it is
- * not an interface
- *
- * @version $Rev$ $Date$
- */
-public class InvalidServiceTypeException extends IntrospectionException {
- private static final long serialVersionUID = -1076466639416644386L;
- private Class<?> serviceType;
-
- public InvalidServiceTypeException(String message) {
- super(message);
- }
-
- public InvalidServiceTypeException(String message, Class<?> clazz) {
- super(message);
- this.serviceType = clazz;
- }
-
- /**
- * @return the serviceType
- */
- public Class<?> getServiceType() {
- return serviceType;
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java
deleted file mode 100644
index 453cfa35fe..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when a suitable constructor for a component implementation cannot be found
- *
- * @version $Rev$ $Date$
- */
-public class NoConstructorException extends IntrospectionException {
- private static final long serialVersionUID = 3086706387280694424L;
-
- public NoConstructorException() {
- }
-
- public NoConstructorException(String message) {
- super(message);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
deleted file mode 100644
index 79a0adac88..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Reference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySubject;
-import org.oasisopen.sca.ServiceRuntimeException;
-import org.oasisopen.sca.annotation.PolicySets;
-import org.oasisopen.sca.annotation.Qualifier;
-import org.oasisopen.sca.annotation.Requires;
-
-/**
- * Processes an {@link org.oasisopen.sca.annotation.Requires} annotation
- *
- * @version $Rev$ $Date$
- */
-public class PolicyProcessor extends BaseJavaClassVisitor {
-
- private PolicyFactory policyFactory;
-
- public PolicyProcessor(AssemblyFactory assemblyFactory,
- PolicyFactory policyFactory,
- JavaInterfaceFactory javaInterfaceFactory) {
- super(assemblyFactory);
- this.policyFactory = policyFactory;
- this.javaInterfaceFactory = javaInterfaceFactory;
- }
-
- public PolicyProcessor(ExtensionPointRegistry registry) {
- super(registry);
- FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- this.policyFactory = factories.getFactory(PolicyFactory.class);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
-
- // Read intents on the Java implementation class
- readPolicySetAndIntents((PolicySubject)type, clazz);
-
- /*
- // FIXME: [rfeng] We might want to refactor this out
- // Find the business methods in the implementation class for all services
- Set<Method> methods = new HashSet<Method>();
- for (Service service : type.getServices()) {
- for (Operation op : service.getInterfaceContract().getInterface().getOperations()) {
- Method method;
- try {
- method = JavaInterfaceUtil.findMethod(clazz, op);
- } catch (NoSuchMethodException e1) {
- throw new IntrospectionException(e1);
- }
- if (method != null) {
- methods.add(method);
- }
- }
- }
- for (Method method : methods) {
- JavaOperation op = javaInterfaceFactory.createJavaOperation(method);
- type.getOperations().add(op);
- }
-
- // Read the operation-level policy settings for the implementation
- for (Operation op : type.getOperations()) {
- JavaOperation operation = (JavaOperation)op;
- PolicySubject subject = op;
- Method method = operation.getJavaMethod();
- if (subject != null) {
- readPolicySetAndIntents(subject, method);
- }
- }
- */
-
- // Start to process annotations on the reference members
- Map<String, Reference> referenceMap = new HashMap<String, Reference>();
- for (Reference ref : type.getReferences()) {
- referenceMap.put(ref.getName(), ref);
- }
- Map<String, JavaElementImpl> members = type.getReferenceMembers();
- for (Map.Entry<String, JavaElementImpl> e : members.entrySet()) {
- Reference reference = referenceMap.get(e.getKey());
- readPolicySetAndIntents(reference, e.getValue().getAnchor());
- }
-
- }
-
- private void readPolicySetAndIntents(PolicySubject subject, AnnotatedElement element) {
- readIntents(element.getAnnotation(Requires.class), subject.getRequiredIntents());
- readSpecificIntents(element.getAnnotations(), subject.getRequiredIntents());
- readPolicySets(element.getAnnotation(PolicySets.class), subject.getPolicySets());
- }
-
- private void readPolicySetAndIntents(PolicySubject subject, JavaElementImpl element) {
- readIntents(element.getAnnotation(Requires.class), subject.getRequiredIntents());
- readSpecificIntents(element.getAnnotations(), subject.getRequiredIntents());
- readPolicySets(element.getAnnotation(PolicySets.class), subject.getPolicySets());
- }
-
- private void readSpecificIntents(Annotation[] annotations, List<Intent> requiredIntents) {
- for (Annotation a : annotations) {
- org.oasisopen.sca.annotation.Intent intentAnnotation =
- a.annotationType().getAnnotation(org.oasisopen.sca.annotation.Intent.class);
- if (intentAnnotation == null) {
- continue;
- }
- QName qname = null;
- String value = intentAnnotation.value();
- if (!value.equals("")) {
- qname = getQName(value);
- } else {
- qname = new QName(intentAnnotation.targetNamespace(), intentAnnotation.localPart());
- }
- Set<String> qualifiers = new HashSet<String>();
- for (Method m : a.annotationType().getMethods()) {
- Qualifier qualifier = m.getAnnotation(Qualifier.class);
- if (qualifier != null && m.getReturnType() == String[].class) {
- try {
- qualifiers.addAll(Arrays.asList((String[])m.invoke(a)));
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
- qualifiers.remove("");
- if (qualifiers.isEmpty()) {
- Intent intent = policyFactory.createIntent();
- intent.setUnresolved(true);
- intent.setName(qname);
- requiredIntents.add(intent);
- } else {
- for (String q : qualifiers) {
- Intent intent = policyFactory.createIntent();
- intent.setUnresolved(true);
- qname = new QName(qname.getNamespaceURI(), qname.getLocalPart() + "." + q);
- intent.setName(qname);
- requiredIntents.add(intent);
- }
- }
- }
- }
-
- /**
- * Read intent annotations on the given interface or class
- * @param intentAnnotation
- * @param requiredIntents
- */
- private void readIntents(Requires intentAnnotation, List<Intent> requiredIntents) {
- //Requires intentAnnotation = method.getAnnotation(Requires.class);
- if (intentAnnotation != null) {
- String[] intentNames = intentAnnotation.value();
- if (intentNames.length != 0) {
- //Operation operation = assemblyFactory.createOperation();
- //operation.setName(method.getName());
- //operation.setUnresolved(true);
- for (String intentName : intentNames) {
-
- // Add each intent to the list, associated with the
- // operation corresponding to the annotated method
- Intent intent = policyFactory.createIntent();
- intent.setName(getQName(intentName));
- //intent.getOperations().add(operation);
- requiredIntents.add(intent);
- }
- }
- }
- }
-
- /**
- * Read policy set annotations on a given interface or class
- * @param policySetAnnotation
- * @param policySets
- */
- private void readPolicySets(PolicySets policySetAnnotation, List<PolicySet> policySets) {
- if (policySetAnnotation != null) {
- String[] policySetNames = policySetAnnotation.value();
- if (policySetNames.length != 0) {
- //Operation operation = assemblyFactory.createOperation();
- //operation.setName(method.getName());
- //operation.setUnresolved(true);
- for (String policySetName : policySetNames) {
- // Add each intent to the list, associated with the
- // operation corresponding to the annotated method
- PolicySet policySet = policyFactory.createPolicySet();
- policySet.setName(getQName(policySetName));
- //intent.getOperations().add(operation);
- policySets.add(policySet);
- }
- }
- }
- }
-
- /**
- * Utility methods
- */
-
- /**
- *
- * @param intentName
- * @return
- */
- private static QName getQName(String intentName) {
- QName qname;
- if (intentName.startsWith("{")) {
- int i = intentName.indexOf('}');
- if (i != -1) {
- qname = new QName(intentName.substring(1, i), intentName.substring(i + 1));
- } else {
- qname = new QName("", intentName);
- }
- } else {
- qname = new QName("", intentName);
- }
- return qname;
- }
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
- // Check if a field that is not an SCA reference has any policySet/intent annotations
- JavaElementImpl element = new JavaElementImpl(field);
- if (!type.getReferenceMembers().values().contains(element)) {
- PolicySubject subject = assemblyFactory.createComponent();
- readPolicySetAndIntents(subject, field);
- if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
- return;
- }
- throw new ServiceRuntimeException(
- "Field that is not an SCA reference cannot have policySet/intent annotations: " + field);
- }
- }
-
- @Override
- public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type) {
- if (!type.getReferenceMembers().values().contains(parameter)) {
- PolicySubject subject = assemblyFactory.createComponent();
- readPolicySetAndIntents(subject, parameter);
- if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
- return;
- }
- throw new ServiceRuntimeException(
- "Constructor parameter that is not an SCA reference cannot have policySet/intent annotations: " + parameter);
- }
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- Set<AnnotatedElement> annotatedElements = new HashSet<AnnotatedElement>();
- for (JavaElementImpl element : type.getReferenceMembers().values()) {
- annotatedElements.add(element.getAnchor());
- }
- // Check if a field that is not an SCA reference has any policySet/intent annotations
- if (!annotatedElements.contains(method)) {
- PolicySubject subject = assemblyFactory.createComponent();
- readPolicySetAndIntents(subject, method);
- if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
- return;
- }
- throw new ServiceRuntimeException(
- "Method that is not an SCA reference cannot have policySet/intent annotations: " + method);
- }
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
deleted file mode 100644
index ed68be20b4..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.oasisopen.sca.annotation.Property;
-
-/**
- * Processes an {@link @Property} annotation, updating the component type with
- * corresponding {@link JavaMappedProperty}
- *
- * @version $Rev$ $Date$
- */
-public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
-
- public PropertyProcessor(ExtensionPointRegistry registry) {
- super(registry, Property.class);
- }
-
- @Override
- protected String getName(Property annotation) {
- return annotation.name();
- }
-
- @Override
- protected void initProperty(org.apache.tuscany.sca.assembly.Property property, Property annotation) {
- property.setMustSupply(annotation.required());
- }
-
- @Override
- protected boolean getRequired(Property annotation) {
- return annotation.required();
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
deleted file mode 100644
index d30ac074af..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getBaseType;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.annotation.Reference;
-
-/**
- * Processes an {@link @Reference} annotation, updating the component type with
- * corresponding {@link
- * org.apache.tuscany.spi.implementation.java.JavaMappedReference}
- *
- * @version $Rev$ $Date$
- */
-public class ReferenceProcessor extends BaseJavaClassVisitor {
-
- public ReferenceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
- super(assemblyFactory);
- this.javaInterfaceFactory = javaFactory;
- }
-
- public ReferenceProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- Reference annotation = method.getAnnotation(Reference.class);
- if (annotation != null) {
-
- if (!JavaIntrospectionHelper.isSetter(method)) {
- throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
- }
-
- if(Modifier.isStatic(method.getModifiers())) {
- throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Reference");
- }
-
- String name = annotation.name();
- if ("".equals(name)) {
- name = JavaIntrospectionHelper.toPropertyName(method.getName());
- }
- JavaElementImpl ref = type.getReferenceMembers().get(name);
- // Setter override field
- if (ref != null && ref.getElementType() != ElementType.FIELD) {
- throw new DuplicateReferenceException(name);
- }
- removeReference(ref, type);
-
- JavaElementImpl element = new JavaElementImpl(method, 0);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
- type.getReferences().add(reference);
- type.getReferenceMembers().put(name, element);
- }
-
- // enforce the constraint that an ordinary method's argument can not be a reference
- Annotation paramsAnnotations[][] = method.getParameterAnnotations();
- for (int i = 0; i < paramsAnnotations.length; i++) {
- Annotation argAnnotations[] = paramsAnnotations[i];
- for (int j = 0; j < argAnnotations.length; j++) {
- if(argAnnotations[j].annotationType() == Reference.class) {
- throw new IllegalReferenceException("Argument " + (i+1) + " of method " + method.getName() + " in class " + method.getDeclaringClass() + " can not be a Reference");
- }
- }
- }
- }
-
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
- Reference annotation = field.getAnnotation(Reference.class);
- if (annotation == null) {
- return;
- }
-
- if(Modifier.isStatic(field.getModifiers())) {
- throw new IllegalReferenceException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as Reference");
- }
- String name = annotation.name();
- if ("".equals(name)) {
- name = field.getName();
- }
- JavaElementImpl ref = type.getReferenceMembers().get(name);
- if (ref != null && ref.getElementType() == ElementType.FIELD) {
- throw new DuplicateReferenceException(name);
- }
-
- // Setter method override field
- if (ref == null) {
- JavaElementImpl element = new JavaElementImpl(field);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
- type.getReferences().add(reference);
- type.getReferenceMembers().put(name, element);
- }
- }
-
- @Override
- public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
- throws IntrospectionException {
- Reference refAnnotation = parameter.getAnnotation(Reference.class);
- if (refAnnotation == null) {
- return;
- }
-
- if (!refAnnotation.required()) {
- throw new InvalidReferenceException("JCA90016 Constructor has @Reference with required=false: " + type.getName());
- }
-
- if (refAnnotation.name() == null || refAnnotation.name().length() < 1) {
- throw new InvalidReferenceException("JCA90018 @Reference in a Constructor must have a name attribute" + type.getName());
- }
-
- String paramName = parameter.getName();
- String name = getReferenceName(paramName, parameter.getIndex(), refAnnotation.name());
- JavaElementImpl ref = type.getReferenceMembers().get(name);
-
- // Setter override field
- if (ref != null && ref.getElementType() != ElementType.FIELD) {
- throw new DuplicateReferenceException(name);
- }
-
- removeReference(ref, type);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(parameter, name);
- type.getReferences().add(reference);
- type.getReferenceMembers().put(name, parameter);
- parameter.setClassifer(Reference.class);
- parameter.setName(name);
- }
-
- /**
- * Create a SCA reference for a java Element
- * @param element
- * @param name
- * @return
- * @throws IntrospectionException
- */
- private org.apache.tuscany.sca.assembly.Reference createReference(JavaElementImpl element, String name)
- throws IntrospectionException {
- org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
- JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- reference.setInterfaceContract(interfaceContract);
-
- // reference.setMember((Member)element.getAnchor());
- boolean required = true;
- Reference ref = element.getAnnotation(Reference.class);
- if (ref != null) {
- required = ref.required();
- }
- // reference.setRequired(required);
- reference.setName(name);
- Class<?> rawType = element.getType();
- if (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) {
- if (required) {
- reference.setMultiplicity(Multiplicity.ONE_N);
- } else {
- reference.setMultiplicity(Multiplicity.ZERO_N);
- }
- } else {
- if (required) {
- reference.setMultiplicity(Multiplicity.ONE_ONE);
- } else {
- reference.setMultiplicity(Multiplicity.ZERO_ONE);
- }
- }
- Type genericType = element.getGenericType();
- Class<?> baseType = getBaseType(rawType, genericType);
- if (ServiceReference.class.isAssignableFrom(baseType)) {
- if (Collection.class.isAssignableFrom(rawType)) {
- genericType = JavaIntrospectionHelper.getParameterType(genericType);
- }
- baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
- }
- try {
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(baseType);
- reference.getInterfaceContract().setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
- reference.getInterfaceContract().setCallbackInterface(callbackInterface);
- }
- } catch (InvalidInterfaceException e) {
- throw new IntrospectionException(e);
- }
- return reference;
- }
-
-
- /**
- * Utility methods
- */
-
- /**
- *
- * @param paramName
- * @param pos
- * @param name
- * @return
- * @throws InvalidConstructorException
- */
- private static String getReferenceName(String paramName, int pos, String name) throws InvalidConstructorException {
- if ("".equals(name)) {
- name = paramName;
- }
- if ("".equals(name)) {
- return "_ref" + pos;
- }
- if (!"".equals(paramName) && !name.equals(paramName)) {
- throw new InvalidConstructorException("Mismatching names specified for reference parameter " + pos);
- } else {
- return name;
- }
- }
-
- /**
- *
- * @param ref
- * @param type
- * @return
- */
- private static boolean removeReference(JavaElementImpl ref, JavaImplementation type) {
- if (ref == null) {
- return false;
- }
- List<org.apache.tuscany.sca.assembly.Reference> refs = type.getReferences();
- for (int i = 0; i < refs.size(); i++) {
- if (refs.get(i).getName().equals(ref.getName())) {
- refs.remove(i);
- return true;
- }
- }
- return false;
- }
-
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java
deleted file mode 100644
index 3d43e39ce8..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation used to indicate a resource should be provided to an implementation by the runtime.
- *
- * @version $Rev$ $Date$
- */
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Resource {
-
- /**
- * Denotes the name of the resource declared by the implementation.
- */
- String name() default "";
-
- /**
- * Denotes if the resource is optional
- */
- boolean optional() default false;
-
- /**
- * Denotes the default name of the resource provided by the runtime environment.
- */
- String mappedName() default "";
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
deleted file mode 100644
index 3abe832cb9..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
-import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-
-/**
- * Processes an {@link @Resource} annotation, updating the component type with
- * corresponding {@link org.apache.tuscany.spi.implementation.java.JavaResourceImpl}
- *
- * @version $Rev$ $Date$
- */
-public class ResourceProcessor extends BaseJavaClassVisitor {
-
- public ResourceProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public ResourceProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = method
- .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- if (annotation == null) {
- return;
- }
- if (method.getParameterTypes().length != 1) {
- throw new IllegalResourceException("Resource setter must have one parameter", method);
- }
- String name = annotation.name();
- if (name.length() < 1) {
- name = JavaIntrospectionHelper.toPropertyName(method.getName());
- }
- if (type.getResources().get(name) != null) {
- throw new DuplicateResourceException(name);
- }
-
- String mappedName = annotation.mappedName();
- JavaResourceImpl resource = createResource(name, new JavaElementImpl(method, 0));
- resource.setOptional(annotation.optional());
- if (mappedName.length() > 0) {
- resource.setMappedName(mappedName);
- }
- type.getResources().put(resource.getName(), resource);
- }
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
-
- org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = field
- .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- if (annotation == null) {
- return;
- }
- String name = annotation.name();
- if (name.length() < 1) {
- name = field.getName();
- }
- if (type.getResources().get(name) != null) {
- throw new DuplicateResourceException(name);
- }
-
- String mappedName = annotation.mappedName();
-
- JavaResourceImpl resource = createResource(name, new JavaElementImpl(field));
- resource.setOptional(annotation.optional());
- if (mappedName.length() > 0) {
- resource.setMappedName(mappedName);
- }
- type.getResources().put(resource.getName(), resource);
- }
-
- @Override
- public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
- throws IntrospectionException {
- org.apache.tuscany.sca.implementation.java.introspect.impl.Resource resourceAnnotation = parameter
- .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- if (resourceAnnotation != null) {
- String name = resourceAnnotation.name();
- if ("".equals(name)) {
- name = parameter.getName();
- }
- if ("".equals(name)) {
- throw new InvalidResourceException("Missing resource name", (Member)parameter.getAnchor());
- }
-
- if (!"".equals(parameter.getName()) && !name.equals(parameter.getName())) {
- throw new InvalidConstructorException("Mismatched resource name: " + parameter);
- }
-
- if (type.getResources().get(name) != null) {
- throw new DuplicateResourceException(name);
- }
-
- String mappedName = resourceAnnotation.mappedName();
-
- JavaResourceImpl resource = createResource(name, parameter);
- resource.setOptional(resourceAnnotation.optional());
- if (mappedName.length() > 0) {
- resource.setMappedName(mappedName);
- }
- type.getResources().put(resource.getName(), resource);
- }
- }
-
-
- /**
- * Utility methods
- */
-
- /**
- *
- * @param name
- * @param element
- * @return
- */
- private static JavaResourceImpl createResource(String name, JavaElementImpl element) {
- element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
- element.setName(name);
- return new JavaResourceImpl(element);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
deleted file mode 100644
index dfc122c715..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-
-/**
- * Processes the {@link JavaScopeImpl} annotation and updates the component type with the corresponding implmentation scope
- *
- * @version $Rev$ $Date$
- */
-public class ScopeProcessor extends BaseJavaClassVisitor {
-
- public ScopeProcessor(AssemblyFactory factory) {
- super(factory);
- }
-
- public ScopeProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz,
- JavaImplementation type)
- throws IntrospectionException {
- org.oasisopen.sca.annotation.Scope annotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Scope.class);
- if (annotation == null) {
- type.setJavaScope(JavaScopeImpl.STATELESS);
- return;
- }
-
- String name = annotation.value();
- JavaScopeImpl scope;
- if ("COMPOSITE".equals(name)) {
- scope = JavaScopeImpl.COMPOSITE;
- } else if ("STATELESS".equals(name)) {
- scope = JavaScopeImpl.STATELESS;
- } else {
- scope = JavaScopeImpl.INVALID;
- }
- type.setJavaScope(scope);
-
- if (type.getJavaScope().equals(JavaScopeImpl.INVALID)) {
- throw new IntrospectionException("Invalid scope :" + name + " for " + type.getName());
- }
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
deleted file mode 100644
index 30ed5dda44..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllInterfaces;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.jws.WebService;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-import org.apache.tuscany.sca.implementation.java.JavaImplementation;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.annotation.Callback;
-import org.oasisopen.sca.annotation.Remotable;
-
-/**
- * Processes an {@link org.oasisopen.sca.annotation.Service} annotation and updates
- * the component type with corresponding {@link Service}s. Also processes
- * related {@link org.oasisopen.sca.annotation.Callback} annotations.
- *
- * @version $Rev$ $Date$
- */
-public class ServiceProcessor extends BaseJavaClassVisitor {
-
- public ServiceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
- super(assemblyFactory);
- this.javaInterfaceFactory = javaFactory;
- }
-
- public ServiceProcessor(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
- org.oasisopen.sca.annotation.Service annotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class);
- if (annotation == null) {
- // scan interfaces for remotable
- Set<Class<?>> interfaces = getAllInterfaces(clazz);
- for (Class<?> interfaze : interfaces) {
- if (interfaze.isAnnotationPresent(Remotable.class)
- || interfaze.isAnnotationPresent(WebService.class)
- || interfaze.isAnnotationPresent(Callback.class)
- ) {
- Service service;
- try {
- service = createService(interfaze, null);
- } catch (InvalidInterfaceException e) {
- throw new IntrospectionException(e);
- }
- type.getServices().add(service);
- }
- }
- return;
- }
-
- if (annotation.value().length == 0) {
- throw new IntrospectionException("JCA90059 The array of interfaces or classes specified by the value attribute of the @Service annotation MUST contain at least one element");
- }
- Class<?>[] interfaces = annotation.value();
- if (annotation.names().length > 0) {
- if (annotation.names().length != interfaces.length) {
- throw new IntrospectionException("JCA90050 The number of Strings in the names attribute array of the @Service annotation MUST match the number of elements in the value attribute array");
- }
- Set<String> names = new HashSet<String>();
- names.addAll(Arrays.asList(annotation.names()));
- if (names.size() != annotation.names().length) {
- throw new IntrospectionException("JCA90060 The value of each element in the @Service names array MUST be unique amongst all the other element values in the array");
- }
- }
-
- //validate no scope on servce interface
- for (Class<?> iface : interfaces) {
- if (iface.getAnnotation(org.oasisopen.sca.annotation.Scope.class) != null) {
- throw new IntrospectionException("JCA90041 @Scope annotation not allowed on service interface " + iface
- .getName());
- }
- }
-
- //validate service methods implemented
- Method[] ms = clazz.getMethods();
- for (Class<?> iface : interfaces) {
- for (Method m : iface.getMethods()) {
- if (!hasMethod(m, ms)) {
- throw new IntrospectionException("JCA???? Implementation missing service method " + m.getName() + " service interface " + iface.getName());
- }
- }
- }
-
- for (int i=0; i < interfaces.length; i++) {
- try {
- String name = (annotation.names().length > 0) ? annotation.names()[i] : null;
- Service service = createService(interfaces[i], name);
- type.getServices().add(service);
- } catch (InvalidInterfaceException e) {
- throw new IntrospectionException(e);
- }
- }
- }
-
- protected boolean hasMethod(Method m1, Method[] ms) {
- for (Method m2 : ms) {
- if (JavaIntrospectionHelper.exactMethodMatch(m1, m2)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
-
- Callback annotation = method.getAnnotation(Callback.class);
- if (annotation == null) {
- return;
- }
-
- if (!(annotation.value() == null || annotation.value() == Void.class)) {
- throw new IllegalCallbackReferenceException("JCA90046 @Callback on field of method must not have any parameters: " + type.getName() + "." + method.getName());
- }
-
- if(Modifier.isPrivate(method.getModifiers())) {
- throw new IllegalCallbackReferenceException("Illegal annotation @Callback found on "+method, method);
- }
- if (method.getParameterTypes().length != 1) {
- throw new IllegalCallbackReferenceException("Setter must have one parameter", method);
- }
- JavaElementImpl element = new JavaElementImpl(method, 0);
- createCallback(type, element);
- }
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
-
- Callback annotation = field.getAnnotation(Callback.class);
- if (annotation == null) {
- return;
- }
- if (!(annotation.value() == null || annotation.value() == Void.class)) {
- throw new IllegalCallbackReferenceException("JCA90046 @Callback on field of method must not have any parameters: " + type.getName() + "." + field.getName());
- }
- if(Modifier.isPrivate(field.getModifiers())) {
- throw new IllegalCallbackReferenceException("Illegal annotation @Callback found on "+field, field);
- }
- JavaElementImpl element = new JavaElementImpl(field);
- createCallback(type, element);
- }
-
- public Service createService(Class<?> interfaze, String name) throws InvalidInterfaceException {
- Service service = assemblyFactory.createService();
- JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- service.setInterfaceContract(interfaceContract);
-
- if (name == null) {
- service.setName(interfaze.getSimpleName());
- } else {
- service.setName(name);
- }
-
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
- service.getInterfaceContract().setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
- service.getInterfaceContract().setCallbackInterface(callbackInterface);
- }
- return service;
- }
-
- /**
- * Utility methods
- */
-
-
- /**
- * @param type
- * @param element
- * @throws IllegalCallbackReferenceException
- */
- private static void createCallback(JavaImplementation type, JavaElementImpl element)
- throws IllegalCallbackReferenceException {
- Service callbackService = null;
- Class<?> callbackClass = element.getType();
- Type genericType = element.getGenericType();
- Class<?> baseType = callbackClass;
- if(ServiceReference.class.isAssignableFrom(baseType)) {
- // @Callback protected CallableReference<MyCallback> callback;
- // The base type will be MyCallback
- baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
- }
- for (Service service : type.getServices()) {
- JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getCallbackInterface();
- if (javaInterface != null && baseType == javaInterface.getJavaClass()) {
- callbackService = service;
- }
- }
- if (callbackService == null) {
- throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface: " + type.getName() );
- }
- if(type.getCallbackMembers().get(baseType.getName()) == null) {
- type.getCallbackMembers().put(baseType.getName(), new ArrayList<JavaElementImpl>());
- }
- type.getCallbackMembers().get(baseType.getName()).add(element);
- }
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java
deleted file mode 100644
index e1ca3ea565..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-import org.apache.tuscany.sca.implementation.java.IntrospectionException;
-
-/**
- * Thrown when a service interface cannot be determined based on a heuristic evaluation of an implementation
- *
- * @version $Rev$ $Date$
- */
-public class ServiceTypeNotFoundException extends IntrospectionException {
- private static final long serialVersionUID = -5124437274726947007L;
-
- public ServiceTypeNotFoundException(String message) {
- super(message);
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java
deleted file mode 100644
index bfaa759cd2..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.introspect.impl;
-
-/**
- * Thrown when a method or field marked with {@link org.oasisopen.sca.annotation.Context} takes an unknown type
- *
- * @version $Rev$ $Date$
- */
-public class UnknownContextTypeException extends IllegalContextException {
- private static final long serialVersionUID = 8125863714365422419L;
-
- public UnknownContextTypeException(String message) {
- super(message);
- }
-
-}