abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r441673 - in /incubator/abdera/java/trunk: examples/src/main/java/org/apache/abdera/examples/appserver/ server/src/main/java/org/apache/abdera/protocol/server/provider/ server/src/main/java/org/apache/abdera/protocol/server/util/
Date Fri, 08 Sep 2006 22:15:07 GMT
Author: jmsnell
Date: Fri Sep  8 15:15:06 2006
New Revision: 441673

URL: http://svn.apache.org/viewvc?view=rev&rev=441673
Log:
Initial attempt at separating the RequestHandler from the backend storage provider.

The model here is that a server may actually pool up multiple request handlers, all
of which may share the same Provider instance.  It's the RequestHandlerFactory's job
to figure it all out.  

Use of the separate Provider model is optional but recommended.

More work needs to be done to develop this further.

Added:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
    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/provider/Provider.java
Modified:
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleRequestHandler.java
    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/util/AbstractRequestHandler.java

Added: 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=auto&rev=441673
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
(added)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
Fri Sep  8 15:15:06 2006
@@ -0,0 +1,268 @@
+/*
+* 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 java.io.IOException;
+import java.util.Date;
+
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Source;
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.stax.util.FOMHelper;
+import org.apache.abdera.protocol.server.AbderaServer;
+import org.apache.abdera.protocol.server.RequestContext;
+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.util.Constants;
+import org.apache.abdera.util.MimeTypeHelper;
+
+public class SimpleProvider 
+  implements Provider {
+
+  private final AbderaServer abderaServer;
+  private static Document<Service> service_doc = null;
+  private static Document<Feed> feed_doc = null;
+  
+  public SimpleProvider(AbderaServer abderaServer) {
+    this.abderaServer = abderaServer;
+  }
+  
+  private AbderaServer getAbderaServer() {
+    return abderaServer;
+  }
+  
+  private Abdera getAbdera() {
+    return getAbderaServer().getAbdera();
+  }
+  
+  private Factory getFactory() {
+    return getAbdera().getFactory();
+  }
+  
+  private Parser getParser() {
+    return getAbdera().getParser();
+  }
+
+  private synchronized Document<Service> getService() {
+    if (service_doc == null) {
+      try {
+        Factory factory = getFactory();
+        service_doc = factory.newDocument();
+        Service service = factory.newService(service_doc);
+        Workspace workspace = service.addWorkspace("Simple");
+        Collection entries = workspace.addCollection("foo", "atom/foo");
+        entries.setAccept("entry");
+      } catch (Exception e) {}
+    }
+    return service_doc;
+  }
+  
+  private synchronized Document<Feed> getFeed() {
+    if (feed_doc == null) {
+      try {
+        Factory factory = getFactory();
+        feed_doc = factory.newDocument();
+        Feed feed = factory.newFeed(feed_doc);
+        feed.setId(FOMHelper.generateUuid());
+        feed.setTitle("Foo");
+        feed.setUpdated(new Date());
+        feed.addLink("http://example.org");
+        feed.addLink("", "self");
+        feed.addAuthor("Simple Service");
+      } catch (Exception e) {}
+    }
+    return feed_doc;
+  }
+
+  public void checkExists(
+    RequestContext context) 
+      throws AbderaServerException {
+  }
+
+  public void checkModified(
+    RequestContext context)
+      throws AbderaServerException {
+  }
+  
+  public Entry addEntry(
+    RequestContext context) 
+      throws AbderaServerException {
+    try {
+      Document<Entry> entry_doc = 
+        getEntryFromRequestContext(context);
+      Entry entry = null;
+      if (entry_doc != null) {
+        entry = (Entry) entry_doc.getRoot().clone();
+        if (!isValidEntry(entry))
+          throw new AbderaServerException(
+            AbderaServerException.Code.BADREQUEST, "Invalid Entry", "");
+        entry.setUpdated(new Date());
+        entry.setModified(entry.getUpdated());
+        entry.getIdElement().setValue(FOMHelper.generateUuid());
+        entry.addLink("foo/" + entry.getId().toString(), "edit");
+        getFeed().getRoot().insertEntry((Entry) entry.clone());
+      }
+      return entry;
+    } catch (Exception e) {
+      throw new AbderaServerException(Code.INTERNALSERVERERROR);
+    }
+  }
+
+  public void deleteEntry(
+    RequestContext context) 
+      throws AbderaServerException {
+    Entry entry = getEntryFromFeed(context);
+    if (entry != null)
+      entry.discard();
+    else
+      throw new AbderaServerException(Code.NOTFOUND);
+  }
+
+  public Entry getEntry(
+    RequestContext context) 
+      throws AbderaServerException {
+    Entry entry = getEntryFromFeed(context);
+    if (entry != null)
+      return (Entry)entry.clone();
+    else
+      throw new AbderaServerException(Code.NOTFOUND);
+  }
+
+  public Entry updateEntry(
+    RequestContext context) 
+      throws AbderaServerException {
+    Entry entry = getEntryFromFeed(context);
+    if (entry == null) throw new AbderaServerException(Code.NOTFOUND);
+    try {
+      Document<Entry> entry_doc = getEntryFromRequestContext(context);
+      if (entry_doc == null) 
+        throw new AbderaServerException(
+          AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, 
+          "Unsupported Media Type", "");
+      Document<Feed> feed_doc = getFeed();
+      Entry e = (Entry) entry_doc.getRoot().clone();
+      // check to see if it's a valid atom entry
+      if (!isValidEntry(entry))
+        throw new AbderaServerException(
+          AbderaServerException.Code.BADREQUEST, "Invalid Entry", "");
+      // check to see if the atom:id matches
+      if (!e.getId().equals(entry.getId()))
+        throw new AbderaServerException(
+          AbderaServerException.Code.CONFLICT, "Conflict. Cannot change atom:id", "");
+      // override atom:updated 
+      e.setUpdated(new Date());
+      // set the app:modified date
+      e.setModified(e.getUpdated());
+      // make sure the edit link stays the same
+      Link editLink = e.getEditLink();
+      if (editLink == null) 
+        e.addLink("foo/" + e.getId().toString(), "edit");
+      else editLink.setHref("foo/" + e.getId().toString());
+      // discard the original
+      entry.discard();
+      // insert the new
+      e = (Entry) e.clone();
+      feed_doc.getRoot().insertEntry(e);
+      return e;
+    } catch (Exception e) {
+      throw new AbderaServerException(e);
+    }
+  }
+  
+  public Feed getFeed(
+    RequestContext context) 
+      throws AbderaServerException {
+    return getFeed().getRoot();
+  }
+
+  public Source getFeedForEntry(
+    Entry entry) 
+      throws AbderaServerException {
+    return getFeed().getRoot().getAsSource();
+  }
+
+  public Service getService(
+    RequestContext context)
+      throws AbderaServerException {
+    return getService().getRoot();
+  }
+
+  private Entry getEntryFromFeed(RequestContext context) {
+    try {
+      Target target = context.getTarget();
+      Document<Feed> doc_feed = getFeed();
+      String id = target.getValue(2);
+      return doc_feed.getRoot().getEntry(id);
+    } catch (Exception e) {
+      return null;
+    }
+  }
+  
+  @SuppressWarnings("unchecked")
+  private Document<Entry> getEntryFromRequestContext(
+    RequestContext context) 
+      throws IOException, 
+             MimeTypeParseException {
+    String ctype = context.getContentType().toString();
+    if (ctype != null && ctype.length() != 0 &&
+        (!MimeTypeHelper.isMatch(ctype, "application/atom+xml") &&
+         !MimeTypeHelper.isMatch(ctype, "application/xml"))) {
+      return null;
+    }
+    // might still be an atom entry, let's try it
+    try {
+      Parser parser = getParser();
+      Document doc = parser.parse(context.getInputStream());
+      Element root = doc.getRoot();
+      if (root != null && root.getQName().equals(Constants.ENTRY)) {
+        return doc;
+      }
+    } catch (Exception e) {}
+    return null;
+  }
+  
+  private boolean isValidEntry(Entry entry) {
+    try {
+      if (entry.getId() == null || entry.getId().toString().length() == 0) return false;
+      if (entry.getTitle() == null) return false;
+      if (entry.getAuthor() == null) return false;
+      if (entry.getUpdated() == null) return false;
+      if (entry.getContent() == null) {
+        if (entry.getAlternateLink() == null) return false;
+        if (entry.getSummary() == null) return false;
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return true;
+  }
+
+}

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=441673&r1=441672&r2=441673
==============================================================================
--- 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
Fri Sep  8 15:15:06 2006
@@ -17,34 +17,22 @@
 */
 package org.apache.abdera.examples.appserver;
 
-import java.io.IOException;
 import java.util.Date;
 
-import javax.activation.MimeTypeParseException;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Link;
 import org.apache.abdera.model.Service;
-import org.apache.abdera.model.Workspace;
-import org.apache.abdera.parser.Parser;
-import org.apache.abdera.parser.stax.util.FOMHelper;
 import org.apache.abdera.protocol.server.AbderaServer;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ResponseContext;
 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;
 import org.apache.abdera.protocol.server.util.ResourceType;
-import org.apache.abdera.util.Constants;
-import org.apache.abdera.util.MimeTypeHelper;
 
 /**
  * <p>RequestHandlers are the components that actually do the work in the APP
@@ -63,11 +51,9 @@
  */
 public class SimpleRequestHandler 
   extends AbstractRequestHandler {
-
-  private final AbderaServer abderaServer;
   
-  public SimpleRequestHandler(AbderaServer abderaServer) {
-    this.abderaServer = abderaServer;
+  public SimpleRequestHandler(AbderaServer abderaServer, Provider provider) {
+    super(provider);
   }
   
   @Override
@@ -99,28 +85,18 @@
                 AbderaServerException.Code.NOTMODIFIED, 
                 "Not Modified", "");
           } catch (NullPointerException npe) {}
-          return getServiceDocument();
+          return getServiceDocument(requestContext);
       } 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();
+            return getFeedDocument(requestContext);
           } else if (method.equals("POST")) {
             try {
-              Document<Entry> entry_doc = 
-                getEntryFromRequestContext(requestContext);
-              if (entry_doc != null) {
-                Entry entry = (Entry) entry_doc.getRoot().clone();
-                if (!isValidEntry(entry))
-                  throw new AbderaServerException(
-                    AbderaServerException.Code.BADREQUEST, "Invalid Entry", "");
-                entry.setUpdated(new Date());
-                entry.setModified(entry.getUpdated());
-                entry.getIdElement().setValue(FOMHelper.generateUuid());
-                entry.addLink("foo/" + entry.getId().toString(), "edit");
-                getFeed().getRoot().insertEntry((Entry) entry.clone());
+              Entry entry = getProvider().addEntry(requestContext);
+              if (entry != null) {
                 BaseResponseContext rc = getEntryDocument(entry);
                 rc.setStatus(201);
                 String elink = entry.getEditLink().getHref().toString();
@@ -139,49 +115,24 @@
             }
           }
       } else if (type == ResourceType.ENTRY_EDIT) {
-          Entry entry = getEntryFromFeed(requestContext);
-          if (entry == null)
-            throw new AbderaServerException(
-              AbderaServerException.Code.NOTFOUND, "Not Found", "");
           if (method.equals("GET")) {
-            Entry e = (Entry) entry.clone();
+            Entry e = getProvider().getEntry(requestContext);
             return new BaseResponseContext(e.getDocument());
           } else if (method.equals("PUT")) {
             try {
-              Document<Entry> entry_doc = getEntryFromRequestContext(requestContext);
-              if (entry_doc == null) 
+              Entry entry = getProvider().updateEntry(requestContext);
+              if (entry == null) 
                 throw new AbderaServerException(
                   AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, 
                   "Unsupported Media Type", "");
-              Document<Feed> feed_doc = getFeed();
-              Entry e = (Entry) entry_doc.getRoot().clone();
-              // check to see if it's a valid atom entry
-              if (!isValidEntry(entry))
-                throw new AbderaServerException(
-                  AbderaServerException.Code.BADREQUEST, "Invalid Entry", "");
-              // check to see if the atom:id matches
-              if (!e.getId().equals(entry.getId()))
-                throw new AbderaServerException(
-                  AbderaServerException.Code.CONFLICT, "Conflict. Cannot change atom:id",
"");
-              // override atom:updated 
-              e.setUpdated(new Date());
-              // set the app:modified date
-              e.setModified(e.getUpdated());
-              // make sure the edit link stays the same
-              Link editLink = e.getEditLink();
-              if (editLink == null) 
-                e.addLink("foo/" + e.getId().toString(), "edit");
-              else editLink.setHref("foo/" + e.getId().toString());
-              // discard the original
-              entry.discard();
-              // insert the new
-              feed_doc.getRoot().insertEntry((Entry) e.clone());
               return new EmptyResponseContext(204);
+            } catch (AbderaServerException ase) {
+              throw ase;
             } catch (Exception e) {
               throw new AbderaServerException(e);
             }
           } else if (method.equals("DELETE")) {
-            entry.discard();
+            getProvider().deleteEntry(requestContext);
             return new EmptyResponseContext(204);
           }
       }
@@ -193,61 +144,8 @@
     }
   }
   
-  private Entry getEntryFromFeed(RequestContext context) {
-    try {
-      Target target = context.getTarget();
-      Document<Feed> doc_feed = getFeed();
-      String id = target.getValue(2);
-      return doc_feed.getRoot().getEntry(id);
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  private Document<Entry> getEntryFromRequestContext(
-    RequestContext context) 
-      throws IOException, 
-             MimeTypeParseException {
-    String ctype = context.getContentType().toString();
-    if (ctype != null && ctype.length() != 0 &&
-        (!MimeTypeHelper.isMatch(ctype, "application/atom+xml") &&
-         !MimeTypeHelper.isMatch(ctype, "application/xml"))) {
-      return null;
-    }
-    // might still be an atom entry, let's try it
-    try {
-      Parser parser = getParser();
-      Document doc = parser.parse(context.getInputStream());
-      Element root = doc.getRoot();
-      if (root != null && root.getQName().equals(Constants.ENTRY)) {
-        return doc;
-      }
-    } catch (Exception e) {}
-    return null;
-  }
-  
-  private boolean isValidEntry(Entry entry) {
-    try {
-      if (entry.getId() == null || entry.getId().toString().length() == 0) return false;
-      if (entry.getTitle() == null) return false;
-      if (entry.getAuthor() == null) return false;
-      if (entry.getUpdated() == null) return false;
-      if (entry.getContent() == null) {
-        if (entry.getAlternateLink() == null) return false;
-        if (entry.getSummary() == null) return false;
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return true;
-  }
-  
   // The service doc, collection, etc
   
-  private static Document<Service> service_doc = null;
-  private static Document<Feed> feed_doc = null;
-  
   private BaseResponseContext<Document<Entry>> getEntryDocument(Entry entry)
{
     Document<Entry> entry_doc = entry.getDocument();
     BaseResponseContext<Document<Entry>> rc =
@@ -256,67 +154,28 @@
     return rc;
   }
   
-  private BaseResponseContext<Document<Service>> getServiceDocument() {
+  private BaseResponseContext<Document<Service>> getServiceDocument(
+    RequestContext context) 
+      throws AbderaServerException {
+    Document<Service> service_doc = 
+      getProvider().getService(context).getDocument();
     BaseResponseContext<Document<Service>> rc = 
-      new BaseResponseContext<Document<Service>>(getService());
+      new BaseResponseContext<Document<Service>>(service_doc);
     rc.setEntityTag("\"service\"");
     rc.setLastModified(new Date());
     rc.setContentType("application/atomserv+xml");
     return rc;
   }
   
-  private BaseResponseContext<Document<Feed>> getFeedDocument() {
+  private BaseResponseContext<Document<Feed>> getFeedDocument(
+    RequestContext context) 
+      throws AbderaServerException {
+    Document<Feed> feed_doc = 
+      getProvider().getFeed(context).getDocument();
     BaseResponseContext<Document<Feed>> rc =
-      new BaseResponseContext<Document<Feed>>(getFeed());
+      new BaseResponseContext<Document<Feed>>(feed_doc);
     rc.setContentType("application/atom+xml");
     return rc;
   }
   
-  private synchronized Document<Service> getService() {
-    if (service_doc == null) {
-      try {
-        Factory factory = getFactory();
-        service_doc = factory.newDocument();
-        Service service = factory.newService(service_doc);
-        Workspace workspace = service.addWorkspace("Simple");
-        Collection entries = workspace.addCollection("foo", "atom/foo");
-        entries.setAccept("entry");
-      } catch (Exception e) {}
-    }
-    return service_doc;
-  }
-  
-  private synchronized Document<Feed> getFeed() {
-    if (feed_doc == null) {
-      try {
-        Factory factory = getFactory();
-        feed_doc = factory.newDocument();
-        Feed feed = factory.newFeed(feed_doc);
-        feed.setId(FOMHelper.generateUuid());
-        feed.setTitle("Foo");
-        feed.setUpdated(new Date());
-        feed.addLink("http://example.org");
-        feed.addLink("", "self");
-        feed.addAuthor("Simple Service");
-      } catch (Exception e) {}
-    }
-    return feed_doc;
-  }
-  
-  private AbderaServer getAbderaServer() {
-    return abderaServer;
-  }
-  
-  private Abdera getAbdera() {
-    return getAbderaServer().getAbdera();
-  }
-  
-  private Factory getFactory() {
-    return getAbdera().getFactory();
-  }
-  
-  private Parser getParser() {
-    return getAbdera().getParser();
-  }
-
 }

Modified: 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/SimpleRequestHandlerFactory.java?view=diff&rev=441673&r1=441672&r2=441673
==============================================================================
--- 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/SimpleRequestHandlerFactory.java
Fri Sep  8 15:15:06 2006
@@ -20,16 +20,26 @@
 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;
 
 public class SimpleRequestHandlerFactory
   extends AbstractRequestHandlerFactory
   implements RequestHandlerFactory {
 
+  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);
+      return new SimpleRequestHandler(abderaServer, getProvider(abderaServer));
   }
 
 }

Added: 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/Provider.java?view=auto&rev=441673
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java
(added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java
Fri Sep  8 15:15:06 2006
@@ -0,0 +1,47 @@
+/*
+* 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.provider;
+
+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 {
+
+  void checkModified(RequestContext context) throws AbderaServerException;
+
+  void checkExists(RequestContext context) throws AbderaServerException;
+
+  Service getService(RequestContext context) throws AbderaServerException;
+  
+  Feed getFeed(RequestContext context) throws AbderaServerException;
+  
+  Entry getEntry(RequestContext context) throws AbderaServerException;
+  
+  Entry addEntry(RequestContext context) throws AbderaServerException;
+  
+  Entry updateEntry(RequestContext context) throws AbderaServerException;
+  
+  void deleteEntry(RequestContext context) throws AbderaServerException;
+  
+  Source getFeedForEntry(Entry entry) throws AbderaServerException;  
+  
+}

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=441673&r1=441672&r2=441673
==============================================================================
--- 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
Fri Sep  8 15:15:06 2006
@@ -21,11 +21,24 @@
 import org.apache.abdera.protocol.server.RequestHandler;
 import org.apache.abdera.protocol.server.ResponseContext;
 import org.apache.abdera.protocol.server.exceptions.AbderaServerException;
+import org.apache.abdera.protocol.server.provider.Provider;
 
 public abstract class AbstractRequestHandler 
   implements RequestHandler, ServerConstants {
   
-  public AbstractRequestHandler() {}
+  protected final Provider provider;
+  
+  protected AbstractRequestHandler() {
+    this(null);
+  }
+  
+  protected AbstractRequestHandler(Provider provider) {
+    this.provider = provider;
+  }
+  
+  protected Provider getProvider() {
+    return provider;
+  }
   
   public void clean() {
     // by default, there is nothing to clean



Mime
View raw message