You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/05/05 06:46:53 UTC
svn commit: r535443 - in
/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded:
SCADomain.java impl/DefaultSCADomain.java impl/ReallySmallRuntime.java
Author: jsdelfino
Date: Fri May 4 21:46:51 2007
New Revision: 535443
URL: http://svn.apache.org/viewvc?view=rev&rev=535443
Log:
Minor code and javadoc cleanup.
Modified:
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntime.java
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java?view=diff&rev=535443&r1=535442&r2=535443
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java Fri May 4 21:46:51 2007
@@ -40,11 +40,11 @@
public abstract class SCADomain {
/**
- * Returns a new instance of an SCA domain. The given deployable composites will
- * be included in the SCA domain and the contributions that contirbute them will
- * be made available in the domain as well.
+ * Returns a new instance of a local SCA domain. The specified deployable composites will
+ * be included in the SCA domain.
*
- * @param uri the URI of the SCA domain
+ * @param domainURI the URI of the SCA domain
+ * @param contributionLocation the location of an SCA contribution
* @param composites the deployable composites to include in the SCA domain.
* @return
*/
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java?view=diff&rev=535443&r1=535442&r2=535443
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java Fri May 4 21:46:51 2007
@@ -40,15 +40,17 @@
import org.apache.tuscany.core.runtime.DefaultCompositeActivator;
import org.apache.tuscany.host.embedded.SCADomain;
import org.apache.tuscany.interfacedef.IncompatibleInterfaceContractException;
-import org.apache.tuscany.spi.Scope;
-import org.apache.tuscany.spi.component.GroupInitializationException;
-import org.apache.tuscany.spi.component.WorkContextTunnel;
import org.osoa.sca.CallableReference;
import org.osoa.sca.ComponentContext;
import org.osoa.sca.Constants;
import org.osoa.sca.ServiceReference;
import org.osoa.sca.ServiceRuntimeException;
+/**
+ * A default SCA domain facade implementation.
+ *
+ * @version $Rev$ $Date$
+ */
public class DefaultSCADomain extends SCADomain {
private String domainURI;
@@ -57,9 +59,15 @@
private Composite domainComposite;
private Contribution contribution;
private Map<String, ComponentContext> components = new HashMap<String, ComponentContext>();
-
private ReallySmallRuntime runtime;
-
+
+ /**
+ * Constructs a new domain facade.
+ *
+ * @param domainURI
+ * @param contributionLocation
+ * @param composites
+ */
public DefaultSCADomain(String domainURI, String contributionLocation, String... composites) {
this.domainURI = domainURI;
this.location = contributionLocation;
@@ -125,7 +133,7 @@
components.put(component.getName(), (ComponentContext)component);
}
}
-
+
@Override
public void close() {
@@ -154,6 +162,16 @@
}
}
+ /**
+ * Determine the location of a contribution, given a contribution path and a
+ * list of composites.
+ *
+ * @param contributionPath
+ * @param composites
+ * @param classLoader
+ * @return
+ * @throws MalformedURLException
+ */
private URL getContributionLocation(String contributionPath, String[] composites, ClassLoader classLoader) throws MalformedURLException {
URI contributionURI = URI.create(contributionPath);
if (contributionURI.isAbsolute() || composites.length == 0) {
@@ -192,7 +210,6 @@
return contributionURL;
}
-
@Override
public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
// TODO Auto-generated method stub
@@ -201,25 +218,37 @@
@Override
public <B> B getService(Class<B> businessInterface, String serviceName) {
- return getServiceReference(businessInterface, serviceName).getService();
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
}
@Override
public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName) {
+ String componentName;
int i = serviceName.indexOf('/');
if (i != -1) {
- String componentName = serviceName.substring(0, i);
+ componentName = serviceName.substring(0, i);
serviceName = serviceName.substring(i+1);
- ComponentContext componentContext = components.get(componentName);
- ServiceReference<B> serviceReference = componentContext.createSelfReference(businessInterface, serviceName);
- return serviceReference;
-
} else {
- ComponentContext componentContext = components.get(serviceName);
- ServiceReference<B> serviceReference = componentContext.createSelfReference(businessInterface);
- return serviceReference;
+ componentName = serviceName;
+ serviceName = null;
}
+ ComponentContext componentContext = components.get(componentName);
+ if (componentContext == null) {
+ throw new ServiceRuntimeException("Component not found: " + componentName);
+ }
+ ServiceReference<B> serviceReference;
+ if (serviceName != null) {
+ serviceReference = componentContext.createSelfReference(businessInterface, serviceName);
+ } else {
+ serviceReference = componentContext.createSelfReference(businessInterface);
+ }
+ return serviceReference;
+
}
@Override
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntime.java?view=diff&rev=535443&r1=535442&r2=535443
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntime.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/ReallySmallRuntime.java Fri May 4 21:46:51 2007
@@ -148,6 +148,7 @@
}
//FIXME Remove this
+ @SuppressWarnings("unchecked")
public void startDomainWorkContext(Composite domain) {
workContext.setIdentifier(Scope.COMPOSITE, domain);
WorkContextTunnel.setThreadWorkContext(workContext);
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org