abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r442370 - in /incubator/abdera/java/trunk: examples/src/main/java/org/apache/abdera/examples/appserver/ examples/src/main/resources/org/apache/abdera/examples/appserver/ server/src/main/java/org/apache/abdera/protocol/server/ server/src/mai...
Date Mon, 11 Sep 2006 22:04:09 GMT
Author: jmsnell
Date: Mon Sep 11 15:04:08 2006
New Revision: 442370

URL: http://svn.apache.org/viewvc?view=rev&rev=442370
Log:
More incremental improvement.
Shift stuff around to eliminate unnecessary packages
Use a pool model for Providers and Request Handlers
Call it RequestHandlerManager and ProviderManager instead of a *Factory.

Added:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerManager.java
      - copied, changed from r441673, incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java
      - copied, changed from r441673, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerManager.java
      - copied, changed from r441582, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/SubjectResolver.java
      - copied, changed from r441629, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/SubjectResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java
      - copied, changed from r442264, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/Target.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetResolver.java
      - copied, changed from r438670, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/TargetResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractPooledProviderManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerManager.java
      - copied, changed from r441582, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSimpleProviderManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/PoolManager.java
Removed:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerFactory.java
Modified:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java
    incubator/abdera/java/trunk/examples/src/main/resources/org/apache/abdera/examples/appserver/web.xml
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbderaServer.java
    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/RequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractProvider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/EmptyResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ResourceType.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ServerConstants.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/TargetIterator.java

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java Mon Sep 11 15:04:08 2006
@@ -30,11 +30,11 @@
 import org.apache.abdera.model.Workspace;
 import org.apache.abdera.parser.stax.util.FOMHelper;
 import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException.Code;
-import org.apache.abdera.protocol.server.provider.Provider;
-import org.apache.abdera.protocol.server.target.Target;
 import org.apache.abdera.protocol.server.util.AbstractProvider;
 
 public class SimpleProvider 
@@ -44,8 +44,8 @@
   private static Document<Service> service_doc = null;
   private static Document<Feed> feed_doc = null;
   
-  public SimpleProvider(AbderaServer abderaServer) {
-    super(abderaServer);
+  public SimpleProvider(AbderaServer abderaServer, SimpleProviderManager factory) {
+    super(abderaServer, factory);
   }
   
   private synchronized Document<Service> getService() {

Added: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java?view=auto&rev=442370
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java (added)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java Mon Sep 11 15:04:08 2006
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.examples.appserver;
+
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.ProviderManager;
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+import org.apache.abdera.protocol.server.util.AbstractSimpleProviderManager;
+
+public class SimpleProviderManager 
+  extends AbstractSimpleProviderManager
+  implements ProviderManager {
+
+  private Provider provider = null;
+  
+  protected synchronized Provider getProvider(
+    AbderaServer abderaServer) throws AbderaServerException {
+      if (provider == null)  {
+        provider = new SimpleProvider(abderaServer, this);
+      }
+      return provider;
+  }
+
+}

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java Mon Sep 11 15:04:08 2006
@@ -24,11 +24,11 @@
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Service;
 import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
 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.exceptions.AbderaServerException;
-import org.apache.abdera.protocol.server.provider.Provider;
-import org.apache.abdera.protocol.server.target.Target;
 import org.apache.abdera.protocol.server.util.AbstractRequestHandler;
 import org.apache.abdera.protocol.server.util.BaseResponseContext;
 import org.apache.abdera.protocol.server.util.EmptyResponseContext;
@@ -52,27 +52,17 @@
 public class SimpleRequestHandler 
   extends AbstractRequestHandler {
   
-  public SimpleRequestHandler(AbderaServer abderaServer, Provider provider) {
-    super(provider);
-  }
-  
-  @Override
-  protected ResourceType getResourceType(RequestContext requestContext) {
-    Target target = requestContext.getTarget();
-    return (target != null && target.getResourceType() != null) ? 
-      target.getResourceType() : ResourceType.UNKNOWN;
-  }
-
-  @Override
-  protected ResponseContext createResponseContext() {
-    return null;
+  public SimpleRequestHandler(
+    AbderaServer abderaServer, 
+    SimpleRequestHandlerManager factory) {
+      super(factory);
   }
   
   @SuppressWarnings("unchecked")
   @Override
   protected ResponseContext internalInvoke(
     RequestContext requestContext,
-    ResponseContext responseContext) 
+    Provider provider) 
       throws AbderaServerException {
     Target target = requestContext.getTarget();
     String method = requestContext.getMethod();
@@ -85,17 +75,17 @@
                 AbderaServerException.Code.NOTMODIFIED, 
                 "Not Modified", "");
           } catch (NullPointerException npe) {}
-          return getServiceDocument(requestContext);
+          return getServiceDocument(requestContext, provider);
       } else if (type == ResourceType.COLLECTION) {
           if (method.equals("GET")) {
             if (!target.getValue(1).equals("foo")) 
               throw new AbderaServerException(
                 AbderaServerException.Code.NOTFOUND, 
                 "Not Found", "");
-            return getFeedDocument(requestContext);
+            return getFeedDocument(requestContext, provider);
           } else if (method.equals("POST")) {
             try {
-              Entry entry = getProvider().addEntry(requestContext);
+              Entry entry = provider.addEntry(requestContext);
               if (entry != null) {
                 BaseResponseContext rc = getEntryDocument(entry);
                 rc.setStatus(201);
@@ -116,11 +106,11 @@
           }
       } else if (type == ResourceType.ENTRY_EDIT) {
           if (method.equals("GET")) {
-            Entry e = getProvider().getEntry(requestContext);
+            Entry e = provider.getEntry(requestContext);
             return new BaseResponseContext(e.getDocument());
           } else if (method.equals("PUT")) {
             try {
-              Entry entry = getProvider().updateEntry(requestContext);
+              Entry entry = provider.updateEntry(requestContext);
               if (entry == null) 
                 throw new AbderaServerException(
                   AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, 
@@ -132,7 +122,7 @@
               throw new AbderaServerException(e);
             }
           } else if (method.equals("DELETE")) {
-            getProvider().deleteEntry(requestContext);
+            provider.deleteEntry(requestContext);
             return new EmptyResponseContext(204);
           }
       }
@@ -155,10 +145,11 @@
   }
   
   private BaseResponseContext<Document<Service>> getServiceDocument(
-    RequestContext context) 
+    RequestContext context, 
+    Provider provider) 
       throws AbderaServerException {
     Document<Service> service_doc = 
-      getProvider().getService(context).getDocument();
+      provider.getService(context).getDocument();
     BaseResponseContext<Document<Service>> rc = 
       new BaseResponseContext<Document<Service>>(service_doc);
     rc.setEntityTag("\"service\"");
@@ -168,10 +159,10 @@
   }
   
   private BaseResponseContext<Document<Feed>> getFeedDocument(
-    RequestContext context) 
+    RequestContext context, Provider provider) 
       throws AbderaServerException {
     Document<Feed> feed_doc = 
-      getProvider().getFeed(context).getDocument();
+      provider.getFeed(context).getDocument();
     BaseResponseContext<Document<Feed>> rc =
       new BaseResponseContext<Document<Feed>>(feed_doc);
     rc.setContentType("application/atom+xml");

Copied: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerManager.java (from r441673, incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerFactory.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerManager.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerFactory.java&r1=441673&p2=incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerManager.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerFactory.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandlerManager.java Mon Sep 11 15:04:08 2006
@@ -19,27 +19,18 @@
 
 import org.apache.abdera.protocol.server.AbderaServer;
 import org.apache.abdera.protocol.server.RequestHandler;
-import org.apache.abdera.protocol.server.RequestHandlerFactory;
-import org.apache.abdera.protocol.server.provider.Provider;
-import org.apache.abdera.protocol.server.util.AbstractRequestHandlerFactory;
+import org.apache.abdera.protocol.server.RequestHandlerManager;
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+import org.apache.abdera.protocol.server.util.AbstractRequestHandlerManager;
 
-public class SimpleRequestHandlerFactory
-  extends AbstractRequestHandlerFactory
-  implements RequestHandlerFactory {
+public class SimpleRequestHandlerManager
+  extends AbstractRequestHandlerManager
+  implements RequestHandlerManager {
 
-  private Provider provider = null;
-
-  private synchronized Provider getProvider(AbderaServer server) {
-    if (provider == null) {
-      provider = new SimpleProvider(server);
-    }
-    return provider;
-  }
-  
   @Override
   protected RequestHandler newRequestHandlerInstance(
-    AbderaServer abderaServer) {
-      return new SimpleRequestHandler(abderaServer, getProvider(abderaServer));
+    AbderaServer abderaServer) throws AbderaServerException {
+      return new SimpleRequestHandler(abderaServer, this);
   }
 
 }

Modified: incubator/abdera/java/trunk/examples/src/main/resources/org/apache/abdera/examples/appserver/web.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/resources/org/apache/abdera/examples/appserver/web.xml?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/resources/org/apache/abdera/examples/appserver/web.xml (original)
+++ incubator/abdera/java/trunk/examples/src/main/resources/org/apache/abdera/examples/appserver/web.xml Mon Sep 11 15:04:08 2006
@@ -12,7 +12,7 @@
       <param-value>org.apache.abdera.examples.appserver.SimpleRequestHandlerFactory</param-value>
     </init-param>
     <init-param>
-      <param-name>org.apache.abdera.protocol.server.target.TargetResolver</param-name>
+      <param-name>org.apache.abdera.protocol.server.TargetResolver</param-name>
       <param-value>org.apache.abdera.examples.appserver.SimpleTargetResolver</param-value>
     </init-param>
   </servlet>

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbderaServer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbderaServer.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbderaServer.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbderaServer.java Mon Sep 11 15:04:08 2006
@@ -18,65 +18,86 @@
 package org.apache.abdera.protocol.server;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.protocol.server.auth.SubjectResolver;
-import org.apache.abdera.protocol.server.target.TargetResolver;
 import org.apache.abdera.protocol.server.util.ServerConstants;
 import org.apache.abdera.util.ServiceUtil;
 
 public class AbderaServer implements ServerConstants {
   
   private final Abdera abdera;
-  private final RequestHandlerFactory handlerFactory;
+  private final RequestHandlerManager handlerManager;
   private final TargetResolver targetResolver;
   private final SubjectResolver subjectResolver;
-  private final String defaultHandlerFactory;
+  private final ProviderManager providerManager;
+  private final String defaultHandlerManager;
+  private final String defaultProviderManager;
   private final String defaultTargetResolver;
   private final String defaultSubjectResolver;
   
   public AbderaServer() {
-    this(new Abdera(),"","",DEFAULT_SUBJECT_RESOLVER);
+    this(new Abdera());
   }
   
   public AbderaServer(
     String defaultTargetResolver, 
-    String defaultHandlerFactory,
-    String defaultSubjectResolver) {
-      this(new Abdera(), defaultTargetResolver, defaultHandlerFactory, defaultSubjectResolver);
+    String defaultHandlerManager,
+    String defaultSubjectResolver,
+    String defaultProviderManager) {
+      this(new Abdera(), 
+           defaultTargetResolver, 
+           defaultHandlerManager, 
+           defaultSubjectResolver,
+           defaultProviderManager);
   }
   
   public AbderaServer(Abdera abdera) {
-    this(abdera,"","",DEFAULT_SUBJECT_RESOLVER);
+    this(abdera,"","",DEFAULT_SUBJECT_RESOLVER, "");
   }
   
   public AbderaServer(
     Abdera abdera, 
     String defaultTargetResolver, 
-    String defaultHandlerFactory,
-    String defaultSubjectResolver) {
+    String defaultHandlerManager,
+    String defaultSubjectResolver,
+    String defaultProviderFactory) {
       this.abdera = abdera;
-      this.handlerFactory = newRequestHandlerFactory(defaultHandlerFactory);
+      this.handlerManager = newRequestHandlerManager(defaultHandlerManager);
       this.targetResolver = newTargetResolver(defaultTargetResolver);
       this.subjectResolver = newSubjectResolver(defaultSubjectResolver);
-      this.defaultHandlerFactory = defaultHandlerFactory;
+      this.providerManager = newProviderManager(defaultProviderFactory);
+      this.defaultHandlerManager = defaultHandlerManager;
       this.defaultTargetResolver = defaultTargetResolver;
       this.defaultSubjectResolver = defaultSubjectResolver;
+      this.defaultProviderManager = defaultProviderFactory;
   }
   
   public Abdera getAbdera() {
     return abdera;
   }
   
-  public RequestHandlerFactory newRequestHandlerFactory() {
-    return newRequestHandlerFactory(defaultHandlerFactory);
+  public ProviderManager newProviderManager() {
+    return newProviderManager(defaultProviderManager);
   }
   
-  public RequestHandlerFactory newRequestHandlerFactory(String _default) {
-    return (RequestHandlerFactory) ServiceUtil.newInstance(
-      HANDLER_FACTORY, (_default != null) ? _default : "", abdera);
+  public ProviderManager newProviderManager(String _default) {
+    return (ProviderManager) ServiceUtil.newInstance(
+      PROVIDER_MANAGER, (_default != null) ? _default : "", abdera);
+  }
+
+  public ProviderManager getProviderManager() {
+    return providerManager;
+  }
+  
+  public RequestHandlerManager newRequestHandlerManager() {
+    return newRequestHandlerManager(defaultHandlerManager);
+  }
+  
+  public RequestHandlerManager newRequestHandlerManager(String _default) {
+    return (RequestHandlerManager) ServiceUtil.newInstance(
+      HANDLER_MANAGER, (_default != null) ? _default : "", abdera);
   }
   
-  public RequestHandlerFactory getRequestHandlerFactory() {
-    return handlerFactory;
+  public RequestHandlerManager getRequestHandlerManager() {
+    return handlerManager;
   }
   
   public TargetResolver newTargetResolver() {

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java (from r441673, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java&r1=441673&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java Mon Sep 11 15:04:08 2006
@@ -15,13 +15,12 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Service;
 import org.apache.abdera.model.Source;
-import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
 
 public interface Provider {
@@ -43,5 +42,7 @@
   void deleteEntry(RequestContext context) throws AbderaServerException;
   
   Source getFeedForEntry(Entry entry) throws AbderaServerException;  
+  
+  ProviderManager getProviderManager();
   
 }

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderManager.java?view=auto&rev=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderManager.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderManager.java Mon Sep 11 15:04:08 2006
@@ -0,0 +1,28 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server;
+
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+
+public interface ProviderManager {
+
+  Provider newProvider(AbderaServer server) throws AbderaServerException;
+  
+  void releaseProvider(Provider provider);
+  
+}

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?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- 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 Mon Sep 11 15:04:08 2006
@@ -24,10 +24,14 @@
 
 import javax.security.auth.Subject;
 
+import org.apache.abdera.Abdera;
 import org.apache.abdera.protocol.Request;
-import org.apache.abdera.protocol.server.target.Target;
 
 public interface RequestContext extends Request {
+  
+  Abdera getAbdera();
+  
+  AbderaServer getServer();
   
   Target getTarget();
   

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java Mon Sep 11 15:04:08 2006
@@ -28,10 +28,6 @@
     RequestContext requestContext) 
       throws AbderaServerException;
   
-  /**
-   * RequestHandlers that do have reason to store request specific state MUST
-   * clean that internal state when the clean method is invoked.
-   */
-  void clean();
+  RequestHandlerManager getRequestHandlerManager();
   
 }

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerManager.java (from r441582, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerFactory.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerManager.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerFactory.java&r1=441582&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerManager.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerFactory.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandlerManager.java Mon Sep 11 15:04:08 2006
@@ -19,7 +19,7 @@
 
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
 
-public interface RequestHandlerFactory {
+public interface RequestHandlerManager {
   
   RequestHandler newRequestHandler(
     AbderaServer abderaServer) 

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/SubjectResolver.java (from r441629, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/SubjectResolver.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/SubjectResolver.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/SubjectResolver.java&r1=441629&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/SubjectResolver.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/SubjectResolver.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/SubjectResolver.java Mon Sep 11 15:04:08 2006
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.auth;
+package org.apache.abdera.protocol.server;
 
 import java.security.Principal;
 

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java (from r442264, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/Target.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/Target.java&r1=442264&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/Target.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java Mon Sep 11 15:04:08 2006
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.target;
+package org.apache.abdera.protocol.server;
 
 import java.io.Serializable;
 

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetResolver.java (from r438670, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/TargetResolver.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetResolver.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/TargetResolver.java&r1=438670&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetResolver.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/target/TargetResolver.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetResolver.java Mon Sep 11 15:04:08 2006
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.target;
+package org.apache.abdera.protocol.server;
 
 public interface TargetResolver {
 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java Mon Sep 11 15:04:08 2006
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -32,11 +33,9 @@
 import org.apache.abdera.protocol.server.AbderaServer;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.RequestHandler;
-import org.apache.abdera.protocol.server.RequestHandlerFactory;
+import org.apache.abdera.protocol.server.RequestHandlerManager;
 import org.apache.abdera.protocol.server.ResponseContext;
-import org.apache.abdera.protocol.server.auth.SubjectResolver;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
-import org.apache.abdera.protocol.server.target.TargetResolver;
 import org.apache.abdera.protocol.server.util.ServerConstants;
 
 public class AbderaServlet 
@@ -45,16 +44,28 @@
 
   private static final long serialVersionUID = -4273782501412352619L;
 
-  private final Abdera abdera;
-  private final AbderaServer abderaServer;
-  
-  public AbderaServlet() {
-    this.abdera = new Abdera();
-    this.abderaServer = new AbderaServer(abdera);
-  }
+  private Abdera abdera;
+  private AbderaServer abderaServer;
   
   @Override
-  public void init() throws ServletException {}
+  public void init() throws ServletException {
+    ServletContext context = getServletContext();
+    if (context.getAttribute("abdera") == null) {
+      synchronized(context) {
+        ServletConfig config = getServletConfig();
+        this.abdera = new Abdera();
+        this.abderaServer = 
+          new AbderaServer(
+            abdera, 
+            config.getInitParameter(TARGET_RESOLVER), 
+            config.getInitParameter(HANDLER_MANAGER), 
+            config.getInitParameter(SUBJECT_RESOLVER), 
+            config.getInitParameter(PROVIDER_MANAGER));
+        context.setAttribute("abdera", abdera);
+        context.setAttribute("server", abderaServer);
+      }
+    }
+  }
 
   /**
    * The RequestContext will either be set on the HttpServletRequest by 
@@ -62,63 +73,11 @@
    * to be created and set on the request 
    */
   private RequestContext getRequestContext(HttpServletRequest request) {
-    RequestContext context = 
-      (RequestContext) request.getAttribute(REQUESTCONTEXT);
-    if (context == null) {
-      context = new ServletRequestContext(
-        abdera,
-        getTargetResolver(),
-        getSubjectResolver(),
-        request);
-      request.setAttribute(REQUESTCONTEXT, context);
-    }
-    return context;
-  }
-  
-  
-  private RequestHandlerFactory getRequestHandlerFactory() {
-    ServletContext context = getServletContext();
-    synchronized(context) {
-      RequestHandlerFactory factory = 
-        (RequestHandlerFactory) context.getAttribute(
-        HANDLER_FACTORY);
-      if (factory == null) {
-        String s = getServletConfig().getInitParameter(HANDLER_FACTORY);
-        factory = abderaServer.newRequestHandlerFactory(s);
-        context.setAttribute(HANDLER_FACTORY, factory);
-      }
-      return factory;
-    }
+    return new ServletRequestContext(abderaServer,request);
   }
   
-  private TargetResolver getTargetResolver() {
-    ServletContext context = getServletContext();
-    synchronized(context) {
-      TargetResolver resolver = 
-        (TargetResolver) context.getAttribute(
-          TARGET_RESOLVER);
-      if (resolver == null) {
-        String s = getServletConfig().getInitParameter(TARGET_RESOLVER);
-        resolver = abderaServer.newTargetResolver(s);
-        context.setAttribute(TARGET_RESOLVER, resolver);
-      }
-      return resolver;
-    }
-  }
-  
-  private SubjectResolver getSubjectResolver() {
-    ServletContext context = getServletContext();
-    synchronized(context) {
-      SubjectResolver resolver = 
-        (SubjectResolver) context.getAttribute(
-          SUBJECT_RESOLVER);
-      if (resolver  == null) {
-        String s = getServletConfig().getInitParameter(SUBJECT_RESOLVER);
-        resolver = abderaServer.newSubjectResolver(s);
-        context.setAttribute(SUBJECT_RESOLVER, resolver);
-      }
-      return resolver;
-    }
+  private RequestHandlerManager getRequestHandlerManager() {
+    return abderaServer.getRequestHandlerManager();
   }
   
   @Override
@@ -129,25 +88,21 @@
     RequestContext requestContext = getRequestContext(request);
     ResponseContext responseContext = null;
     RequestHandler handler = null;
-    RequestHandlerFactory factory = null;
+    RequestHandlerManager manager = null;
     try {
-      factory = getRequestHandlerFactory();
-      if (factory != null)
-        handler = factory.newRequestHandler(abderaServer);
-      if (handler != null) {
-        responseContext = handler.invoke(requestContext);
-      } else {
-        throw new AbderaServerException(
-          AbderaServerException.Code.NOTFOUND, 
-          "Handler Not Found", "");
-      }
+      manager = getRequestHandlerManager();
+      handler = (manager != null) ? 
+        manager.newRequestHandler(abderaServer) : null;
+      responseContext = (handler != null) ? 
+        handler.invoke(requestContext) :
+        new AbderaServerException(AbderaServerException.Code.NOTFOUND);
     } catch (AbderaServerException exception) {  
       responseContext = exception;
     } catch (Throwable t) {
       responseContext = new AbderaServerException(t);
     } finally {
-      if (factory != null && handler != null)
-        factory.releaseRequestHandler(handler);
+      if (manager != null)
+        manager.releaseRequestHandler(handler);
     }
     doOutput(response, responseContext); 
   }

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?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- 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 Mon Sep 11 15:04:08 2006
@@ -30,10 +30,11 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.abdera.Abdera;
+import org.apache.abdera.protocol.server.AbderaServer;
 import org.apache.abdera.protocol.server.RequestContext;
-import org.apache.abdera.protocol.server.auth.SubjectResolver;
-import org.apache.abdera.protocol.server.target.Target;
-import org.apache.abdera.protocol.server.target.TargetResolver;
+import org.apache.abdera.protocol.server.SubjectResolver;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.TargetResolver;
 import org.apache.abdera.protocol.server.util.ServerConstants;
 import org.apache.abdera.protocol.util.AbstractRequest;
 import org.apache.abdera.protocol.util.CacheControlUtil;
@@ -43,7 +44,7 @@
   implements RequestContext, ServerConstants {
   
   private final Target target;
-  private final Abdera abdera;
+  private final AbderaServer abderaServer;
   private final Subject subject;
   private final HttpServletRequest servletRequest;
   private final String method;
@@ -52,22 +53,31 @@
   private final URI pathInfo;
     
   public ServletRequestContext(
-    Abdera abdera,
-    TargetResolver resolver,
-    SubjectResolver subjectResolver,
+    AbderaServer abdera,
     HttpServletRequest request) {
-      this.abdera = abdera;
+      this.abderaServer = abdera;
       this.servletRequest = request;
+      this.uri = initUri();
+      this.baseUri = initBaseUri();
+      this.pathInfo = initPathInfo();
+      this.method = request.getMethod();
       CacheControlUtil.parseCacheControl(getCacheControl(), this);
-      uri = initUri();
-      baseUri = initBaseUri();
-      pathInfo = initPathInfo();
-      target = resolver.resolve(getUri().toString());
-      method = request.getMethod();
-      subject = (subjectResolver != null) ?
+      TargetResolver targetResolver = abdera.getTargetResolver();
+      this.target = (targetResolver != null) ?
+        abdera.getTargetResolver().resolve(getUri().toString()) : null;
+      SubjectResolver subjectResolver = abdera.getSubjectResolver();
+      this.subject = (subjectResolver != null) ?
         subjectResolver.resolve(request.getUserPrincipal()) : null;
   }
   
+  public AbderaServer getServer() {
+    return abderaServer;
+  }
+  
+  public Abdera getAbdera() {
+    return getServer().getAbdera();
+  }
+  
   public Subject getSubject() {
     return subject;
   }
@@ -99,7 +109,7 @@
   }
   
   private String getHost() {
-    String host = abdera.getConfiguration().getConfigurationOption(
+    String host = getAbdera().getConfiguration().getConfigurationOption(
       "org.apache.abdera.protocol.server.Host");
     return (host != null) ? 
       host : 
@@ -107,7 +117,7 @@
   }
   
   private int getPort() {
-    String port = abdera.getConfiguration().getConfigurationOption(
+    String port = getAbdera().getConfiguration().getConfigurationOption(
       "org.apache.abdera.protocol.server.Port");
     return (port != null) ? 
       Integer.parseInt(port) : 

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractPooledProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractPooledProviderManager.java?view=auto&rev=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractPooledProviderManager.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractPooledProviderManager.java Mon Sep 11 15:04:08 2006
@@ -0,0 +1,53 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server.util;
+
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.ProviderManager;
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+
+public abstract class AbstractPooledProviderManager 
+  extends PoolManager<Provider>
+  implements ProviderManager {
+  
+  public Provider newProvider(
+    AbderaServer abderaServer) 
+      throws AbderaServerException {
+    Provider prov = getProvider(abderaServer);
+    return prov;
+  }
+  
+  private synchronized Provider getProvider(
+    AbderaServer abderaServer) throws AbderaServerException {
+      return getInstance(abderaServer);
+  }
+
+  public synchronized void releaseProvider(
+    Provider provider) {
+      release(provider);
+  }
+  
+  protected abstract Provider newProviderInstance( 
+    AbderaServer abderaServer) throws AbderaServerException;
+  
+  protected Provider internalNewInstance( 
+    AbderaServer abderaServer) throws AbderaServerException {
+      return newProviderInstance(abderaServer);
+  }
+}

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractProvider.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractProvider.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractProvider.java Mon Sep 11 15:04:08 2006
@@ -28,8 +28,9 @@
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.ProviderManager;
 import org.apache.abdera.protocol.server.RequestContext;
-import org.apache.abdera.protocol.server.provider.Provider;
 import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
 
@@ -37,9 +38,15 @@
   implements Provider {
 
   private final AbderaServer abderaServer;
+  private final ProviderManager providerManager;
   
-  protected AbstractProvider(AbderaServer abderaServer) {
+  protected AbstractProvider(AbderaServer abderaServer, ProviderManager manager) {
     this.abderaServer = abderaServer;
+    this.providerManager = manager;
+  }
+  
+  public ProviderManager getProviderManager() {
+    return providerManager;
   }
   
   protected AbderaServer getAbderaServer() {
@@ -99,5 +106,6 @@
     }
     return true;
   }
-  
+
 }
+

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandler.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandler.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandler.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandler.java Mon Sep 11 15:04:08 2006
@@ -17,72 +17,67 @@
 */
 package org.apache.abdera.protocol.server.util;
 
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.ProviderManager;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.RequestHandler;
+import org.apache.abdera.protocol.server.RequestHandlerManager;
 import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
-import org.apache.abdera.protocol.server.provider.Provider;
 
 public abstract class AbstractRequestHandler 
   implements RequestHandler, ServerConstants {
   
-  protected final Provider provider;
+  protected final RequestHandlerManager manager;
   
-  protected AbstractRequestHandler() {
-    this(null);
+  protected AbstractRequestHandler(RequestHandlerManager manager) {
+    this.manager = manager;
   }
   
-  protected AbstractRequestHandler(Provider provider) {
-    this.provider = provider;
-  }
-  
-  protected Provider getProvider() {
-    return provider;
-  }
-  
-  public void clean() {
-    // by default, there is nothing to clean
+  public RequestHandlerManager getRequestHandlerManager() {
+    return manager;
   }
   
   public ResponseContext invoke(
     RequestContext requestContext)
       throws AbderaServerException {
+    AbderaServer server = requestContext.getServer();
+    ProviderManager providerManager =  server.getProviderManager();
+    Provider provider = null;
     try {
-      ResponseContext response = createResponseContext();
-      checkExists(requestContext);
+      provider = (providerManager != null) ? 
+        providerManager.newProvider(server) : null;
       checkMethod(requestContext);
-      checkModified(requestContext);
-      checkRequest(requestContext);
-      response = internalInvoke(requestContext, response);
-      if (response != null)
-        return response;
-      else
-        throw new AbderaServerException(
-          AbderaServerException.Code.NOTFOUND);
-    } catch (AbderaServerException ase) {
-      throw ase;
+      checkExists(requestContext, provider);
+      checkModified(requestContext, provider);
+      ResponseContext response = internalInvoke(requestContext, provider);
+      if (response != null) return response;
+      else throw new AbderaServerException(AbderaServerException.Code.NOTFOUND);
     } catch (Throwable t) {
       t.printStackTrace();
       String message = t.getMessage();
       if (message == null || message.length() == 0)
         message = "Unknown Server Exception";
       throw new AbderaServerException(500,message);
+    } finally {
+      if (provider != null)
+        providerManager.releaseProvider(provider);
     }
   }
-
-  protected abstract ResponseContext createResponseContext();
-  
-  /**
-   * Returns the type of the requested resource
-   */
-  protected abstract ResourceType getResourceType(RequestContext requestContext);
   
   /**
    * Check that the requested resource exists.  If not, the method
    * MUST throw an appropriate ExistenceException (e.g. not found,
    * gone, moved, etc)
    */
-  protected void checkExists(RequestContext requestContext) throws AbderaServerException{}
+  protected void checkExists(
+    RequestContext requestContext, 
+    Provider provider) 
+      throws AbderaServerException{
+    if (provider != null) provider.checkExists(requestContext);
+  }
   
   /**
    * Check the request method.  If the method is not supported, 
@@ -91,7 +86,8 @@
    */
   protected void checkMethod(RequestContext requestContext) throws AbderaServerException {
     String method = requestContext.getMethod();
-    String[] methods = getAllowedMethods(getResourceType(requestContext));
+    Target target = requestContext.getTarget();
+    String[] methods = getAllowedMethods(target.getResourceType());
     java.util.Arrays.sort(methods);
     if (java.util.Arrays.binarySearch(methods, method) < 0)
       notAllowed(requestContext);
@@ -101,21 +97,21 @@
    * Check to see if the requested resource has been modified.  If not,
    * a NotModifiedException MUST be thrown, otherwise the method
    * should return with no exceptions
+   * @throws AbderaServerException 
    */
-  protected void checkModified(RequestContext requestContext) {}
-  
-  /**
-   * Check to see if the request is valid. If not, throw an appropriate
-   * RequestException
-   */
-  protected void checkRequest(RequestContext requestContext) throws AbderaServerException {}
+  protected void checkModified(
+    RequestContext requestContext, 
+    Provider provider) 
+      throws AbderaServerException {
+    if (provider != null) provider.checkModified(requestContext);
+  }
   
   /**
    * Handle the request
    */
   protected abstract ResponseContext internalInvoke(
     RequestContext requestContext,
-    ResponseContext responseContext) 
+    Provider provider) 
       throws AbderaServerException;
   
   /**
@@ -138,12 +134,11 @@
    * Utility method for reporting MethodNotAllowedExceptions properly
    */
   protected void notAllowed(RequestContext requestContext) throws AbderaServerException {
+    Target target = requestContext.getTarget();
     AbderaServerException notallowed = 
       new AbderaServerException(
         AbderaServerException.Code.METHODNOTALLOWED);
-    notallowed.setAllow(
-      getAllowedMethods(
-        getResourceType(requestContext)));
+    notallowed.setAllow(getAllowedMethods(target.getResourceType()));
     throw notallowed;
   }
   

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerManager.java (from r441582, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerFactory.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerManager.java?view=diff&rev=442370&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerFactory.java&r1=441582&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerManager.java&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerFactory.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractRequestHandlerManager.java Mon Sep 11 15:04:08 2006
@@ -17,17 +17,14 @@
 */
 package org.apache.abdera.protocol.server.util;
 
-import java.util.Stack;
-
 import org.apache.abdera.protocol.server.AbderaServer;
 import org.apache.abdera.protocol.server.RequestHandler;
-import org.apache.abdera.protocol.server.RequestHandlerFactory;
+import org.apache.abdera.protocol.server.RequestHandlerManager;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
 
-public abstract class AbstractRequestHandlerFactory 
-  implements RequestHandlerFactory {
-
-  private static Stack<RequestHandler> requestHandlerPool = new Stack<RequestHandler>();
+public abstract class AbstractRequestHandlerManager 
+  extends PoolManager<RequestHandler>
+  implements RequestHandlerManager {
   
   public RequestHandler newRequestHandler(
     AbderaServer abderaServer) 
@@ -37,18 +34,20 @@
   }
   
   private synchronized RequestHandler getRequestHandler(
-    AbderaServer abderaServer) {
-      if (!requestHandlerPool.empty()) 
-        return requestHandlerPool.pop();
-      return newRequestHandlerInstance(abderaServer);
+    AbderaServer abderaServer) throws AbderaServerException {
+      return getInstance(abderaServer);
   }
 
-  public synchronized void releaseRequestHandler(RequestHandler handler) {
-    handler.clean(); // tell the handler to clean any internal state
-    requestHandlerPool.push(handler);
+  public synchronized void releaseRequestHandler(
+    RequestHandler handler) {
+      release(handler);
   }
   
   protected abstract RequestHandler newRequestHandlerInstance( 
-    AbderaServer abderaServer);
+    AbderaServer abderaServer) throws AbderaServerException;
   
+  protected RequestHandler internalNewInstance( 
+    AbderaServer abderaServer) throws AbderaServerException {
+      return newRequestHandlerInstance(abderaServer);
+  }
 }

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSimpleProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSimpleProviderManager.java?view=auto&rev=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSimpleProviderManager.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSimpleProviderManager.java Mon Sep 11 15:04:08 2006
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server.util;
+
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.ProviderManager;
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+
+public abstract class AbstractSimpleProviderManager 
+  implements ProviderManager {
+
+  protected abstract Provider getProvider(
+    AbderaServer server) 
+      throws AbderaServerException;
+  
+  public Provider newProvider(
+    AbderaServer server) 
+      throws AbderaServerException {
+    return getProvider(server);
+  }
+
+  public void releaseProvider(Provider provider) {}
+
+}

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/EmptyResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/EmptyResponseContext.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/EmptyResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/EmptyResponseContext.java Mon Sep 11 15:04:08 2006
@@ -20,7 +20,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class EmptyResponseContext extends AbstractResponseContext {
+public final class EmptyResponseContext 
+  extends AbstractResponseContext {
 
   public EmptyResponseContext(int status) {
     setStatus(status);
@@ -30,7 +31,7 @@
     return false;
   }
 
-  public void writeTo(OutputStream out) throws IOException {
-  }
+  public void writeTo(OutputStream out) 
+    throws IOException {}
 
 }

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/PoolManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/PoolManager.java?view=auto&rev=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/PoolManager.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/PoolManager.java Mon Sep 11 15:04:08 2006
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.server.util;
+
+import java.util.Stack;
+
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+
+public abstract class PoolManager<T> {
+
+  private final Stack<T> pool = new Stack<T>();
+  
+  protected synchronized T getInstance(
+    AbderaServer abderaServer) throws AbderaServerException {
+      if (!pool.empty()) 
+        return pool.pop();
+      return internalNewInstance(abderaServer);
+  }
+
+  protected synchronized void release(T t) {
+    if (t == null || pool.contains(t)) return;
+    pool.push(t);
+  }
+  
+  protected abstract T internalNewInstance( 
+    AbderaServer abderaServer) throws AbderaServerException;
+ 
+}

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java Mon Sep 11 15:04:08 2006
@@ -17,17 +17,20 @@
 */
 package org.apache.abdera.protocol.server.util;
 
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.abdera.protocol.server.target.Target;
-import org.apache.abdera.protocol.server.target.TargetResolver;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.TargetResolver;
 
 /**
  * <p>Provides a utility class helpful for determining which type of resource
@@ -68,6 +71,32 @@
       Pattern pattern = Pattern.compile(p);
       this.patterns.put(type, pattern);
     }
+  }
+  
+  public RegexTargetResolver(Properties properties) {
+    this.patterns = new HashMap<ResourceType,Pattern>();
+    loadPatterns(properties);
+  }
+  
+  public synchronized void loadPatterns(Properties properties) {
+    this.patterns.clear();
+    for (Object key : properties.keySet()) {
+      String skey = (String) key;
+      String value = properties.getProperty(skey);
+      ResourceType type = ResourceType.getOrCreate(skey);
+      Pattern pattern = Pattern.compile(value);
+      this.patterns.put(type, pattern);
+    }
+  }
+  
+  public synchronized void loadPatterns(InputStream in) throws IOException {
+    Properties properties = new Properties();
+    properties.load(in);
+    loadPatterns(properties);
+  }
+  
+  public synchronized void loadPatterns(String file) throws IOException {
+    loadPatterns(new FileInputStream(file));
   }
   
   public synchronized void setPattern(ResourceType type, String pattern) {

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ResourceType.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ResourceType.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ResourceType.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ResourceType.java Mon Sep 11 15:04:08 2006
@@ -92,6 +92,11 @@
     return null;
   }
   
+  public static ResourceType getOrCreate(String string) {
+    ResourceType type = valueOf(string);
+    return (type != null) ? type : new ResourceType(string);
+  }
+  
   public static ResourceType valueOf(int ordinal) {
     return values()[ordinal];
   }
@@ -148,4 +153,5 @@
   public String toString() {
     return name();
   }
+
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ServerConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ServerConstants.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ServerConstants.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/ServerConstants.java Mon Sep 11 15:04:08 2006
@@ -22,14 +22,17 @@
   public static final String REQUESTCONTEXT = 
     "org.apache.abdera.protocol.server.RequestContext";
  
-  public static final String HANDLER_FACTORY = 
-    "org.apache.abdera.protocol.server.RequestHandlerFactory";
+  public static final String HANDLER_MANAGER = 
+    "org.apache.abdera.protocol.server.RequestHandlerManager";
+  
+  public static final String PROVIDER_MANAGER = 
+    "org.apache.abdera.protocol.server.ProviderManager";
   
   public static final String TARGET_RESOLVER = 
-    "org.apache.abdera.protocol.server.target.TargetResolver";
+    "org.apache.abdera.protocol.server.TargetResolver";
   
   public static final String SUBJECT_RESOLVER = 
-    "org.apache.abdera.protocol.server.auth.SubjectResolver";
+    "org.apache.abdera.protocol.server.SubjectResolver";
   
   public static final String DEFAULT_SUBJECT_RESOLVER = 
     "org.apache.abdera.protocol.server.util.SimpleSubjectResolver";

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java Mon Sep 11 15:04:08 2006
@@ -22,7 +22,7 @@
 
 import javax.security.auth.Subject;
 
-import org.apache.abdera.protocol.server.auth.SubjectResolver;
+import org.apache.abdera.protocol.server.SubjectResolver;
 
 public class SimpleSubjectResolver 
   implements SubjectResolver {

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/TargetIterator.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/TargetIterator.java?view=diff&rev=442370&r1=442369&r2=442370
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/TargetIterator.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/TargetIterator.java Mon Sep 11 15:04:08 2006
@@ -19,7 +19,7 @@
 
 import java.util.Iterator;
 
-import org.apache.abdera.protocol.server.target.Target;
+import org.apache.abdera.protocol.server.Target;
 
 public final class TargetIterator 
   implements Iterator<String> {



Mime
View raw message