You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/11 04:55:07 UTC
svn commit: r527378 [4/9] - in /incubator/tuscany/java/sca/modules:
assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/
assembly-xml/src/main/java/org/apache/tuscany/assembly/xml/impl/
assembly-xml/src/test/java/org/apache/tuscany/assembly/xml/...
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+
+/**
+ * Implementations process class-level metadata, typically parsing annotations
+ * and updating the corresponding <code>ComponentType</code>. A processor
+ * may, for example, create a Property which is responsible for injecting a
+ * complex type on a component implementation instance when it is instantiated.
+ * <p/> Processors will receive callbacks as the implementation class is walked
+ * while evalauting an assembly. It is the responsibility of the parser to
+ * determine whether to perform an action during the callback.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaClassIntrospectorExtension {
+
+ /**
+ * A callback received when the component implementation class is first
+ * loaded
+ *
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation class hierarchy is
+ * evaluated
+ *
+ * @param clazz the superclass in the component implmentation's class
+ * hierarchy
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitSuperClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and
+ * protected methods are evaluated
+ *
+ * @param method the current public or protected method being evaluated
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's constructor used
+ * for instantiation by the runtime is evaluated. If an implementation
+ * contains more than one constructor, the constructor passed to the
+ * callback will be chosen according to the algorithm described in the SCA
+ * Java Client and Implementation Model Specification.
+ *
+ * @param constructor the constructor used for instantiating component
+ * implementation instances
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitConstructor(Constructor<T> constructor, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * @param parameter
+ * @param type
+ * @throws ProcessingException
+ */
+ void visitConstructorParameter(Parameter parameter, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and
+ * protected fields are evaluated
+ *
+ * @param field the current public or protected field being evaluated
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ void visitField(Field field, JavaImplementationDefinition type) throws ProcessingException;
+
+ /**
+ * The final callback received when all other callbacks during evaluation of
+ * the component implementation have been issued
+ *
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws ProcessingException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitEnd(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException;
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtension.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+/**
+ * A system service which tracks {@link JavaClassIntrospectorExtension}s
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaClassIntrospectorExtensionPoint extends JavaClassIntrospector {
+
+ /**
+ * Registers the given processor and makes it available during assembly evaluation (i.e. build)
+ */
+ void addExtension(JavaClassIntrospectorExtension processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void removeExtension(JavaClassIntrospectorExtension processor);
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/JavaClassIntrospectorExtensionPoint.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect;
+
+import java.lang.reflect.Member;
+
+/**
+ * Denotes a problem processing annotations on a POJO implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProcessingException extends Exception {
+ private static final long serialVersionUID = -361025119035104470L;
+ private Member member;
+
+ public ProcessingException() {
+ }
+
+ public ProcessingException(String message) {
+ super(message);
+ }
+
+ public ProcessingException(String message, Member member) {
+ super(message);
+ this.member = member;
+ }
+
+ public ProcessingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProcessingException(Throwable cause) {
+ super(cause);
+ }
+
+ public Member getMember() {
+ return member;
+ }
+
+ public void setMember(Member member) {
+ this.member = member;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/ProcessingException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.DuplicatePropertyException;
+import org.apache.tuscany.implementation.java.introspect.IllegalPropertyException;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.apache.tuscany.interfacedef.util.JavaXMLMapper;
+
+/**
+ * Base class for ImplementationProcessors that handle annotations that add
+ * Properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractPropertyProcessor<A extends Annotation> extends BaseJavaClassIntrospectorExtension {
+ private final Class<A> annotationClass;
+
+ protected AbstractPropertyProcessor(Class<A> annotationClass) {
+ this.annotationClass = annotationClass;
+ }
+
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ A annotation = method.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ if (!Void.TYPE.equals(method.getReturnType())) {
+ throw new IllegalPropertyException("Method does not have void return type", method);
+ }
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length != 1) {
+ throw new IllegalPropertyException("Method must have a single parameter", method);
+ }
+
+ String name = getName(annotation);
+ if (name == null || "".equals(name)) {
+ name = method.getName();
+ if (name.startsWith("set")) {
+ name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ }
+ }
+
+ Map<String, JavaElement> properties = type.getPropertyMembers();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ JavaElement element = new JavaElement(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);
+ }
+
+ public void visitField(Field field, JavaImplementationDefinition type) throws ProcessingException {
+
+ A annotation = field.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ String name = getName(annotation);
+ if (name == null) {
+ name = "";
+ }
+ if ("".equals(name) || name.equals(field.getType().getName())) {
+ name = field.getName();
+ }
+
+ Map<String, JavaElement> properties = type.getPropertyMembers();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ JavaElement element = new JavaElement(field);
+ Property property = createProperty(name, element);
+ initProperty(property, annotation);
+ type.getProperties().add(property);
+ properties.put(name, element);
+ }
+
+ public void visitConstructorParameter(Parameter parameter, JavaImplementationDefinition type)
+ throws ProcessingException {
+
+ Map<String, JavaElement> 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 (properties.containsKey(name)) {
+ throw new DuplicatePropertyException("Duplication property: " + name);
+ }
+ 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 void initProperty(Property property, A annotation) throws ProcessingException;
+
+ @SuppressWarnings("unchecked")
+ protected Property createProperty(String name, JavaElement element) throws ProcessingException {
+
+ Property property = factory.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;
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AbstractPropertyProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.osoa.sca.annotations.AllowsPassByReference;
+
+/**
+ * Processes {@link AllowsPassByReference} on an implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class AllowsPassByReferenceProcessor extends BaseJavaClassIntrospectorExtension {
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ type.setAllowsPassByReference(clazz.isAnnotationPresent(AllowsPassByReference.class));
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ boolean pbr = method.isAnnotationPresent(AllowsPassByReference.class);
+ if (pbr) {
+ type.getAllowsPassByReferenceMethods().add(method);
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when constructor parameters cannot be unambiguously resolved to a property or reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class AmbiguousConstructorException extends ProcessingException {
+ private static final long serialVersionUID = 3662860753837091880L;
+
+ public AmbiguousConstructorException(String message) {
+ super(message);
+ }
+
+ public AmbiguousConstructorException(String message, Member member) {
+ super(message, member);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/AmbiguousConstructorException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Handles processing of a constructor decorated with
+ * {@link org.osoa.sca.annotations.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings("unchecked")
+public class ConstructorProcessor extends BaseJavaClassIntrospectorExtension {
+
+ public ConstructorProcessor() {
+ }
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ Constructor[] ctors = clazz.getConstructors();
+ boolean found = false;
+ for (Constructor constructor : ctors) {
+ ConstructorDefinition<?> definition = new ConstructorDefinition(constructor);
+ type.getConstructors().put(constructor, definition);
+ if (constructor.getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) {
+ if (found) {
+ throw new DuplicateConstructorException("Multiple constructors marked with @Constructor", constructor);
+ }
+ found = true;
+ type.setConstructorDefinition(definition);
+ }
+ }
+ }
+
+ public <T> void visitConstructor(Constructor<T> constructor, JavaImplementationDefinition type)
+ throws ProcessingException {
+ org.osoa.sca.annotations.Constructor annotation = constructor
+ .getAnnotation(org.osoa.sca.annotations.Constructor.class);
+ if (annotation == null) {
+ return;
+ }
+ ConstructorDefinition<?> definition = type.getConstructorDefinition();
+ if (definition == null) {
+ definition = new ConstructorDefinition(constructor);
+ type.setConstructorDefinition(definition);
+ }
+ Parameter[] 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 Nubmer of names in @Constructor");
+ }
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i].setName(i < value.length ? value[i] : "");
+ }
+ type.setConstructorDefinition(definition);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConstructorProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Resource;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.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 BaseJavaClassIntrospectorExtension {
+
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ 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)) {
+ JavaElement element = new JavaElement(method, 0);
+ element.setName(name);
+ element.setClassifer(org.apache.tuscany.api.annotation.Resource.class);
+ Resource resource = new Resource(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new UnknownContextTypeException(paramType.getName());
+ }
+ }
+
+ public void visitField(Field field, JavaImplementationDefinition type) throws ProcessingException {
+ if (field.getAnnotation(Context.class) == null) {
+ return;
+ }
+ Class<?> paramType = field.getType();
+ if (ComponentContext.class.equals(paramType) || RequestContext.class.equals(paramType)) {
+ JavaElement element = new JavaElement(field);
+ element.setClassifer(org.apache.tuscany.api.annotation.Resource.class);
+ Resource resource = new Resource(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new UnknownContextTypeException(paramType.getName());
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ContextProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConversationProcessor extends BaseJavaClassIntrospectorExtension {
+ private static final String SECONDS = " SECONDS";
+ private static final String MINUTES = " MINUTES";
+ private static final String HOURS = " HOURS";
+ private static final String DAYS = " DAYS";
+ private static final String YEARS = " YEARS";
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+
+ ConversationAttributes conversation = clazz.getAnnotation(ConversationAttributes.class);
+ if (conversation == null) {
+ return;
+ }
+ Scope scope = clazz.getAnnotation(Scope.class);
+ if (scope == null) {
+ // implicitly assume conversation
+ type.setScope(org.apache.tuscany.implementation.java.impl.Scope.CONVERSATION);
+ } else if (scope != null && !"CONVERSATION".equals(scope.value().toUpperCase())) {
+ throw new InvalidConversationalImplementation(
+ "Service is marked with @ConversationAttributes but the scope is not @Scope(\"CONVERSATION\")"
+ );
+ } else if (conversation != null) {
+ long maxAge;
+ long maxIdleTime;
+ String maxAgeVal = conversation.maxAge();
+ String maxIdleTimeVal = conversation.maxIdleTime();
+ if (maxAgeVal.length() > 0 && maxIdleTimeVal.length() > 0) {
+ throw new InvalidConversationalImplementation("Max idle time and age both specified");
+ }
+ try {
+ if (maxAgeVal.length() > 0) {
+ maxAge = convertTimeMillis(maxAgeVal);
+ type.setMaxAge(maxAge);
+ }
+ } catch (NumberFormatException e) {
+ throw new InvalidConversationalImplementation("Invalid maximum age", e);
+ }
+ try {
+ if (maxIdleTimeVal.length() > 0) {
+ maxIdleTime = convertTimeMillis(maxIdleTimeVal);
+ type.setMaxIdleTime(maxIdleTime);
+ }
+ } catch (NumberFormatException e) {
+ throw new InvalidConversationalImplementation("Invalid maximum idle time", e);
+ }
+ }
+
+ }
+
+ public void visitMethod(Method method,
+ JavaImplementationDefinition type) throws ProcessingException {
+ ConversationID conversationID = method.getAnnotation(ConversationID.class);
+ if (conversationID == null) {
+ return;
+ }
+ type.setConversationIDMember(method);
+ }
+
+ public void visitField(Field field,
+ JavaImplementationDefinition type) throws ProcessingException {
+ ConversationID conversationID = field.getAnnotation(ConversationID.class);
+ if (conversationID == null) {
+ return;
+ }
+ type.setConversationIDMember(field);
+ }
+
+ protected long convertTimeMillis(String expr) throws NumberFormatException {
+ expr = expr.trim().toUpperCase();
+ int i = expr.lastIndexOf(SECONDS);
+ if (i >= 0) {
+ String units = expr.substring(0, i);
+ return Long.parseLong(units) * 1000;
+ }
+ i = expr.lastIndexOf(MINUTES);
+ if (i >= 0) {
+ String units = expr.substring(0, i);
+ return Long.parseLong(units) * 60000;
+ }
+
+ i = expr.lastIndexOf(HOURS);
+ if (i >= 0) {
+ String units = expr.substring(0, i);
+ return Long.parseLong(units) * 3600000;
+ }
+ i = expr.lastIndexOf(DAYS);
+ if (i >= 0) {
+ String units = expr.substring(0, i);
+ return Long.parseLong(units) * 86400000;
+ }
+ i = expr.lastIndexOf(YEARS);
+ if (i >= 0) {
+ String units = expr.substring(0, i);
+ return Long.parseLong(units) * 31556926000L;
+ }
+ return Long.parseLong(expr) * 1000; // assume seconds if no suffix
+ // specified
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/ConversationProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.osoa.sca.annotations.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 BaseJavaClassIntrospectorExtension {
+
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ 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 (type.getDestroyMethod() != null) {
+ throw new DuplicateDestructorException("More than one destructor found on implementation");
+ }
+ if (Modifier.isProtected(method.getModifiers())) {
+ method.setAccessible(true);
+ }
+ type.setDestroyMethod(method);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DestroyProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when more than one component implementation constructor is annotated with {@link
+ * org.osoa.sca.annotations.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateConstructorException extends ProcessingException {
+ private static final long serialVersionUID = -5926763756570552986L;
+
+ public DuplicateConstructorException(String message) {
+ super(message);
+ }
+
+ public DuplicateConstructorException(String message, Member member) {
+ super(message, member);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateConstructorException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link org.osoa.sca.annotations.Destroy}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateDestructorException extends ProcessingException {
+ private static final long serialVersionUID = -7474912510114895203L;
+
+ public DuplicateDestructorException(String message) {
+ super(message);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateDestructorException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link @org.osoa.sca.annotations.Init}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateInitException extends ProcessingException {
+ private static final long serialVersionUID = -6282935288115512057L;
+
+ public DuplicateInitException(String message) {
+ super(message);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateInitException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when an implementation has more than one reference injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateReferenceException extends ProcessingException {
+ private static final long serialVersionUID = 907910648213477158L;
+
+ public DuplicateReferenceException(String message) {
+ super(message);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateReferenceException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+
+/**
+ * Thrown when an implementation has more than one resource injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateResourceException extends ProcessingException {
+
+ private static final long serialVersionUID = 1619276459330463299L;
+
+ public DuplicateResourceException(String message) {
+ super(message);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/DuplicateResourceException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java?view=auto&rev=527378
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java Tue Apr 10 19:55:00 2007
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspect.impl;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.introspect.BaseJavaClassIntrospectorExtension;
+import org.apache.tuscany.implementation.java.introspect.ProcessingException;
+import org.osoa.sca.annotations.EagerInit;
+
+/**
+ * Handles processing of {@link org.osoa.sca.annotations.EagerInit}
+ *
+ * @version $Rev$ $Date$
+ */
+public class EagerInitProcessor extends BaseJavaClassIntrospectorExtension {
+
+ public <T> void visitClass(Class<T> clazz,
+ JavaImplementationDefinition type) throws ProcessingException {
+ 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);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspect/impl/EagerInitProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org