From 4abe8b6a78e80783baa3b87aa87da49d1d338567 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 24 Mar 2010 21:41:17 +0000 Subject: Porting Binding.RSS for 2.x runtime SPIs git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@927191 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/rss/collection/Collection.java | 2 +- .../binding/rss/collection/MediaCollection.java | 2 +- .../rss/provider/RSSBindingListenerServlet.java | 6 +-- .../rss/provider/RSSBindingProviderFactory.java | 21 ++++------ .../rss/provider/RSSReferenceBindingProvider.java | 15 ++++--- .../rss/provider/RSSServiceBindingProvider.java | 46 +++++++++++++--------- .../apache/tuscany/sca/binding/rss/Consumer.java | 15 +++++-- .../sca/binding/rss/CustomerClientImpl.java | 2 +- .../sca/binding/rss/CustomerCollectionImpl.java | 2 +- .../apache/tuscany/sca/binding/rss/Provider.java | 14 +++++-- .../tuscany/sca/binding/rss/RSSGetTestCase.java | 33 ++++++++++------ .../tuscany/sca/binding/rss/Consumer.composite | 4 +- .../tuscany/sca/binding/rss/Provider.composite | 4 +- 13 files changed, 98 insertions(+), 68 deletions(-) (limited to 'sca-java-2.x/trunk/modules/binding-rss-runtime/src') diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java index ed86dc4848..581ae59ae6 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java @@ -18,7 +18,7 @@ */ package org.apache.tuscany.sca.binding.rss.collection; -import org.osoa.sca.annotations.Remotable; +import org.oasisopen.sca.annotation.Remotable; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java index 2213b50b53..a2b83465da 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java @@ -20,7 +20,7 @@ package org.apache.tuscany.sca.binding.rss.collection; import java.io.InputStream; -import org.osoa.sca.annotations.Remotable; +import org.oasisopen.sca.annotation.Remotable; import com.sun.syndication.feed.atom.Entry; diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java index 96493a5150..44c84ce5bb 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java @@ -46,7 +46,7 @@ import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; import com.sun.syndication.feed.synd.SyndContent; import com.sun.syndication.feed.synd.SyndContentImpl; @@ -69,7 +69,7 @@ class RSSBindingListenerServlet extends HttpServlet { private static final Logger logger = Logger.getLogger(RSSBindingListenerServlet.class.getName()); private static final long serialVersionUID = 1L; - private RuntimeWire wire; + private Invocable wire; private Invoker getFeedInvoker; private Invoker getAllInvoker; private Invoker queryInvoker; @@ -85,7 +85,7 @@ class RSSBindingListenerServlet extends HttpServlet { * @param wire * @param messageFactory */ - RSSBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator) { + RSSBindingListenerServlet(Invocable wire, MessageFactory messageFactory, Mediator mediator) { this.wire = wire; this.messageFactory = messageFactory; this.mediator = mediator; diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java index d588f041db..e1bafdd3cd 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java @@ -20,8 +20,8 @@ package org.apache.tuscany.sca.binding.rss.provider; import org.apache.tuscany.sca.binding.rss.RSSBinding; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.host.http.ServletHost; @@ -30,9 +30,8 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * Implementation of the RSS binding provider factory. @@ -48,21 +47,17 @@ public class RSSBindingProviderFactory implements BindingProviderFactory getModelType() { diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java index 8a30e9d3fb..d234a0c92c 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java @@ -19,12 +19,13 @@ package org.apache.tuscany.sca.binding.rss.provider; +import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.rss.RSSBinding; +import org.apache.tuscany.sca.databinding.Mediator; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; /** @@ -34,14 +35,16 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentReference; */ class RSSReferenceBindingProvider implements ReferenceBindingProvider { + private EndpointReference endpointReference; + private RuntimeComponentReference reference; private RSSBinding binding; - RSSReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - RSSBinding binding) { - this.reference = reference; - this.binding = binding; + RSSReferenceBindingProvider(EndpointReference endpointReference, + Mediator mediator) { + this.endpointReference = endpointReference; + this.reference = (RuntimeComponentReference) endpointReference.getReference(); + this.binding = (RSSBinding) endpointReference.getBinding(); } public Invoker createInvoker(Operation operation) { diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java index 4e5429ac83..25ab939341 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java @@ -25,9 +25,8 @@ import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.Invocable; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; /** * Implementation of the RSS binding provider. @@ -36,28 +35,32 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ class RSSServiceBindingProvider implements ServiceBindingProvider { - private RuntimeComponentService service; + private RuntimeEndpoint endpoint; + + //private RuntimeComponentService service; private RSSBinding binding; - private ServletHost servletHost; + private MessageFactory messageFactory; - private String servletMapping; private Mediator mediator; - - RSSServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, - RSSBinding binding, - ServletHost servletHost, + private ServletHost servletHost; + + private String servletMapping; + + RSSServiceBindingProvider(RuntimeEndpoint endpoint, MessageFactory messageFactory, - Mediator mediator) { - this.service = service; - this.binding = binding; + Mediator mediator, + ServletHost servletHost) { + this.endpoint = endpoint; + + //this.service = (RuntimeComponentService)endpoint.getService(); + this.binding = (RSSBinding) endpoint.getBinding(); this.servletHost = servletHost; this.messageFactory = messageFactory; this.mediator = mediator; } public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); + return endpoint.getComponentTypeServiceInterfaceContract(); } public boolean supportsOneWayInvocation() { @@ -65,17 +68,22 @@ class RSSServiceBindingProvider implements ServiceBindingProvider { } public void start() { - RuntimeComponentService componentService = (RuntimeComponentService)service; - RuntimeWire wire = componentService.getRuntimeWire(binding); + Invocable wire = (RuntimeEndpoint) endpoint; RSSBindingListenerServlet servlet = new RSSBindingListenerServlet(wire, messageFactory, mediator); servletMapping = binding.getURI(); + if (!servletMapping.endsWith("/")) { + servletMapping += "/"; + } + if (!servletMapping.endsWith("*")) { + servletMapping += "*"; + } servletHost.addServletMapping(servletMapping, servlet); - + // Save the actual binding URI in the binding - binding.setURI(servletHost.getURLMapping(binding.getURI()).toString()); + //binding.setURI(servletHost.getURLMapping(binding.getURI()).toString()); } public void stop() { diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java index 19370285f5..1ae4515e70 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java @@ -19,17 +19,24 @@ package org.apache.tuscany.sca.binding.rss; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + public class Consumer { public static void main(String[] args) throws Exception { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Consumer.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class); + Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Consumer.composite", new Contribution("consumer", contribution)); + + node.start(); - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); + CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient"); testService.testCustomerCollection(); - scaDomain.close(); + node.stop(); } } diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java index e71156c379..a80f721136 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java @@ -20,7 +20,7 @@ package org.apache.tuscany.sca.binding.rss; import org.apache.tuscany.sca.binding.rss.collection.Collection; -import org.osoa.sca.annotations.Reference; +import org.oasisopen.sca.annotation.Reference; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java index 02d73ab3ae..4b5bf373e7 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java @@ -29,7 +29,7 @@ import java.util.UUID; import org.apache.tuscany.sca.binding.rss.collection.Collection; import org.apache.tuscany.sca.binding.rss.collection.NotFoundException; -import org.osoa.sca.annotations.Scope; +import org.oasisopen.sca.annotation.Scope; import com.sun.syndication.feed.synd.SyndContent; import com.sun.syndication.feed.synd.SyndContentImpl; diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java index ae7b72834e..6dc23ac503 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java @@ -21,13 +21,21 @@ package org.apache.tuscany.sca.binding.rss; import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Provider { public static void main(String[] args) { + + + String contribution = ContributionLocationHelper.getContributionLocation(Provider.class); + Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Provider.composite", new Contribution("provider", contribution)); + + node.start(); - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Provider.composite"); System.out.println("Provider.composite ready..."); try { @@ -36,6 +44,6 @@ public class Provider { e.printStackTrace(); } - scaDomain.close(); + node.stop(); } } diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java index cb5c280211..8eb007d75c 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java @@ -21,7 +21,10 @@ package org.apache.tuscany.sca.binding.rss; import junit.framework.Assert; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -30,33 +33,39 @@ import org.junit.Test; * Basic test case that will get the feed entries from an RSS feed. */ public class RSSGetTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; + protected static Node scaConsumerNode; + protected static Node scaProviderNode; protected static CustomerClient testService; @BeforeClass public static void init() throws Exception { System.out.println(">>>RSSGetTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/rss/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/rss/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(RSSGetTestCase.class); + + scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Provider.composite", new Contribution("provider", contribution)); + scaProviderNode.start(); + + scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Consumer.composite", new Contribution("consumer", contribution)); + scaConsumerNode.start(); + + testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient"); } @AfterClass public static void destroy() throws Exception { // System.out.println(">>>RSSGetTestCase.destroy entry"); - if (scaConsumerDomain != null) { - scaConsumerDomain.close(); + if (scaConsumerNode != null) { + scaConsumerNode.stop(); } - if (scaProviderDomain != null) { - scaProviderDomain.close(); + if (scaProviderNode != null) { + scaProviderNode.stop(); } } @Test public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); + Assert.assertNotNull(scaProviderNode); + Assert.assertNotNull(scaConsumerNode); Assert.assertNotNull(testService); } diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite index 48ab6b94b2..22141805cd 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite @@ -17,8 +17,8 @@ * specific language governing permissions and limitations * under the License. --> - diff --git a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite index 45718dfedb..b2b1f3d776 100644 --- a/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite +++ b/sca-java-2.x/trunk/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite @@ -17,8 +17,8 @@ * specific language governing permissions and limitations * under the License. --> - -- cgit v1.2.3