diff options
Diffstat (limited to '')
43 files changed, 2162 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java new file mode 100644 index 0000000000..09faf1b15e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java @@ -0,0 +1,194 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import java.util.Collection; + +/** + * The ComponentContext interface is used to obtain contextual information + * about the SCA component which is executing at the time the API is + * invoked. + * + * <p>Note: An SCA component can obtain a service reference either through + * injection or programmatically through the ComponentContext API. Using + * reference injection is the recommended way to access a service, since it + * results in code with minimal use of middleware APIs. The ComponentContext + * API is provided for use in cases where reference injection is not possible. + */ +public interface ComponentContext { + + /** + * Returns the absolute URI of the component within the SCA domain. + * + * @return the absolute URI of the component within the SCA domain. + */ + String getURI(); + + /** + * Returns a typed service proxy object for a reference defined by the + * current component, where the reference has multiplicity 0..1 or 1..1. + * + * @param <B> the Java type that is implemented by the returned proxy + * object. + * @param businessInterface the Class object for the Java type that + * is implemented by the returned proxy object. + * @param referenceName the name of the service reference. + * @return a proxy for the reference defined by the current component. + * Returns null if the named reference has no target service + * configured. + * @exception IllegalArgumentException if the reference has multiplicity + * greater than one, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> B getService(Class<B> businessInterface, String referenceName) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference object for a reference defined by the current + * component, where the reference has multiplicity 0..1 or 1..1. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @param referenceName the name of the service reference. + * @return a ServiceReference object for a reference defined by the current + * component, where the reference has multiplicity 0..1 or 1..1. + * Returns null if the named reference has no target service + * configured. + * @exception IllegalArgumentException if the reference has multiplicity + * greater than one, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, + String referenceName) + throws IllegalArgumentException; + + /** + * Returns a list of typed service proxies for a reference defined by the current + * component, where the reference has multiplicity 0..n or 1..n. + * + * @param <B> the Java type that is implemented by the returned proxy + * objects. + * @param businessInterface the Class object for the Java type that + * is implemented by the returned proxy objects. + * @param referenceName the name of the service reference. + * @return a collection of proxy objects for the reference, one for each target + * service to which the reference is wired, where each proxy object + * implements the interface B contained in the + * <code>businessInterface</code> parameter. The collection is empty if the + * reference is not wired to any target services. + * @exception IllegalArgumentException if the reference has multiplicity + * greater other than 0..1 or 1..1, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> Collection<B> getServices(Class<B> businessInterface, + String referenceName) + throws IllegalArgumentException; + + /** + * Returns a list of typed ServiceReference objects for a reference defined by the current + * component, where the reference has multiplicity 0..n or 1..n. + * + * @param <B> the Java type that is associated with returned proxy + * objects. + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param referenceName the name of the service reference. + * @return a collection of ServiceReference objects for the reference, one for each target + * service to which the reference is wired, where each proxy object implements + * the interface B contained in the <code>businessInterface</code> parameter. + * The collection is empty if the reference is not wired to any target services. + * @exception IllegalArgumentException if the reference has multiplicity + * greater other than 0..1 or 1..1, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> Collection<ServiceReference<B>> getServiceReferences( + Class<B> businessInterface, String referenceName) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference that can be used to invoke this component + * over the designated service. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @return a ServiceReference that can be used to invoke this + * component over the designated service. + * @exception IllegalArgumentException if the component does not have a service + * which implements the interface identified by the <code> + * businessinterface</code> parameter. + */ + <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference that can be used to invoke this component + * over the designated service. The <code>serviceName</code> parameter explicitly names + * the service with which the returned ServiceReference is associated. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @param serviceName the service name with which the returned ServiceReference + * is associated. + * @return a ServiceReference that can be used to invoke this component + * over the designated service. + * @exception IllegalArgumentException if the component does not have a service + * with the name identified by the <code>serviceName</code> parameter, or + * if the named service does not implement the interface identified by the + * <code>businessinterface</code> parameter. + */ + <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, + String serviceName) + throws IllegalArgumentException; + + /** + * Returns the value of an SCA property defined by this component. + * + * @param <B> the property type. + * @param type the Class object for the property type. + * @param propertyName the property name. + * @return The value of an SCA property defined by this component, or null if + * the property is not configured. + * @exception IllegalArgumentException if the component does not have a property + * with the name identified by the <code>propertyName</code> parameter, or + * if the named property type is not compatible with the <code>type</code> + * parameter. + */ + <B> B getProperty(Class<B> type, String propertyName) + throws IllegalArgumentException; + + /** + * Casts a type-safe reference to a ServiceReference. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param target the type-safe reference proxy that implements interface <B>. + * @return a type-safe reference to a ServiceReference. + */ + <B> ServiceReference<B> cast(B target) + throws IllegalArgumentException; + + /** + * Returns the RequestContext for the current SCA service request. + * + * @return the RequestContext for the current SCA service request when + * invoked during the execution of a component service method or + * callback method. Returns null in all other cases. + */ + RequestContext getRequestContext(); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java new file mode 100644 index 0000000000..f32289dcb1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java @@ -0,0 +1,90 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * The SCA Constants interface defines a number of constant values + * that are used in the SCA Java APIs and Annotations. + * + * <p> The serialized QNames are used with the @Requires annotation + * to specify a policy intent. The policy intent strings in this + * interface do not have a corresponding Java annotation, so these + * policy intents have ot be specified through the use of the + * @Requires annotation. + */ +public interface Constants { + + /** + * The SCA V1.1 namespace. + */ + String SCA_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912"; + + /** + * The serialized form of the SCA namespace for construction of QNames. + */ + String SCA_PREFIX = "{"+SCA_NS+"}"; + + /** + * The serialized QName of the serverAuthentication policy intent. + */ + String SERVERAUTHENTICATION = SCA_PREFIX + "serverAuthentication"; + /** + * The serialized QName of the clientAuthentication policy intent. + */ + String CLIENTAUTHENTICATION = SCA_PREFIX + "clientAuthentication"; + /** + * The serialized QName of the atleastOnce policy intent. + */ + String ATLEASTONCE = SCA_PREFIX + "atLeastOnce"; + /** + * The serialized QName of the atMostOnce policy intent. + */ + String ATMOSTONCE = SCA_PREFIX + "atMostOnce"; + /** + * The serialized QName of the exactlyOnce policy intent. + */ + String EXACTLYONCE = SCA_PREFIX + "exactlyOnce"; + /** + * The serialized QName of the ordered policy intent. + */ + String ORDERED = SCA_PREFIX + "ordered"; + /** + * The serialized QName of the transactedOneWay policy intent. + */ + String TRANSACTEDONEWAY = SCA_PREFIX + "transactedOneWay"; + /** + * The serialized QName of the immediateOneWay policy intent. + */ + String IMMEDIATEONEWAY = SCA_PREFIX + "immediateOneWay"; + /** + * The serialized QName of the propagatesTransaction policy intent. + */ + String PROPAGATESTRANSACTION = SCA_PREFIX + "propagatesTransaction"; + /** + * The serialized QName of the suspendsTransaction policy intent. + */ + String SUSPENDSTRANSACTION = SCA_PREFIX + "suspendsTransaction"; + /** + * The serialized QName of the asyncInvocation policy intent. + */ + String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation"; + /** + * The serialized QName of the SOAP policy intent. + */ + String SOAP = SCA_PREFIX + "SOAP"; + /** + * The serialized QName of the JMS policy intent. + */ + String JMS = SCA_PREFIX + "JMS"; + /** + * The serialized QName of the noListener policy intent. + */ + String NOLISTENER = SCA_PREFIX + "noListener"; + /** + * The serialized QName of the EJB policy intent. + */ + String EJB = SCA_PREFIX + "EJB"; + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java new file mode 100644 index 0000000000..02c575c05c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java @@ -0,0 +1,60 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the ServiceReference is no longer valid. + * This can happen when the target of the reference is undeployed. + * + * This exception is not transient and therefore is unlikely to be + * resolved by retrying the operation and will most likely require + * human intervention. + */ +public class InvalidServiceException extends ServiceRuntimeException { + /** + * Constructs a InvalidServiceException with no detail message. + */ + public InvalidServiceException() { + super(); + } + + /** + * Constructs a InvalidServiceException with the specified detail + * message. + * + * @param message the detail message + */ + public InvalidServiceException(String message) { + super(message); + } + + /** + * Constructs a InvalidServiceException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public InvalidServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a InvalidServiceException with the specified cause and + * a detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public InvalidServiceException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 7520492728695222145L; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java new file mode 100644 index 0000000000..d0f8a3e24d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the given SCA Domain does not exist. + */ + +public class NoSuchDomainException extends Exception { + /** + * Constructs a NoSuchDomainException with no detail message. + */ + public NoSuchDomainException() { + super(); + } + + /** + * Constructs a NoSuchDomainException with the specified detail + * message. + * + * @param message the detail message + */ + public NoSuchDomainException(String message) { + super(message); + } + + /** + * Constructs a NoSuchDomainException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchDomainException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a NoSuchDomainException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchDomainException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java new file mode 100644 index 0000000000..189e713e97 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the given SCA service does not exist. + */ + +public class NoSuchServiceException extends Exception { + /** + * Constructs a NoSuchServiceException with no detail message. + */ + public NoSuchServiceException() { + super(); + } + + /** + * Constructs a NoSuchServiceException with the specified detail + * message. + * + * @param message the detail message + */ + public NoSuchServiceException(String message) { + super(message); + } + + /** + * Constructs a NoSuchServiceException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a NoSuchServiceException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchServiceException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java new file mode 100644 index 0000000000..162e8e2055 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java @@ -0,0 +1,71 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import javax.security.auth.Subject; + +/** + * The RequestContext interface is used to obtain information about + * the service invocation which is executing when one of the + * RequestContext methods is called. + */ +public interface RequestContext { + + /** + * Returns the JAAS Subject of the current request. + * + * @return The JAAS (javax.security.auth.Subject) Subject of the + * current request. Returns null if there is no JAAS + * Subject. + */ + Subject getSecuritySubject(); + + /** + * Returns the name of the service under which the current service + * method is executing. + * + * @return the name of the service under which the current service + * operation is executing, or null if called outside of the + * execution of a service method. + */ + String getServiceName(); + + /** + * Returns a service reference for the callback for the invoked service + * operation, as specified by the service caller. + * + * @param <CB> the Java interface type of the callback. + * @return a service reference for the callback as specified by + * the service caller. Returns null when called for a service + * request whose interface is not bidirectional, or when called + * during execution of a callback request, or when called outside + * the execution of a service method. + */ + <CB> ServiceReference<CB> getCallbackReference(); + + /** + * Returns a proxy for the callback for the invoked service as specified + * by the service client. + * + * @param <CB> the type of the callback proxy + * @return a proxy for the callback for the invoked service as specified + * by the service client. Returns null when called during the + * execution of a service method whose interface is not + * bidirectional, or when called during the execution of a + * callback request, or when called outside the execution of a + * service method. + */ + <CB> CB getCallback(); + + /** + * Returns a ServiceReference object for the service that is executing. + * + * @param <B> the Java interface type associated with the service reference. + * @return the ServiceReference representing the service or callback + * that is executing. Returns null if when called outside the + * execution of a service method. + */ + <B> ServiceReference<B> getServiceReference(); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java new file mode 100644 index 0000000000..1192b16778 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java @@ -0,0 +1,46 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import java.util.Map; + +/** + * + * The following defines the ResponseDispatch interface, used to return a response + * message asynchronously from a service implementation method. + * + * @param <T> the type of the Response message returned by the service implementation method + */ +public interface ResponseDispatch<T> { + + /** + * Sends the response message from an asynchronous service method. + * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked + * if sendFault has previously been invoked for the same ResponseDispatch object. + * @param res an instance of the response message returned by the service operation + * @exception InvalidStateException if this method is called more than once for the same service + * operation. + */ + void sendResponse(T res); + + /** + * Sends an exception as a fault from an asynchronous service method. + * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked + * if sendResponse has previously been invoked for the same ResponseDispatch object. + * @param e an instance of an exception returned by the service operation + * @exception InvalidStateException if this method is called more than once for the same service + * operation. + */ + void sendFault(Throwable e); + + /** + * Obtains the context object for the ResponseDispatch method + * @return a Map which is is the context object for the ResponseDispatch object. + * The invoker can update the context object with appropriate context information, prior to invoking + * either the sendResponse method or the sendFault method + */ + Map<String, Object> getContext(); +} + diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java new file mode 100644 index 0000000000..d2d62763fa --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java @@ -0,0 +1,36 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * The ServiceReference interface represents a component reference. + * It can be injected using the @Reference annotation + * on a field, a setter method, or constructor parameter taking the + * type ServiceReference. + * + * @param <B> the type of the service reference + */ +public interface ServiceReference<B> extends java.io.Serializable { + + /** + * Returns a type-safe reference to the target of this reference. + * The instance returned is guaranteed to implement the business + * interface for this reference. The value returned is a proxy + * to the target that implements the business interface associated + * with this reference. + * + * @return a type-safe reference to the target of this reference. + */ + B getService(); + + /** + * Returns the Java class for the business interface associated + * with this reference. + * + * @return the Java class for the business interface associated + * with this reference. + */ + Class<B> getBusinessInterface(); +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java new file mode 100644 index 0000000000..8ebaa96500 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java @@ -0,0 +1,55 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals problems in the management of SCA component execution. + */ +public class ServiceRuntimeException extends RuntimeException { + /** + * Constructs a ServiceRuntimeException with no detail message. + */ + public ServiceRuntimeException() { + super(); + } + + /** + * Constructs a ServiceRuntimeException with the specified detail + * message. + * + * @param message the detail message + */ + public ServiceRuntimeException(String message) { + super(message); + } + + /** + * Constructs a ServiceRuntimeException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a ServiceRuntimeException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceRuntimeException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java new file mode 100644 index 0000000000..355a84a4c3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java @@ -0,0 +1,62 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals problems in the interaction with remote + * services. + * + * These are exceptions that can be transient, so retrying is + * appropriate. Any exception that is a ServiceRuntimeException + * that is not a ServiceUnavailableException is unlikely to be + * resolved by retrying the operation, since it most likely + * requires human intervention. + */ +public class ServiceUnavailableException extends ServiceRuntimeException { + /** + * Constructs a ServiceUnavailableException with no detail message. + */ + public ServiceUnavailableException() { + super(); + } + + /** + * Constructs a ServiceUnavailableException with the specified detail + * message. + * + * @param message the detail message + */ + public ServiceUnavailableException(String message) { + super(message); + } + + /** + * Constructs a ServiceUnavailableException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceUnavailableException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a ServiceUnavailableException with the specified cause and + * a detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceUnavailableException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 5750303470949048271L; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java new file mode 100644 index 0000000000..3350e9413b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java @@ -0,0 +1,39 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AllowsPassByReference annotation is used on implementations + * of remotable interfaces to indicate that interactions with the + * service from a client within the same address space are allowed + * to use pass by reference data exchange semantics. + * + * The implementation promises that its by-value semantics will be + * maintained even if the parameters and return values are actually + * passed by-reference. This means that the service will not modify + * any operation input parameter or return value, even after returning + * from the operation. + * + * Either a whole class implementing a remotable service or an individual + * remotable service method implementation can be annotated using the + * {@literal @AllowsPassByReference} annotation. + * + * {@literal @AllowsPassByReference} has no attributes. + */ +@Target({TYPE, METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface AllowsPassByReference { + + boolean value() default true; +} + diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java new file mode 100644 index 0000000000..278e8ead57 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java @@ -0,0 +1,27 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AsyncFault annotation is used to indicate the faults/exceptions which are returned by + * the asynchronous service method which it annotates. + * + */ +@Inherited +@Target({METHOD}) +@Retention(RUNTIME) +public @interface AsyncFault { + + Class<?>[] value() default {}; + +} + diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java new file mode 100644 index 0000000000..c6a4147afd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java @@ -0,0 +1,29 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AsyncInvocation annotation is used to indicate that the operations of a Java interface + * uses the long-running request-response pattern as described in the SCA Assembly specification. + * + */ +@Inherited +@Target({TYPE, METHOD}) +@Retention(RUNTIME) +@Intent(AsyncInvocation.ASYNCINVOCATION) +public @interface AsyncInvocation { + String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation"; + + boolean value() default true; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java new file mode 100644 index 0000000000..2b18388c8b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java @@ -0,0 +1,51 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Authentication annotation is used to indicate that the + * invocation requires authentication. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Authentication.AUTHENTICATION) +public @interface Authentication { + /** + * The serialized QName of the authentication policy intent, + * for use with the SCA @Requires annotation. + */ + String AUTHENTICATION = SCA_PREFIX + "authentication"; + /** + * The serialized QName of the authentication.message policy + * intent, for use with the SCA @Requires annotation. + */ + String AUTHENTICATION_MESSAGE = AUTHENTICATION + ".message"; + /** + * The serialized QName of the authentication.transport policy + * intent, for use with the SCA @Requires annotation. + */ + String AUTHENTICATION_TRANSPORT = AUTHENTICATION + ".transport"; + + /** + * List of authentication qualifiers (such as "message" + * or "transport"). + * + * @return authentication qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java new file mode 100644 index 0000000000..6893f6196a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Authorization annotation is used to indicate that + * an authorization policy is required. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Authorization.AUTHORIZATION) +public @interface Authorization { + /** + * The serialized QName of the authorization policy intent, + * for use with the SCA @Requires annotation. + */ + String AUTHORIZATION = SCA_PREFIX + "authorization"; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java new file mode 100644 index 0000000000..cc68baaba9 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java @@ -0,0 +1,29 @@ +/* + * Copyright(C) OASIS(R) 2005, 2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Callback annotation is used to annotate a service interface + * with a callback interface, which takes the Java Class object of + * the callback interface as a parameter. + */ +@Target({TYPE, METHOD, FIELD}) +@Retention(RUNTIME) +public @interface Callback { + + /** + * The name of a Java class file containing the callback interface. + * + * @return the callback interface + */ + Class<?> value() default Void.class; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java new file mode 100644 index 0000000000..5ea768a9ca --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java @@ -0,0 +1,21 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ComponentName annotation is used to denote a Java class field + * or setter method that is used to inject the component name. + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +public @interface ComponentName { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java new file mode 100644 index 0000000000..df5c3c502e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java @@ -0,0 +1,50 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Confidentiality annotation is used to indicate that the + * invocation requires confidentiality. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Confidentiality.CONFIDENTIALITY) +public @interface Confidentiality { + /** + * The serialized QName of the confidentiality policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY = SCA_PREFIX + "confidentiality"; + /** + * The serialized QName of the confidentiality.message policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY_MESSAGE = CONFIDENTIALITY + ".message"; + /** + * The serialized QName of the confidentiality.transport policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY_TRANSPORT = CONFIDENTIALITY + ".transport"; + + /** + * List of confidentiality qualifiers (such as "message" or "transport"). + * + * @return confidentiality qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java new file mode 100644 index 0000000000..c1c99de683 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Used to indicate the constructor the runtime is to use when instantiating a component implementation instance + * + * @version $Rev$ $Date$ + */ +@Target(CONSTRUCTOR) +@Retention(RUNTIME) +public @interface Constructor { + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java new file mode 100644 index 0000000000..90cf9b81ce --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java @@ -0,0 +1,26 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Context annotation is used to denote a Java class field + * or a setter method that is used to inject a composite context + * for the component. The type of context to be injected is defined + * by the type of the Java class field or type of the setter method + * input argument; the type is either ComponentContext or RequestContext. + * + * The @Context annotation has no attributes. + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +public @interface Context { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java new file mode 100644 index 0000000000..b4d3cd4369 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Destroy annotation is used to denote a single Java class method + * that will be called when the scope defined for the implementation + * class ends. The method MAY have any access modifier and MUST have a + * void return type and no arguments. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Destroy { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java new file mode 100644 index 0000000000..e4cd03ea4b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @EagerInit annotation is used to annotate the Java class of a + * COMPOSITE scoped implementation for eager initialization. When marked + * for eager initialization, the composite scoped instance is created + * when its containing component is started. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface EagerInit { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java new file mode 100644 index 0000000000..b4b420c175 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Init annotation is used to denote a single Java class method + * that is called when the scope defined for the implementation class + * starts. The method MAY have any access modifier and MUST have a + * void return type and no arguments. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Init { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java new file mode 100644 index 0000000000..e9918533d9 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java @@ -0,0 +1,51 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Integrity annotation is used to indicate that the invocation + * requires integrity (ie no tampering of the messages between client + * and service). + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Integrity.INTEGRITY) +public @interface Integrity { + /** + * The serialized QName of the integrity policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY = SCA_PREFIX + "integrity"; + /** + * The serialized QName of the integrity.message policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY_MESSAGE = INTEGRITY + ".message"; + /** + * The serialized QName of the integrity.transport policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY_TRANSPORT = INTEGRITY + ".transport"; + + /** + * List of integrity qualifiers (such as "message" or "transport"). + * + * @return integrity qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java new file mode 100644 index 0000000000..593ae56e67 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java @@ -0,0 +1,38 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Intent annotation is used for the creation of new annotations + * for specific intents. It is not expected that the @Intent annotation + * will be used in application code. + */ +@Target({ANNOTATION_TYPE}) +@Retention(RUNTIME) +public @interface Intent { + /** + * The qualified name of the intent, in the form defined by + * javax.xml.namespace.QName.toString(). + * @return the qualified name of the intent + */ + String value() default ""; + + /** + * The XML namespace for the intent. + * @return the XML namespace for the intent + */ + String targetNamespace() default ""; + + /** + * The name of the intent within its namespace. + * @return name of the intent within its namespace + */ + String localPart() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java new file mode 100644 index 0000000000..ba6b086756 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ManagedSharedTransaction annotation is used to indicate that + * a distributed ACID transaction is required. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(ManagedSharedTransaction.MANAGEDSHAREDTRANSACTION) +public @interface ManagedSharedTransaction { + /** + * The serialized QName of the managedSharedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDSHAREDTRANSACTION = SCA_PREFIX + "managedSharedTransaction"; +}
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java new file mode 100644 index 0000000000..6fca1ab5df --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java @@ -0,0 +1,50 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ManagedTransaction annotation is used to indicate the + * need for an ACID transaction environment. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(ManagedTransaction.MANAGEDTRANSACTION) +public @interface ManagedTransaction { + /** + * The serialized QName of the managedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION = SCA_PREFIX + "managedTransaction"; + /** + * The serialized QName of the managedTransaction.local policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION_MESSAGE = MANAGEDTRANSACTION + ".local"; + /** + * The serialized QName of the managedTransaction.global policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION_TRANSPORT = MANAGEDTRANSACTION + ".global"; + + /** + * List of managedTransaction qualifiers (such as "global" or "local"). + * + * @return managedTransaction qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java new file mode 100644 index 0000000000..9a4bf86053 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @MutualAuthentication annotation is used to indicate that + * a mutual authentication policy is needed. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(MutualAuthentication.MUTUALAUTHENTICATION) +public @interface MutualAuthentication { + /** + * The serialized QName of the mutualAuthentication policy intent, + * for use with the SCA @Requires annotation. + */ + String MUTUALAUTHENTICATION = SCA_PREFIX + "mutualAuthentication"; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java new file mode 100644 index 0000000000..5c31fbc99f --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @NoManagedTransaction annotation is used to indicate that + * a non-transactional environment is needed. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(NoManagedTransaction.NOMANAGEDTRANSACTION) +public @interface NoManagedTransaction { + /** + * The serialized QName of the noManagedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String NOMANAGEDTRANSACTION = SCA_PREFIX + "noManagedTransaction"; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java new file mode 100644 index 0000000000..1fbf83458e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java @@ -0,0 +1,23 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @OneWay annotation is used on a Java interface or class method + * to indicate that invocations will be dispatched in a non-blocking + * fashion as described in the section on Asynchronous Programming. + * + * The @OneWay annotation has no attributes. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface OneWay { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java new file mode 100644 index 0000000000..2f9fe9a098 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java @@ -0,0 +1,30 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @PolicySets annotation is used to attach one or more + * SCA Policy Sets to a Java implementation class or to one + * of its subelements. + */ +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +public @interface PolicySets { + /** + * Returns the policy sets to be applied. + * + * @return the policy sets to be applied + */ + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java new file mode 100644 index 0000000000..6a8c8a0e04 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java @@ -0,0 +1,58 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Property annotation is used to denote a Java class field, + * a setter method, or a constructor parameter that is used to + * inject an SCA property value. The type of the property injected, + * which can be a simple Java type or a complex Java type, is defined + * by the type of the Java class field or the type of the input + * parameter of the setter method or constructor. + * + * The @Property annotation can be used on fields, on setter methods + * or on a constructor method parameter. However, the @Property annotation + * MUST NOT be used on a class field that is declared as final. + * + * Properties can also be injected via setter methods even when + * the @Property annotation is not present. However, the @Property + * annotation must be used in order to inject a property onto a + * non-public field. In the case where there is no @Property + * annotation, the name of the property is the same as the name of the + * field or setter. + * + * Where there is both a setter method and a field for a property, the + * setter method is used. + */ +@Target({METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface Property { + + /** + * The name of the property. For a field annotation, the default is + * the name of the field of the Java class. For a setter method annotation, + * the default is the JavaBeans property name corresponding to the setter + * method name. For a constructor parameter annotation, there is no + * default and the name attribute MUST be present. + * + * @return the name of the property + */ + String name() default ""; + + /** + * Specifies whether injection is required, defaults to true. For a + * constructor parameter annotation, this attribute MUST have the value true. + * + * @return true if injection is required + */ + boolean required() default true; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java new file mode 100644 index 0000000000..dd002d27c7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java @@ -0,0 +1,24 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Qualifier annotation is applied to an attribute of a + * specific intent annotation definition, defined using the @Intent + * annotation, to indicate that the attribute provides qualifiers + * for the intent. The @Qualifier annotation MUST be used in a + * specific intent annotation definition where the intent has qualifiers. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Qualifier { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java new file mode 100644 index 0000000000..4dbf9412fc --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Reference annotation type is used to annotate a Java class field, + * a setter method, or a constructor parameter that is used to inject a + * service that resolves the reference. The interface of the service + * injected is defined by the type of the Java class field or the type + * of the input parameter of the setter method or constructor. + * + * The @Reference annotation MUST NOT be used on a class field that is + * declared as final. + * + * References can also be injected via setter methods even when + * the @Reference annotation is not present. However, the @Reference + * annotation must be used in order to inject a reference onto a non-public + * field. In the case where there is no @Reference annotation, the name + * of the reference is the same as the name of the field or setter. + * + * Where there is both a setter method and a field for a reference, the + * setter method is used. + */ +@Target({METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface Reference { + + /** + * The name of the reference. For a field annotation, the default is + * the name of the field of the Java class. For a setter method + * annotation, the default is the JavaBeans property name corresponding + * to the setter method name. For a constructor parameter annotation, + * there is no default and the name attribute MUST be present. + * + * @return the name of the reference + */ + String name() default ""; + + /** + * Specifies whether injection of service or services is required. + * Defaults to true. For a constructor parameter annotation, this + * attribute MUST have the value true. + * + * @return true if injection is required + */ + boolean required() default true; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java new file mode 100644 index 0000000000..50f3557bed --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java @@ -0,0 +1,23 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Remotable annotation is used to specify a Java service + * interface as remotable. A remotable service can be published + * externally as a service and must be translatable into a WSDL portType. + * + * The @Remotable annotation has no attributes. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface Remotable { + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java new file mode 100644 index 0000000000..b5d485e016 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Requires annotation supports general purpose intents + * specified as strings. Users can also define specific intent + * annotations using the @Intent annotation. + */ +@Inherited +@Retention(RUNTIME) +@Target({TYPE, METHOD, FIELD, PARAMETER}) +public @interface Requires { + /** + * Returns the attached intents. + * + * @return the attached intents + */ + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java new file mode 100644 index 0000000000..087f589168 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java @@ -0,0 +1,36 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Scope annotation MUST only be used on a service's implementation + * class. It is an error to use this annotation on an interface. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface Scope { + + /** + * The name of the scope. + * + * For 'STATELESS' implementations, a different implementation + * instance can be used to service each request. Implementation + * instances can be newly created or be drawn from a pool of instances. + * + * SCA defines the following scope names, but others can be defined + * by particular Java-based implementation types: + * STATELESS + * COMPOSITE + * The default value is STATELESS. + * + * @return the name of the scope + */ + String value() default "STATELESS"; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java new file mode 100644 index 0000000000..5c2600ff12 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java @@ -0,0 +1,45 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Service annotation is used on a component implementation + * class to specify the SCA services offered by the implementation. + * + * The class need not be declared as implementing all of the + * interfaces implied by the services, but all methods of the service + * interfaces must be present. + * + * A class used as the implementation of a service is not required + * to have a @Service annotation. If a class has no @Service annotation, + * then the rules determining which services are offered and what + * interfaces those services have are determined by the specific + * implementation type. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface Service { + + /** + * The value is an array of interface or class objects that should be + * exposed as services by this component. + * + * @return the services of this component + */ + Class<?>[] value(); + + /** + * The value is an array of strings which are used as the service names + * for each of the interfaces declared in the value array. + * + * @return the service names + */ + String[] names() default {}; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html new file mode 100644 index 0000000000..b29df75b5f --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html @@ -0,0 +1,3 @@ +<body>
+Provides SCA common annotation definitions for Java.
+</body>
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java new file mode 100644 index 0000000000..9e25d407a5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java @@ -0,0 +1,152 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.client; + +import java.net.URI; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; +import org.oasisopen.sca.client.SCAClientFactoryFinder; +import org.oasisopen.sca.client.impl.SCAClientFactoryFinderImpl; + +/** + * The SCAClientFactory can be used by non-SCA managed code to + * lookup services that exist in a SCA Domain. + * + * @see SCAClientFactoryFinderImpl + * + * @author OASIS Open + */ + +public abstract class SCAClientFactory { + + /** + * The SCAClientFactoryFinder. + * Provides a means by which a provider of an SCAClientFactory + * implementation can inject a factory finder implementation into + * the abstract SCAClientFactory class - once this is done, future + * invocations of the SCAClientFactory use the injected factory + * finder to locate and return an instance of a subclass of + * SCAClientFactory. + */ + protected static SCAClientFactoryFinder factoryFinder; + /** + * The Domain URI of the SCA Domain which is accessed by this + * SCAClientFactory + */ + private URI domainURI; + + /** + * Prevent concrete subclasses from using the no-arg constructor + */ + private SCAClientFactory() { + } + + /** + * Constructor used by concrete subclasses + * @param domainURI - The Domain URI of the Domain accessed via this + * SCAClientFactory + */ + protected SCAClientFactory(URI domainURI) + throws NoSuchDomainException { + this.domainURI = domainURI; + } + + /** + * Gets the Domain URI of the Domain accessed via this SCAClientFactory + * @return - the URI for the Domain + */ + protected URI getDomainURI() { + return domainURI; + } + + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory + */ + public static SCAClientFactory newInstance( URI domainURI ) + throws NoSuchDomainException { + return newInstance(null, null, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param properties Properties that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(Properties properties, + URI domainURI) + throws NoSuchDomainException { + return newInstance(properties, null, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param classLoader ClassLoader that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(ClassLoader classLoader, + URI domainURI) + throws NoSuchDomainException { + return newInstance(null, classLoader, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param properties Properties that may be used when + * creating a new instance of the SCAClientFactory + * @param classLoader ClassLoader that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(Properties properties, + ClassLoader classLoader, + URI domainURI) + throws NoSuchDomainException { + final SCAClientFactoryFinder finder = + factoryFinder != null ? factoryFinder : + new SCAClientFactoryFinderImpl(); + final SCAClientFactory factory + = finder.find(properties, classLoader, domainURI); + return factory; + } + + /** + * Returns a reference proxy that implements the business interface <T> + * of a service in the SCA Domain handled by this SCAClientFactory + * + * @param serviceURI the relative URI of the target service. Takes the + * form componentName/serviceName. + * Can also take the extended form componentName/serviceName/bindingName + * to use a specific binding of the target service + * + * @param interfaze The business interface class of the service in the + * domain + * @param <T> The business interface class of the service in the domain + * + * @return a proxy to the target service, in the specified SCA Domain + * that implements the business interface <B>. + * @throws NoSuchServiceException Service requested was not found + * @throws NoSuchDomainException Domain requested was not found + */ + public abstract <T> T getService(Class<T> interfaze, String serviceURI) + throws NoSuchServiceException, NoSuchDomainException; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java new file mode 100644 index 0000000000..54a73fc023 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java @@ -0,0 +1,35 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ + +package org.oasisopen.sca.client; + +import java.net.URI; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; + +/* A Service Provider Interface representing a SCAClientFactory finder. + * SCA provides a default reference implementation of this interface. + * SCA runtime vendors can create alternative implementations of this + * interface that use different class loading or lookup mechanisms. + */ +public interface SCAClientFactoryFinder { + + /** + * Method for finding the SCAClientFactory for a given Domain URI using + * a specified set of properties and a a specified ClassLoader + * @param properties - properties to use - may be null + * @param classLoader - ClassLoader to use - may be null + * @param domainURI - the Domain URI - must be a valid SCA Domain URI + * @return - the SCAClientFactory or null if the factory could not be + * @throws - NoSuchDomainException if the domainURI does not reference + * a valid SCA Domain + * found + */ + SCAClientFactory find(Properties properties, + ClassLoader classLoader, + URI domainURI ) + throws NoSuchDomainException ; +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java new file mode 100644 index 0000000000..0f5eae7603 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java @@ -0,0 +1,289 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.client.impl; + +import org.oasisopen.sca.client.SCAClientFactoryFinder; + +import java.io.BufferedReader; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URL; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.client.SCAClientFactory; + +/** + * This is a default implementation of an SCAClientFactoryFinder which is + * used to find an implementation of the SCAClientFactory interface. + * + * @see SCAClientFactoryFinder + * @see SCAClientFactory + * + * @author OASIS Open + */ +public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder { + + /** + * The name of the System Property used to determine the SPI + * implementation to use for the SCAClientFactory. + */ + private static final String SCA_CLIENT_FACTORY_PROVIDER_KEY = + SCAClientFactory.class.getName(); + + /** + * The name of the file loaded from the ClassPath to determine + * the SPI implementation to use for the SCAClientFactory. + */ + private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE + = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY; + + /** + * Public Constructor + */ + public SCAClientFactoryFinderImpl() { + } + + /** + * Creates an instance of the SCAClientFactorySPI implementation. + * This discovers the SCAClientFactorySPI Implementation and instantiates + * the provider's implementation. + * + * @param properties Properties that may be used when creating a new + * instance of the SCAClient + * @param classLoader ClassLoader that may be used when creating a new + * instance of the SCAClient + * @return new instance of the SCAClientFactory + * @throws ServiceRuntimeException Failed to create SCAClientFactory + * Implementation. + */ + public SCAClientFactory find(Properties properties, + ClassLoader classLoader, + URI domainURI ) + throws NoSuchDomainException, ServiceRuntimeException { + if (classLoader == null) { + classLoader = getThreadContextClassLoader (); + } + final String factoryImplClassName = + discoverProviderFactoryImplClass(properties, classLoader); + final Class<? extends SCAClientFactory> factoryImplClass + = loadProviderFactoryClass(factoryImplClassName, + classLoader); + final SCAClientFactory factory = + instantiateSCAClientFactoryClass(factoryImplClass, + domainURI ); + return factory; + } + + /** + * Gets the Context ClassLoader for the current Thread. + * + * @return The Context ClassLoader for the current Thread. + */ + private static ClassLoader getThreadContextClassLoader () { + final ClassLoader threadClassLoader = + Thread.currentThread().getContextClassLoader(); + return threadClassLoader; + } + + /** + * Attempts to discover the class name for the SCAClientFactorySPI + * implementation from the specified Properties, the System Properties + * or the specified ClassLoader. + * + * @return The class name of the SCAClientFactorySPI implementation + * @throw ServiceRuntimeException Failed to find implementation for + * SCAClientFactorySPI. + */ + private static String + discoverProviderFactoryImplClass(Properties properties, + ClassLoader classLoader) + throws ServiceRuntimeException { + String providerClassName = + checkPropertiesForSPIClassName(properties); + if (providerClassName != null) { + return providerClassName; + } + + providerClassName = + checkPropertiesForSPIClassName(System.getProperties()); + if (providerClassName != null) { + return providerClassName; + } + + providerClassName = checkMETAINFServicesForSPIClassName(classLoader); + if (providerClassName == null) { + throw new ServiceRuntimeException( + "Failed to find implementation for SCAClientFactory"); + } + + return providerClassName; + } + + /** + * Attempts to find the class name for the SCAClientFactorySPI + * implementation from the specified Properties. + * + * @return The class name for the SCAClientFactorySPI implementation + * or <code>null</code> if not found. + */ + private static String + checkPropertiesForSPIClassName(Properties properties) { + if (properties == null) { + return null; + } + + final String providerClassName = + properties.getProperty(SCA_CLIENT_FACTORY_PROVIDER_KEY); + if (providerClassName != null && providerClassName.length() > 0) { + return providerClassName; + } + + return null; + } + + /** + * Attempts to find the class name for the SCAClientFactorySPI + * implementation from the META-INF/services directory + * + * @return The class name for the SCAClientFactorySPI implementation or + * <code>null</code> if not found. + */ + private static String checkMETAINFServicesForSPIClassName(ClassLoader cl) + { + final URL url = + cl.getResource(SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE); + if (url == null) { + return null; + } + + InputStream in = null; + try { + in = url.openStream(); + BufferedReader reader = null; + try { + reader = + new BufferedReader(new InputStreamReader(in, "UTF-8")); + + String line; + while ((line = readNextLine(reader)) != null) { + if (!line.startsWith("#") && line.length() > 0) { + return line; + } + } + + return null; + } finally { + closeStream(reader); + } + } catch (IOException ex) { + throw new ServiceRuntimeException( + "Failed to discover SCAClientFactory provider", ex); + } finally { + closeStream(in); + } + } + + /** + * Reads the next line from the reader and returns the trimmed version + * of that line + * + * @param reader The reader from which to read the next line + * @return The trimmed next line or <code>null</code> if the end of the + * stream has been reached + * @throws IOException I/O error occurred while reading from Reader + */ + private static String readNextLine(BufferedReader reader) + throws IOException { + + String line = reader.readLine(); + if (line != null) { + line = line.trim(); + } + return line; + } + + /** + * Loads the specified SCAClientFactory Implementation class. + * + * @param factoryImplClassName The name of the SCAClientFactory + * Implementation class to load + * @return The specified SCAClientFactory Implementation class + * @throws ServiceRuntimeException Failed to load the SCAClientFactory + * Implementation class + */ + private static Class<? extends SCAClientFactory> + loadProviderFactoryClass(String factoryImplClassName, + ClassLoader classLoader) + throws ServiceRuntimeException { + + try { + final Class<?> providerClass = + classLoader.loadClass(factoryImplClassName); + final Class<? extends SCAClientFactory> providerFactoryClass = + providerClass.asSubclass(SCAClientFactory.class); + return providerFactoryClass; + } catch (ClassNotFoundException ex) { + throw new ServiceRuntimeException( + "Failed to load SCAClientFactory implementation class " + + factoryImplClassName, ex); + } catch (ClassCastException ex) { + throw new ServiceRuntimeException( + "Loaded SCAClientFactory implementation class " + + factoryImplClassName + + " is not a subclass of " + + SCAClientFactory.class.getName() , ex); + } + } + + /** + * Instantiate an instance of the specified SCAClientFactorySPI + * Implementation class. + * + * @param factoryImplClass The SCAClientFactorySPI Implementation + * class to instantiate. + * @return An instance of the SCAClientFactorySPI Implementation class + * @throws ServiceRuntimeException Failed to instantiate the specified + * specified SCAClientFactorySPI Implementation class + */ + private static SCAClientFactory instantiateSCAClientFactoryClass( + Class<? extends SCAClientFactory> factoryImplClass, + URI domainURI) + throws NoSuchDomainException, ServiceRuntimeException { + + try { + Constructor<? extends SCAClientFactory> URIConstructor = + factoryImplClass.getConstructor(domainURI.getClass()); + SCAClientFactory provider = + URIConstructor.newInstance( domainURI ); + return provider; + } catch (Throwable ex) { + throw new ServiceRuntimeException( + "Failed to instantiate SCAClientFactory implementation class " + + factoryImplClass, ex); + } + } + + /** + * Utility method for closing Closeable Object. + * + * @param closeable The Object to close. + */ + private static void closeStream(Closeable closeable) { + if (closeable != null) { + try{ + closeable.close(); + } catch (IOException ex) { + throw new ServiceRuntimeException("Failed to close stream", + ex); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/package.html b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/package.html new file mode 100644 index 0000000000..236fc686a0 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/sca-api/src/main/java/org/oasisopen/sca/package.html @@ -0,0 +1,3 @@ +<body>
+Provides SCA common API definitions for Java.
+</body>
|