abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r619777 - in /incubator/abdera/java/trunk/server/src: main/java/org/apache/abdera/protocol/server/ main/java/org/apache/abdera/protocol/server/impl/ main/java/org/apache/abdera/protocol/server/provider/basic/ main/java/org/apache/abdera/pro...
Date Fri, 08 Feb 2008 06:33:34 GMT
Author: jmsnell
Date: Thu Feb  7 22:33:31 2008
New Revision: 619777

URL: http://svn.apache.org/viewvc?rev=619777&view=rev
Log:
Incorporate the concepts from https://issues.apache.org/jira/browse/ABDERA-97

This was refactored into the form of a new "ManagedProvider" in order to keep it from affecting
all Provider implementations, the AbderaServlet, etc.  BasicProvider now extends ManagedProvider.
 BasicAdapter extends ManagedCollectionAdapter.

Removed:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/StructuredTargetResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
    incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java
    incubator/abdera/java/trunk/server/src/test/resources/abdera/adapter/sample.properties

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
Thu Feb  7 22:33:31 2008
@@ -72,7 +72,8 @@
     LOCALADDR, 
     LOCALNAME,
     SERVERNAME, 
-    SERVERPORT
+    SERVERPORT,
+    SECURE
   };
 
   /**

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
Thu Feb  7 22:33:31 2008
@@ -9,7 +9,6 @@
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
-import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.i18n.text.UrlEncoding;
 import org.apache.abdera.model.AtomDate;
 import org.apache.abdera.model.Collection;

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
Thu Feb  7 22:33:31 2008
@@ -18,7 +18,6 @@
 package org.apache.abdera.protocol.server.provider.basic;
 
 import java.util.Date;
-import java.util.Properties;
 import java.util.logging.Logger;
 
 import javax.activation.MimeType;
@@ -28,59 +27,45 @@
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.parser.Parser;
-import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.ProviderHelper;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ResponseContext;
 import org.apache.abdera.protocol.server.Target;
-import org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter;
+import org.apache.abdera.protocol.server.provider.managed.FeedConfiguration;
+import org.apache.abdera.protocol.server.provider.managed.ManagedCollectionAdapter;
 import org.apache.abdera.util.MimeTypeHelper;
 
 public abstract class BasicAdapter 
-  extends AbstractCollectionAdapter
-  implements CollectionAdapter {
+  extends ManagedCollectionAdapter {
 
   public static Logger logger =
     Logger.getLogger(BasicAdapter.class.getName());
 
-  protected Properties feedProperties;
-  protected final String feedId;
-  protected final Abdera abdera;
-
-  protected static final String PROP_NAME_FEED_URI = "feedUri";
-  protected static final String PROP_NAME_TITLE = "title";
-  protected static final String PROP_NAME_AUTHOR = "author";
-
-  public static final String ENTRY_ELEM_NAME_ID = "id";
-  public static final String ENTRY_ELEM_NAME_TITLE = "title";
-  public static final String ENTRY_ELEM_NAME_AUTHOR = "author";
-  public static final String ENTRY_ELEM_NAME_UPDATED = "updated";
-
   protected BasicAdapter(
     Abdera abdera, 
-    Properties feedProperties,
-    String feedId) {
-      this.abdera = abdera;
-      this.feedProperties = feedProperties;
-      this.feedId = feedId;
+    FeedConfiguration config) {
+      super(abdera,config);
   }
 
   public String getProperty(String key) throws Exception {
-    String val = feedProperties.getProperty(key);
+    Object val = config.getProperty(key);
     if (val == null) {
       logger.warning("Cannot find property " + key +
-          "in Adapter properties file for feed " + feedId);
+        "in Adapter properties file for feed " +
+        config.getFeedId());
       throw new RuntimeException();
     }
-    return val;
+    if (val instanceof String)
+      return (String) val;
+    throw new RuntimeException();
   }
 
   protected Feed createFeed() throws Exception {
     Feed feed = abdera.newFeed();
-    feed.setId(getProperty(PROP_NAME_FEED_URI));
-    feed.setTitle(getProperty(PROP_NAME_TITLE));
+    feed.setId(config.getFeedUri());
+    feed.setTitle(config.getFeedTitle());
     feed.setUpdated(new Date());
-    feed.addAuthor(getProperty(PROP_NAME_AUTHOR));
+    feed.addAuthor(config.getFeedAuthor());
     return feed;
   }
 
@@ -102,7 +87,7 @@
   }
 
   protected String createEntryIdUri(String entryId) throws Exception{
-    return getProperty(PROP_NAME_FEED_URI) + "/" + entryId;
+    return config.getFeedUri() + "/" + entryId;
   }
   
   private ResponseContext createOrUpdateEntry(

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
Thu Feb  7 22:33:31 2008
@@ -17,21 +17,26 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
-import org.apache.abdera.Abdera;
 import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.TargetType;
-import org.apache.abdera.protocol.server.impl.AbstractWorkspaceProvider;
-import org.apache.abdera.protocol.server.impl.CollectionAdapterManager;
 import org.apache.abdera.protocol.server.impl.RouteManager;
+import org.apache.abdera.protocol.server.provider.managed.BasicServerConfiguration;
+import org.apache.abdera.protocol.server.provider.managed.ManagedProvider;
+import org.apache.abdera.protocol.server.provider.managed.ServerConfiguration;
 
 public class BasicProvider 
-  extends AbstractWorkspaceProvider {
+  extends ManagedProvider {
 
   public static final String PARAM_FEED = "feed";
   public static final String PARAM_ENTRY = "entry";
   
   public BasicProvider() {
+    super();
+    init();
+  }
+  
+  private void init() {
     RouteManager routeManager = 
       new RouteManager()
         .addRoute("service", "/", TargetType.TYPE_SERVICE)
@@ -39,28 +44,23 @@
         .addRoute("entry", "/:feed/:entry", TargetType.TYPE_ENTRY);
     setTargetBuilder(routeManager);
     setTargetResolver(routeManager);
-    addWorkspace(new BasicWorkspace(this));
-  }
-
-  protected CollectionAdapterManager cam;
-  
-  protected CollectionAdapterManager getCollectionAdapterManager(
-    Abdera abdera) {
-      if (cam == null) 
-        cam = new CollectionAdapterManager(abdera);
-    return cam;
   }
   
   public CollectionAdapter getCollectionAdapter(RequestContext request) {
     try {
-      return getCollectionAdapterManager(request.getAbdera())
+      return getCollectionAdapterManager(request)
         .getAdapter(
           request.getTarget()
             .getParameter(
-                BasicProvider.PARAM_FEED));
+              PARAM_FEED));
     } catch (Exception e) {
       return null;
     }
+  }
+
+  protected ServerConfiguration getServerConfiguration(
+    RequestContext request) {
+      return new BasicServerConfiguration(request);
   }
   
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
Thu Feb  7 22:33:31 2008
@@ -80,6 +80,7 @@
       case LOCALNAME:         return request.getLocalName();
       case SERVERNAME:        return request.getServerName();
       case SERVERPORT:        return request.getServerPort();
+      case SECURE:            return request.isSecure();
       default:
         throw new UnsupportedOperationException(Localizer.get("PROPERTY.NOT.SUPPORTED"));

     }

Modified: incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java
Thu Feb  7 22:33:31 2008
@@ -21,7 +21,6 @@
 import java.io.ByteArrayOutputStream;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Properties;
 import java.util.Set;
 import java.util.logging.Logger;
 
@@ -33,6 +32,7 @@
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
 import org.apache.abdera.protocol.server.provider.basic.BasicAdapter;
+import org.apache.abdera.protocol.server.provider.managed.FeedConfiguration;
 
 public class SampleBasicAdapter 
   extends BasicAdapter {
@@ -43,9 +43,10 @@
   public static Logger logger = Logger.getLogger(SampleBasicAdapter.class.getName());
   protected HashMap<String, byte[]> entries = new HashMap<String, byte[]>();
 
-  public SampleBasicAdapter(Abdera abdera, Properties feedProperties,
-    String feedId) {
-    super(abdera, feedProperties, feedId);
+  public SampleBasicAdapter(
+    Abdera abdera, 
+    FeedConfiguration config) {
+      super(abdera, config);
   }
 
   public Feed getFeed() throws Exception {
@@ -143,19 +144,16 @@
 
   @Override
   public String getAuthor() throws ResponseContextException {
-    // TODO Auto-generated method stub
-    return null;
+    return config.getFeedAuthor();
   }
 
   @Override
   public String getId(RequestContext request) {
-    // TODO Auto-generated method stub
-    return null;
+    return config.getFeedId();
   }
 
   public String getTitle(RequestContext request) {
-    // TODO Auto-generated method stub
-    return null;
+    return config.getFeedTitle();
   }
 }
 

Modified: incubator/abdera/java/trunk/server/src/test/resources/abdera/adapter/sample.properties
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/test/resources/abdera/adapter/sample.properties?rev=619777&r1=619776&r2=619777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/test/resources/abdera/adapter/sample.properties
(original)
+++ incubator/abdera/java/trunk/server/src/test/resources/abdera/adapter/sample.properties
Thu Feb  7 22:33:31 2008
@@ -1,4 +1,5 @@
-feedUri=http://localhost:9002/sample
+subUri=sample
 adapterClassName=org.apache.abdera.protocol.server.test.basic.SampleBasicAdapter
 title=title for any sample feed
-author=rayc
\ No newline at end of file
+author=rayc
+configFile=dummyFileLocation
\ No newline at end of file



Mime
View raw message