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 2006/08/30 02:59:43 UTC
svn commit: r438317 - in /incubator/tuscany/java/sca:
core/src/main/java/org/apache/tuscany/core/idl/java/
core/src/main/java/org/apache/tuscany/core/implementation/processor/
spi/src/main/java/org/apache/tuscany/spi/model/
Author: rfeng
Date: Tue Aug 29 17:59:42 2006
New Revision: 438317
URL: http://svn.apache.org/viewvc?rev=438317&view=rev
Log:
Add dataBinding to ServiceContract & Operation
Remove setter for operations/callbackOperations Map
Modified:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorService.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java Tue Aug 29 17:59:42 2006
@@ -82,12 +82,12 @@
contract.setInterfaceName(getBaseName(type));
contract.setInterfaceClass(type);
boolean remotable = type.isAnnotationPresent(Remotable.class);
- contract.setOperations(getOperations(type, remotable));
+ contract.getOperations().putAll(getOperations(type, remotable));
if (callback != null) {
contract.setCallbackName(getBaseName(callback));
contract.setCallbackClass(callback);
- contract.setCallbacksOperations(getOperations(callback, remotable));
+ contract.getCallbacksOperations().putAll(getOperations(callback, remotable));
}
Scope interactionScope = type.getAnnotation(Scope.class);
@@ -130,8 +130,13 @@
for (Type faultType : faultTypes) {
faultDataTypes.add(new DataType<Type>(faultType, faultType));
}
+
+ org.apache.tuscany.api.annotation.DataType dataType =
+ method.getAnnotation(org.apache.tuscany.api.annotation.DataType.class);
+ String dataBinding = (dataType != null) ? dataType.name() : Object.class.getName();
+
Operation<Type> operation =
- new Operation<Type>(name, returnDataType, paramDataTypes, faultDataTypes, nonBlocking);
+ new Operation<Type>(name, returnDataType, paramDataTypes, faultDataTypes, nonBlocking, dataBinding);
operations.put(name, operation);
}
return operations;
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java Tue Aug 29 17:59:42 2006
@@ -18,6 +18,12 @@
*/
package org.apache.tuscany.core.implementation.processor;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -32,9 +38,6 @@
import java.util.Map;
import java.util.Set;
-import org.osoa.sca.annotations.Remotable;
-import org.osoa.sca.annotations.Service;
-
import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.deployer.DeploymentContext;
@@ -46,37 +49,34 @@
import org.apache.tuscany.spi.implementation.java.JavaMappedService;
import org.apache.tuscany.spi.implementation.java.PojoComponentType;
import org.apache.tuscany.spi.implementation.java.ProcessingException;
-import org.apache.tuscany.spi.model.ServiceContract;
-
-import org.apache.tuscany.core.idl.java.IllegalCallbackException;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
/**
* Heuristically evaluates an un-annotated Java implementation type to determine services, references, and properties
- * according to the algorithm described in the SCA Java Client and Implementation Model Specification
- * <p/>
- * TODO Implement:<p> When no service inteface is annotated, need to calculate a single service comprising all public
- * methods that are not reference or property injection sites. If that service can be exactly mapped to an interface
- * implemented by the class then the service interface will be defined in terms of that interface.
- *
+ * according to the algorithm described in the SCA Java Client and Implementation Model Specification <p/> TODO
+ * Implement:
+ * <p>
+ * When no service inteface is annotated, need to calculate a single service comprising all public methods that are not
+ * reference or property injection sites. If that service can be exactly mapped to an interface implemented by the class
+ * then the service interface will be defined in terms of that interface.
+ *
* @version $Rev$ $Date$
*/
public class HeuristicPojoProcessor extends ImplementationProcessorSupport {
private ImplementationProcessorService implService;
- public HeuristicPojoProcessor(@Autowire ImplementationProcessorService service) {
+ public HeuristicPojoProcessor(@Autowire
+ ImplementationProcessorService service) {
this.implService = service;
}
- public void visitEnd(CompositeComponent<?> parent, Class<?> clazz,
- PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
- DeploymentContext context) throws ProcessingException {
+ public void visitEnd(
+ CompositeComponent<?> parent,
+ Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
Map<String, JavaMappedService> services = type.getServices();
if (services.isEmpty()) {
// heuristically determine the service
@@ -164,23 +164,23 @@
/**
* Determines the constructor to use based on the component type's references and properties
- *
- * @param type the component type
+ *
+ * @param type the component type
* @param clazz the implementation class corresponding to the component type
- * @throws NoConstructorException if no suitable constructor is found
+ * @throws NoConstructorException if no suitable constructor is found
* @throws AmbiguousConstructorException if the parameters of a constructor cannot be unambiguously mapped to
- * references and properties
+ * references and properties
*/
@SuppressWarnings("unchecked")
private void evaluateConstructor(
- PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
- Class<?> clazz) throws ProcessingException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<?> clazz) throws ProcessingException {
// determine constructor if one is not annotated
ConstructorDefinition<?> definition = type.getConstructorDefinition();
Constructor constructor;
boolean explict = false;
if (definition != null
- && definition.getConstructor().getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) {
+ && definition.getConstructor().getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) {
// the constructor was already defined explicitly
return;
} else if (definition != null) {
@@ -204,10 +204,10 @@
selected = ctor;
}
if (ctor.getParameterTypes().length == sites) {
- //TODO finish
- //selected = constructor;
+ // TODO finish
+ // selected = constructor;
// select constructor
- //break;
+ // break;
}
}
if (selected == null) {
@@ -216,7 +216,7 @@
constructor = selected;
definition = new ConstructorDefinition(selected);
type.setConstructorDefinition(definition);
- //return;
+ // return;
}
definition = new ConstructorDefinition(constructor);
type.setConstructorDefinition(definition);
@@ -274,8 +274,9 @@
/**
* Returns true if the union of the given collections of properties and references have unique Java types
*/
- private boolean calcPropRefUniqueness(Collection<JavaMappedProperty<?>> props,
- Collection<JavaMappedReference> refs) {
+ private boolean calcPropRefUniqueness(
+ Collection<JavaMappedProperty<?>> props,
+ Collection<JavaMappedReference> refs) {
Class[] classes = new Class[props.size() + refs.size()];
int i = 0;
@@ -292,21 +293,21 @@
/**
* Unambiguously finds the reference or property associated with the given type
- *
+ *
* @return the name of the reference or property if found, null if not
* @throws AmbiguousConstructorException if the constructor parameter cannot be resolved to a property or reference
*/
- private String findReferenceOrProperty(Class<?> type,
- Map<String, JavaMappedProperty<?>> props,
- Map<String, JavaMappedReference> refs)
- throws AmbiguousConstructorException {
+ private String findReferenceOrProperty(
+ Class<?> type,
+ Map<String, JavaMappedProperty<?>> props,
+ Map<String, JavaMappedReference> refs) throws AmbiguousConstructorException {
String name = null;
for (JavaMappedProperty<?> property : props.values()) {
if (property.getJavaType().equals(type)) {
if (name != null) {
- AmbiguousConstructorException e = new AmbiguousConstructorException(
- "Ambiguous property or reference for constructor type");
+ AmbiguousConstructorException e =
+ new AmbiguousConstructorException("Ambiguous property or reference for constructor type");
e.setIdentifier(type.getName());
throw e;
}
@@ -317,8 +318,8 @@
for (JavaMappedReference reference : refs.values()) {
if (reference.getServiceContract().getInterfaceClass().equals(type)) {
if (name != null) {
- AmbiguousConstructorException e = new AmbiguousConstructorException(
- "Ambiguous property or reference for constructor type");
+ AmbiguousConstructorException e =
+ new AmbiguousConstructorException("Ambiguous property or reference for constructor type");
e.setIdentifier(type.getName());
throw e;
}
@@ -353,7 +354,7 @@
}
if (referenceType != null) {
return referenceType.getAnnotation(Remotable.class) != null
- || referenceType.getAnnotation(Service.class) != null;
+ || referenceType.getAnnotation(Service.class) != null;
} else {
return rawType.getAnnotation(Remotable.class) != null || rawType.getAnnotation(Service.class) != null;
}
@@ -371,7 +372,7 @@
Method[] methods = service.getServiceContract().getInterfaceClass().getMethods();
for (Method method : methods) {
if (operation.getName().equals(method.getName())
- && operation.getParameterTypes().length == method.getParameterTypes().length) {
+ && operation.getParameterTypes().length == method.getParameterTypes().length) {
Class<?>[] methodTypes = method.getParameterTypes();
for (int i = 0; i < operation.getParameterTypes().length; i++) {
Class<?> paramType = operation.getParameterTypes()[i];
@@ -389,35 +390,21 @@
/**
* Creates a mapped reference
- *
- * @param name the reference name
- * @param member the injection site the reference maps to
+ *
+ * @param name the reference name
+ * @param member the injection site the reference maps to
* @param paramType the service interface of the reference
*/
private JavaMappedReference createReference(String name, Member member, Class<?> paramType)
throws ProcessingException {
- JavaMappedReference reference = new JavaMappedReference();
- reference.setName(name);
- reference.setMember(member);
- reference.setRequired(false);
- ServiceContract contract = new JavaServiceContract();
- String interfaceName = getBaseName(paramType);
- contract.setInterfaceName(interfaceName);
- contract.setInterfaceClass(paramType);
- try {
- implService.processCallback(paramType, contract);
- } catch (IllegalCallbackException e) {
- throw new ProcessingException(e);
- }
- reference.setServiceContract(contract);
- return reference;
+ return implService.createReference(name, member, paramType);
}
/**
* Creates a mapped property
- *
- * @param name the property name
- * @param member the injection site the reference maps to
+ *
+ * @param name the property name
+ * @param member the injection site the reference maps to
* @param paramType the property type
*/
private <T> JavaMappedProperty<T> createProperty(String name, Member member, Class<T> paramType) {
@@ -433,17 +420,17 @@
* Populates a component type with a service whose interface type is determined by examining all implemented
* interfaces of the given class and chosing one whose operations match all of the class's non-property and
* non-reference methods
- *
- * @param clazz the class to examine
- * @param type the component type
+ *
+ * @param clazz the class to examine
+ * @param type the component type
* @param methods all methods in the class to examine
*/
private void calculateServiceInterface(
- Class<?> clazz,
- PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
- Set<Method> methods) throws ProcessingException {
+ Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Set<Method> methods) throws ProcessingException {
List<Method> nonPropRefMethods = new ArrayList<Method>();
- //Map<String, JavaMappedService> services = type.getServices();
+ // Map<String, JavaMappedService> services = type.getServices();
Map<String, JavaMappedReference> references = type.getReferences();
Map<String, JavaMappedProperty<?>> properties = type.getProperties();
// calculate methods that are not properties or references
@@ -473,8 +460,8 @@
/**
* Determines if the methods of a given interface match the given list of methods
- *
- * @param interfaze the interface to examine
+ *
+ * @param interfaze the interface to examine
* @param nonPropRefMethods the list of methods to match against
* @return true if the interface matches
*/
@@ -512,19 +499,14 @@
return true;
}
-
}
/*
-1) public setter methods that are not included in any service interface
-2) protected setter methods
-3) public or protected fields unless there is a setter method for the same name
-If the type associated with the member is an array or a
-java.util.Collection, then the basetype will be the element type of
-the array or the parameterized type of the Collection, otherwise the
-basetype will be the member type. If the basetype is an interface with
-an @Remotable or @Service annotation then the member will be defined
-as a reference, otherwise it will be defined as a property.
-
-
-*/
+ * 1) public setter methods that are not included in any service interface 2) protected setter methods 3) public or
+ * protected fields unless there is a setter method for the same name If the type associated with the member is an array
+ * or a java.util.Collection, then the basetype will be the element type of the array or the parameterized type of the
+ * Collection, otherwise the basetype will be the member type. If the basetype is an interface with an @Remotable or
+ * @Service annotation then the member will be defined as a reference, otherwise it will be defined as a property.
+ *
+ *
+ */
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorService.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorService.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorService.java Tue Aug 29 17:59:42 2006
@@ -19,8 +19,10 @@
package org.apache.tuscany.core.implementation.processor;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
import java.util.List;
+import org.apache.tuscany.core.idl.java.IllegalCallbackException;
import org.apache.tuscany.spi.idl.InvalidServiceContractException;
import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
@@ -29,11 +31,9 @@
import org.apache.tuscany.spi.implementation.java.ProcessingException;
import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.core.idl.java.IllegalCallbackException;
-
/**
* Provides utility methods for Java implementation processing
- *
+ *
* @version $Rev$ $Date$
*/
public interface ImplementationProcessorService {
@@ -41,22 +41,23 @@
/**
* Introspects the given interface to produce a mapped service
*/
- JavaMappedService createService(Class<?> interfaze)
- throws IllegalCallbackException, InvalidServiceContractException;
+ JavaMappedService createService(Class<?> interfaze) throws IllegalCallbackException,
+ InvalidServiceContractException;
+
+ JavaMappedReference createReference(String name, Member member, Class<?> paramType) throws ProcessingException;
/**
* Processes the callback contract for a given interface type
- *
+ *
* @param interfaze the interface type to examine
- * @param contract the service contract the callback is associated wth
+ * @param contract the service contract the callback is associated wth
* @throws org.apache.tuscany.core.idl.java.IllegalCallbackException
*/
- void processCallback(Class<?> interfaze, ServiceContract<?> contract)
- throws IllegalCallbackException;
+ void processCallback(Class<?> interfaze, ServiceContract<?> contract) throws IllegalCallbackException;
/**
* Determines if all the members of a collection have unique types
- *
+ *
* @param collection the collection to analyze
* @return true if the types are unique
*/
@@ -69,26 +70,28 @@
/**
* Processes a constructor parameter by introspecting its annotations
- *
- * @param param the parameter to process
+ *
+ * @param param the parameter to process
* @param paramAnnotations the parameter annotations
- * @param constructorNames the array of constructorNames specified by @Constructor
- * @param pos the declaration position of the constructor parameter
- * @param type the component type associated with implementation being reflected
- * @param injectionNames the list of parameter constructorNames specified on parameter annotations
+ * @param constructorNames the array of constructorNames specified by
+ * @Constructor
+ * @param pos the declaration position of the constructor parameter
+ * @param type the component type associated with implementation being reflected
+ * @param injectionNames the list of parameter constructorNames specified on parameter annotations
* @throws org.apache.tuscany.spi.implementation.java.ProcessingException
- *
+ *
*/
- boolean processParam(Class<?> param,
- Annotation[] paramAnnotations,
- String[] constructorNames,
- int pos,
- PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
- List<String> injectionNames)
- throws ProcessingException;
+ boolean processParam(
+ Class<?> param,
+ Annotation[] paramAnnotations,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws ProcessingException;
/**
* Returns true if {@link @Autowire}, {@link @Property}, or {@link @Reference} are present in the given array
*/
boolean injectionAnnotationsPresent(Annotation[][] annots);
+
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java Tue Aug 29 17:59:42 2006
@@ -19,6 +19,7 @@
package org.apache.tuscany.core.implementation.processor;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
import java.util.List;
import org.osoa.sca.annotations.Callback;
@@ -43,7 +44,7 @@
/**
* The default implementation of an <code>ImplementationProcessorService</code>
- *
+ *
* @version $Rev$ $Date$
*/
public class ImplementationProcessorServiceImpl implements ImplementationProcessorService {
@@ -63,16 +64,15 @@
return service;
}
- public void processCallback(Class<?> interfaze, ServiceContract<?> contract)
- throws IllegalCallbackException {
+ public void processCallback(Class<?> interfaze, ServiceContract<?> contract) throws IllegalCallbackException {
Callback callback = interfaze.getAnnotation(Callback.class);
if (callback != null && !Void.class.equals(callback.value())) {
Class<?> callbackClass = callback.value();
contract.setCallbackClass(callbackClass);
contract.setCallbackName(getBaseName(callbackClass));
} else if (callback != null && Void.class.equals(callback.value())) {
- IllegalCallbackException e =
- new IllegalCallbackException("Callback annotation must specify an interface on service type");
+ IllegalCallbackException e = new IllegalCallbackException(
+ "Callback annotation must specify an interface on service type");
e.setIdentifier(interfaze.getName());
throw e;
}
@@ -99,13 +99,13 @@
}
}
- public boolean processParam(Class<?> param,
- Annotation[] paramAnnotations,
- String[] constructorNames,
- int pos,
- PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
- List<String> injectionNames)
- throws ProcessingException {
+ public boolean processParam(
+ Class<?> param,
+ Annotation[] paramAnnotations,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws ProcessingException {
boolean processed = false;
for (Annotation annot : paramAnnotations) {
if (Autowire.class.equals(annot.annotationType())) {
@@ -126,9 +126,8 @@
for (Annotation[] annotations : annots) {
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotType = annotation.annotationType();
- if (annotType.equals(Autowire.class)
- || annotType.equals(Property.class)
- || annotType.equals(Reference.class)) {
+ if (annotType.equals(Autowire.class) || annotType.equals(Property.class)
+ || annotType.equals(Reference.class)) {
return true;
}
}
@@ -138,9 +137,9 @@
/**
* Determines if all the members of a collection have unique types
- *
+ *
* @param collection the collection to analyze
- * @param start the position in the collection to start
+ * @param start the position in the collection to start
* @return true if the types are unique
*/
private boolean areUnique(Class[] collection, int start) {
@@ -159,24 +158,24 @@
/**
* Processes autowire metadata for a constructor parameter
- *
- * @param annot the autowire annotation
+ *
+ * @param annot the autowire annotation
* @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
- * annotation
- * @param pos the position of the parameter in the constructor's parameter list
- * @param param the parameter type
- * @param type the component type associated with the implementation being processed
- * @param injectionNames the collection of injection names to update
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param param the parameter type
+ * @param type the component type associated with the implementation being processed
+ * @param injectionNames the collection of injection names to update
* @throws InvalidAutowireException
* @throws InvalidConstructorException
*/
- private void processAutowire(Annotation annot, String[] constructorNames,
- int pos,
- Class<?> param,
- PojoComponentType<JavaMappedService, JavaMappedReference,
- JavaMappedProperty<?>> type,
- List<String> injectionNames) throws InvalidAutowireException,
- InvalidConstructorException {
+ private void processAutowire(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ Class<?> param,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws InvalidAutowireException, InvalidConstructorException {
// the param is marked as an autowire
Autowire autowireAnnot = (Autowire) annot;
JavaMappedReference reference = new JavaMappedReference();
@@ -184,19 +183,17 @@
String name = autowireAnnot.name();
if (name == null || name.length() == 0) {
if (constructorNames.length > 0 && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) {
- throw new InvalidAutowireException(
- "Names in @Constructor and autowire parameter do not match at " + (pos + 1));
+ throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at "
+ + (pos + 1));
} else if (constructorNames.length == 0 || constructorNames[pos].length() == 0) {
name = param.getName();
} else {
name = constructorNames[pos];
}
- } else if (pos < constructorNames.length
- && constructorNames[pos] != null
- && constructorNames[pos].length() != 0
- && !name.equals(constructorNames[pos])) {
- throw new InvalidConstructorException(
- "Name specified by @Constructor does not match autowire name at " + (pos + 1));
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match autowire name at "
+ + (pos + 1));
}
reference.setName(name);
ServiceContract<?> contract = new JavaServiceContract();
@@ -208,24 +205,23 @@
/**
* Processes parameter metadata for a constructor parameter
- *
- * @param annot the parameter annotation
+ *
+ * @param annot the parameter annotation
* @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
- * annotation
- * @param pos the position of the parameter in the constructor's parameter list
- * @param type the component type associated with the implementation being processed
- * @param param the parameter type
- * @param explicitNames the collection of injection names to update
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param type the component type associated with the implementation being processed
+ * @param param the parameter type
+ * @param explicitNames the collection of injection names to update
* @throws ProcessingException
*/
- private <T> void processProperty(Annotation annot,
- String[] constructorNames,
- int pos,
- PojoComponentType<JavaMappedService, JavaMappedReference,
- JavaMappedProperty<?>> type,
- Class<T> param,
- List<String> explicitNames)
- throws ProcessingException {
+ private <T> void processProperty(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<T> param,
+ List<String> explicitNames) throws ProcessingException {
// TODO multiplicity
// the param is marked as a property
Property propAnnot = (Property) annot;
@@ -233,16 +229,14 @@
String name = propAnnot.name();
if (name == null || name.length() == 0) {
if (constructorNames.length < pos + 1 || constructorNames[pos] == null
- || constructorNames[pos].length() == 0) {
+ || constructorNames[pos].length() == 0) {
throw new InvalidPropertyException("No name specified for property parameter " + (pos + 1));
}
name = constructorNames[pos];
- } else if (pos < constructorNames.length
- && constructorNames[pos] != null
- && constructorNames[pos].length() != 0
- && !name.equals(constructorNames[pos])) {
- throw new InvalidConstructorException(
- "Name specified by @Constructor does not match property name at " + (pos + 1));
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match property name at "
+ + (pos + 1));
}
if (type.getProperties().get(name) != null) {
throw new DuplicatePropertyException(name);
@@ -256,23 +250,23 @@
/**
* Processes reference metadata for a constructor parameter
- *
- * @param annot the parameter annotation
+ *
+ * @param annot the parameter annotation
* @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
- * annotation
- * @param pos the position of the parameter in the constructor's parameter list
- * @param type the component type associated with the implementation being processed
- * @param param the parameter type
- * @param explicitNames the collection of injection names to update
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param type the component type associated with the implementation being processed
+ * @param param the parameter type
+ * @param explicitNames the collection of injection names to update
* @throws ProcessingException
*/
- private void processReference(Annotation annot, String[] constructorNames,
- int pos,
- PojoComponentType<JavaMappedService, JavaMappedReference,
- JavaMappedProperty<?>> type,
- Class<?> param,
- List<String> explicitNames)
- throws ProcessingException {
+ private void processReference(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<?> param,
+ List<String> explicitNames) throws ProcessingException {
// TODO multiplicity
// the param is marked as a reference
@@ -281,27 +275,49 @@
String name = refAnnotation.name();
if (name == null || name.length() == 0) {
if (constructorNames.length < pos + 1 || constructorNames[pos] == null
- || constructorNames[pos].length() == 0) {
+ || constructorNames[pos].length() == 0) {
throw new InvalidReferenceException("No name specified for reference parameter " + (pos + 1));
}
name = constructorNames[pos];
- } else if (pos < constructorNames.length
- && constructorNames[pos] != null
- && constructorNames[pos].length() != 0
- && !name.equals(constructorNames[pos])) {
- throw new InvalidConstructorException(
- "Name specified by @Constructor does not match reference name at " + (pos + 1));
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match reference name at "
+ + (pos + 1));
}
if (type.getReferences().get(name) != null) {
throw new DuplicateReferenceException(name);
}
reference.setName(name);
reference.setRequired(refAnnotation.required());
- ServiceContract<?> contract = new JavaServiceContract();
- contract.setInterfaceClass(param);
- reference.setServiceContract(contract);
+ try {
+ ServiceContract<?> contract = registry.introspect(param);
+ reference.setServiceContract(contract);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
type.getReferences().put(name, reference);
addName(explicitNames, pos, name);
+ }
+
+ public JavaMappedReference createReference(String name, Member member, Class<?> paramType)
+ throws ProcessingException {
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setName(name);
+ reference.setMember(member);
+ reference.setRequired(false);
+ ServiceContract contract = null;
+ try {
+ contract = registry.introspect(paramType);
+ } catch (InvalidServiceContractException e1) {
+ throw new ProcessingException(e1);
+ }
+ try {
+ processCallback(paramType, contract);
+ } catch (IllegalCallbackException e) {
+ throw new ProcessingException(e);
+ }
+ reference.setServiceContract(contract);
+ return reference;
}
}
Modified: incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java (original)
+++ incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java Tue Aug 29 17:59:42 2006
@@ -32,6 +32,7 @@
private final List<DataType<T>> parameterTypes;
private final List<DataType<T>> faultTypes;
private final boolean nonBlocking;
+ private final String dataBinding;
/**
* Construct an operation specifying all characteristics.
@@ -46,12 +47,14 @@
DataType<T> returnType,
List<DataType<T>> parameterTypes,
List<DataType<T>> faultTypes,
- boolean nonBlocking) {
+ boolean nonBlocking,
+ String dataBinding) {
this.name = name;
this.returnType = returnType;
this.parameterTypes = parameterTypes;
this.faultTypes = faultTypes;
this.nonBlocking = nonBlocking;
+ this.dataBinding = dataBinding;
}
/**
@@ -94,5 +97,9 @@
*/
public boolean isNonBlocking() {
return nonBlocking;
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
}
}
Modified: incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java?rev=438317&r1=438316&r2=438317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java (original)
+++ incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java Tue Aug 29 17:59:42 2006
@@ -18,21 +18,30 @@
*/
package org.apache.tuscany.spi.model;
+import java.util.HashMap;
import java.util.Map;
/**
* Base class representing service contract information
- *
+ *
* @version $Rev$ $Date$
*/
public abstract class ServiceContract<T> extends ModelObject {
- private InteractionScope interactionScope;
- private Class<?> interfaceClass;
- private String interfaceName;
- private String callbackName;
- private Class<?> callbackClass;
- private Map<String, Operation<T>> operations;
- private Map<String, Operation<T>> callbacksOperations;
+ protected InteractionScope interactionScope;
+
+ protected Class<?> interfaceClass;
+
+ protected String interfaceName;
+
+ protected String callbackName;
+
+ protected Class<?> callbackClass;
+
+ protected Map<String, Operation<T>> operations;
+
+ protected Map<String, Operation<T>> callbacksOperations;
+
+ protected String dataBinding;
protected ServiceContract() {
}
@@ -107,18 +116,24 @@
}
public Map<String, Operation<T>> getOperations() {
+ if (operations == null) {
+ operations = new HashMap<String, Operation<T>>();
+ }
return operations;
}
- public void setOperations(Map<String, Operation<T>> operations) {
- this.operations = operations;
- }
-
public Map<String, Operation<T>> getCallbacksOperations() {
+ if (callbacksOperations == null) {
+ callbacksOperations = new HashMap<String, Operation<T>>();
+ }
return callbacksOperations;
}
- public void setCallbacksOperations(Map<String, Operation<T>> callbacksOperations) {
- this.callbacksOperations = callbacksOperations;
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org