From b3b20053852bb9104b782c481ba6cd3bcbbeadcf Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 18 Feb 2009 09:36:29 +0000 Subject: Remove context script code as its not used presently, move JSP taglib from host-webapp to implementation-web-runtime git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745453 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/modules/host-webapp/META-INF/MANIFEST.MF | 2 - java/sca/modules/host-webapp/pom.xml | 6 - .../tuscany/sca/host/webapp/jsp/ReferenceTEI.java | 45 -- .../tuscany/sca/host/webapp/jsp/ReferenceTag.java | 118 ----- .../sca/modules/implementation-web-runtime/pom.xml | 4 +- .../web/ComponentContextServlet.java | 156 ------- .../implementation/web/ContextScriptProcessor.java | 32 -- .../web/ContextScriptProcessorExtensionPoint.java | 27 -- ...efaultContextScriptProcessorExtensionPoint.java | 51 --- .../implementation/web/JSONRPCScripProcessor.java | 57 --- .../web/runtime/ComponentContextProxy.java | 87 ---- .../runtime/WebImplementationProviderFactory.java | 25 +- .../src/main/resources/META-INF/sca.tld | 6 +- ...tation.web.ContextScriptProcessorExtensionPoint | 19 - .../src/main/resources/jsonrpc.js | 493 --------------------- 15 files changed, 5 insertions(+), 1123 deletions(-) delete mode 100644 java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTEI.java delete mode 100644 java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessor.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessorExtensionPoint.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/DefaultContextScriptProcessorExtensionPoint.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/JSONRPCScripProcessor.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint delete mode 100644 java/sca/modules/implementation-web-runtime/src/main/resources/jsonrpc.js diff --git a/java/sca/modules/host-webapp/META-INF/MANIFEST.MF b/java/sca/modules/host-webapp/META-INF/MANIFEST.MF index f5164a6db9..ab42b3df1f 100644 --- a/java/sca/modules/host-webapp/META-INF/MANIFEST.MF +++ b/java/sca/modules/host-webapp/META-INF/MANIFEST.MF @@ -26,8 +26,6 @@ Bundle-Description: Apache Tuscany SCA Webapp Host Import-Package: javax.naming, javax.servlet, javax.servlet.http, - javax.servlet.jsp, - javax.servlet.jsp.tagext, org.apache.tuscany.sca.core;version="2.0.0", org.apache.tuscany.sca.host.http;version="2.0.0", org.apache.tuscany.sca.host.webapp;version="2.0.0", diff --git a/java/sca/modules/host-webapp/pom.xml b/java/sca/modules/host-webapp/pom.xml index 5a3f247d7e..bcdc2e283b 100644 --- a/java/sca/modules/host-webapp/pom.xml +++ b/java/sca/modules/host-webapp/pom.xml @@ -76,12 +76,6 @@ 2.5 - - org.apache.geronimo.specs - geronimo-jsp_2.1_spec - 1.0.1 - - diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTEI.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTEI.java deleted file mode 100644 index 6e1b187a48..0000000000 --- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTEI.java +++ /dev/null @@ -1,45 +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.host.webapp.jsp; - -import javax.servlet.jsp.tagext.TagData; -import javax.servlet.jsp.tagext.TagExtraInfo; -import javax.servlet.jsp.tagext.VariableInfo; - -/** - * TagExtraInfo class for the SCA reference tags - * - * - * @version $Rev$ $Date$ - */ -public class ReferenceTEI extends TagExtraInfo { - - @Override - public VariableInfo[] getVariableInfo(TagData data) { - VariableInfo info1 - = new VariableInfo( - data.getAttributeString("name"), - data.getAttributeString("type"), - true, - VariableInfo.AT_END); - VariableInfo[] info = { info1 } ; - return info; - } -} diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java deleted file mode 100644 index 555ad16cd8..0000000000 --- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java +++ /dev/null @@ -1,118 +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.host.webapp.jsp; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.tagext.TagSupport; - -import org.apache.tuscany.sca.host.webapp.WebAppServletHost; -import org.apache.tuscany.sca.node.Node; -import org.oasisopen.sca.ComponentContext; - -/** - * Tag to handle SCA references - * - * - * @version $Rev$ $Date$ - */ -public class ReferenceTag extends TagSupport { - private static final long serialVersionUID = 1L; - - protected String name; - protected String type; - protected Integer scope = PageContext.PAGE_SCOPE; - - @Override - public int doStartTag() throws JspException { - return SKIP_BODY; - } - - @Override - public int doEndTag() throws JspException { - - try { - WebAppServletHost.getInstance().init(pageContext.getServletConfig()); - } catch (ServletException e) { - throw new JspException("Exception initializing Tuscany webapp: " + e, e); - } - - ServletContext servletContext = pageContext.getServletContext(); - ComponentContext componentContext = (ComponentContext)servletContext.getAttribute("org.oasisopen.sca.ComponentContext"); - Node scaDomain = null; - if (componentContext == null) { - scaDomain = (Node)servletContext.getAttribute(WebAppServletHost.SCA_NODE_ATTRIBUTE); - if (scaDomain == null) { - throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml"); - } - } - - Class typeClass; - try { - typeClass = Class.forName(type, true, Thread.currentThread().getContextClassLoader()); - } catch (ClassNotFoundException e) { - throw new JspException("Reference '" + name + "' type class not found: " + type); - } - - Object o; - try { - if (componentContext != null) { - o = componentContext.getService(typeClass, name); - } else { - o = scaDomain.getService(typeClass, name); - } - } catch (Exception e) { - throw new JspException("Exception getting service for reference'" + name + "': " + e, e); - } - if (o == null) { - throw new JspException("Reference '" + name + "' not found"); - } - - pageContext.setAttribute(name, o, scope); - - return EVAL_PAGE; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getScope() { - return scope; - } - - public void setScope(Integer scope) { - this.scope = scope; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/java/sca/modules/implementation-web-runtime/pom.xml b/java/sca/modules/implementation-web-runtime/pom.xml index e70da9a54f..1f4c619915 100644 --- a/java/sca/modules/implementation-web-runtime/pom.xml +++ b/java/sca/modules/implementation-web-runtime/pom.xml @@ -45,7 +45,7 @@ org.apache.tuscany.sca - tuscany-host-http + tuscany-host-webapp 2.0-SNAPSHOT @@ -59,7 +59,7 @@ org.apache.geronimo.specs geronimo-jsp_2.1_spec - 1.0 + 1.0.1 provided diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java deleted file mode 100644 index bf33f7ad9e..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java +++ /dev/null @@ -1,156 +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.implementation.web; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * Servlet that handles the GET request for the componentContext.js script - * - * The script is generated by calling ScriptProcessors to output the code - * for the SCA references, properties etc. - */ -public class ComponentContextServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - - protected static final String HEADER = "/** --- Apache Tuscany componentContext.js --- */\n"; - protected static final String FOOTER = "/** --- Apache Tuscany componentContext.js EOF --- */\n"; - - public static final String COMPONENT_CONTEXT_SCRIPT_URI = "org.apache.tuscany.sca.componentContext.js"; - - protected transient Map attributes = new HashMap(); - protected transient ServletContext servletContext; - private transient List contextScriptProcessors = new ArrayList(); - - public ComponentContextServlet() { - contextScriptProcessors.add(new JSONRPCScripProcessor()); - } - - @Override - public void init(ServletConfig servletConfig) throws ServletException { - this.servletContext = servletConfig.getServletContext(); - if (attributes.size() > 0) { - for (String name : attributes.keySet()) { - servletContext.setAttribute(name, attributes.get(name)); - } - } - } - - @Override - public void doGet(HttpServletRequest req, HttpServletResponse response) throws IOException { - response.setContentType("text/plain;charset=utf-8"); - PrintWriter out = response.getWriter(); - - out.write(HEADER); - - doScriptInit(req, response); - - doScriptReferences(req, response); - - out.write(FOOTER); - - out.flush(); - out.close(); - } - - /** - * Calls each ContextScriptProcessor once to insert any required initilization code into componentContext.js - */ - protected void doScriptInit(HttpServletRequest req, HttpServletResponse response) throws IOException, UnsupportedEncodingException { - - PrintWriter out = response.getWriter(); - - out.println("if (SCA == undefined) var SCA = new Object();"); - out.println("if (SCA.componentContext == undefined) {"); - out.println(" SCA.componentContext = new Object();"); - out.println(" SCA.componentContext.serviceNames = [];"); - out.println(" SCA.componentContext.serviceProxys = [];"); - out.println(" SCA.componentContext.getService = function(serviceName){"); - out.println(" var i = SCA.componentContext.serviceNames.indexOf(serviceName);"); - out.println(" return SCA.componentContext.serviceProxys[i];"); - out.println(" };"); - out.println(" if (componentContext == undefined) var componentContext = SCA.componentContext;"); - out.println("}"); - - for (ContextScriptProcessor csp : contextScriptProcessors) { - csp.scriptInit(req, response); - } - } - - /** - * Calls each ContextScriptProcessor for each SCA reference to insert code for the reference into componentContext.js - */ - protected void doScriptReferences(HttpServletRequest req, HttpServletResponse response) throws IOException, UnsupportedEncodingException { - - PrintWriter out = response.getWriter(); - - out.write("// SCA References\n"); - - RuntimeComponent component = (RuntimeComponent)servletContext.getAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent"); - - for (ComponentReference cr : component.getReferences()) { - String ref = "// SCA Reference " + cr.getName() + "\n"; - out.write(ref); - for (ContextScriptProcessor csp : contextScriptProcessors) { - csp.scriptReference(cr, req, response); - } - } - - out.write("\n// SCA References end.\n"); - } - - /** - * Calls each ContextScriptProcessor for each SCA property to insert code for the property into componentContext.js - */ - protected void doScriptProperties(HttpServletRequest req, HttpServletResponse response) throws IOException, UnsupportedEncodingException { - // TODO: support properties - } - - /** - * Set an attribute on the ServletContext - */ - public void setAttribute(String name, Object value) { - if (servletContext != null) { - servletContext.setAttribute(name, value); - } else { - attributes.put(name, value); - } - } - - public void addContextScriptProcessor(ContextScriptProcessor csp) { - contextScriptProcessors.add(csp); - } -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessor.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessor.java deleted file mode 100644 index 02c99debb0..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessor.java +++ /dev/null @@ -1,32 +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.implementation.web; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.tuscany.sca.assembly.ComponentReference; - -public interface ContextScriptProcessor { - void scriptInit(HttpServletRequest req, HttpServletResponse response) throws IOException; - void scriptReference(ComponentReference cr, HttpServletRequest req, HttpServletResponse response) throws IOException; -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessorExtensionPoint.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessorExtensionPoint.java deleted file mode 100644 index 6d3f590309..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ContextScriptProcessorExtensionPoint.java +++ /dev/null @@ -1,27 +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.implementation.web; - - -public interface ContextScriptProcessorExtensionPoint { - - void addContextScriptProcessor(ContextScriptProcessor csp); - -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/DefaultContextScriptProcessorExtensionPoint.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/DefaultContextScriptProcessorExtensionPoint.java deleted file mode 100644 index 89b951e7d2..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/DefaultContextScriptProcessorExtensionPoint.java +++ /dev/null @@ -1,51 +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.implementation.web; - -import java.util.ArrayList; -import java.util.List; - - -public class DefaultContextScriptProcessorExtensionPoint implements ContextScriptProcessorExtensionPoint { - - protected ComponentContextServlet componentContextServlet; - protected List tempCSPHolder = new ArrayList(); - - public DefaultContextScriptProcessorExtensionPoint() { - } - - public void addContextScriptProcessor(ContextScriptProcessor csp) { - if (componentContextServlet != null) { - componentContextServlet.addContextScriptProcessor(csp); - } else { - tempCSPHolder.add(csp); - } - } - - public void setComponentContextServlet(ComponentContextServlet servlet) { - componentContextServlet = servlet; - if (tempCSPHolder.size() > 0) { - for (ContextScriptProcessor csp : tempCSPHolder) { - componentContextServlet.addContextScriptProcessor(csp); - } - } - } - -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/JSONRPCScripProcessor.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/JSONRPCScripProcessor.java deleted file mode 100644 index e4ec0d71f9..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/JSONRPCScripProcessor.java +++ /dev/null @@ -1,57 +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.implementation.web; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.ComponentReference; - -public class JSONRPCScripProcessor implements ContextScriptProcessor { - - public void scriptInit(HttpServletRequest req, HttpServletResponse response) throws IOException { - PrintWriter out = response.getWriter(); - InputStream is = getClass().getClassLoader().getResourceAsStream("jsonrpc.js"); - if (is != null) { - int i; - while ((i = is.read()) != -1) { - out.write(i); - } - } - - out.println(); - } - - public void scriptReference(ComponentReference cr, HttpServletRequest req, HttpServletResponse response) throws IOException { - for (Binding b : cr.getBindings()) { - if ("org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding".equals(b.getClass().getName())) { - PrintWriter out = response.getWriter(); - out.println("SCA.componentContext.serviceNames.push('" + cr.getName() + "');"); - out.println("SCA.componentContext.serviceProxys.push(new JSONRpcClient('" + cr.getReference().getTargets().get(0).getName() + "').Service);"); - } - } - } - -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java deleted file mode 100644 index 26b6e051ab..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java +++ /dev/null @@ -1,87 +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.implementation.web.runtime; - -import java.util.Collection; - -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.oasisopen.sca.CallableReference; -import org.oasisopen.sca.ComponentContext; -import org.oasisopen.sca.RequestContext; -import org.oasisopen.sca.ServiceReference; - -/** - * Proxy ComponentContext wrappering a RuntimeComponent as the - * RuntimeComponent ComponentContext has not been created till later - */ -public class ComponentContextProxy implements ComponentContext { - - protected RuntimeComponent runtimeComponent; - - public ComponentContextProxy(RuntimeComponent runtimeComponent) { - this.runtimeComponent = runtimeComponent; - } - - protected ComponentContext getComponentContext() { - return runtimeComponent.getComponentContext(); - } - - @SuppressWarnings("unchecked") - public > R cast(B arg0) throws IllegalArgumentException { - return (R) getComponentContext().cast(arg0); - } - - public ServiceReference createSelfReference(Class arg0) { - return getComponentContext().createSelfReference(arg0); - } - - public ServiceReference createSelfReference(Class arg0, String arg1) { - return getComponentContext().createSelfReference(arg0, arg1); - } - - public B getProperty(Class arg0, String arg1) { - return getComponentContext().getProperty(arg0, arg1); - } - - public RequestContext getRequestContext() { - return getComponentContext().getRequestContext(); - } - - public B getService(Class arg0, String arg1) { - return getComponentContext().getService(arg0, arg1); - } - - public ServiceReference getServiceReference(Class arg0, String arg1) { - return getComponentContext().getServiceReference(arg0, arg1); - } - - public String getURI() { - return getComponentContext().getURI(); - } - - public Collection> getServiceReferences(Class businessInterface, String referenceName) { - return ((ComponentContext)getComponentContext()).getServiceReferences(businessInterface, referenceName); - } - - public Collection getServices(Class businessInterface, String referenceName) { - return ((ComponentContext)getComponentContext()).getServices(businessInterface, referenceName); - } - -} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java index 2518ba5381..06615178bf 100644 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java +++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java @@ -18,14 +18,7 @@ */ package org.apache.tuscany.sca.implementation.web.runtime; -import java.util.List; - import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.host.http.ServletHost; -import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; -import org.apache.tuscany.sca.implementation.web.ComponentContextServlet; -import org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint; -import org.apache.tuscany.sca.implementation.web.DefaultContextScriptProcessorExtensionPoint; import org.apache.tuscany.sca.implementation.web.WebImplementation; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; @@ -33,30 +26,14 @@ import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -public class WebImplementationProviderFactory implements ImplementationProviderFactory { - private ServletHost servletHost; - private ComponentContextServlet contextServlet; +public class WebImplementationProviderFactory implements ImplementationProviderFactory { public WebImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { - ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); - List hosts = servletHosts.getServletHosts(); - if (!hosts.isEmpty()) { - this.servletHost = hosts.get(0); - } - - contextServlet = new ComponentContextServlet(); - - DefaultContextScriptProcessorExtensionPoint dcspep = (DefaultContextScriptProcessorExtensionPoint)extensionPoints.getExtensionPoint(ContextScriptProcessorExtensionPoint.class); - dcspep.setComponentContextServlet(contextServlet); } public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) { - servletHost.addServletMapping("org.osoa.sca.componentContext.js", contextServlet); - contextServlet.setAttribute("org.osoa.sca.ComponentContext", new ComponentContextProxy(component)); - contextServlet.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component); - return new ImplementationProvider() { public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) { throw new UnsupportedOperationException("Components using implementation.web have no services"); diff --git a/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld b/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld index 44ce1b1d8a..c86154c994 100644 --- a/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld +++ b/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld @@ -7,8 +7,6 @@ AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 200 see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications --> - - 1.0 @@ -20,8 +18,8 @@ see http://www.osoa.org/display/Main/Service+Component+Architecture+Specificatio reference - org.apache.tuscany.sca.implementation.web.taglib.ReferenceTag - org.apache.tuscany.sca.implementation.web.taglib.ReferenceTEI + org.apache.tuscany.sca.implementation.web.runtime.jsp.ReferenceTag + org.apache.tuscany.sca.implementation.web.runtime.jsp.ReferenceTEI name diff --git a/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint b/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint deleted file mode 100644 index 960ae30552..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint +++ /dev/null @@ -1,19 +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. -# Implementation class for the ModuleActivator -org.apache.tuscany.sca.implementation.web.DefaultContextScriptProcessorExtensionPoint - diff --git a/java/sca/modules/implementation-web-runtime/src/main/resources/jsonrpc.js b/java/sca/modules/implementation-web-runtime/src/main/resources/jsonrpc.js deleted file mode 100644 index 8eb477c2e5..0000000000 --- a/java/sca/modules/implementation-web-runtime/src/main/resources/jsonrpc.js +++ /dev/null @@ -1,493 +0,0 @@ -/* - * JSON-RPC JavaScript client - * - * $Id: jsonrpc.js,v 1.36.2.3 2006/03/08 15:09:37 mclark Exp $ - * - * Copyright (c) 2003-2004 Jan-Klaas Kollhof - * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd - * - * This code is based on Jan-Klaas' JavaScript o lait library (jsolait). - * - * 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. - * - */ - -/* - * Modifications for Apache Tuscany: - * - JSONRpcClient_createMethod changed so callback is last arg - */ - -/* escape a character */ - -escapeJSONChar = -function escapeJSONChar(c) -{ - if(c == "\"" || c == "\\") return "\\" + c; - else if (c == "\b") return "\\b"; - else if (c == "\f") return "\\f"; - else if (c == "\n") return "\\n"; - else if (c == "\r") return "\\r"; - else if (c == "\t") return "\\t"; - var hex = c.charCodeAt(0).toString(16); - if(hex.length == 1) return "\\u000" + hex; - else if(hex.length == 2) return "\\u00" + hex; - else if(hex.length == 3) return "\\u0" + hex; - else return "\\u" + hex; -}; - - -/* encode a string into JSON format */ - -escapeJSONString = -function escapeJSONString(s) -{ - /* The following should suffice but Safari's regex is b0rken - (doesn't support callback substitutions) - return "\"" + s.replace(/([^\u0020-\u007f]|[\\\"])/g, - escapeJSONChar) + "\""; - */ - - /* Rather inefficient way to do it */ - var parts = s.split(""); - for(var i=0; i < parts.length; i++) { - var c =parts[i]; - if(c == '"' || - c == '\\' || - c.charCodeAt(0) < 32 || - c.charCodeAt(0) >= 128) - parts[i] = escapeJSONChar(parts[i]); - } - return "\"" + parts.join("") + "\""; -}; - - -/* Marshall objects to JSON format */ - -toJSON = function toJSON(o) -{ - if(o == null) { - return "null"; - } else if(o.constructor == String) { - return escapeJSONString(o); - } else if(o.constructor == Number) { - return o.toString(); - } else if(o.constructor == Boolean) { - return o.toString(); - } else if(o.constructor == Date) { - return '{javaClass: "java.util.Date", time: ' + o.valueOf() +'}'; - } else if(o.constructor == Array) { - var v = []; - for(var i = 0; i < o.length; i++) v.push(toJSON(o[i])); - return "[" + v.join(", ") + "]"; - } else { - var v = []; - for(attr in o) { - if(o[attr] == null) v.push("\"" + attr + "\": null"); - else if(typeof o[attr] == "function"); /* skip */ - else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr])); - } - return "{" + v.join(", ") + "}"; - } -}; - - -/* JSONRpcClient constructor */ - -JSONRpcClient = -function JSONRpcClient_ctor(serverURL, user, pass, objectID) -{ - this.serverURL = serverURL; - this.user = user; - this.pass = pass; - this.objectID = objectID; - - /* Add standard methods */ - if(this.objectID) { - this._addMethods(["listMethods"]); - var req = this._makeRequest("listMethods", []); - } else { - this._addMethods(["system.listMethods"]); - var req = this._makeRequest("system.listMethods", []); - } - var m = this._sendRequest(req); - this._addMethods(m); -}; - - -/* JSONRpcCLient.Exception */ - -JSONRpcClient.Exception = -function JSONRpcClient_Exception_ctor(code, message, javaStack) -{ - this.code = code; - var name; - if(javaStack) { - this.javaStack = javaStack; - var m = javaStack.match(/^([^:]*)/); - if(m) name = m[0]; - } - if(name) this.name = name; - else this.name = "JSONRpcClientException"; - this.message = message; -}; - -JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION = 490; -JSONRpcClient.Exception.CODE_ERR_CLIENT = 550; -JSONRpcClient.Exception.CODE_ERR_PARSE = 590; -JSONRpcClient.Exception.CODE_ERR_NOMETHOD = 591; -JSONRpcClient.Exception.CODE_ERR_UNMARSHALL = 592; -JSONRpcClient.Exception.CODE_ERR_MARSHALL = 593; - -JSONRpcClient.Exception.prototype = new Error(); - -JSONRpcClient.Exception.prototype.toString = -function JSONRpcClient_Exception_toString(code, msg) -{ - return this.name + ": " + this.message; -}; - - -/* Default top level exception handler */ - -JSONRpcClient.default_ex_handler = -function JSONRpcClient_default_ex_handler(e) { alert(e); }; - - -/* Client settable variables */ - -JSONRpcClient.toplevel_ex_handler = JSONRpcClient.default_ex_handler; -JSONRpcClient.profile_async = false; -JSONRpcClient.max_req_active = 1; -JSONRpcClient.requestId = 1; - - -/* JSONRpcClient implementation */ - -JSONRpcClient.prototype._createMethod = -function JSONRpcClient_createMethod(methodName) -{ - var fn=function() - { - var args = []; - var callback = null; - for(var i=0;i 0) { - var res = JSONRpcClient.async_responses.shift(); - if(res.canceled) continue; - if(res.profile) res.profile.dispatch = new Date(); - try { - res.cb(res.result, res.ex, res.profile); - } catch(e) { - JSONRpcClient.toplevel_ex_handler(e); - } - } - - while(JSONRpcClient.async_requests.length > 0 && - JSONRpcClient.num_req_active < JSONRpcClient.max_req_active) { - var req = JSONRpcClient.async_requests.shift(); - if(req.canceled) continue; - req.client._sendRequest.call(req.client, req); - } -}; - -JSONRpcClient.kick_async = -function JSONRpcClient_kick_async() -{ - if(JSONRpcClient.async_timeout == null) - JSONRpcClient.async_timeout = - setTimeout(JSONRpcClient._async_handler, 0); -}; - -JSONRpcClient.cancelRequest = -function JSONRpcClient_cancelRequest(requestId) -{ - /* If it is in flight then mark it as canceled in the inflight map - and the XMLHttpRequest callback will discard the reply. */ - if(JSONRpcClient.async_inflight[requestId]) { - JSONRpcClient.async_inflight[requestId].canceled = true; - return true; - } - - /* If its not in flight yet then we can just mark it as canceled in - the the request queue and it will get discarded before being sent. */ - for(var i in JSONRpcClient.async_requests) { - if(JSONRpcClient.async_requests[i].requestId == requestId) { - JSONRpcClient.async_requests[i].canceled = true; - return true; - } - } - - /* It may have returned from the network and be waiting for its callback - to be dispatched, so mark it as canceled in the response queue - and the response will get discarded before calling the callback. */ - for(var i in JSONRpcClient.async_responses) { - if(JSONRpcClient.async_responses[i].requestId == requestId) { - JSONRpcClient.async_responses[i].canceled = true; - return true; - } - } - - return false; -}; - -JSONRpcClient.prototype._makeRequest = -function JSONRpcClient_makeRequest(methodName, args, cb) -{ - var req = {}; - req.client = this; - req.requestId = JSONRpcClient.requestId++; - - var obj = {}; - obj.id = req.requestId; - if (this.objectID) - obj.method = ".obj#" + this.objectID + "." + methodName; - else - obj.method = methodName; - obj.params = args; - - if (cb) req.cb = cb; - if (JSONRpcClient.profile_async) - req.profile = { "submit": new Date() }; - req.data = toJSON(obj); - - return req; -}; - -JSONRpcClient.prototype._sendRequest = -function JSONRpcClient_sendRequest(req) -{ - if(req.profile) req.profile.start = new Date(); - - /* Get free http object from the pool */ - var http = JSONRpcClient.poolGetHTTPRequest(); - JSONRpcClient.num_req_active++; - - /* Send the request */ - if (typeof(this.user) == "undefined") { - http.open("POST", this.serverURL, (req.cb != null)); - } else { - http.open("POST", this.serverURL, (req.cb != null), this.user, this.pass); - } - - /* setRequestHeader is missing in Opera 8 Beta */ - try { http.setRequestHeader("Content-type", "text/plain"); } catch(e) {} - - /* Construct call back if we have one */ - if(req.cb) { - var self = this; - http.onreadystatechange = function() { - if(http.readyState == 4) { - http.onreadystatechange = function () {}; - var res = { "cb": req.cb, "result": null, "ex": null}; - if (req.profile) { - res.profile = req.profile; - res.profile.end = new Date(); - } - try { res.result = self._handleResponse(http); } - catch(e) { res.ex = e; } - if(!JSONRpcClient.async_inflight[req.requestId].canceled) - JSONRpcClient.async_responses.push(res); - delete JSONRpcClient.async_inflight[req.requestId]; - JSONRpcClient.kick_async(); - } - }; - } else { - http.onreadystatechange = function() {}; - } - - JSONRpcClient.async_inflight[req.requestId] = req; - - try { - http.send(req.data); - } catch(e) { - JSONRpcClient.poolReturnHTTPRequest(http); - JSONRpcClient.num_req_active--; - throw new JSONRpcClient.Exception - (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed"); - } - - if(!req.cb) return this._handleResponse(http); -}; - -JSONRpcClient.prototype._handleResponse = -function JSONRpcClient_handleResponse(http) -{ - /* Get the charset */ - if(!this.charset) { - this.charset = JSONRpcClient._getCharsetFromHeaders(http); - } - - /* Get request results */ - var status, statusText, data; - try { - status = http.status; - statusText = http.statusText; - data = http.responseText; - } catch(e) { - JSONRpcClient.poolReturnHTTPRequest(http); - JSONRpcClient.num_req_active--; - JSONRpcClient.kick_async(); - throw new JSONRpcClient.Exception - (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed"); - } - - /* Return http object to the pool; */ - JSONRpcClient.poolReturnHTTPRequest(http); - JSONRpcClient.num_req_active--; - - /* Unmarshall the response */ - if(status != 200) { - throw new JSONRpcClient.Exception(status, statusText); - } - var obj; - try { - eval("obj = " + data); - } catch(e) { - throw new JSONRpcClient.Exception(550, "error parsing result"); - } - if(obj.error) - throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg, - obj.error.trace); - var res = obj.result; - - /* Handle CallableProxy */ - if(res && res.objectID && res.JSONRPCType == "CallableReference") - return new JSONRpcClient(this.serverURL, this.user, - this.pass, res.objectID); - - return res; -}; - - -/* XMLHttpRequest wrapper code */ - -/* XMLHttpRequest pool globals */ -JSONRpcClient.http_spare = []; -JSONRpcClient.http_max_spare = 8; - -JSONRpcClient.poolGetHTTPRequest = -function JSONRpcClient_pool_getHTTPRequest() -{ - if(JSONRpcClient.http_spare.length > 0) { - return JSONRpcClient.http_spare.pop(); - } - return JSONRpcClient.getHTTPRequest(); -}; - -JSONRpcClient.poolReturnHTTPRequest = -function JSONRpcClient_poolReturnHTTPRequest(http) -{ - if(JSONRpcClient.http_spare.length >= JSONRpcClient.http_max_spare) - delete http; - else - JSONRpcClient.http_spare.push(http); -}; - -JSONRpcClient.msxmlNames = [ "MSXML2.XMLHTTP.5.0", - "MSXML2.XMLHTTP.4.0", - "MSXML2.XMLHTTP.3.0", - "MSXML2.XMLHTTP", - "Microsoft.XMLHTTP" ]; - -JSONRpcClient.getHTTPRequest = -function JSONRpcClient_getHTTPRequest() -{ - /* Mozilla XMLHttpRequest */ - try { - JSONRpcClient.httpObjectName = "XMLHttpRequest"; - return new XMLHttpRequest(); - } catch(e) {} - - /* Microsoft MSXML ActiveX */ - for (var i=0;i < JSONRpcClient.msxmlNames.length; i++) { - try { - JSONRpcClient.httpObjectName = JSONRpcClient.msxmlNames[i]; - return new ActiveXObject(JSONRpcClient.msxmlNames[i]); - } catch (e) {} - } - - /* None found */ - JSONRpcClient.httpObjectName = null; - throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object"); -}; - -- cgit v1.2.3