ApplicationContext Configuration

Abdera comes with Spring 2 configuration support and several classes to make building Spring based applications easier. Most server applications should be able to built by writing a Provider and a small bit of Spring XML.

The first step then is to write a CollectionAdapter. This is the place where your application specific logic goes for creating, editing or deleting resources. Please see the Server Implementation Guide for more information.

package org.example;

import org.apache.abdera.server.CollectionAdapter;

public class FooCollectionAdapter implements CollectionAdapter {
  ...
}

And add it to your beans.xml:

<bean id="employeeCollectionAdapter" class="org.example.EmployeeCollectionAdapter">
  <property name="href" value="employees"/>
</bean>

Now you'll need to configure the Abdera Provider. The Provider hosts all the workspaces and collections inside Abdera.

<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 id="provider">
  
    <a:workspace title="My Atom Workspace">
      <ref bean="fooCollectionAdapter"/>
    </a:workspace>
    
  </a:provider>

</beans>

Servlet Configuration

You'll probably also want set up the AbderaServlet so it can pull the ServiceContext from your ApplicationContext. Here is an example web.xml configuration:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath:your-applicationContext.xml
    </param-value>
  </context-param>

  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  
  <servlet id="abdera">
    <servlet-name>Abdera</servlet-name>  
    <servlet-class>org.apache.abdera.spring.SpringAbderaServlet</servlet-class>
  </servlet>

  <servlet-mapping id="abdera-mapping">
    <servlet-name>Abdera</servlet-name>
    <url-pattern>/atom/*</url-pattern>
  </servlet-mapping>
</web-app>