You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/28 23:25:47 UTC
svn commit: r513015 -
/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
Author: rfeng
Date: Wed Feb 28 14:25:46 2007
New Revision: 513015
URL: http://svn.apache.org/viewvc?view=rev&rev=513015
Log:
Clean up the code
Modified:
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java?view=diff&rev=513015&r1=513014&r2=513015
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java Wed Feb 28 14:25:46 2007
@@ -65,7 +65,7 @@
protected CompositeContextImpl context;
protected LauncherImpl launcher;
protected MonitorFactory monitorFactory;
- //lresende - contribution
+ // lresende - contribution
protected AssemblyService assemblyService;
protected ContributionService contributionService;
@@ -86,13 +86,16 @@
try {
CompositeComponent composite = launcher.bootRuntime(system, monitorFactory);
- //lresende - contribution
+ // lresende - contribution
AtomicComponent csComponent =
(AtomicComponent)composite.getSystemChild(ComponentNames.TUSCANY_CONTRIBUTION_SERVICE);
- contributionService = (ContributionService) csComponent.getTargetInstance();
-
+ contributionService = (ContributionService)csComponent.getTargetInstance();
+
+ // TODO: Make assembly service a pluggable component?
this.assemblyService = new AssemblyServiceImpl(contributionService, composite);
- composite.registerJavaObject(ComponentNames.TUSCANY_ASSEMBLY_SERVICE, AssemblyService.class, assemblyService);
+ composite.registerJavaObject(ComponentNames.TUSCANY_ASSEMBLY_SERVICE,
+ AssemblyService.class,
+ assemblyService);
List<URL> extensions = new ArrayList<URL>();
Enumeration<URL> urls = cl.getResources(SCAContainer.SERVICE_SCDL);
@@ -103,7 +106,7 @@
for (URL ext : exts) {
if (!extensions.contains(ext)) {
extensions.add(ext);
- }
+ }
}
}
int i = 0;
@@ -118,29 +121,31 @@
WireService wireService = (WireService)((AtomicComponent)wireServiceComponent).getTargetInstance();
- //Start using contribution services
+ // Start using contribution services
if (applicationSCDL == null) {
applicationSCDL = cl.getResource(SCAContainer.APPLICATION_SCDL);
if (applicationSCDL == null) {
applicationSCDL = cl.getResource(SCAContainer.META_APPLICATION_SCDL);
- if (applicationSCDL != null)
+ if (applicationSCDL != null) {
compositePath = SCAContainer.META_APPLICATION_SCDL;
+ }
} else {
- if (compositePath == null)
+ if (compositePath == null) {
compositePath = SCAContainer.APPLICATION_SCDL;
+ }
}
if (applicationSCDL == null) {
throw new RuntimeException("application SCDL not found: " + SCAContainer.APPLICATION_SCDL);
}
- }
-
- //lresende - contribution
+ }
+
+ // lresende - contribution
URL contributionLocation = getContributionLocation(applicationSCDL, compositePath);
URI contributionId = this.contributionService.contribute(contributionLocation, false);
URI compositeDefinitionId = new URI(contributionId + FileHelper.getName(applicationSCDL.toString()));
-
- component = (CompositeComponent) this.assemblyService.addCompositeToDomain(contributionId, compositeDefinitionId);
+ component =
+ (CompositeComponent)this.assemblyService.addCompositeToDomain(contributionId, compositeDefinitionId);
context = new CompositeContextImpl(component, wireService);
CurrentCompositeContext.setContext(context);
@@ -151,31 +156,31 @@
}
}
-
+
private URL getContributionLocation(URL applicationSCDL, String compositePath) {
URL root = null;
// "jar:file://....../something.jar!/a/b/c/app.composite"
-
+
try {
String scdlUrl = applicationSCDL.toExternalForm();
String protocol = applicationSCDL.getProtocol();
- if(protocol.equals("file")){
- //directory contribution
- if(scdlUrl.endsWith( compositePath )) {
- String location = scdlUrl.substring(0, scdlUrl.lastIndexOf((compositePath)));
- //workaround from evil url/uri form maven
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (scdlUrl.endsWith(compositePath)) {
+ String location = scdlUrl.substring(0, scdlUrl.lastIndexOf(compositePath));
+ // workaround from evil url/uri form maven
root = FileHelper.toFile(new URL(location)).toURI().toURL();
}
- } else if( protocol.equals("jar")) {
- //jar contribution
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
String location = scdlUrl.substring(4, scdlUrl.lastIndexOf("!/"));
- //workaround from evil url/uri form maven
+ // workaround from evil url/uri form maven
root = FileHelper.toFile(new URL(location)).toURI().toURL();
}
} catch (MalformedURLException mfe) {
-
+ throw new IllegalArgumentException(mfe);
}
return root;
@@ -207,7 +212,7 @@
Component component = deployer.deploy(composite, definition);
component.start();
}
-
+
protected void shutdown() throws Exception {
CurrentCompositeContext.setContext(null);
component.stop();
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org