diff options
Diffstat (limited to 'tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache')
6 files changed, 0 insertions, 332 deletions
diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/assembly/JSONRPCBinding.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/assembly/JSONRPCBinding.java deleted file mode 100644 index 3629bbe98c..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/assembly/JSONRPCBinding.java +++ /dev/null @@ -1,39 +0,0 @@ -/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.binding.jsonrpc.assembly;
-
-import org.apache.tuscany.model.assembly.impl.BindingImpl;
-
-/**
- * An Binding implementation for JSON-RPC.
- */
-public class JSONRPCBinding extends BindingImpl {
-
- private String webAppName;
-
- public JSONRPCBinding() {
- }
-
- public void setWebAppName(String webAppName) {
- this.webAppName = webAppName;
- }
-
- public String getWebAppName() {
- return webAppName;
- }
-
-}
diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java deleted file mode 100644 index b0725c464b..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/**
- * Copyright 2005 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.
- */
-package org.apache.tuscany.binding.jsonrpc.builder;
-
-import org.apache.tuscany.binding.jsonrpc.assembly.JSONRPCBinding;
-import org.apache.tuscany.binding.jsonrpc.config.JSONEntryPointContextFactory;
-import org.apache.tuscany.core.extension.EntryPointBuilderSupport;
-import org.apache.tuscany.core.extension.EntryPointContextFactory;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.webapp.ServletHost;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("MODULE")
-public class JSONRPCEntryPointBuilder extends EntryPointBuilderSupport<JSONRPCBinding> {
-
- private ServletHost tomcatHost;
-
- @Autowire
- public void setTomcatHost(ServletHost tomcatHost) {
- this.tomcatHost = tomcatHost;
- }
-
- @Override
- protected EntryPointContextFactory createEntryPointContextFactory(EntryPoint entryPoint, MessageFactory msgFactory) {
- String webAppName = ((JSONRPCBinding) entryPoint.getBindings().get(0)).getWebAppName();
- return new JSONEntryPointContextFactory(entryPoint.getName(), msgFactory, webAppName, tomcatHost);
- }
-
-}
diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/config/JSONEntryPointContextFactory.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/config/JSONEntryPointContextFactory.java deleted file mode 100644 index 7c36f83e6b..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/config/JSONEntryPointContextFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * Copyright 2005 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. - */ -package org.apache.tuscany.binding.jsonrpc.config; - -import org.apache.tuscany.binding.jsonrpc.handler.JSONRPCEntryPointServlet; -import org.apache.tuscany.binding.jsonrpc.handler.ScriptGetterServlet; -import org.apache.tuscany.core.builder.ContextCreationException; -import org.apache.tuscany.core.context.EntryPointContext; -import org.apache.tuscany.core.extension.EntryPointContextFactory; -import org.apache.tuscany.core.message.MessageFactory; -import org.apache.tuscany.core.webapp.ServletHost; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class JSONEntryPointContextFactory extends EntryPointContextFactory { - - private ServletHost tomcatHost; - - private String webAppName; - - public JSONEntryPointContextFactory(String name, MessageFactory msgFactory, String webAppName, ServletHost tomcatHost) { - super(name, msgFactory); - this.webAppName = webAppName; - this.tomcatHost = tomcatHost; - } - - public EntryPointContext createContext() throws ContextCreationException { - EntryPointContext epc = super.createContext(); - JSONRPCEntryPointServlet jsonrpcServlet = getServlet(); - jsonrpcServlet.addEntryPoint(epc); - return epc; - } - - private JSONRPCEntryPointServlet getServlet() { - String jsonrpcServletMapping = webAppName + "/SCA/jsonrpc"; - JSONRPCEntryPointServlet servlet; - synchronized (tomcatHost) { - servlet = (JSONRPCEntryPointServlet) tomcatHost.getMapping(jsonrpcServletMapping); - if (servlet == null) { - servlet = new JSONRPCEntryPointServlet(); - tomcatHost.registerMapping(jsonrpcServletMapping, servlet); - tomcatHost.registerMapping(webAppName + "/SCA/scripts/*", new ScriptGetterServlet()); - } - } - return servlet; - } - -} diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/JSONRPCEntryPointServlet.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/JSONRPCEntryPointServlet.java deleted file mode 100644 index f59867b725..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/JSONRPCEntryPointServlet.java +++ /dev/null @@ -1,76 +0,0 @@ -/**
- *
- * Copyright 2005 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.
- */
-
-package org.apache.tuscany.binding.jsonrpc.handler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.tuscany.core.context.EntryPointContext;
-
-import com.metaparadigm.jsonrpc.JSONRPCBridge;
-import com.metaparadigm.jsonrpc.JSONRPCServlet;
-
-/**
- *
- *
- */
-public class JSONRPCEntryPointServlet extends JSONRPCServlet {
- private static final long serialVersionUID = 1L;
-
- private transient List<EntryPointContext> entryPoints;
-
- public JSONRPCEntryPointServlet() {
- entryPoints = new ArrayList<EntryPointContext>();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.metaparadigm.jsonrpc.JSONRPCServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- */
- @Override
- public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassCastException {
-
- /*
- * Create a new bridge for every request to aviod all the problems with JSON-RPC-Java storing the bridge in the session
- */
- HttpSession session = request.getSession();
- try {
-
- JSONRPCBridge jsonrpcBridge = new JSONRPCBridge();
- for (EntryPointContext epc : entryPoints) {
- jsonrpcBridge.registerObject(epc.getName(), epc.getInstance(null));
- }
- session.setAttribute("JSONRPCBridge", jsonrpcBridge);
-
- super.service(request, response);
-
- } finally {
- session.removeAttribute("JSONRPCBridge");
- }
- }
-
- public void addEntryPoint(EntryPointContext epc) {
- entryPoints.add(epc);
- }
-}
diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/ScriptGetterServlet.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/ScriptGetterServlet.java deleted file mode 100644 index 9177462de0..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/handler/ScriptGetterServlet.java +++ /dev/null @@ -1,51 +0,0 @@ -/**
- *
- * Copyright 2005 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.
- */
-package org.apache.tuscany.binding.jsonrpc.handler;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public class ScriptGetterServlet extends HttpServlet {
-
- private static final long serialVersionUID = 1L;
-
- private static final String SCA_INIT_JS = "SCA = new JSONRpcClient(\"SCA/jsonrpc\");";
-
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
- URL url = getClass().getResource("jsonrpc.js");
- InputStream is = url.openStream();
- writeToStream(response, is);
-
- writeToStream(response, new ByteArrayInputStream(SCA_INIT_JS.getBytes()));
- }
-
- private void writeToStream(HttpServletResponse response, InputStream is) throws IOException {
- ServletOutputStream os = response.getOutputStream();
- int i;
- while ((i = is.read()) != -1) {
- os.write(i);
- }
- }
-
-}
diff --git a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/loader/JSONRPCBindingLoader.java b/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/loader/JSONRPCBindingLoader.java deleted file mode 100644 index 64cefc9ea3..0000000000 --- a/tags/java-M1-final/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/loader/JSONRPCBindingLoader.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Copyright 2006 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.binding.jsonrpc.loader; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.binding.jsonrpc.assembly.JSONRPCBinding; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.core.loader.StAXElementLoader; -import org.apache.tuscany.core.loader.StAXLoaderRegistry; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class JSONRPCBindingLoader implements StAXElementLoader<JSONRPCBinding> { - - public static final QName BINDING_JSONRPC = new QName("http://org.apache.tuscany/xmlns/jsonrpc/0.9", "binding.jsonrpc"); - - protected StAXLoaderRegistry registry; - - @Autowire - public void setRegistry(StAXLoaderRegistry registry) { - this.registry = registry; - } - - @Init(eager = true) - public void start() { - registry.registerLoader(BINDING_JSONRPC, this); - } - - @Destroy - public void stop() { - registry.unregisterLoader(BINDING_JSONRPC, this); - } - - @SuppressWarnings("deprecation") - public JSONRPCBinding load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - JSONRPCBinding binding = new JSONRPCBinding(); - binding.setURI(reader.getAttributeValue(null, "uri")); - binding.setWebAppName(registry.getContext().getWebAppName()); - return binding; - } -} |