You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/04/04 05:32:03 UTC
svn commit: r525388 - in /incubator/tuscany/java/sca/modules: impl-java-xml/
impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/
impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/
Author: rfeng
Date: Tue Apr 3 20:32:02 2007
New Revision: 525388
URL: http://svn.apache.org/viewvc?view=rev&rev=525388
Log:
Add the base for java introspection and annotation processing
Added:
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java (with props)
incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java (with props)
incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java (with props)
incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java (with props)
incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java (with props)
incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java (with props)
incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java (with props)
Modified:
incubator/tuscany/java/sca/modules/impl-java-xml/pom.xml
Modified: incubator/tuscany/java/sca/modules/impl-java-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/pom.xml?view=diff&rev=525388&r1=525387&r2=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/pom.xml Tue Apr 3 20:32:02 2007
@@ -29,10 +29,24 @@
<name>Apache Tuscany SCA XML Java Implementation Extension</name>
<dependencies>
+
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r1.0</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xml</artifactId>
<version>1.0-alpha1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-idl-java-xml</artifactId>
+ <version>${version}</version>
</dependency>
<dependency>
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspection;
+
+/**
+ * Thrown when an implementation has more than one property injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicatePropertyException extends ProcessingException {
+ private static final long serialVersionUID = 5536415875694904037L;
+
+ public DuplicatePropertyException(String message) {
+ super(message);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/DuplicatePropertyException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspection;
+
+/**
+ * Denotes an illegal property definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalPropertyException extends ProcessingException {
+ private static final long serialVersionUID = -2836849110706758494L;
+
+ public IllegalPropertyException(String message) {
+ super(message);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IllegalPropertyException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java Tue Apr 3 20:32:02 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.introspection;
+
+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 ImplementationProcessor {
+
+ /**
+ * 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/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.introspection;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.idl.java.introspection.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.implementation.java.impl.Parameter;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * A convenience class for annotation processors which alleviates the need to
+ * implement unused callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public abstract class ImplementationProcessorExtension implements ImplementationProcessor {
+ protected IntrospectionRegistry registry;
+ protected JavaInterfaceProcessorRegistry interfaceProcessorRegistry;
+
+ /**
+ * @param registry
+ */
+ public ImplementationProcessorExtension(IntrospectionRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ @Reference
+ public void setRegistry(IntrospectionRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Reference
+ public void setInterfaceProcessorRegistry(JavaInterfaceProcessorRegistry interfaceProcessorRegistry) {
+ this.interfaceProcessorRegistry = interfaceProcessorRegistry;
+ }
+
+ @Init
+ public void init() {
+ registry.registerProcessor(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ registry.unregisterProcessor(this);
+ }
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitSuperClass(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitMethod(Method method, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitConstructor(Constructor<T> constructor, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitField(Field field, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public <T> void visitEnd(Class<T> clazz, JavaImplementationDefinition type) throws ProcessingException {
+ }
+
+ public void visitConstructorParameter(Parameter parameter, JavaImplementationDefinition type) throws ProcessingException {
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ImplementationProcessorExtension.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java Tue Apr 3 20:32:02 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.introspection;
+
+/**
+ * A system service which tracks {@link ImplementationProcessor}s
+ *
+ * @version $Rev$ $Date$
+ */
+public interface IntrospectionRegistry extends Introspector {
+
+ /**
+ * Registers the given processor and makes it available during assembly evaluation (i.e. build)
+ */
+ void registerProcessor(ImplementationProcessor processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void unregisterProcessor(ImplementationProcessor processor);
+
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/IntrospectionRegistry.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspection;
+
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+
+/**
+ * Implementations are responsible for walking a component implementation class,
+ * adding additional component type information as appropriate
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Introspector {
+
+ /**
+ * Walks the given component implementation class
+ *
+ * @param clazz the component implementation class
+ * @param type the component type associated with the implementation class
+ * @return the updated component type
+ * @throws ProcessingException if an error is encountered evaluating the
+ * implementation class
+ */
+ JavaImplementationDefinition introspect(Class<?> clazz, JavaImplementationDefinition type) throws ProcessingException;
+
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/Introspector.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.implementation.java.introspection;
+
+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, 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/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java-xml/src/main/java/org/apache/tuscany/implementation/java/introspection/ProcessingException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java Tue Apr 3 20:32:02 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.impl;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * Hold injection information for the constructor used to instantiate a
+ * component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstructorDefinition<T> {
+
+ private Constructor<T> constructor;
+ private Parameter[] parameters;
+
+ public ConstructorDefinition(Constructor<T> constructor) {
+ this.constructor = constructor;
+ int size = constructor.getParameterTypes().length;
+ parameters = new Parameter[size];
+ for (int i = 0; i < size; i++) {
+ parameters[i] = new Parameter(constructor, i);
+ }
+ }
+
+ public Constructor<T> getConstructor() {
+ return constructor;
+ }
+
+ /**
+ * @return the parameters
+ */
+ public Parameter[] getParameters() {
+ return parameters;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/ConstructorDefinition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,209 @@
+/*
+ * 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.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+/**
+ * This class represents a java element such as a Package, Class, Constructor, Field, Method or
+ * Parameter.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaElement {
+ private AnnotatedElement anchor;
+ private ElementType elementType;
+ private Class<?> type;
+ private Type genericType;
+ private int index = -1;
+ private String name;
+
+ public JavaElement(Package pkg) {
+ this.anchor = pkg;
+ this.elementType = ElementType.PACKAGE;
+ this.name = pkg.getName();
+ }
+
+ public JavaElement(Class<?> cls) {
+ this.anchor = cls;
+ this.elementType = ElementType.TYPE;
+ this.type = cls;
+ this.genericType = cls;
+ this.name = cls.getName();
+ }
+
+ public JavaElement(Field field) {
+ this.anchor = field;
+ this.elementType = ElementType.FIELD;
+ this.type = field.getType();
+ this.genericType = field.getGenericType();
+ this.name = field.getName();
+ }
+
+ public JavaElement(Method method) {
+ this.anchor = method;
+ this.elementType = ElementType.METHOD;
+ this.type = method.getReturnType();
+ this.genericType = method.getGenericReturnType();
+ this.name = method.getName();
+ }
+
+ public JavaElement(Constructor<?> constructor) {
+ this.anchor = constructor;
+ this.elementType = ElementType.CONSTRUCTOR;
+ this.type = null;
+ this.genericType = null;
+ this.name = constructor.getName();
+ }
+
+ public JavaElement(Constructor<?> constructor, int index) {
+ this.anchor = constructor;
+ this.elementType = ElementType.PARAMETER;
+ this.type = constructor.getParameterTypes()[index];
+ this.genericType = constructor.getGenericParameterTypes()[index];
+ this.index = index;
+ this.name = "";
+ }
+
+ public JavaElement(Method method, int index) {
+ this.anchor = method;
+ this.elementType = ElementType.PARAMETER;
+ this.type = method.getParameterTypes()[index];
+ this.genericType = method.getGenericParameterTypes()[index];
+ this.index = index;
+ this.name = "";
+ }
+
+ /**
+ * @return the anchor
+ */
+ public AnnotatedElement getAnchor() {
+ return anchor;
+ }
+
+ /**
+ * @return the elementType
+ */
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ /**
+ * @return the genericType
+ */
+ public Type getGenericType() {
+ return genericType;
+ }
+
+ /**
+ * @return the index
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * @return the type
+ */
+ public Class<?> getType() {
+ return type;
+ }
+
+ public Annotation[] getAnnotations() {
+ if (elementType == ElementType.PARAMETER) {
+ if (anchor instanceof Method) {
+ // We only care about the method-level annotaions
+ return ((Method)anchor).getAnnotations();
+ }
+ if (anchor instanceof Constructor) {
+ return ((Constructor)anchor).getParameterAnnotations()[index];
+ }
+ }
+ return anchor.getAnnotations();
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ for (Annotation a : getAnnotations()) {
+ if (a.annotationType() == annotationType) {
+ return annotationType.cast(a);
+ }
+ }
+ return null;
+ }
+
+ public String toString() {
+ return anchor.toString() + (elementType == ElementType.PARAMETER ? "[" + index + "]" : "");
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((anchor == null) ? 0 : anchor.hashCode());
+ result = PRIME * result + index;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final JavaElement other = (JavaElement)obj;
+ if (anchor == null) {
+ if (other.anchor != null) {
+ return false;
+ }
+ } else if (!anchor.equals(other.anchor)) {
+ return false;
+ }
+ if (index != other.index) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaElement.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,174 @@
+/*
+ * 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.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A component type specialization for POJO implementations
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaImplementationDefinition {
+ private Class<?> implClass;
+ private ConstructorDefinition<?> constructorDefinition;
+ private Map<Constructor, ConstructorDefinition> constructors = new HashMap<Constructor, ConstructorDefinition>();
+ private Method initMethod;
+ private Method destroyMethod;
+ private final Map<String, Resource> resources = new HashMap<String, Resource>();
+ private Member conversationIDMember;
+
+ private boolean allowsPassByReference;
+ private List<Method> allowsPassByReferenceMethods = new ArrayList<Method>();
+
+ /**
+ * Constructor specifying the java class for the POJO this is describing.
+ *
+ * @param implClass the java class for the POJO this is describing
+ */
+ public JavaImplementationDefinition(Class<?> implClass) {
+ this.implClass = implClass;
+ }
+
+ /**
+ * Returns the java class for the POJO this is describing.
+ *
+ * @return the java class for the POJO this is describing
+ */
+ public Class<?> getImplClass() {
+ return implClass;
+ }
+
+ /**
+ * Sets the java class for the POJO this is describing.
+ *
+ * @param implClass the java class for the POJO this is describing
+ */
+ public void setImplClass(Class<?> implClass) {
+ this.implClass = implClass;
+ }
+
+ /**
+ * Returns the constructor used to instantiate implementation instances.
+ *
+ * @return the constructor used to instantiate implementation instances
+ */
+ public ConstructorDefinition<?> getConstructorDefinition() {
+ return constructorDefinition;
+ }
+
+ /**
+ * Sets the constructor used to instantiate implementation instances
+ *
+ * @param definition the constructor used to instantiate implementation instances
+ */
+ public void setConstructorDefinition(ConstructorDefinition<?> definition) {
+ this.constructorDefinition = definition;
+ }
+
+ /**
+ * Returns the component initializer method.
+ *
+ * @return the component initializer method
+ */
+ public Method getInitMethod() {
+ return initMethod;
+ }
+
+ /**
+ * Sets the component initializer method.
+ *
+ * @param initMethod the component initializer method
+ */
+ public void setInitMethod(Method initMethod) {
+ this.initMethod = initMethod;
+ }
+
+ /**
+ * Returns the component destructor method.
+ *
+ * @return the component destructor method
+ */
+ public Method getDestroyMethod() {
+ return destroyMethod;
+ }
+
+ /**
+ * Sets the component destructor method.
+ *
+ * @param destroyMethod the component destructor method
+ */
+ public void setDestroyMethod(Method destroyMethod) {
+ this.destroyMethod = destroyMethod;
+ }
+
+ public Map<String, Resource> getResources() {
+ return resources;
+ }
+
+ public void add(Resource resource) {
+ resources.put(resource.getName(), resource);
+ }
+
+ public Member getConversationIDMember() {
+ return this.conversationIDMember;
+ }
+
+ public void setConversationIDMember(Member conversationIDMember) {
+ this.conversationIDMember = conversationIDMember;
+ }
+
+ /**
+ * @return the allowsPassByReference
+ */
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ /**
+ * @param allowsPassByReference the allowsPassByReference to set
+ */
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
+
+ /**
+ * @return the allowsPassByReferenceMethods
+ */
+ public List<Method> getAllowsPassByReferenceMethods() {
+ return allowsPassByReferenceMethods;
+ }
+
+ public boolean isAllowsPassByReference(Method method) {
+ return allowsPassByReference || allowsPassByReferenceMethods.contains(method);
+ }
+
+ /**
+ * @return the constructors
+ */
+ public Map<Constructor, ConstructorDefinition> getConstructors() {
+ return constructors;
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/JavaImplementationDefinition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java Tue Apr 3 20:32:02 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.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Parameter extends JavaElement {
+ private Class<? extends Annotation> classifer;
+
+ /**
+ * @param constructor
+ * @param index
+ */
+ public Parameter(Constructor<?> constructor, int index) {
+ super(constructor, index);
+ }
+
+ /**
+ * @return the classifer
+ */
+ public Class<? extends Annotation> getClassifer() {
+ return classifer;
+ }
+
+ /**
+ * @param classifer the classifer to set
+ */
+ public void setClassifer(Class<? extends Annotation> classifer) {
+ this.classifer = classifer;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Parameter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java?view=auto&rev=525388
==============================================================================
--- incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java (added)
+++ incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java Tue Apr 3 20:32:02 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.impl;
+
+import java.lang.reflect.Member;
+
+/**
+ * A resource dependency declared by a Java component implementation
+ *
+ * @version $Rev$ $Date$
+ * @param <T> the Java type of the resource
+ */
+public class Resource<T> {
+
+ private String name;
+ private String mappedName;
+ private boolean optional;
+ private Member member;
+ private Class<T> type;
+
+ public Resource(String name, Class<T> type, Member member) {
+ this.name = name;
+ this.type = type;
+ this.member = member;
+ }
+
+ /**
+ * The name of the resource
+ *
+ * @return the name of the resource
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the resource
+ *
+ * @param name the name of the resource
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the URI of the resource
+ *
+ * @return the URI of the resource
+ */
+ public String getMappedName() {
+ return mappedName;
+ }
+
+ /**
+ * Sets the resource URI
+ */
+ public void setMappedName(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ /**
+ * If true, the resource is optional
+ *
+ * @return true if the resource is optional
+ */
+ public boolean isOptional() {
+ return optional;
+ }
+
+ /**
+ * Sets whether the resource is optional
+ */
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ /**
+ * Returns the Member that this resource is mapped to.
+ *
+ * @return the Member that this resource is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this resource is mapped to
+ *
+ * @param member the Member that this resource is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+
+ /**
+ * Returns the resource type
+ *
+ * @return the resource type
+ */
+ public Class<T> getType() {
+ return type;
+ }
+
+ /**
+ * Sets the resource type
+ */
+ public void setType(Class<T> type) {
+ this.type = type;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/impl-java/src/main/java/org/apache/tuscany/implementation/java/impl/Resource.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