You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/02/16 01:25:31 UTC
svn commit: r508251 - in /incubator/tuscany/java/sca/runtime/standalone:
launcher/src/main/java/org/apache/tuscany/launcher/
launcher/src/main/resources/org/apache/tuscany/launcher/
standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/ st...
Author: meerajk
Date: Thu Feb 15 16:25:30 2007
New Revision: 508251
URL: http://svn.apache.org/viewvc?view=rev&rev=508251
Log:
Added code to deploy the app scdl
Added:
incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java (with props)
Modified:
incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties
incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
Modified: incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java?view=diff&rev=508251&r1=508250&r2=508251
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java Thu Feb 15 16:25:30 2007
@@ -32,6 +32,7 @@
import org.apache.tuscany.host.runtime.TuscanyRuntime;
import org.apache.tuscany.runtime.standalone.DirectoryHelper;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntime;
import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
/**
@@ -44,6 +45,7 @@
* @version $Rev$ $Date$
*/
public class Main {
+
/**
* Main method.
*
@@ -52,7 +54,8 @@
* application
*/
public static void main(String[] args) throws Throwable {
- if (args.length != 2) {
+
+ if (args.length != 1) {
usage();
throw new AssertionError();
}
@@ -60,48 +63,28 @@
URI applicationURI = new URI(args[0]);
StandaloneRuntimeInfo runtimeInfo = DirectoryHelper.createRuntimeInfo("launcher", Main.class);
- TuscanyRuntime runtime = DirectoryHelper.createRuntime(runtimeInfo);
+ StandaloneRuntime runtime = (StandaloneRuntime)DirectoryHelper.createRuntime(runtimeInfo);
runtime.initialize();
- deployApplication(args, applicationURI, runtime);
-
- try {
-
- String serviceName = applicationURI.getFragment();
- ComponentContext context = runtime.getComponentContext(applicationURI);
- if (context == null) {
- noComponent(applicationURI);
- throw new AssertionError();
- }
- ServiceReference<Callable> service;
- if (serviceName == null) {
- service = context.createSelfReference(Callable.class);
- } else {
- service = context.createSelfReference(Callable.class, serviceName);
- }
- Callable callable = service.getService();
- callable.call();
- } finally {
- runtime.destroy();
- }
+ ComponentContext componentContext = deployApplication(args, applicationURI, runtime);
+ // TODO lookup implementation.lauched and do the rest
+
}
- private static void deployApplication(String[] args, URI applicationURI, TuscanyRuntime runtime) throws MalformedURLException {
+ /**
+ * @deprecated Hack for deployment.
+ */
+ private static ComponentContext deployApplication(String[] args, URI applicationURI, StandaloneRuntime runtime)
+ throws Exception {
+
+ URI compositeUri = new URI("/test/composite");
URL applicationJar = new File(args[1]).toURL();
ClassLoader applicationClassLoader =
new URLClassLoader(new URL[] {applicationJar}, runtime.getHostClassLoader());
- URL appScdl = applicationClassLoader.getResource("META-INF/sca/default.scdl");
- // TODO Deploy the SCDL
-/* the launcher's classloader should not contain the SPI module
-
- CompositeImplementation impl = new CompositeImplementation();
- impl.setScdlLocation(appScdl);
- impl.setClassLoader(applicationClassLoader);
-
- ComponentDefinition<CompositeImplementation> definition =
- new ComponentDefinition<CompositeImplementation>(applicationURI, impl);
-*/
+ URL applicationScdl = applicationClassLoader.getResource("META-INF/sca/default.scdl");
+ return runtime.deploy(compositeUri, applicationScdl, applicationClassLoader);
+
}
private static void usage() {
Modified: incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties?view=diff&rev=508251&r1=508250&r2=508251
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties (original)
+++ incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties Thu Feb 15 16:25:30 2007
@@ -17,5 +17,5 @@
#
# $Rev$ $Date$
#
-org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar <componentURI> <componentJar>
+org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar <componentJar>
org.apache.tuscany.launcher.NoComponent=No component found with id "{0}"
Added: incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java?view=auto&rev=508251
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java (added)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java Thu Feb 15 16:25:30 2007
@@ -0,0 +1,47 @@
+/*
+ * 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.apache.tuscany.runtime.standalone;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * Extends the tuscany runtime to add the behavious to deploy an
+ * application SCDL.
+ *
+ * @version $Revision$ $Date$
+ *
+ */
+public interface StandaloneRuntime extends TuscanyRuntime {
+
+ /**
+ * Deploys the specified application SCDL.
+ *
+ * @param compositeUri URI by which the composite is deployed.
+ * @param applicationScdl Application SCDL that implements the composite.
+ * @param applicationClassLoader Classloader used to deploy the composite.
+ * @return The component context for the deployed composite.
+ * @deprecated This is a hack for deployment and should be removed.
+ */
+ ComponentContext deploy(URI compositeUri, URL applicationScdl, ClassLoader applicationClassLoader) throws Exception;
+
+}
Propchange: incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java?view=diff&rev=508251&r1=508250&r2=508251
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java Thu Feb 15 16:25:30 2007
@@ -18,16 +18,26 @@
*/
package org.apache.tuscany.runtime.standalone.host;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.RegistrationException;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
import org.apache.tuscany.core.runtime.AbstractRuntime;
import org.apache.tuscany.host.runtime.InitializationException;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntime;
import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+import org.osoa.sca.ComponentContext;
/**
* @version $Rev$ $Date$
*/
-public class StandaloneRuntimeImpl extends AbstractRuntime {
+public class StandaloneRuntimeImpl extends AbstractRuntime implements StandaloneRuntime {
protected void registerSystemComponents() throws InitializationException {
super.registerSystemComponents();
@@ -37,6 +47,37 @@
(StandaloneRuntimeInfo) getRuntimeInfo());
} catch (RegistrationException e) {
throw new InitializationException(e);
+ }
+ }
+
+ /**
+ * Deploys the specified application SCDL.
+ *
+ * @param compositeUri URI by which the composite is deployed.
+ * @param applicationScdl Application SCDL that implements the composite.
+ * @param applicationClassLoader Classloader used to deploy the composite.
+ * @return The component context for the deployed composite.
+ * @deprecated This is a hack for deployment and should be removed.
+ */
+ public ComponentContext deploy(URI compositeUri, URL applicationScdl, ClassLoader applicationClassLoader) throws Exception {
+
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(applicationScdl);
+ impl.setClassLoader(applicationClassLoader);
+
+ ComponentDefinition<CompositeImplementation> definition =
+ new ComponentDefinition<CompositeImplementation>(compositeUri, impl);
+
+ return getDeployer().deploy(null, definition).getComponentContext();
+ }
+
+ protected Deployer getDeployer() {
+ try {
+ URI uri = URI.create("sca://root.system/main/deployer");
+ AtomicComponent component = (AtomicComponent) getComponentManager().getComponent(uri);
+ return (Deployer) component.getTargetInstance();
+ } catch (TargetResolutionException e) {
+ throw new AssertionError(e);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org