You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/01/19 21:19:02 UTC
svn commit: r497937 - in /incubator/tuscany/sandbox/jboynes/sca-client: ./
src/main/java/org/osoa/sca/ src/main/java/org/osoa/sca/annotations/
src/test/java/org/osoa/sca/ src/test/resources/
src/test/resources/META-INF/ src/test/resources/META-INF/serv...
Author: jboynes
Date: Fri Jan 19 12:19:01 2007
New Revision: 497937
URL: http://svn.apache.org/viewvc?view=rev&rev=497937
Log:
strawman for updates to client API
Added:
incubator/tuscany/sandbox/jboynes/sca-client/
- copied from r497628, incubator/tuscany/java/spec/sca/
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java (with props)
incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/
incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/
incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/
incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/org.osoa.sca.DomainFactory
Removed:
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CurrentCompositeContext.java
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentName.java
Modified:
incubator/tuscany/sandbox/jboynes/sca-client/pom.xml
incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java
Modified: incubator/tuscany/sandbox/jboynes/sca-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/pom.xml?view=diff&rev=497937&r1=497628&r2=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/pom.xml (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/pom.xml Fri Jan 19 12:19:01 2007
@@ -32,7 +32,7 @@
<packaging>osgi-bundle</packaging>
<properties>
- <specVersion>0.95</specVersion>
+ <specVersion>1.0</specVersion>
</properties>
<!-- definition of repositories where the parent pom can be found -->
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,14 @@
+package org.osoa.sca;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ComponentContext {
+ /**
+ * Returns the absolute URI of the component within the SCA Domain.
+ *
+ * @return the absolute URI of the component
+ */
+ String getURI();
+
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java?view=diff&rev=497937&r1=497628&r2=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java Fri Jan 19 12:19:01 2007
@@ -24,37 +24,16 @@
*
* @version $Rev$ $Date$
*/
-public interface CompositeContext {
-
+public interface CompositeContext extends ComponentContext {
/**
- * Returns the name of the parent composite.
+ * Returns a reference to a service within this composite. The service may be provided by a component
+ * or a reference that is defined in this composite.
*
- * @return the name of the module
- */
- String getName();
-
- /**
- * Returns the absolute URI of the composite component.
- *
- * @return the absolute URI of the module component
- */
- String getURI();
-
- /**
- * Returns the request context that corresponds to the last remotable service invocation. If this is
- * invoked from outside an SCA component then <tt>null</tt> is returned.
- *
- * @return the current request context
- */
- RequestContext getRequestContext();
-
- /**
- * Returns an object implementing the interface defined for the named service.
- *
- * @param serviceName the name of another service in the current module
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param serviceName the name of another service in thus composite
* @return an object that implements the service's interface
*/
- <T> T locateService(Class<T> serviceType, String serviceName);
+ <T> T locateService(Class<T> businessInterface, String serviceName);
/**
* Create a reference to the supplied component. The component must define only one service.
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,86 @@
+package org.osoa.sca;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class DomainFactory {
+ /**
+ * Returns a DomainFactory based on the calling Thread's context classloader.
+ * Equivalent to
+ * <code>
+ * DomainFactory.getInstance(Thread.currentThread.getContextClassLoader);
+ * </code>
+ *
+ * @return a DomainFactory based on the current context classloader
+ * @see #getInstance(ClassLoader)
+ */
+ public static DomainFactory getInstance() {
+ ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ return getInstance(classLoader);
+ }
+
+ /**
+ * Returns a DomainFactory instantiated using the supplied classloader.
+ * If the system property "org.osoa.sca.DomainFactory" is set, its value is used as the name of the
+ * implementation class. Otherwise, if the resource "META-INF/services/org.osoa.sca.DomainFactory"
+ * can be loaded from the supplied classloader it is assumed to contain a single line containing the name of
+ * the implementation class. The named class is loaded from the supplied classloader and instantiated using
+ * its default (no-arg) constructor.
+ *
+ * @param classloader the classloader to use to locate and instantiate the DomainFactory implementation
+ * @return a DomainFactory loaded from the supplied classloader or null if a factory could not be located
+ * @throws DomainFactoryException if there was a problem instantiating the factory
+ */
+ public static DomainFactory getInstance(ClassLoader classloader) {
+ String name = AccessController.doPrivileged(new PrivilegedAction<String>() {
+
+ public String run() {
+ return System.getProperty("org.osoa.sca.DomainFactory");
+ }
+ });
+
+ if (name == null) {
+ try {
+ name = getServiceName(classloader);
+ } catch (IOException e) {
+ throw new DomainFactoryException(e);
+ }
+ }
+
+ try {
+ Class<?> implClass = Class.forName(name, true, classloader);
+ return (DomainFactory) implClass.newInstance();
+ } catch (Exception e) {
+ throw new DomainFactoryException(e);
+ }
+ }
+
+ private static String getServiceName(ClassLoader classLoader) throws IOException {
+ InputStream is = classLoader.getResourceAsStream("META-INF/services/org.osoa.sca.DomainFactory");
+ if (is == null) {
+ return null;
+ }
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ return reader.readLine();
+ } finally {
+ is.close();
+ }
+ }
+
+ public abstract SCADomain createLocalDomain();
+
+ public abstract SCADomain joinDomain(URI domainId);
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,12 @@
+package org.osoa.sca;
+
+/**
+ * Exception indicating that there was a problem instantiating a DomainFactory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DomainFactoryException extends RuntimeException {
+ public DomainFactoryException(Throwable throwable) {
+ super(throwable);
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/DomainFactoryException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,26 @@
+package org.osoa.sca;
+
+import java.net.URI;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface SCADomain {
+ /**
+ * Return the base URI for this domain.
+ *
+ * @return the base URI for this domain
+ */
+ URI getBaseURI();
+
+ /**
+ * Return the CompositeContext identified by the supplied component id.
+ * The supplied URI must identify a component implemented by a composite.
+ * The returned context can be used by unmanaged code to access services
+ * provided by components defined in the composite.
+ *
+ * @param componentURI the id of a component implemented by a composite
+ * @return the context for that component
+ */
+ CompositeContext getContext(URI componentURI);
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/SCADomain.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.osoa.sca.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to indicate an injection site for the SCA identity of a component.
+ * Every component in a SCA Domain has a unique identity that derived from the base URI of the domain.
+ * This annotation can be used to indicate to the container that a component implemention requires that
+ * its identity be injected. The annotation can be applied to:
+ * <ul>
+ * <li>a public or protected field with type @{link java.lang.String} or @{link java.net.URI}</li>
+ * <li>a public or protected method with a single parameter with type @{link java.lang.String} or @{link java.net.URI}</li>
+ * <li>a parameter of a public constructor with type @{link java.lang.String} or @{link java.net.URI}</li>
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface ComponentID {
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/annotations/ComponentID.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java Fri Jan 19 12:19:01 2007
@@ -0,0 +1,18 @@
+package org.osoa.sca;
+
+import java.net.URI;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DelegatingDomainFactory extends DomainFactory {
+ DomainFactory delegate;
+
+ public SCADomain createLocalDomain() {
+ return delegate.createLocalDomain();
+ }
+
+ public SCADomain joinDomain(URI domainId) {
+ return delegate.joinDomain(domainId);
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/org/osoa/sca/DelegatingDomainFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/org.osoa.sca.DomainFactory
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/org.osoa.sca.DomainFactory?view=auto&rev=497937
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/org.osoa.sca.DomainFactory (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/resources/META-INF/services/org.osoa.sca.DomainFactory Fri Jan 19 12:19:01 2007
@@ -0,0 +1 @@
+org.osoa.sca.DelegatingDomainFactory
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org