summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat')
-rw-r--r--branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java266
-rw-r--r--branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java67
-rw-r--r--branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java138
-rw-r--r--branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java63
-rw-r--r--branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java47
5 files changed, 0 insertions, 581 deletions
diff --git a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java b/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java
deleted file mode 100644
index 769ac4912d..0000000000
--- a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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.sca.runtime.tomcat;
-
-import java.util.Hashtable;
-
-import javax.naming.Binding;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NameClassPair;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-
-import org.apache.catalina.core.StandardContext;
-
-public class TuscanyContext extends StandardContext {
- private static final long serialVersionUID = 1L;
-
- public TuscanyContext() {
- setProcessTlds(false);
- }
-
- @Override
- public boolean getConfigured() {
- return true;
- }
-
- @Override
- public DirContext getResources() {
- return DUMMY_CONTEXT;
- }
-
- @Override
- public synchronized void setResources(DirContext resources) {
- setDocBase("tuscany");
- super.setResources(DUMMY_CONTEXT);
- }
-
- private static final DirContext DUMMY_CONTEXT = new DirContext(){
-
- public void bind(Name name, Object obj, Attributes attrs) throws NamingException {
- }
-
- public void bind(String name, Object obj, Attributes attrs) throws NamingException {
- }
-
- public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException {
- return null;
- }
-
- public DirContext createSubcontext(String name, Attributes attrs) throws NamingException {
- return null;
- }
-
- public Attributes getAttributes(Name name) throws NamingException {
- return null;
- }
-
- public Attributes getAttributes(String name) throws NamingException {
- return null;
- }
-
- public Attributes getAttributes(Name name, String[] attrIds) throws NamingException {
- return null;
- }
-
- public Attributes getAttributes(String name, String[] attrIds) throws NamingException {
- return null;
- }
-
- public DirContext getSchema(Name name) throws NamingException {
- return null;
- }
-
- public DirContext getSchema(String name) throws NamingException {
- return null;
- }
-
- public DirContext getSchemaClassDefinition(Name name) throws NamingException {
- return null;
- }
-
- public DirContext getSchemaClassDefinition(String name) throws NamingException {
- return null;
- }
-
- public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException {
- }
-
- public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException {
- }
-
- public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException {
- }
-
- public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException {
- }
-
- public void rebind(Name name, Object obj, Attributes attrs) throws NamingException {
- }
-
- public void rebind(String name, Object obj, Attributes attrs) throws NamingException {
- }
-
- public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(Name name, String filter, SearchControls cons) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<SearchResult> search(String name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException {
- return null;
- }
-
- public Object addToEnvironment(String propName, Object propVal) throws NamingException {
- return null;
- }
-
- public void bind(Name name, Object obj) throws NamingException {
- }
-
- public void bind(String name, Object obj) throws NamingException {
- }
-
- public void close() throws NamingException {
- }
-
- public Name composeName(Name name, Name prefix) throws NamingException {
- return null;
- }
-
- public String composeName(String name, String prefix) throws NamingException {
- return null;
- }
-
- public Context createSubcontext(Name name) throws NamingException {
- return null;
- }
-
- public Context createSubcontext(String name) throws NamingException {
- return null;
- }
-
- public void destroySubcontext(Name name) throws NamingException {
- }
-
- public void destroySubcontext(String name) throws NamingException {
- }
-
- public Hashtable<?, ?> getEnvironment() throws NamingException {
- return null;
- }
-
- public String getNameInNamespace() throws NamingException {
- return null;
- }
-
- public NameParser getNameParser(Name name) throws NamingException {
- return null;
- }
-
- public NameParser getNameParser(String name) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
- return null;
- }
-
- public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
- throw new NamingException();
- }
-
- public Object lookup(Name name) throws NamingException {
- return null;
- }
-
- public Object lookup(String name) throws NamingException {
- return null;
- }
-
- public Object lookupLink(Name name) throws NamingException {
- return null;
- }
-
- public Object lookupLink(String name) throws NamingException {
- return null;
- }
-
- public void rebind(Name name, Object obj) throws NamingException {
- }
-
- public void rebind(String name, Object obj) throws NamingException {
- }
-
- public Object removeFromEnvironment(String propName) throws NamingException {
- return null;
- }
-
- public void rename(Name oldName, Name newName) throws NamingException {
- }
-
- public void rename(String oldName, String newName) throws NamingException {
- }
-
- public void unbind(Name name) throws NamingException {
- }
-
- public void unbind(String name) throws NamingException {
- }
- };
-
-}
diff --git a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java b/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java
deleted file mode 100644
index e4398b95fe..0000000000
--- a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.sca.runtime.tomcat;
-
-import java.io.File;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.core.StandardContext;
-import org.apache.tuscany.sca.runtime.Launcher;
-
-/**
- */
-public class TuscanyContextListener implements LifecycleListener {
-
- private Launcher launcher;
-
- public TuscanyContextListener(Launcher launcher) {
- this.launcher = launcher;
- }
-
- public void lifecycleEvent(LifecycleEvent event) {
- String type = event.getType();
- if (Lifecycle.AFTER_START_EVENT.equals(type)) {
- startContext((Context) event.getLifecycle());
- } else if (Lifecycle.STOP_EVENT.equals(type)) {
- stopContext((Context) event.getLifecycle());
- }
- }
-
- protected void startContext(Context context) {
- StandardContext sc = (StandardContext) context;
- String path = sc.getServletContext().getRealPath("/");
- try {
- File f = new File(path + "WEB-INF/classes");
- if (f.exists()) {
- System.out.println("adding contribution: "+ path);
- launcher.addContribution(f.toURL());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- protected void stopContext(Context context) {
- }
-
-}
diff --git a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java b/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java
deleted file mode 100644
index a3e3f8f15e..0000000000
--- a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.sca.runtime.tomcat;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardHost;
-import org.apache.tuscany.sca.runtime.Launcher;
-
-/**
- * To use this copy all the Tuscany jars to the Tomcat lib folder and update
- * the Tomcat conf/server.xml <Host> to include className="org.apache.tuscany.sca.runtime.tomcat.TomcatHost"
- *
- * For example:
- *
- * <Host name="localhost" appBase="webapps"
- * className="org.apache.tuscany.sca.runtime.tomcat.TuscanyHost"
- * unpackWARs="true" autoDeploy="true"
- * xmlValidation="false" xmlNamespaceAware="false">
- *
- */
-public class TuscanyHost extends StandardHost {
- private static final long serialVersionUID = 1L;
-
- private static final String REPO = "../sca-contributions";
-
- protected Launcher launcher;
-
- private String contextPath = "/tuscany";
-
- public synchronized void start() throws LifecycleException {
- try {
-
- launcher = initTuscany();
-
- super.start();
-
- launcher.start();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public synchronized void stop() throws LifecycleException {
- super.stop();
- stopRuntime();
- }
-
- private Launcher initTuscany() throws ServletException {
- StandardContext tc = new TuscanyContext();
- tc.setPath(contextPath);
- super.addChild(tc);
-
- TuscanyServlet s = new TuscanyServlet();
- s.init(new MockServletConfig(contextPath));
- Wrapper wrapper = new TuscanyWrapper(s);
- wrapper.setName("TuscanyServlet");
- tc.addChild(wrapper);
- tc.addServletMapping("/*", "TuscanyServlet", true);
-
- Launcher launcher = new Launcher(new File(REPO));
-
- return launcher;
- }
-
- private void stopRuntime() {
- System.out.println("XXXXXXXX TomcatHost.stopRuntime");
- if (launcher != null) {
- launcher.stop();
- }
- }
-
- public synchronized void addChild(Container child) {
- if (!(child instanceof StandardContext)) {
- throw new IllegalArgumentException(sm.getString("tuscanyHost.notContext"));
- }
- super.addChild(child);
- }
-
-}
-
-class MockServletConfig implements ServletConfig {
-
- Map<String, String> initParams;
-
- public MockServletConfig(String contextPath) {
- initParams = new HashMap<String, String>();
- initParams.put("contextPath", contextPath);
- }
-
- public String getInitParameter(String initParam) {
- return initParams.get(initParam);
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getInitParameterNames() {
- return Collections.enumeration(initParams.keySet());
- }
-
- public ServletContext getServletContext() {
- return null;
- }
-
- public String getServletName() {
- return null;
- }
-
-}
diff --git a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java b/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java
deleted file mode 100644
index 90d55af0bb..0000000000
--- a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.sca.runtime.tomcat;
-
-import java.io.IOException;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.tuscany.sca.host.webapp.WebAppServletHost;
-
-/**
- * A servlet that forwards requests to the servlets registered with the Tuscany
- * ServletHost.
- *
- * TODO: Copy of host-webapp TuscanyServlet. Can be removed once host-webapp TuscanyServlet
- * moved over to latest SCADomain API.
- */
-public class TuscanyServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
-
- private transient WebAppServletHost servletHost;
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- servletHost = WebAppServletHost.getInstance();
- servletHost.init(config);
- }
-
- @Override
- public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- String path = ((HttpServletRequest)req).getPathInfo();
- RequestDispatcher dispatcher = servletHost.getRequestDispatcher(path);
- if (dispatcher == null) {
- throw new IllegalStateException("No servlet registered for path: " + path);
- }
-
- dispatcher.forward(req, res);
- }
-
-}
diff --git a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java b/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java
deleted file mode 100644
index 5a409a6a6c..0000000000
--- a/branches/sca-java-1.2/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.sca.runtime.tomcat;
-
-import javax.servlet.Servlet;
-
-import org.apache.catalina.core.StandardWrapper;
-
-/**
- * Override the StandardWrapper so that servlets are not instantiated from the
- * classname but just the instance Tuscany passes in the constructor is always used.
- */
-public class TuscanyWrapper extends StandardWrapper {
- private static final long serialVersionUID = 1L;
-
- private final Servlet servlet;
-
- public TuscanyWrapper(Servlet servlet) {
- super();
- this.servlet = servlet;
- }
-
- public synchronized Servlet loadServlet() {
- return servlet;
- }
-
- public Servlet getServlet() {
- return servlet;
- }
-} \ No newline at end of file