abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r613774 - in /incubator/abdera/java/branches/server_refactor/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/apach...
Date Mon, 21 Jan 2008 06:38:39 GMT
Author: jmsnell
Date: Sun Jan 20 22:38:37 2008
New Revision: 613774

URL: http://svn.apache.org/viewvc?rev=613774&view=rev
Log:
Further simplification by eliminating the notion of a ProviderManager. This, along with the
removal of RequestHandler means we can get rid of ItemManager also

Removed:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractSingletonProviderManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SingletonProviderManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProviderManager.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestProviderManager.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProviderManager.java
Modified:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -22,7 +22,6 @@
 import javax.security.auth.Subject;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.protocol.ItemManager;
 import org.apache.abdera.protocol.Resolver;
 
 public interface ServiceContext {
@@ -31,7 +30,7 @@
   
   void init(Abdera abdera, Map<String,String> config);
   
-  ItemManager<Provider> getProviderManager();
+  Provider getProvider(RequestContext request);
   
   Resolver<Subject> getSubjectResolver();
   

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
Sun Jan 20 22:38:37 2008
@@ -28,14 +28,14 @@
 
 public class ServiceManager {
    
-  public static final String PROVIDER_MANAGER =
-    "org.apache.abdera.protocol.server.provider.ProviderManager";
+  public static final String PROVIDER =
+    "org.apache.abdera.protocol.server.Provider";
   
   public static final String SUBJECT_RESOLVER = 
-    "org.apache.abdera.protocol.server.auth.SubjectResolver";
+    "org.apache.abdera.protocol.server.SubjectResolver";
   
   public static final String TARGET_RESOLVER = 
-    "org.apache.abdera.protocol.server.provider.TargetResolver";
+    "org.apache.abdera.protocol.server.TargetResolver";
   
   public static final String SERVICE_CONTEXT =
     "org.apache.abdera.protocol.server.ServiceContext";

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -36,7 +36,7 @@
 
   protected Abdera abdera;
   protected Map<String,String> config;
-  protected ItemManager<Provider> providerManager;
+  protected Provider provider;
   protected ItemManager<RequestHandler> handlerManager;
   protected Resolver<Subject> subjectResolver;
   protected Resolver<Target> targetResolver;
@@ -60,12 +60,8 @@
     return config.keySet().toArray(new String[config.size()]);
   }
 
-  public void setHandlerManager(ItemManager<RequestHandler> handlerManager) {
-    this.handlerManager = handlerManager;
-  }
-
-  public void setProviderManager(ItemManager<Provider> providerManager) {
-    this.providerManager = providerManager;
+  public void setProvider(Provider provider) {
+    this.provider = provider;
   }
 
   public void setSubjectResolver(Resolver<Subject> subjectResolver) {

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -20,9 +20,9 @@
 import javax.security.auth.Subject;
 
 import org.apache.abdera.i18n.text.Localizer;
-import org.apache.abdera.protocol.ItemManager;
 import org.apache.abdera.protocol.Resolver;
 import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ServiceManager;
 import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.util.ServiceUtil;
@@ -36,7 +36,7 @@
   
   protected String defaultsubjectresolver = SimpleSubjectResolver.class.getName();
   protected String defaulttargetresolver = RegexTargetResolver.class.getName();
-  protected String defaultprovidermanager = null;
+  protected String defaultprovider = null;
   
   public DefaultServiceContext() {}
   
@@ -48,16 +48,16 @@
   }
   
   @SuppressWarnings("unchecked")
-  public synchronized ItemManager<Provider> getProviderManager() {
-    if (providerManager == null) {
-      providerManager = (ItemManager<Provider>) instance(
-        ServiceManager.PROVIDER_MANAGER, getDefaultProviderManager());
+  public synchronized Provider getProvider(RequestContext request) {
+    if (provider == null) {
+      provider = (Provider) instance(
+        ServiceManager.PROVIDER, getDefaultProvider());
     }
-    return providerManager;
+    return provider;
   }
   
-  protected String getDefaultProviderManager() {
-    return defaultprovidermanager;
+  protected String getDefaultProvider() {
+    return defaultprovider;
   }
 
   @SuppressWarnings("unchecked")
@@ -86,8 +86,8 @@
     return defaulttargetresolver;
   }
 
-  public void setDefaultProviderManager(String defaultprovidermanager) {
-    this.defaultprovidermanager = defaultprovidermanager;
+  public void setDefaultProvider(String defaultprovider) {
+    this.defaultprovider = defaultprovider;
   }
 
   public void setDefaultSubjectResolver(String defaultsubjectresolver) {

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -23,7 +23,7 @@
   extends DefaultServiceContext {
 
   public BasicServiceContext() {
-    this.defaultprovidermanager = BasicProviderManager.class.getName();
+    this.defaultprovider = BasicProvider.class.getName();
     this.defaulttargetresolver = BasicTargetResolver.class.getName();
   }
   

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
Sun Jan 20 22:38:37 2008
@@ -31,7 +31,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.protocol.ItemManager;
 import org.apache.abdera.protocol.error.Error;
 import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.RequestContext;
@@ -94,8 +93,7 @@
     HttpServletResponse response) 
       throws ServletException, IOException {
     RequestContext reqcontext = new ServletRequestContext(context, request);
-    ItemManager<Provider> manager = context.getProviderManager();
-    Provider provider = manager.get(reqcontext);
+    Provider provider = context.getProvider(reqcontext);
     log.debug("Provider - " + provider);
     try {
       output(
@@ -106,9 +104,6 @@
     } catch (Throwable t) {
       error("Error servicing request", t, response);
       return;
-    } finally {
-      log.debug("Releasing provider - " + provider);
-      manager.release(provider);
     }
     log.debug("Request complete");
   }

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -23,7 +23,7 @@
   extends DefaultServiceContext {
 
   public TestServiceContext() {
-    this.defaultprovidermanager = TestProviderManager.class.getName();
+    this.defaultprovider = TestExtendedProvider.class.getName();
     this.defaulttargetresolver = TestTargetResolver.class.getName();
   }
   

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
Sun Jan 20 22:38:37 2008
@@ -24,7 +24,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.Base;
 import org.apache.abdera.model.Document;
@@ -160,8 +159,7 @@
         MimeType contentType = request.getContentType();
         String ctype = (contentType != null) ? contentType.toString() : null;
         if (ctype != null && !MimeTypeHelper.isAtom(ctype) && !MimeTypeHelper.isXml(ctype))
-          return new EmptyResponseContext(415);
-  
+          return new EmptyResponseContext(415);  
         Document<Entry> entry_doc = 
           (Document<Entry>) request.getDocument(parser).clone();
         if (entry_doc != null) {
@@ -175,12 +173,13 @@
           feed.insertEntry(entry);
           feed.setUpdated(new Date());
           BaseResponseContext rc = new BaseResponseContext(entry);
-          IRI baseUri = ProviderHelper.resolveBase(request);
-          rc.setLocation(baseUri.resolve(entry.getEditLinkResolvedHref()).toString());
-          rc.setContentLocation(rc.getLocation().toString());
-          rc.setEntityTag(calculateEntityTag(entry));
-          rc.setStatus(201);
-          return rc;
+          return 
+            rc.setLocation(
+                ProviderHelper.resolveBase(request).resolve(
+                  entry.getEditLinkResolvedHref()).toString())
+              .setContentLocation(rc.getLocation().toString())
+              .setEntityTag(calculateEntityTag(entry))
+              .setStatus(201);
         } else {
           return new EmptyResponseContext(400);
         }

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java?rev=613774&r1=613773&r2=613774&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
Sun Jan 20 22:38:37 2008
@@ -23,7 +23,7 @@
   extends DefaultServiceContext {
 
   public SimpleServiceContext() {
-    this.defaultprovidermanager = SimpleProviderManager.class.getName();
+    this.defaultprovider = SimpleProvider.class.getName();
     this.defaulttargetresolver = SimpleTargetResolver.class.getName();
   }
   



Mime
View raw message