abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r614955 - in /incubator/abdera/java/branches/server_refactor_all: server/src/main/java/org/apache/abdera/protocol/server/impl/ spring/src/main/java/org/apache/abdera/spring/ spring/src/main/resources/META-INF/schemas/ spring/src/test/java/o...
Date Thu, 24 Jan 2008 18:31:43 GMT
Author: dandiep
Date: Thu Jan 24 10:31:40 2008
New Revision: 614955

URL: http://svn.apache.org/viewvc?rev=614955&view=rev
Log:
Get Spring integration working again.

Added:
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
      - copied, changed from r614629, incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ServiceContextDefinitionParser.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
  (with props)
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
  (with props)
    incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
      - copied, changed from r614940, incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ServiceContextDefinitionParserTest.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
  (with props)
Removed:
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ServiceContextDefinitionParser.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ServiceContextDefinitionParserTest.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestProvider.java
Modified:
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultProvider.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/AbstractSingleBeanDefinitionParser.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/NamespaceHandler.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/SpringAbderaServlet.java
    incubator/abdera/java/branches/server_refactor_all/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
    incubator/abdera/java/branches/server_refactor_all/spring/src/test/resources/org/apache/abdera/spring/beans.xml

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
Thu Jan 24 10:31:40 2008
@@ -66,6 +66,10 @@
     return null;
   }
 
+  public ResponseContext getCategories(RequestContext request) {
+      return null;
+  }
+
   public ResponseContext deleteMedia(RequestContext request) {
     return ProviderHelper.notallowed(request);
   }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultProvider.java?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultProvider.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultProvider.java
Thu Jan 24 10:31:40 2008
@@ -1,22 +1,24 @@
 /*
-* 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.
-*/
+ * 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.impl;
 
+import java.util.Collection;
+
 import javax.security.auth.Subject;
 
 import org.apache.abdera.protocol.Resolver;
@@ -25,27 +27,26 @@
 import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.WorkspaceManager;
 
-public class DefaultProvider 
-  extends AbstractProvider {
-  
+public class DefaultProvider extends AbstractProvider {
+
   private WorkspaceManager workspaceManager;
   private Resolver<Target> targetResolver;
   private Resolver<Subject> subjectResolver;
-  
+
   public DefaultProvider() {
     workspaceManager = new DefaultWorkspaceManager();
     targetResolver = new StructuredTargetResolver(workspaceManager);
   }
-  
+
   public DefaultProvider(String base) {
     workspaceManager = new DefaultWorkspaceManager();
     targetResolver = new StructuredTargetResolver(workspaceManager, base);
   }
-  
+
   protected Resolver<Target> getTargetResolver(RequestContext request) {
     return targetResolver;
   }
-  
+
   public void setTargetResolver(Resolver<Target> targetResolver) {
     this.targetResolver = targetResolver;
   }
@@ -53,16 +54,23 @@
   protected Resolver<Subject> getSubjectResolver(RequestContext request) {
     return subjectResolver;
   }
-  
+
   public void setSubjectResolver(Resolver<Subject> subjectResolver) {
     this.subjectResolver = subjectResolver;
   }
-  
-  protected WorkspaceManager getWorkspaceManager(
-    RequestContext request) {
-      return getWorkspaceManager();
+
+  public Resolver<Target> getTargetResolver() {
+    return targetResolver;
+  }
+
+  public Resolver<Subject> getSubjectResolver() {
+    return subjectResolver;
+  }
+
+  protected WorkspaceManager getWorkspaceManager(RequestContext request) {
+    return getWorkspaceManager();
   }
-  
+
   public WorkspaceManager getWorkspaceManager() {
     return workspaceManager;
   }
@@ -70,8 +78,14 @@
   public void setWorkspaceManager(WorkspaceManager workspaceManager) {
     this.workspaceManager = workspaceManager;
   }
-  
+
   public void addWorkspace(WorkspaceInfo workspace) {
-    ((DefaultWorkspaceManager) getWorkspaceManager()).addWorkspace(workspace);
+    ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(workspace);
+  }
+
+  public void addWorkspaces(Collection<WorkspaceInfo> workspaces) {
+    for (WorkspaceInfo w : workspaces) {
+      ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(w);
+    }
   }
 }

Modified: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/AbstractSingleBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/AbstractSingleBeanDefinitionParser.java?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/AbstractSingleBeanDefinitionParser.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/AbstractSingleBeanDefinitionParser.java
Thu Jan 24 10:31:40 2008
@@ -84,30 +84,36 @@
             throw new IllegalStateException(propertyName + " property must have child elements!");
         }
         
+        return getAndRegister(ctx, bean, first);
+    }
+
+    protected String getAndRegister(ParserContext ctx, 
+                                    BeanDefinitionBuilder bean,
+                                    Element el) {
         // Seems odd that we have to do the registration, I wonder if there is a better way
         String id;
         BeanDefinition child;
-        if (first.getNamespaceURI().equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI))
{
-            String name = first.getLocalName();
+        if (el.getNamespaceURI().equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI))
{
+            String name = el.getLocalName();
             if ("ref".equals(name)) {
-                id = first.getAttribute("bean");
+                id = el.getAttribute("bean");
                 if (id == null) {
                     throw new IllegalStateException("<ref> elements must have a \"bean\"
attribute!");
                 }
                 return id;
             } else if ("bean".equals(name)) {
-                BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(first);
+                BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(el);
                 child = bdh.getBeanDefinition();
                 id = bdh.getBeanName();
             } else {
                 throw new UnsupportedOperationException("Elements with the name " + name
 
                                                         + " are not currently "
                                                         + "supported as sub elements of "

-                                                        + element.getLocalName());
+                                                        + el.getParentNode().getLocalName());
             }
             
         } else {
-            child = ctx.getDelegate().parseCustomElement(first, bean.getBeanDefinition());
+            child = ctx.getDelegate().parseCustomElement(el, bean.getBeanDefinition());
             id = child.toString();
         }
     

Copied: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
(from r614629, incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ServiceContextDefinitionParser.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java?p2=incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java&p1=incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ServiceContextDefinitionParser.java&r1=614629&r2=614955&rev=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ServiceContextDefinitionParser.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/DefaultProviderDefinitionParser.java
Thu Jan 24 10:31:40 2008
@@ -18,36 +18,41 @@
  */
 package org.apache.abdera.spring;
 
-import org.apache.abdera.protocol.server.ServiceContext;
-import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
-import org.apache.abdera.protocol.server.impl.SingletonProviderManager;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
+
 import org.w3c.dom.Element;
 
-public class ServiceContextDefinitionParser 
+public class DefaultProviderDefinitionParser 
     extends org.apache.abdera.spring.AbstractSingleBeanDefinitionParser {
 
     @Override
+    protected void mapAttribute(BeanDefinitionBuilder bean, Element element, String name,
String val) {
+        if (name.equals("servicesPattern")) {
+            bean.addPropertyValue(name, val);
+        }
+    }
+
+    @Override
     protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {
-        if (name.equals("provider")) {
-            String id = getAndRegisterFirstChild(element, ctx, bean, "provider");
-            
-            BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SingletonProviderManager.class);
-            builder.addPropertyReference("provider", id);
-            AbstractBeanDefinition singletonBean = builder.getBeanDefinition();
-            ctx.getRegistry().registerBeanDefinition(SingletonProviderManager.class.getName()
+ hashCode(), 
-                                                     singletonBean);
-            
-            bean.addPropertyValue("providerManager", singletonBean);
-        } else if (name.equals("providerManager")) {
-            setFirstChildAsProperty(element, ctx, bean, "providerManager");
+        if (name.equals("workspaceManager")) {
+            setFirstChildAsProperty(element, ctx, bean, "workspaceManager");
         } else if (name.equals("targetResolver")) {
             setFirstChildAsProperty(element, ctx, bean, "targetResolver");
         } else if (name.equals("subjectResolver")) {
-            setFirstChildAsProperty(element, ctx, bean, "subjectResolver");
+            setFirstChildAsProperty(element, ctx, bean, name);
+        } else if (name.equals("workspace")) {
+            String id = getAndRegister(ctx, bean, element);
+            
+            bean.addPropertyReference("workspaces", id);
         }
     }
 
@@ -56,7 +61,7 @@
         String cls = super.getBeanClassName(arg0);
         
         if (cls == null) {
-            cls = DefaultServiceContext.class.getName();
+            cls = ProviderFactoryBean.class.getName();
         }
         
         return cls;
@@ -67,12 +72,13 @@
         String id = element.getAttribute("id");
         
         if (id == null || "".equals(id)) {
-            id = ServiceContext.class.getName();
+            id = Provider.class.getName();
         }
         
         
         return id;
     }
+    
     
 }
  

Modified: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/NamespaceHandler.java?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/NamespaceHandler.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/NamespaceHandler.java
Thu Jan 24 10:31:40 2008
@@ -22,7 +22,8 @@
 
 public class NamespaceHandler extends NamespaceHandlerSupport {
     public void init() {
-        registerBeanDefinitionParser("serviceContext", new ServiceContextDefinitionParser());
+        registerBeanDefinitionParser("workspace", new WorkspaceDefinitionParser());
+        registerBeanDefinitionParser("provider", new DefaultProviderDefinitionParser());
         registerBeanDefinitionParser("regexTargetResolver", new RegexTargetResolverDefinitionParser());
     }
 }

Added: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java?rev=614955&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
(added)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
Thu Jan 24 10:31:40 2008
@@ -0,0 +1,93 @@
+package org.apache.abdera.spring;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+
+import javax.security.auth.Subject;
+
+import org.apache.abdera.protocol.Resolver;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
+import org.springframework.beans.factory.FactoryBean;
+
+public class ProviderFactoryBean implements FactoryBean {
+    private Class providerClass = DefaultProvider.class;
+    private String servicesPattern;
+    private Collection<WorkspaceInfo> workspaces;
+    private Resolver<Target> targetResolver;
+    private Resolver<Subject> subjectResolver;
+    
+    public Object getObject() throws Exception {
+        DefaultProvider p = null;
+        
+        if (servicesPattern != null) {
+            Constructor constructor = providerClass.getConstructor(String.class);
+            p = (DefaultProvider) constructor.newInstance(servicesPattern);
+        } else {
+            p = (DefaultProvider) providerClass.newInstance();
+        }
+        
+        if (workspaces != null && workspaces.size() > 0) {
+            p.addWorkspaces(workspaces);
+        }
+        if (targetResolver != null) {
+            p.setTargetResolver(targetResolver);
+        }
+        
+        if (subjectResolver != null) {
+            p.setSubjectResolver(subjectResolver);
+        }
+        
+        return p;
+    }
+
+    public Class getObjectType() {
+        return DefaultProvider.class;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public Class getProviderClass() {
+        return providerClass;
+    }
+
+    public void setProviderClass(Class providerClass) {
+        this.providerClass = providerClass;
+    }
+
+    public String getServicesPattern() {
+        return servicesPattern;
+    }
+
+    public void setServicesPattern(String servicesPattern) {
+        this.servicesPattern = servicesPattern;
+    }
+
+    public Collection<WorkspaceInfo> getWorkspaces() {
+        return workspaces;
+    }
+
+    public void setWorkspaces(Collection<WorkspaceInfo> workspaces) {
+        this.workspaces = workspaces;
+    }
+
+    public Resolver<Target> getTargetResolver() {
+        return targetResolver;
+    }
+
+    public void setTargetResolver(Resolver<Target> targetResolver) {
+        this.targetResolver = targetResolver;
+    }
+
+    public Resolver<Subject> getSubjectResolver() {
+        return subjectResolver;
+    }
+
+    public void setSubjectResolver(Resolver<Subject> subjectResolver) {
+        this.subjectResolver = subjectResolver;
+    }
+
+}

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/ProviderFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/SpringAbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/SpringAbderaServlet.java?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/SpringAbderaServlet.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/SpringAbderaServlet.java
Thu Jan 24 10:31:40 2008
@@ -17,7 +17,7 @@
  */
 package org.apache.abdera.spring;
 
-import org.apache.abdera.protocol.server.ServiceContext;
+import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -33,17 +33,17 @@
     
     private static final long serialVersionUID = -7579564455804753809L;
 
-    protected ServiceContext createServiceContext() {
-        String contextName = getInitParameter("serviceContextBeanName");
-        if (contextName == null) {
-            contextName = ServiceContext.class.getName();
+    protected Provider createProvider() {
+        String providerName = getInitParameter("providerBeanName");
+        if (providerName == null) {
+            providerName = Provider.class.getName();
         }
         
         WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
         
-        ServiceContext sc = (ServiceContext) ctx.getBean(contextName);
-        sc.init(getAbdera(), getProperties(getServletConfig()));
-        return sc;
+        Provider p = (Provider) ctx.getBean(providerName);
+        p.init(getAbdera(), getProperties(getServletConfig()));
+        return p;
     }
 }
  

Added: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java?rev=614955&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
(added)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
Thu Jan 24 10:31:40 2008
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.abdera.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
+import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+
+import org.w3c.dom.Element;
+
+public class WorkspaceDefinitionParser 
+    extends org.apache.abdera.spring.AbstractSingleBeanDefinitionParser {
+
+    @Override
+    protected void mapAttribute(BeanDefinitionBuilder bean, Element element, String name,
String val) {
+        if (name.equals("title")) {
+            bean.addPropertyValue(name, val);
+        }
+    }
+
+    @Override
+    protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element element,
String name) {
+        bean.addPropertyValue("collections", ctx.getDelegate().parseBeanDefinitionElement(element));
+    }
+
+    @Override
+    protected String getBeanClassName(Element arg0) {
+        String cls = super.getBeanClassName(arg0);
+        
+        if (cls == null) {
+            cls = SimpleWorkspaceInfo.class.getName();
+        }
+        
+        return cls;
+    }
+
+    @Override
+    protected boolean shouldGenerateIdAsFallback() {
+        return true;
+    }
+
+    
+}
+ 
\ No newline at end of file

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/main/java/org/apache/abdera/spring/WorkspaceDefinitionParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/abdera/java/branches/server_refactor_all/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/main/resources/META-INF/schemas/abdera-spring.xsd
Thu Jan 24 10:31:40 2008
@@ -1,61 +1,76 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<xsd:schema
-  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-  xmlns:beans="http://www.springframework.org/schema/beans"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
-  targetNamespace="http://abdera.apache.org" 
-  elementFormDefault="qualified"
-  attributeFormDefault="unqualified"  >
-
-  <xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
-  <xsd:element name="serviceContext">
-    <xsd:complexType>
-      <xsd:complexContent>
-        <xsd:extension base="beans:identifiedType">
-          <xsd:sequence>
-            <xsd:element name="provider" type="xsd:anyType" minOccurs="0"/>
-            <xsd:element name="providerManager" type="xsd:anyType" minOccurs="0"/>
-            <xsd:element name="targetResolver" type="xsd:anyType" minOccurs="0"/>
-            <xsd:element name="subjectResolver" type="xsd:anyType" minOccurs="0"/>
-          </xsd:sequence>
-          <xsd:attribute name="class" type="xsd:string" />
-        </xsd:extension>
-      </xsd:complexContent>
-    </xsd:complexType>
-  </xsd:element>
-
-  <xsd:element name="regexTargetResolver">
-    <xsd:complexType>
-      <xsd:complexContent>
-        <xsd:extension base="beans:identifiedType">
-          <xsd:choice maxOccurs="unbounded">
-            <xsd:element name="category" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="collection" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="entry" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="media" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="service" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
-          </xsd:choice>
-        </xsd:extension>
-      </xsd:complexContent>
-    </xsd:complexType>
-  </xsd:element>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<xsd:schema
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:beans="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
+  targetNamespace="http://abdera.apache.org" 
+  elementFormDefault="qualified"
+  attributeFormDefault="unqualified"  >
+
+  <xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
+  <xsd:element name="provider">
+    <xsd:complexType>
+      <xsd:complexContent>
+        <xsd:extension base="beans:identifiedType">
+          <xsd:sequence>
+            <xsd:element name="workspace" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="workspaceManager" type="xsd:anyType" minOccurs="0"/>
+            <xsd:element name="targetResolver" type="xsd:anyType" minOccurs="0"/>
+            <xsd:element name="subjectResolver" type="xsd:anyType" minOccurs="0"/>
+          </xsd:sequence>
+          <xsd:attribute name="class" type="xsd:string" />
+          <xsd:attribute name="servicesPattern" type="xsd:string"/>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="workspace">
+    <xsd:complexType>
+      <xsd:complexContent>
+        <xsd:extension base="beans:identifiedType">
+          <xsd:sequence>
+            <xsd:element ref="beans:bean" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element ref="beans:ref" minOccurs="0" maxOccurs="unbounded"/>
+          </xsd:sequence>
+          <xsd:attribute name="title" type="xsd:string"/>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+  </xsd:element>
+  
+  <xsd:element name="regexTargetResolver">
+    <xsd:complexType>
+      <xsd:complexContent>
+        <xsd:extension base="beans:identifiedType">
+          <xsd:choice maxOccurs="unbounded">
+            <xsd:element name="category" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="collection" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="entry" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="media" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="service" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+          </xsd:choice>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+  </xsd:element>
 </xsd:schema>

Copied: incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
(from r614940, incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ServiceContextDefinitionParserTest.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java?p2=incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java&p1=incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ServiceContextDefinitionParserTest.java&r1=614940&r2=614955&rev=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ServiceContextDefinitionParserTest.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/ProviderDefinitionParserTest.java
Thu Jan 24 10:31:40 2008
@@ -19,29 +19,39 @@
  */
 package org.apache.abdera.spring;
 
+import java.util.Collection;
+
 import org.apache.abdera.protocol.ItemManager;
 import org.apache.abdera.protocol.Resolver;
+import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.Provider;
-import org.apache.abdera.protocol.server.ServiceContext;
 import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
 import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
-import org.apache.abdera.protocol.server.impl.SingletonProviderManager;
 import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
 
-public class ServiceContextDefinitionParserTest 
+public class ProviderDefinitionParserTest 
     extends AbstractDependencyInjectionSpringContextTests {
 
     public void testParser() throws Exception {
-        ServiceContext ctx = (ServiceContext) applicationContext.getBean(ServiceContext.class.getName());
+        DefaultProvider p = (DefaultProvider) applicationContext.getBean(Provider.class.getName());
         
-        ItemManager<Provider> pm = ctx.getProviderManager();
-        assertTrue(pm instanceof SingletonProviderManager);
+        Resolver<Target> tresolver = p.getTargetResolver();
+        assertTrue(tresolver instanceof RegexTargetResolver);
         
-        Provider provider = pm.get(null);
-        assertTrue(provider instanceof TestProvider);
+        WorkspaceManager wm = p.getWorkspaceManager();
+        
+        Collection<WorkspaceInfo> workspaces = wm.getWorkspaces(null);
+        assertEquals(1, workspaces.size());
+        
+        WorkspaceInfo w = workspaces.iterator().next();
+        assertEquals("Foo Workspace", w.getTitle(null));
+        
+        Collection<CollectionInfo> collections = w.getCollections(null);
+        assertEquals(1, collections.size());
         
-        Resolver<Target> tresolver = ctx.getTargetResolver("/path");
-        assertTrue(tresolver instanceof RegexTargetResolver);
     }
     
     @Override

Added: incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java?rev=614955&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
(added)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
Thu Jan 24 10:31:40 2008
@@ -0,0 +1,56 @@
+package org.apache.abdera.spring;
+
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.context.ResponseContextException;
+import org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter;
+
+public class TestAdapter extends AbstractCollectionAdapter {
+
+    @Override
+    public String getAuthor() throws ResponseContextException {
+        return null;
+    }
+
+    @Override
+    public String getId(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getHref(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getTitle(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ResponseContext deleteEntry(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ResponseContext getEntry(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ResponseContext getFeed(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ResponseContext postEntry(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ResponseContext putEntry(RequestContext request) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/abdera/java/branches/server_refactor_all/spring/src/test/java/org/apache/abdera/spring/TestAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/abdera/java/branches/server_refactor_all/spring/src/test/resources/org/apache/abdera/spring/beans.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/spring/src/test/resources/org/apache/abdera/spring/beans.xml?rev=614955&r1=614954&r2=614955&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/spring/src/test/resources/org/apache/abdera/spring/beans.xml
(original)
+++ incubator/abdera/java/branches/server_refactor_all/spring/src/test/resources/org/apache/abdera/spring/beans.xml
Thu Jan 24 10:31:40 2008
@@ -1,30 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-  xmlns:a="http://abdera.apache.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="
-    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
-    http://abdera.apache.org http://abdera.apache.org/schemas/abdera-spring.xsd">
-
-  <!-- Abdera -->
-  <a:serviceContext>
-  
-    <a:provider>
-      <ref bean="provider"/>
-    </a:provider>
-    
-    <a:targetResolver>
-      <a:regexTargetResolver>
-        <a:collection>/atom/feed(\?[^#]*)?</a:collection>
-        <a:entry>/atom/feed/([^/#?]+)(\?[^#]*)?</a:entry>
-        <a:service>/atom(\?[^#]*)?</a:service>
-      </a:regexTargetResolver>
-    </a:targetResolver>
-    
-  </a:serviceContext>
-
-  
-  <bean id="provider" class="org.apache.abdera.spring.TestProvider">
-  </bean>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:a="http://abdera.apache.org"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="
+    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+    http://abdera.apache.org http://abdera.apache.org/schemas/abdera-spring.xsd">
+
+  <!-- Abdera -->
+  <a:provider>
+  
+    <a:workspace title="Foo Workspace">
+      <!-- These are our collections -->
+      <bean class="org.apache.abdera.spring.TestAdapter"/>
+    </a:workspace>
+    
+    <!-- It is not necessary to specify this, but we're testing it -->
+    <a:targetResolver>
+      <a:regexTargetResolver>
+        <a:collection>/atom/feed(\?[^#]*)?</a:collection>
+        <a:entry>/atom/feed/([^/#?]+)(\?[^#]*)?</a:entry>
+        <a:service>/atom(\?[^#]*)?</a:service>
+      </a:regexTargetResolver>
+    </a:targetResolver>
+    
+  </a:provider>
+
 </beans>



Mime
View raw message