diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:28 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:28 +0000 |
commit | 07b7dfd1a70ba222b899d9813f8c449dbf3b785f (patch) | |
tree | ecfc876747e6cfedee0a8533d87c19ac78a2dbd0 /branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache | |
parent | 6fadbc9cd1fcf03d0b3630f772d91df149b70428 (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835124 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache')
10 files changed, 0 insertions, 819 deletions
diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java deleted file mode 100644 index 27a600fe08..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java +++ /dev/null @@ -1,38 +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.widget; - -import java.net.URL; - -/** - * The service interface of resource implementations. - * - * @version $Rev$ $Date$ - */ -public interface Widget { - - /** - * Returns the resource location URL. - * - * @return - */ - public URL getLocationURL(); - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetComponentServlet.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetComponentServlet.java deleted file mode 100644 index 19a186ea8a..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetComponentServlet.java +++ /dev/null @@ -1,149 +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.widget; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.OptimizableBinding; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * Servlet to handle requests for .. - * - * @version $Rev$ $Date$ - */ -public class WidgetComponentServlet extends HttpServlet { - private static final long serialVersionUID = -2996033426789721509L; - - private transient RuntimeComponent component; - private transient URI servletURI; - - public WidgetComponentServlet(RuntimeComponent component, String servletURI) { - this.component = component; - this.servletURI = URI.create(servletURI); - } - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - - ServletOutputStream os = response.getOutputStream(); - - os.println(); - os.println("/* Apache Tuscany - SCA Web Widget */"); - os.println(); - - writeSCAWidgetCode(os, request.getServletPath()); - } - - /** - */ - private void writeSCAWidgetCode(ServletOutputStream out, String path) throws IOException { - out.println(); - out.println("/* Apache Tuscany SCA Widget header */"); - out.println(); - - // remove the leading slash '/' character - path = path.substring(1); - - for(ComponentReference reference : component.getReferences()) { - for(Binding binding : reference.getBindings()) { - String bindingProxyName = WidgetProxyHelper.getJavaScriptProxyFile(binding.getClass().getName()); - if(bindingProxyName != null) { - writeJavaScriptBindingProxy(out,bindingProxyName); - } - } - } - - writeJavaScriptReferenceFunction(out); - - - out.println(); - out.println("/** End of Apache Tuscany SCA Widget */"); - out.println(); - } - - /** - * Retrieve the binding proxy based on the bind name - * and embedded the javascript into this js - */ - private void writeJavaScriptBindingProxy(ServletOutputStream os, String bindingProxyName) throws IOException { - - URL url = getClass().getClassLoader().getResource(bindingProxyName); //Thread.currentThread().getContextClassLoader().getResource(bindingProxyName); - InputStream is = url.openStream(); - int i; - while ((i = is.read()) != -1) { - os.write(i); - } - os.println(); - os.println(); - } - - private void writeJavaScriptReferenceFunction (ServletOutputStream os) throws IOException { - - os.println("var referenceMap = new Object();"); - for(ComponentReference reference : component.getReferences()) { - String referenceName = reference.getName(); - Binding binding = reference.getBindings().get(0); - if (binding != null) { - - String proxyClient = WidgetProxyHelper.getJavaScriptProxyClient(binding.getClass().getName()); - if(proxyClient != null) { - - //FIXME Eventually the binding URI should be initialized from the SCA domain - // for now point to the target binding model directly, assuming that it's available - // in the same node - String targetURI = null; - if (binding instanceof OptimizableBinding) { - Binding targetBinding = ((OptimizableBinding)binding).getTargetBinding(); - if (targetBinding != null) { - targetURI = URI.create(targetBinding.getURI()).getPath(); - } - } - if (targetURI == null) { - targetURI = URI.create(binding.getURI()).getPath(); - if (!targetURI.startsWith("/")) { - targetURI = "/" + targetURI; - } - } - - if(proxyClient.equals("JSONRpcClient")) { - os.println("referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetURI + "\").Service;"); - } else { - os.println("referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetURI + "\");"); - } - } - } - } - - os.println("function Reference(name) {"); - os.println(" return referenceMap[name];"); - os.println("}"); - } - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java deleted file mode 100644 index 6f7ffdee09..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java +++ /dev/null @@ -1,134 +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.widget; - -import java.net.URL; -import java.util.Collections; -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - - -/** - * The model representing a widget implementation in an SCA assembly model. - */ -public class WidgetImplementation implements Implementation { - private AssemblyFactory assemblyFactory; - - private Service widgetService; - private List<Reference> references = null; - - private String location; - private URL url; - private boolean unresolved; - - /** - * Constructs a new resource implementation. - */ - WidgetImplementation(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - - this.assemblyFactory = assemblyFactory; - - // Resource implementation always provide a single service exposing - // the Resource interface, and have no references and properties - widgetService = assemblyFactory.createService(); - widgetService.setName("Widget"); - - // Create the Java interface contract for the Resource service - JavaInterface javaInterface; - try { - javaInterface = javaFactory.createJavaInterface(Widget.class); - } catch (InvalidInterfaceException e) { - throw new IllegalArgumentException(e); - } - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterface); - widgetService.setInterfaceContract(interfaceContract); - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public URL getLocationURL() { - return url; - } - - public void setLocationURL(URL url) { - this.url = url; - } - - public ConstrainingType getConstrainingType() { - // The resource implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - // The resource implementation does not support properties - return Collections.emptyList(); - } - - public List<Service> getServices() { - // The resource implementation does not support services - return Collections.singletonList(widgetService); - } - - public List<Reference> getReferences() { - if(this.references == null) { - WidgetImplementationIntrospector widgetIntrospector = new WidgetImplementationIntrospector(assemblyFactory, this); - references = widgetIntrospector.getReferences(); - } - return references; - } - - public String getURI() { - return location; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - // The resource implementation does not support constrainingTypes - } - - public void setURI(String uri) { - this.location = uri; - } - - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java deleted file mode 100644 index 2493b97f5c..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.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.implementation.widget; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - -/** - * Factory for the widget implementation model. - * - * @version $Rev$ $Date$ - */ -public class WidgetImplementationFactory { - - private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - - public WidgetImplementationFactory(ModelFactoryExtensionPoint modelFactories) { - assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - } - - public WidgetImplementation createWidgetImplementation() { - return new WidgetImplementation(assemblyFactory, javaFactory); - } - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java deleted file mode 100644 index c0e008dec5..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java +++ /dev/null @@ -1,105 +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.widget; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Reference; - -public class WidgetImplementationIntrospector { - private static final String WEB_REFERENCE_ANNOTATION = "//@Reference"; - - private AssemblyFactory assemblyFactory; - private WidgetImplementation widgetImplementation; - - public WidgetImplementationIntrospector(AssemblyFactory assemblyFactory, WidgetImplementation widgetImplementation) { - this.widgetImplementation = widgetImplementation; - this.assemblyFactory = assemblyFactory; - } - - - /** - * Introspect the References of a given htmlWidget - * @return - */ - public List<Reference> getReferences() { - List<Reference> references = new ArrayList<Reference>(); - URL htmlWidget = widgetImplementation.getLocationURL(); - - try { - Scanner scanner = new Scanner(htmlWidget.openStream()); - while(scanner.hasNextLine()) { - String line = scanner.nextLine(); - if(line.contains(WEB_REFERENCE_ANNOTATION)) { - //process the next line, as it has the reference info - if(scanner.hasNextLine()) { - Reference reference = processReferenceScript(scanner.nextLine()); - if(reference != null){ - references.add(reference); - } - - } - } - } - - } catch(Exception e) { - - } - - return references; - - } - - /** - * Process Reference declaration in JavaScript code - * Supported ways : - * //@Reference - * var catalog = new Reference("catalog"); - * - * //@Reference - * catalog = new Reference("catalog"); - * - * @param scriptContent - * @return - */ - private Reference processReferenceScript(String scriptContent) { - Reference reference = null; - String referenceName = null; - - String tokens[] = scriptContent.split("="); - tokens = tokens[0].split(" "); - referenceName = tokens[tokens.length -1]; - - if(referenceName != null) { - reference = assemblyFactory.createReference(); - reference.setName(referenceName); - } - - return reference; - } - - - - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java deleted file mode 100644 index 7f396e95b5..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java +++ /dev/null @@ -1,119 +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.widget; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import java.io.IOException; -import java.net.URL; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DeployedArtifact; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - - -/** - * Implements a STAX artifact processor for resource implementations. - */ -public class WidgetImplementationProcessor implements StAXArtifactProcessor<WidgetImplementation> { - private static final QName IMPLEMENTATION_WIDGET = new QName(Constants.SCA10_TUSCANY_NS, "implementation.widget"); - - private ContributionFactory contributionFactory; - private WidgetImplementationFactory implementationFactory; - - public WidgetImplementationProcessor(ModelFactoryExtensionPoint modelFactories) { - contributionFactory = modelFactories.getFactory(ContributionFactory.class); - implementationFactory = new WidgetImplementationFactory(modelFactories); //modelFactories.getFactory(WidgetImplementationFactory.class); - } - - public QName getArtifactType() { - // Returns the qname of the XML element processed by this processor - return IMPLEMENTATION_WIDGET; - } - - public Class<WidgetImplementation> getModelType() { - // Returns the type of model processed by this processor - return WidgetImplementation.class; - } - - public WidgetImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an <implementation.resource> element - - // Read the location attribute specifying the location of the - // resources - String location = reader.getAttributeValue(null, "location"); - - // Create an initialize the resource implementationmodel - WidgetImplementation implementation = implementationFactory.createWidgetImplementation(); - implementation.setLocation(location); - implementation.setUnresolved(true); - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_WIDGET.equals(reader.getName())) { - break; - } - } - - return implementation; - } - - public void resolve(WidgetImplementation implementation, ModelResolver resolver) throws ContributionResolveException { - - // Resolve the resource directory location - DeployedArtifact artifact = contributionFactory.createDeployedArtifact(); - artifact.setURI(implementation.getLocation()); - DeployedArtifact resolved = resolver.resolveModel(DeployedArtifact.class, artifact); - if (resolved.getLocation() != null) { - try { - implementation.setLocationURL(new URL(resolved.getLocation())); - implementation.setUnresolved(false); - } catch (IOException e) { - throw new ContributionResolveException(e); - } - } - } - - public void write(WidgetImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write <implementation.resource> - writer.setPrefix("widget",IMPLEMENTATION_WIDGET.getNamespaceURI()); - writer.writeStartElement(IMPLEMENTATION_WIDGET.getNamespaceURI(), IMPLEMENTATION_WIDGET.getLocalPart()); - writer.writeNamespace("widget",IMPLEMENTATION_WIDGET.getNamespaceURI()); - - - if (implementation.getLocation() != null) { - writer.writeAttribute("location", implementation.getLocation()); - } - - writer.writeEndElement(); - } -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java deleted file mode 100644 index da37b01e1e..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java +++ /dev/null @@ -1,44 +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.widget; - -import java.util.HashMap; -import java.util.Map; - -class WidgetProxyHelper { - private static Map<String, String> proxyFileRegistry = new HashMap<String, String>(); - private static Map<String, String> proxyClient = new HashMap<String, String>(); - - static { - proxyFileRegistry.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "binding-atom.js"); - proxyClient.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "AtomClient"); - - proxyFileRegistry.put("org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding", "binding-jsonrpc.js"); - proxyClient.put("org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding", "JSONRpcClient"); - } - - static String getJavaScriptProxyFile(String bindingClass) { - return proxyFileRegistry.get(bindingClass); - } - - static String getJavaScriptProxyClient(String bindingClass) { - return proxyClient.get(bindingClass); - } -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java deleted file mode 100644 index e336df9241..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java +++ /dev/null @@ -1,43 +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.widget.provider; - -import java.net.URL; - -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -/** - * Implements an invoker for resource component implementations. - */ -class WidgetImplementationInvoker implements Invoker { - private URL locationURL; - - WidgetImplementationInvoker(URL locationURL) { - this.locationURL = locationURL; - } - - public Message invoke(Message msg) { - // Return the location URL - msg.setBody(locationURL); - return msg; - } - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java deleted file mode 100644 index bff8c99a45..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java +++ /dev/null @@ -1,91 +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.widget.provider; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.host.http.ServletHost; -import org.apache.tuscany.sca.implementation.widget.WidgetImplementation; -import org.apache.tuscany.sca.implementation.widget.WidgetComponentServlet; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.osoa.sca.ServiceRuntimeException; - - -/** - * The model representing a resource implementation in an SCA assembly model. - */ -class WidgetImplementationProvider implements ImplementationProvider { - private RuntimeComponent component; - private WidgetImplementation implementation; - private ServletHost servletHost; - private String servletMapping; - - /** - * Constructs a new resource implementation provider. - */ - WidgetImplementationProvider(RuntimeComponent component, WidgetImplementation implementation, ServletHost servletHost) { - this.component = component; - this.implementation = implementation; - - this.servletHost = servletHost; - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(implementation.getLocationURL()); - return invoker; - } - - public boolean supportsOneWayInvocation() { - return false; - } - - public void start() { - - // Determine the widget URI - String widgetURI = null; - for (ComponentService componentService: component.getServices()) { - if (componentService.getName().equals("Widget")) { - if (componentService.getBindings().size() != 0) { - widgetURI = componentService.getBindings().get(0).getURI(); - } - break; - } - } - if (widgetURI == null) { - throw new ServiceRuntimeException("Could not find Widget service"); - } - - // Register the widget's ComponentServlet under the same URI as the widget - String widgetArtifact = implementation.getLocation(); - widgetArtifact = widgetArtifact.substring(0, widgetArtifact.lastIndexOf('.')); - widgetArtifact = widgetArtifact.substring(widgetArtifact.lastIndexOf('/') + 1); - servletMapping = widgetURI + "/" + widgetArtifact + ".js"; - WidgetComponentServlet widgetComponentServlet = new WidgetComponentServlet(component, servletMapping); - servletHost.addServletMapping(servletMapping, widgetComponentServlet); - } - - public void stop() { - servletHost.removeServletMapping(servletMapping); - } - -} diff --git a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java b/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java deleted file mode 100644 index 9d1dac7751..0000000000 --- a/branches/sca-java-1.1/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.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.widget.provider; - -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.widget.WidgetImplementation; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * The model representing a resource implementation in an SCA assembly model. - */ -public class WidgetImplementationProviderFactory implements ImplementationProviderFactory<WidgetImplementation> { - - private ServletHost servletHost; - - /** - * Constructs a resource implementation. - */ - public WidgetImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { - ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); - this.servletHost = servletHosts.getServletHosts().get(0); - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, WidgetImplementation implementation) { - return new WidgetImplementationProvider(component, implementation, servletHost); - } - - public Class<WidgetImplementation> getModelType() { - return WidgetImplementation.class; - } -} |