diff options
Diffstat (limited to 'branches/sca-java-20080910/modules/binding-rss-rome/src')
16 files changed, 0 insertions, 1176 deletions
diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java deleted file mode 100644 index bb8dab391b..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java +++ /dev/null @@ -1,49 +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.binding.rss.collection; - -import org.osoa.sca.annotations.Remotable; - -import com.sun.syndication.feed.synd.SyndFeed; - - -/** - * Provides access to a collection of resources using RSS. - * - * @version $Rev$ $Date$ - */ -@Remotable -public interface Collection { - - /** - * Get an RSS feed for a collection of resources. - * - * @return the RSS feed - */ - SyndFeed getFeed(); - - /** - * Get an RSS feed for a collection of resources resulting from a query. - * - * @param queryString the query string - * @return the RSS feed - */ - SyndFeed query(String queryString); - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java deleted file mode 100644 index 2213b50b53..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java +++ /dev/null @@ -1,55 +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.binding.rss.collection; - -import java.io.InputStream; - -import org.osoa.sca.annotations.Remotable; - -import com.sun.syndication.feed.atom.Entry; - -/** - * Provides access to a collection of resources using Atom. - * - * @version $Rev$ $Date$ - */ -@Remotable -public interface MediaCollection extends Collection { - - /** - * Creates a new media entry - * - * @param title - * @param slug - * @param contentType - * @param media - */ - Entry postMedia(String title, String slug, String contentType, InputStream media); - - /** - * Update a media entry. - * - * @param id - * @param contentType - * @param media - * @return - */ - void putMedia(String id, String contentType, InputStream media) throws NotFoundException; - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java deleted file mode 100644 index 0912878938..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.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.binding.rss.collection; - -/** - * Indicates that a resource could not be found. - * - * @version $Rev$ $Date$ - */ -public class NotFoundException extends Exception { - private static final long serialVersionUID = -5046027674128627383L; - - public NotFoundException() { - } - - public NotFoundException(String message) { - super(message); - } - - public NotFoundException(Throwable cause) { - super(cause); - } - - public NotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java deleted file mode 100644 index e3a177198c..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java +++ /dev/null @@ -1,76 +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.binding.rss.provider; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.invocation.DataExchangeSemantics; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.SyndFeedInput; -import com.sun.syndication.io.XmlReader; - -/** - * Invoker for the RSS binding. - * - * @version $Rev$ $Date$ - */ -class RSSBindingInvoker implements Invoker , DataExchangeSemantics { - private static final Logger logger = Logger.getLogger(RSSBindingInvoker.class.getName()); - - private String uri; - - RSSBindingInvoker(String uri, String feedType) { - this.uri = uri; - } - - public Message invoke(Message msg) { - try { - logger.fine("invoke " + uri); - - // Read an RSS feed into a Synd feed - SyndFeedInput input = new SyndFeedInput(); - SyndFeed feed = input.build(new XmlReader(new URL(uri))); - - //FIXME Support conversion to data-api entries - - msg.setBody(feed); - - } catch (MalformedURLException e) { - msg.setFaultBody(e); - } catch (IllegalArgumentException e) { - msg.setFaultBody(e); - } catch (FeedException e) { - msg.setFaultBody(e); - } catch (IOException e) { - msg.setFaultBody(e); - } - return msg; - } - - public boolean allowsPassByReference() { - return true; - } -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java deleted file mode 100644 index 7eb5aeb3df..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java +++ /dev/null @@ -1,394 +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.binding.rss.provider; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.StringTokenizer; -import java.util.logging.Logger; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.namespace.QName; - -import org.apache.commons.codec.binary.Base64; -import org.apache.tuscany.sca.data.collection.Item; -import org.apache.tuscany.sca.databinding.Mediator; -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; -import org.apache.tuscany.sca.interfacedef.util.XMLType; -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 com.sun.syndication.feed.synd.SyndContent; -import com.sun.syndication.feed.synd.SyndContentImpl; -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndEntryImpl; -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.feed.synd.SyndFeedImpl; -import com.sun.syndication.feed.synd.SyndLink; -import com.sun.syndication.feed.synd.SyndLinkImpl; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.SyndFeedOutput; - -/** - * An RSS binding listener, implemented as a Servlet and - * registered in a Servlet host provided by the SCA hosting runtime. - * - * @version $Rev$ $Date$ - */ -class RSSBindingListenerServlet extends HttpServlet { - private static final Logger logger = Logger.getLogger(RSSBindingListenerServlet.class.getName()); - private static final long serialVersionUID = 1L; - - private RuntimeWire wire; - private Invoker getFeedInvoker; - private Invoker getAllInvoker; - private Invoker queryInvoker; - private MessageFactory messageFactory; - private Mediator mediator; - private DataType<?> itemClassType; - private DataType<?> itemXMLType; - private boolean supportsFeedEntries; - - /** - * Constructs a new binding listener. - * - * @param wire - * @param messageFactory - */ - RSSBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator) { - this.wire = wire; - this.messageFactory = messageFactory; - this.mediator = mediator; - - // Get the invokers for the supported operations - Operation getOperation = null; - for (InvocationChain invocationChain : this.wire.getInvocationChains()) { - invocationChain.setAllowsPassByReference(true); - Operation operation = invocationChain.getTargetOperation(); - String operationName = operation.getName(); - if (operationName.equals("getFeed")) { - getFeedInvoker = invocationChain.getHeadInvoker(); - } else if (operationName.equals("getAll")) { - getAllInvoker = invocationChain.getHeadInvoker(); - } else if (operationName.equals("query")) { - queryInvoker = invocationChain.getHeadInvoker(); - } else if (operationName.equals("get")) { - getOperation = operation; - } - } - - // Determine the collection item type - itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class); - Class<?> itemClass = getOperation.getOutputType().getPhysical(); - if (itemClass == SyndEntry.class) { - supportsFeedEntries = true; - } - DataType<XMLType> outputType = getOperation.getOutputType(); - QName qname = outputType.getLogical().getElementName(); - qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName()); - itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null)); - - } - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - // No authentication required for a get request - - // Get the request path - String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8"); - - logger.fine("get " + request.getRequestURI()); - - // Handle an RSS request - if (path == null || path.length() == 0 || path.equals("/")) { - - // Return an RSS feed containing the entries in the collection - SyndFeed feed = null; - if (supportsFeedEntries) { - - // The service implementation supports feed entries, invoke its getFeed operation - Message requestMessage = messageFactory.createMessage(); - Message responseMessage = getFeedInvoker.invoke(requestMessage); - if (responseMessage.isFault()) { - throw new ServletException((Throwable)responseMessage.getBody()); - } - feed = (SyndFeed)responseMessage.getBody(); - - } else { - - // The service implementation does not support feed entries, invoke its - // getAll operation to get the data item collection. then create feed entries - // from the data items - Message requestMessage = messageFactory.createMessage(); - Message responseMessage; - if (request.getQueryString() != null) { - requestMessage.setBody(new Object[] {request.getQueryString()}); - responseMessage = queryInvoker.invoke(requestMessage); - } else { - responseMessage = getAllInvoker.invoke(requestMessage); - } - if (responseMessage.isFault()) { - throw new ServletException((Throwable)responseMessage.getBody()); - } - org.apache.tuscany.sca.data.collection.Entry<Object, Object>[] collection = - (org.apache.tuscany.sca.data.collection.Entry<Object, Object>[])responseMessage.getBody(); - if (collection != null) { - // Create the feed - feed = new SyndFeedImpl(); - feed.setTitle("Feed"); - - for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) { - SyndEntry feedEntry = createFeedEntry(entry); - feed.getEntries().add(feedEntry); - } - } - } - - // Convert to an RSS feed - if (feed != null) { - response.setContentType("application/rss+xml; charset=utf-8"); - feed.setFeedType("rss_2.0"); - feed.setLink(path); - SyndFeedOutput syndOutput = new SyndFeedOutput(); - try { - syndOutput.output(feed, getWriter(response)); - } catch (FeedException e) { - throw new ServletException(e); - } - } else { - response.sendError(HttpServletResponse.SC_NOT_FOUND); - } - } else { - response.sendError(HttpServletResponse.SC_NOT_FOUND); - } - - } - - /** - * Create an Atom entry from a data collection entry. - * @param entry - * @return - */ - private SyndEntry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) { - Object key = entry.getKey(); - Object data = entry.getData(); - if (data instanceof Item) { - Item item = (Item)data; - - SyndEntry feedEntry = new SyndEntryImpl(); - feedEntry.setUri(key.toString()); - feedEntry.setTitle(item.getTitle()); - - String value = item.getContents(); - if (value != null) { - SyndContent content = new SyndContentImpl(); - content.setType("text/xml"); - content.setValue(value); - List<SyndContent> contents = new ArrayList<SyndContent>(); - contents.add(content); - feedEntry.setContents(contents); - } - - String href = item.getLink(); - if (href == null) { - href = key.toString(); - } - SyndLink link = new SyndLinkImpl(); - link.setRel("edit"); - link.setHref(href); - feedEntry.getLinks().add(link); - link = new SyndLinkImpl(); - link.setRel("alternate"); - link.setHref(href); - feedEntry.getLinks().add(link); - - Date date = item.getDate(); - if (date == null) { - date = new Date(); - } - feedEntry.setPublishedDate(date); - return feedEntry; - - } else if (data != null) { - SyndEntry feedEntry = new SyndEntryImpl(); - feedEntry.setUri(key.toString()); - feedEntry.setTitle("item"); - - // Convert the item to XML - String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString(); - - SyndContent content = new SyndContentImpl(); - content.setType("text/xml"); - content.setValue(value); - List<SyndContent> contents = new ArrayList<SyndContent>(); - contents.add(content); - feedEntry.setContents(contents); - - SyndLink link = new SyndLinkImpl(); - link.setRel("edit"); - link.setHref(key.toString()); - feedEntry.getLinks().add(link); - link = new SyndLinkImpl(); - link.setRel("alternate"); - link.setHref(key.toString()); - feedEntry.getLinks().add(link); - - feedEntry.setPublishedDate(new Date()); - return feedEntry; - } else { - return null; - } - } - - /** - * Create a data collection entry from an RSS entry. - * @param feedEntry - * @return - */ - private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(SyndEntry feedEntry) { - if (feedEntry != null) { - if (itemClassType.getPhysical() == Item.class) { - String key = feedEntry.getUri(); - - Item item = new Item(); - item.setTitle(feedEntry.getTitle()); - - List<?> contents = feedEntry.getContents(); - if (!contents.isEmpty()) { - SyndContent content = (SyndContent)contents.get(0); - String value = content.getValue(); - item.setContents(value); - } - - for (Object l : feedEntry.getLinks()) { - SyndLink link = (SyndLink)l; - if (link.getRel() == null || "edit".equals(link.getRel())) { - String href = link.getHref(); - if (href.startsWith("null/")) { - href = href.substring(5); - } - item.setLink(href); - break; - } - } - - item.setDate(feedEntry.getPublishedDate()); - - return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item); - - } else { - String key = feedEntry.getUri(); - - // Create the item from XML - List<?> contents = feedEntry.getContents(); - if (contents.isEmpty()) { - return null; - } - SyndContent content = (SyndContent)contents.get(0); - String value = content.getValue(); - Object data = mediator.mediate(value, itemXMLType, itemClassType, null); - - return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data); - } - } else { - return null; - } - } - - - private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException { - Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8"); - return writer; - } - - /** - * Process the authorization header - * - * @param request - * @return - * @throws ServletException - */ - private String processAuthorizationHeader(HttpServletRequest request) throws ServletException { - try { - String authorization = request.getHeader("Authorization"); - if (authorization != null) { - StringTokenizer tokens = new StringTokenizer(authorization); - if (tokens.hasMoreTokens()) { - String basic = tokens.nextToken(); - if (basic.equalsIgnoreCase("Basic")) { - String credentials = tokens.nextToken(); - String userAndPassword = new String(Base64.decodeBase64(credentials.getBytes())); - int colon = userAndPassword.indexOf(":"); - if (colon != -1) { - String user = userAndPassword.substring(0, colon); - String password = userAndPassword.substring(colon + 1); - - // Authenticate the User. - if (authenticate(user, password)) { - return user; - } - } - } - } - } - } catch (Exception e) { - throw new ServletException(e); - } - return null; - } - - /** - * Authenticate a user. - * - * @param user - * @param password - * @return - */ - private boolean authenticate(String user, String password) { - - // TODO Handle this using SCA security policies - //FIXME Why are we using endsWith instead of equals here?? - return ("admin".endsWith(user) && "admin".equals(password)); - } - - /** - * Reject an unauthorized request. - * - * @param response - */ - private void unauthorized(HttpServletResponse response) throws IOException { - response.setHeader("WWW-Authenticate", "BASIC realm=\"Tuscany\""); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - } -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java deleted file mode 100644 index b9cababcab..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java +++ /dev/null @@ -1,74 +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.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.databinding.DataBindingExtensionPoint; -import org.apache.tuscany.sca.databinding.Mediator; -import org.apache.tuscany.sca.databinding.TransformerExtensionPoint; -import org.apache.tuscany.sca.databinding.impl.MediatorImpl; -import org.apache.tuscany.sca.host.http.ServletHost; -import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; -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; - -/** - * Implementation of the RSS binding provider factory. - * - * @version $Rev$ $Date$ - */ -public class RSSBindingProviderFactory implements BindingProviderFactory<RSSBinding> { - - private MessageFactory messageFactory; - private Mediator mediator; - private ServletHost servletHost; - - public RSSBindingProviderFactory(ExtensionPointRegistry extensionPoints) { - ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); - this.servletHost = servletHosts.getServletHosts().get(0); - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - this.messageFactory = modelFactories.getFactory(MessageFactory.class); - this.mediator = new MediatorImpl(extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class), - extensionPoints.getExtensionPoint(TransformerExtensionPoint.class)); - } - - public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - RSSBinding binding) { - return new RSSReferenceBindingProvider(component, reference, binding); - } - - public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, - RSSBinding binding) { - return new RSSServiceBindingProvider(component, service, binding, servletHost, messageFactory, mediator); - } - - public Class<RSSBinding> getModelType() { - return RSSBinding.class; - } -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java deleted file mode 100644 index 8a30e9d3fb..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java +++ /dev/null @@ -1,65 +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.binding.rss.provider; - -import org.apache.tuscany.sca.binding.rss.RSSBinding; -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; - -/** - * Implementation of the RSS binding provider. - * - * @version $Rev$ $Date$ - */ -class RSSReferenceBindingProvider implements ReferenceBindingProvider { - - private RuntimeComponentReference reference; - private RSSBinding binding; - - RSSReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - RSSBinding binding) { - this.reference = reference; - this.binding = binding; - } - - public Invoker createInvoker(Operation operation) { - return new RSSBindingInvoker(binding.getURI(), "rss_2.0"); - } - - public boolean supportsOneWayInvocation() { - return false; - } - - public InterfaceContract getBindingInterfaceContract() { - return reference.getInterfaceContract(); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java deleted file mode 100644 index 4e5429ac83..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java +++ /dev/null @@ -1,85 +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.binding.rss.provider; - -import org.apache.tuscany.sca.binding.rss.RSSBinding; -import org.apache.tuscany.sca.databinding.Mediator; -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; - -/** - * Implementation of the RSS binding provider. - * - * @version $Rev$ $Date$ - */ -class RSSServiceBindingProvider implements ServiceBindingProvider { - - 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, - MessageFactory messageFactory, - Mediator mediator) { - this.service = service; - this.binding = binding; - this.servletHost = servletHost; - this.messageFactory = messageFactory; - this.mediator = mediator; - } - - public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); - } - - public boolean supportsOneWayInvocation() { - return false; - } - - public void start() { - RuntimeComponentService componentService = (RuntimeComponentService)service; - RuntimeWire wire = componentService.getRuntimeWire(binding); - - RSSBindingListenerServlet servlet = - new RSSBindingListenerServlet(wire, messageFactory, mediator); - - servletMapping = binding.getURI(); - servletHost.addServletMapping(servletMapping, servlet); - - // Save the actual binding URI in the binding - binding.setURI(servletHost.getURLMapping(binding.getURI()).toString()); - } - - public void stop() { - servletHost.removeServletMapping(servletMapping); - } - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-20080910/modules/binding-rss-rome/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory deleted file mode 100644 index e60dc2855a..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory +++ /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 binding extension
-org.apache.tuscany.sca.binding.rss.provider.RSSBindingProviderFactory;model=org.apache.tuscany.sca.binding.rss.RSSBinding
diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java deleted file mode 100644 index 19370285f5..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java +++ /dev/null @@ -1,35 +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.binding.rss; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -public class Consumer { - - public static void main(String[] args) throws Exception { - - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Consumer.composite"); - - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); - testService.testCustomerCollection(); - - scaDomain.close(); - } -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java deleted file mode 100644 index af87155f45..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java +++ /dev/null @@ -1,25 +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.binding.rss; - -public interface CustomerClient { - - void testCustomerCollection() throws Exception; -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java deleted file mode 100644 index e71156c379..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.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.binding.rss; - -import org.apache.tuscany.sca.binding.rss.collection.Collection; -import org.osoa.sca.annotations.Reference; - -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndFeed; - - -public class CustomerClientImpl implements CustomerClient { - - @Reference - public Collection resourceCollection; - - public void testCustomerCollection() throws Exception { - - System.out.println(">>> get collection"); - SyndFeed feed = resourceCollection.getFeed(); - System.out.println("<<< get collection"); - for (Object o : feed.getEntries()) { - SyndEntry e = (SyndEntry)o; - System.out.println("id = " + e.getUri() + " entry = " + e.getTitle()); - } - } - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java deleted file mode 100644 index d45be65e20..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java +++ /dev/null @@ -1,103 +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.binding.rss; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.tuscany.sca.binding.rss.collection.Collection; -import org.osoa.sca.annotations.Scope; - -import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.synd.SyndContent; -import com.sun.syndication.feed.synd.SyndContentImpl; -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndEntryImpl; -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.feed.synd.SyndFeedImpl; -import com.sun.syndication.feed.synd.SyndLink; -import com.sun.syndication.feed.synd.SyndLinkImpl; - -@Scope("COMPOSITE") -public class CustomerCollectionImpl implements Collection { - - private Map<String, SyndEntry> entries = new HashMap<String, SyndEntry>(); - - public CustomerCollectionImpl() { - - for (int i = 0; i < 4; i++) { - String id = "urn:uuid:customer-" + UUID.randomUUID().toString(); - - SyndEntry entry = new SyndEntryImpl(); - entry.setTitle("customer " + "Jane Doe_" + String.valueOf(i)); - entry.setUri(id); - - SyndContent content = new SyndContentImpl(); - content.setValue("Jane Doe_" + String.valueOf(i)); - content.setType(Content.TEXT); - entry.setContents(Collections.singletonList(content)); - - List<SyndLink> links = new ArrayList<SyndLink>(); - SyndLink link = new SyndLinkImpl(); - link.setRel("edit"); - link.setHref("" + id); - links.add(link); - entry.setLinks(links); - - links = new ArrayList<SyndLink>(); - link = new SyndLinkImpl(); - link.setRel("alternate"); - link.setHref("" + id); - links.add(link); - entry.setLinks(links); - - entry.setPublishedDate(new Date()); - - entries.put(id, entry); - System.out.println(">>> id=" + id); - } - } - - public SyndFeed getFeed() { - System.out.println(">>> CustomerCollectionImpl.getFeed"); - - SyndFeed feed = new SyndFeedImpl(); - feed.setTitle("customers"); - feed.setDescription("This is a sample feed"); - feed.getEntries().addAll(entries.values()); - return feed; - } - - public SyndFeed query(String queryString) { - System.out.println(">>> CustomerCollectionImpl.query"); - - SyndFeed feed = new SyndFeedImpl(); - feed.setTitle("customers"); - feed.setDescription("This is a sample feed"); - feed.getEntries().addAll(entries.values()); - return feed; - } - -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java deleted file mode 100644 index ae7b72834e..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java +++ /dev/null @@ -1,41 +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.binding.rss; - -import java.io.IOException; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -public class Provider { - - public static void main(String[] args) { - - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Provider.composite"); - System.out.println("Provider.composite ready..."); - - try { - System.in.read(); - } catch (IOException e) { - e.printStackTrace(); - } - - scaDomain.close(); - } -} diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite deleted file mode 100644 index 43cd5e00b9..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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. ---> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" - targetNamespace="http://customer" - name="Consumer"> - - <component name="CustomerClient"> - <implementation.java class="org.apache.tuscany.sca.binding.feed.CustomerClientImpl"/> - <reference name="resourceCollection"> - <tuscany:binding.rss uri="http://localhost:8084/customer"/> - </reference> - </component> - -</composite> diff --git a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite b/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite deleted file mode 100644 index 5ffcb50eb8..0000000000 --- a/branches/sca-java-20080910/modules/binding-rss-rome/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!-- - * 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. ---> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- targetNamespace = "http://customer" - name="Provider">
-
- <service name="customer" promote="CustomerCollection">
- <tuscany:binding.rss uri = "http://localhost:8084/customer"/>
- </service>
-
- <component name="CustomerCollection">
- <implementation.java class="org.apache.tuscany.sca.binding.feed.CustomerCollectionImpl"/>
- </component>
-
-</composite>
|