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 2006/02/28 06:07:33 UTC

svn commit: r381563 - in /incubator/tuscany/java/sca/tomcat: ./ src/main/java/org/apache/tuscany/tomcat/ src/main/resources/org/apache/tuscany/tomcat/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/tuscan...

Author: jboynes
Date: Mon Feb 27 21:07:31 2006
New Revision: 381563

URL: http://svn.apache.org/viewcvs?rev=381563&view=rev
Log:
start of tomcat integration

Added:
    incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java   (with props)
    incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java   (with props)
    incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java   (with props)
    incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties   (with props)
    incubator/tuscany/java/sca/tomcat/src/test/
    incubator/tuscany/java/sca/tomcat/src/test/java/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/
    incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java   (with props)
    incubator/tuscany/java/sca/tomcat/src/test/resources/
    incubator/tuscany/java/sca/tomcat/src/test/resources/app1/
    incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/
    incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/classes/
    incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module
    incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml   (with props)
Modified:
    incubator/tuscany/java/sca/tomcat/pom.xml

Modified: incubator/tuscany/java/sca/tomcat/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/pom.xml?rev=381563&r1=381562&r2=381563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tomcat/pom.xml (original)
+++ incubator/tuscany/java/sca/tomcat/pom.xml Mon Feb 27 21:07:31 2006
@@ -44,7 +44,37 @@
         <dependency>
             <groupId>tomcat</groupId>
             <artifactId>catalina</artifactId>
-            <version>5.5.9</version>
+            <version>5.5.15</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>tomcat</groupId>
+            <artifactId>tomcat-util</artifactId>
+            <version>5.5.15</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>tomcat</groupId>
+            <artifactId>naming-factory</artifactId>
+            <version>5.5.15</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>tomcat</groupId>
+            <artifactId>naming-resources</artifactId>
+            <version>5.5.15</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.0.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-modeler</groupId>
+            <artifactId>commons-modeler</artifactId>
+            <version>1.1M1</version>
             <scope>provided</scope>
         </dependency>
 

Added: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java (added)
+++ incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java Mon Feb 27 21:07:31 2006
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.tomcat;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Valve;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyContextListener implements LifecycleListener {
+    private final AssemblyFactory modelFactory;
+    private final AssemblyModelLoader modelLoader;
+    private final AggregateContext rootContext;
+
+    public TuscanyContextListener(AggregateContext rootContext, AssemblyFactory modelFactory, AssemblyModelLoader modelLoader) {
+        this.rootContext = rootContext;
+        this.modelFactory = modelFactory;
+        this.modelLoader = modelLoader;
+    }
+
+    public void lifecycleEvent(LifecycleEvent event) {
+        String type = event.getType();
+        if (Lifecycle.START_EVENT.equals(type)) {
+            startContext((Context) event.getLifecycle());
+        } else if (Lifecycle.STOP_EVENT.equals(type)) {
+            stopContext((Context) event.getLifecycle());
+        }
+    }
+
+    private void startContext(Context ctx) {
+        ResourceLoader resourceLoader = new ResourceLoaderImpl(ctx.getLoader().getClassLoader());
+        AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+        ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+
+        AggregateContext moduleContext;
+        try {
+            // Load the SCDL configuration of the application module
+            ModuleComponent moduleComponent = loader.loadModuleComponent(ctx.getName(), ctx.getPath());
+
+            // Register it under the root application context
+            rootContext.registerModelObject(moduleComponent);
+            moduleContext = (AggregateContext)rootContext.getContext(moduleComponent.getName());
+            moduleContext.registerModelObject(moduleComponent.getComponentImplementation());
+        } catch (ConfigurationLoadException e) {
+            throw new UnsupportedOperationException();
+        } catch (ConfigurationException e) {
+            throw new UnsupportedOperationException();
+        }
+
+        Valve valve = new TuscanyValve(moduleContext);
+        ctx.getPipeline().addValve(valve);
+    }
+
+    private void stopContext(Context ctx) {
+        // todo unload module component from runtime
+    }
+}

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java (added)
+++ incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java Mon Feb 27 21:07:31 2006
@@ -0,0 +1,166 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.tomcat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.ContainerListener;
+import org.apache.catalina.ContainerEvent;
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Valve;
+import org.apache.catalina.util.StringManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.loader.SystemSCDLModelLoader;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+/**
+ * A Tomcat listener to be attached to a Host container to add SCA runtime functionality.
+ * The listener wraps a Tuscany runtime and listens for container events to detect the
+ * addition and removal of Context children.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyHostListener implements LifecycleListener, ContainerListener {
+    private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+    private static final Log log = LogFactory.getLog(TuscanyHostListener.class);
+    private static final StringManager sm = StringManager.getManager("org.apache.tuscany.tomcat");
+
+    private RuntimeContext runtime;
+    private AssemblyModelLoader modelLoader;
+    private AssemblyFactory modelFactory;
+
+    public void lifecycleEvent(LifecycleEvent event) {
+        String type = event.getType();
+        if (Lifecycle.START_EVENT.equals(type)) {
+            startRuntime();
+            if (event.getLifecycle() instanceof Container) {
+                Container container = (Container) event.getLifecycle();
+                container.addContainerListener(this);
+            }
+        } else if (Lifecycle.STOP_EVENT.equals(type)) {
+            if (event.getLifecycle() instanceof Container) {
+                Container container = (Container) event.getLifecycle();
+                container.removeContainerListener(this);
+            }
+            stopRuntime();
+        }
+    }
+
+    public void containerEvent(ContainerEvent event) {
+        if (Container.ADD_CHILD_EVENT.equals(event.getType()) && event.getData() instanceof Context) {
+            contextAdded((Context) event.getData());
+        }
+    }
+
+    private void startRuntime() {
+        ResourceLoader resourceLoader = new ResourceLoaderImpl(getClass().getClassLoader());
+
+        // Create an assembly model factory
+        modelFactory = new AssemblyFactoryImpl();
+
+        // Create an assembly model loader
+        List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+        scdlLoaders.add(new SystemSCDLModelLoader());
+        modelLoader = new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+        // Create an assembly model context
+        AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+
+        // Load the system module component
+        ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+        ModuleComponent systemModuleComponent;
+        try {
+            systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+        } catch (ConfigurationLoadException e) {
+            log.warn(sm.getString("runtime.loadSystemFailed"), e);
+            return;
+        }
+
+        List<RuntimeConfigurationBuilder> configBuilders = new ArrayList();
+        configBuilders.add((new SystemComponentContextBuilder()));
+        configBuilders.add(new SystemEntryPointBuilder());
+        configBuilders.add(new SystemExternalServiceBuilder());
+
+        runtime = new RuntimeContextImpl(new NullMonitorFactory(), scdlLoaders, configBuilders, new DefaultWireBuilder());
+        runtime.start();
+
+        try {
+            SystemAggregateContext systemContext = runtime.getSystemContext();
+            systemContext.registerModelObject(systemModuleComponent);
+
+            // Get the aggregate context representing the system module component
+            AggregateContext systemModuleComponentContext = (AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
+            systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
+            systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
+        } catch (Exception e) {
+            log.warn(sm.getString("runtime.registerSystemFailed"), e);
+            runtime.stop();
+            runtime = null;
+            return;
+        }
+
+        log.info(sm.getString("runtime.started"));
+    }
+
+    private void stopRuntime() {
+        if (runtime == null) {
+            return;
+        }
+
+        runtime.stop();
+        runtime = null;
+        log.info(sm.getString("runtime.stopped"));
+    }
+
+
+    private void contextAdded(Context ctx) {
+        if (ctx instanceof Lifecycle) {
+            TuscanyContextListener contextListener = new TuscanyContextListener(runtime.getRootContext(), modelFactory, modelLoader);
+            ((Lifecycle) ctx).addLifecycleListener(contextListener);
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHostListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java (added)
+++ incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java Mon Feb 27 21:07:31 2006
@@ -0,0 +1,102 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.tomcat;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+
+/**
+ * Valve that can be added to a pipeline to
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyValve extends ValveBase {
+    /**
+     * Name of the note that contains the request id
+     */
+    private static final String REQUEST_ID = "org.apache.tuscany.tomcat.REQUEST_ID";
+
+    private static final ContextBinder BINDER = new ContextBinder();
+
+    private final AggregateContext moduleComponentContext;
+
+    public TuscanyValve(AggregateContext moduleComponentContext) {
+        this.moduleComponentContext = moduleComponentContext;
+    }
+
+    public void invoke(Request request, Response response) throws IOException, ServletException {
+        Object oldRequestId = request.getNote(REQUEST_ID);
+        ModuleContext oldContext = CurrentModuleContext.getContext();
+        try {
+            // bind the current module context to the thread
+            BINDER.setContext((ModuleContext) moduleComponentContext);
+
+            // if we have not notified the runtime about this request, fire a request start event
+            if (oldRequestId == null) {
+                Object requestId = new Object();
+                request.setNote(REQUEST_ID, requestId);
+                moduleComponentContext.fireEvent(EventContext.REQUEST_START, requestId);
+            }
+
+            // invoke the next valve in the pipeline
+            next.invoke(request, response);
+        } catch (IOException e) {
+            // rethrow exception from next valve
+            throw e;
+        } catch (ServletException e) {
+            // rethrow exception from next valve
+            throw e;
+        } catch (Exception e) {
+            // wrap other (unchecked) exceptions potentially thrown by the runtime
+            throw new ServletException(e.getMessage(), e);
+        } finally {
+            // if we sent the request start notification, fire the request end event
+            if (oldRequestId == null) {
+                Object requestId = request.getNote(REQUEST_ID);
+                moduleComponentContext.fireEvent(EventContext.REQUEST_END, requestId);
+                request.removeNote(REQUEST_ID);
+            }
+
+            // restore the previous module context onto the thread
+            BINDER.setContext(oldContext);
+        }
+    }
+
+    private static class ContextBinder extends SCA {
+        public void setContext(ModuleContext context) {
+            setModuleContext(context);
+        }
+
+        public void start() {
+            throw new AssertionError();
+        }
+
+        public void stop() {
+            throw new AssertionError();
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties (added)
+++ incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties Mon Feb 27 21:07:31 2006
@@ -0,0 +1,18 @@
+#  Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+#
+#  Licensed 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.
+
+runtime.loadSystemFailed = Error loading system configuration:
+runtime.registerSystemFailed = Error registering system configuration:
+runtime.started = Started Tuscany runtime
+runtime.stopped = Stopped Tuscany runtime
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java (added)
+++ incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java Mon Feb 27 21:07:31 2006
@@ -0,0 +1,83 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.tomcat.integration;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.core.StandardService;
+import org.apache.catalina.startup.ContextConfig;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TomcatIntegrationTestCase extends TestCase {
+    private File baseDir;
+    private File appBase;
+    private File app1;
+    private StandardServer server;
+    private StandardHost host;
+
+    public void testRuntimeIntegration() throws Exception {
+        StandardContext ctx = new StandardContext();
+        ctx.addLifecycleListener(new ContextConfig());
+        ctx.setName("test");
+        ctx.setDocBase(app1.getAbsolutePath());
+        host.addChild(ctx);
+        host.removeChild(ctx);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        app1 = new File(getClass().getResource("/app1").toURI());
+        baseDir = new File(app1, "../../tomcat").getCanonicalFile();
+        appBase = new File(baseDir, "webapps").getCanonicalFile();
+        setupTomcat();
+        server.start();
+    }
+
+    protected void tearDown() throws Exception {
+        server.stop();
+        super.tearDown();
+    }
+
+    private void setupTomcat() {
+        // build a typical Tomcat configuration
+        server = new StandardServer();
+        StandardService service = new StandardService();
+        service.setName("Catalina");
+        server.addService(service);
+
+        StandardEngine engine = new StandardEngine();
+        engine.setName("Catalina");
+        engine.setDefaultHost("localhost");
+        engine.setBaseDir(baseDir.getAbsolutePath());
+        service.setContainer(engine);
+
+        host = new StandardHost();
+        host.setName("localhost");
+        host.setAppBase(appBase.getAbsolutePath());
+        engine.addChild(host);
+
+        // add in the Tuscany specific components
+//        host.addLifecycleListener(new TuscanyHostListener());
+    }
+}

Propchange: incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module?rev=381563&view=auto
==============================================================================
    (empty)

Added: incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml?rev=381563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml (added)
+++ incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml Mon Feb 27 21:07:31 2006
@@ -0,0 +1,6 @@
+<!DOCTYPE web-app
+    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+    "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+</web-app>
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:keywords = Rev,Date