summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:26:33 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:26:33 +0000
commita40e527938d76ba71f211da7e327adb50384ba69 (patch)
treecb8f99f1727122b040a3f0fbb6649292b6a74302 /sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java
parent968721109881107520d7aefa91d7fcc0519d7739 (diff)
Moving 1.x tags
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java')
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java57
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java49
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java63
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java49
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java39
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java46
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java45
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java146
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java41
-rw-r--r--sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java107
10 files changed, 642 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java
new file mode 100644
index 0000000000..64f2e8b9a0
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java
@@ -0,0 +1,57 @@
+/*
+ * 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.host;
+
+import java.net.URL;
+
+import org.osoa.sca.CompositeContext;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Interface that allows a host to launch a runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Launcher {
+ /**
+ * Boot the Tuscany runtime.
+ *
+ * @param systemScdl the SCDL defining the runtime's system configuration
+ * @param systemClassLoader the root classloader to use to deploy the system SCDL
+ * @param monitorFactory the monitor factory initialize the runtime with
+ * @throws TuscanyException if there was a problem booting the runtimr
+ */
+ void bootRuntime(URL systemScdl, ClassLoader systemClassLoader, MonitorFactory monitorFactory)
+ throws TuscanyException;
+
+ /**
+ * Shutdown the Tuscany runtime.
+ */
+ void shutdownRuntime();
+
+ /**
+ * Boot a default application into the runtime.
+ *
+ * @param applicationScdl the application's SCDL
+ * @param applicationClassLoader the classloader to use to deploy the application
+ * @return the CompositeContext for the application
+ */
+ CompositeContext bootApplication(URL applicationScdl, ClassLoader applicationClassLoader);
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java
new file mode 100644
index 0000000000..d338681641
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java
@@ -0,0 +1,49 @@
+/*
+ * 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.host;
+
+import java.util.Map;
+
+/**
+ * A MonitorFactory creates implementations of components' monitor interfaces that interface with a its monitoring
+ * scheme. For example, a implementation may create versions that emit appropriate logging events or which send
+ * notifications to a management API.
+ *
+ * MonitorFactory implementations must provide a no-arg constructor and implement the {@link #initialize} method
+ * to perform configuration of instances created using that constructor. Additional constructors may be defined;
+ * typically their implementations delegate to {@link #initialize}.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MonitorFactory {
+ /**
+ * Initializes MonitorFactory instances with implementation-specific configuration properties.
+ *
+ * @param configProperties a map of named configuration properties. May be null.
+ * @throws IllegalArgumentException if the instance can't be configured using the supplied properties
+ */
+ void initialize(Map<String, Object> configProperties);
+ /**
+ * Return a monitor for a component's monitor interface.
+ *
+ * @param monitorInterface the component's monitoring interface
+ * @return an implementation of the monitoring interface; will not be null
+ */
+ <T> T getMonitor(Class<T> monitorInterface);
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java
new file mode 100644
index 0000000000..b22235f4c3
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java
@@ -0,0 +1,63 @@
+/*
+ * 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.host;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * Interface that provides information on the runtime environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeInfo {
+ /**
+ * The default name that the runtime should assign to the component providing this service.
+ */
+ String COMPONENT_NAME = "RuntimeInfo";
+
+ /**
+ * Return the directory where the running runtime was installed.
+ *
+ * @return the directory where the runtime was installed
+ */
+ File getInstallDirectory();
+
+ /**
+ * Return the root directory used to resolve application file paths.
+ *
+ * @return the directory used to resolve application file paths.
+ */
+ File getApplicationRootDirectory();
+
+ /**
+ * Gets the base URL for the runtime.
+ *
+ * @return The base URL for the runtime.
+ */
+ URL getBaseURL();
+
+ /**
+ * Returns whether the runtime considers itself "online" or connected to the internet.
+ * This can be used by services to enable access to remote resources.
+ *
+ * @return true if the runtime is online.
+ */
+ boolean isOnline();
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java
new file mode 100644
index 0000000000..203179de92
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java
@@ -0,0 +1,49 @@
+/*
+ * 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.host.rmi;
+
+import java.rmi.Remote;
+
+/* RMI Service hosting interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components
+ */
+
+public interface RMIHost {
+ int RMI_DEFAULT_PORT = 1099;
+
+ // registers an RMI service with the given name and port
+ void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // registers an RMI service with the given name and default port (1099)
+ void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // unregister a service registered under the given service name and port number
+ void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // unregister a service registered under the given service name and defalut port number (1099)
+ void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ //find a remote service hosted on the given host, port and service name
+ Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException;
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java
new file mode 100644
index 0000000000..dedfff1cdd
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java
@@ -0,0 +1,39 @@
+/*
+ * 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.host.rmi;
+
+import java.rmi.registry.Registry;
+import java.util.List;
+
+/* RMI Service hosting Admin Interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components. This interface
+ * can be used by admin functions to obtain information on RMI registries started and running in the host
+ * environment
+ */
+
+public interface RMIHostAdmin {
+ //gets all RMI registries running on the host. Each element of the list is an object of type
+ //java.rmi.registry
+ List getAllRegistries() throws RMIHostRuntimeException;
+
+ //gets a registry that is running at a particular port
+ Registry getRegistry(int port) throws RMIHostRuntimeException;
+
+ //more methods to be added
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java
new file mode 100644
index 0000000000..3a5d27dcc7
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.host.rmi;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * This exception will relate to situations where the end applicaition's
+ * input is the cause of the exception
+ *
+ */
+public class RMIHostException extends TuscanyException {
+
+ private static final long serialVersionUID = -1L;
+
+ public RMIHostException() {
+ }
+
+ public RMIHostException(String message) {
+ super(message);
+ }
+
+ public RMIHostException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java
new file mode 100644
index 0000000000..35b207b5d2
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java
@@ -0,0 +1,45 @@
+/*
+ * 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.host.rmi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * This exception relates to cases where there is a problem with the
+ * Host runtime
+ *
+ */
+public class RMIHostRuntimeException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -1L;
+
+ public RMIHostRuntimeException() {
+ }
+
+ public RMIHostRuntimeException(String message) {
+ super(message);
+ }
+
+ public RMIHostRuntimeException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
new file mode 100644
index 0000000000..72bdc38774
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
@@ -0,0 +1,146 @@
+/*
+ * 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.host.runtime;
+
+import java.net.URL;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TuscanyRuntime {
+ /**
+ * Returns the location of the SCDL used to boot this runtime.
+ *
+ * @return the location of the SCDL used to boot this runtime
+ */
+ URL getSystemScdl();
+
+ /**
+ * Sets the location of the SCDL used to boot this runtime.
+ *
+ * @param systemScdl the location of the SCDL used to boot this runtime
+ */
+ void setSystemScdl(URL systemScdl);
+
+ /**
+ * Returns the name of the component associated with the application SCDL.
+ * @return the name of the component associated with the application SCDL
+ */
+ String getApplicationName();
+
+ /**
+ * Sets the name of the component associated with the application SCDL.
+ * @param applicationName the name of the component associated with the application SCDL
+ */
+ void setApplicationName(String applicationName);
+
+ /**
+ * Returns the location of the default application's SCDL.
+ *
+ * @return the location of the default application's SCDL
+ */
+ URL getApplicationScdl();
+
+ /**
+ * Sets the location of the default application's SCDL
+ *
+ * @param applicationScdl the location of the default application's SCDL
+ */
+ void setApplicationScdl(URL applicationScdl);
+
+ /**
+ * Returns the host ClassLoader that is parent to all Tuscany classloaders.
+ *
+ * @return the host's ClassLoader
+ */
+ ClassLoader getHostClassLoader();
+
+ /**
+ * Sets the host ClassLoader; this will be a parent for all Tuscany classloaders.
+ *
+ * @param classLoader the host's ClassLoader
+ */
+ void setHostClassLoader(ClassLoader classLoader);
+
+ /**
+ * Returns the info this runtime will make available to service components.
+ *
+ * @return the info this runtime will make available to service components
+ */
+ RuntimeInfo getRuntimeInfo();
+
+ /**
+ * Sets the info this runtime should make available to service components.
+ * The instance supplied here should be registered in the system composite with the name
+ * {@link RuntimeInfo#COMPONENT_NAME "RuntimeInfo"}.
+ *
+ * @param runtimeInfo the information this runtime should make available to service components
+ */
+ void setRuntimeInfo(RuntimeInfo runtimeInfo);
+
+ /** Returns the MonitorFactory that this runtime is using.
+ *
+ * @return the MonitorFactory that this runtime is using
+ */
+ MonitorFactory getMonitorFactory();
+
+ /**
+ * Sets the MonitorFactory that this runtime should use.
+ * @param monitorFactory the MonitorFactory that this runtime should use
+ */
+ void setMonitorFactory(MonitorFactory monitorFactory);
+
+ /**
+ * Create the default MonitorFactory for this runtime.
+ *
+ * @return the default MonitorFactory for this runtime
+ */
+ MonitorFactory createDefaultMonitorFactory();
+
+ /**
+ * Initialize a runtime.
+ *
+ */
+ void initialize();
+
+ /**
+ * Destroy the runtime. Any further invocations should result in an error.
+ */
+ void destroy();
+
+ /**
+ * Returns the current SCA context
+ */
+ SCA getContext();
+
+ /**
+ * Get the application classloader
+ */
+ ClassLoader getApplicationClassLoader();
+
+ /**
+ * Set the application classloader
+ */
+ void setApplicationClassLoader(ClassLoader applicationClassLoader);
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java
new file mode 100644
index 0000000000..e4b11aee90
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java
@@ -0,0 +1,41 @@
+/*
+ * 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.host.servlet;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * Interface to a system component that dispatches servlet requests to the Tuscany runtime
+ */
+public interface ServletRequestInjector {
+
+ /**
+ * Dispatch servlet requests to the Tuscany runtime
+ *
+ * @param req the ServletRequest object that contains the request the client made of the servlet
+ * @param res the ServletResponse object that contains the response the servlet returns to the client
+ * @throws ServletException if the request cannot be handled
+ * @throws IOException if an input or output error occurs while handling the request
+ */
+ void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
+
+}
diff --git a/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
new file mode 100644
index 0000000000..c0f9003b89
--- /dev/null
+++ b/sca-java-1.x/tags/1.0-incubator-M2/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
@@ -0,0 +1,107 @@
+/*
+ * 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.host.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class LaunchHelper {
+
+ ///CLOVER:OFF
+ private LaunchHelper() {
+ }
+
+ /**
+ * Scan a directory for jar files to be added to the classpath.
+ *
+ * @param lib the directory to scan
+ * @return the URLs or jar files in that directory
+ */
+ public static URL[] scanDirectoryForJars(File lib) {
+ File[] jars = lib.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ });
+
+ URL[] urls = new URL[jars.length];
+ for (int i = 0; i < jars.length; i++) {
+ try {
+ urls[i] = jars[i].toURI().toURL();
+ } catch (MalformedURLException e) {
+ // toURI should have escaped the URL
+ throw new AssertionError();
+ }
+ }
+ return urls;
+ }
+
+ /**
+ * Set a JavaBean property on an object.
+ *
+ * @param instance the object whose property should be set
+ * @param name the name of the property
+ * @param value the value to set it to
+ */
+ public static void setProperty(Object instance, String name, Object value) {
+ Class<?> beanType = instance.getClass();
+ name = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ Class<?> propertyType = value.getClass();
+ try {
+ Method setter = beanType.getMethod(name, propertyType);
+ setter.invoke(instance, value);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ } catch (InvocationTargetException e) {
+ throw new IllegalStateException(e.getCause());
+ }
+ }
+
+ /**
+ * Invoke a method on an object.
+ *
+ * @param instance the object to invoke
+ * @param name the name of the method to invoke
+ * @param args arguments to call the method with
+ * @return the value returned by the method
+ * @throws InvocationTargetException if the method throw an Exception
+ */
+ public static Object invoke(Object instance, String name, Class<?>[] paramTypes, Object... args)
+ throws InvocationTargetException {
+ try {
+ Method method = instance.getClass().getMethod(name, paramTypes);
+ return method.invoke(instance, (Object[]) args);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+
+}