Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #27 from futures/JAXBification
JAXB replaces Freemarker, and Enunciate finally works.
  • Loading branch information
ajs6f committed Feb 5, 2013
2 parents abfc2cd + dee64f0 commit 3af4d67
Show file tree
Hide file tree
Showing 25 changed files with 512 additions and 334 deletions.
218 changes: 117 additions & 101 deletions pom.xml
Expand Up @@ -17,6 +17,7 @@
<modeshape.version>3.1.1.Final</modeshape.version>
<cxf.version>2.7.2</cxf.version>
<activemq.version>5.7.0</activemq.version>
<enunciate.version>1.26.2</enunciate.version>
</properties>


Expand Down Expand Up @@ -48,19 +49,19 @@
<artifactId>modeshape-jcr</artifactId>
</dependency>

<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>5.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>5.2.0.Final</version>
</dependency>

<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
<version>3.2.6.Final</version>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
<version>3.2.6.Final</version>
</dependency>

<dependency>
<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-jcr-api</artifactId>
</dependency>
Expand All @@ -82,11 +83,6 @@
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.19</version>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
Expand Down Expand Up @@ -127,78 +123,102 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-spring</artifactId>
<version>${activemq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-spring</artifactId>
<version>${activemq.version}</version>
</dependency>

<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.9</version>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.9</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-cxf-rt</artifactId>
<version>${enunciate.version}</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<!--This plugin's configuration is used to store Eclipse m2e settings only.
It has no influence on the Maven build itself. -->
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<versionRange>[2.15.2,)</versionRange>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<pluginManagement>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<versionRange>[2.15.2,)</versionRange>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.enunciate
</groupId>
<artifactId>
maven-enunciate-cxf-plugin
</artifactId>
<versionRange>
[1.26.2,)
</versionRange>
<goals>
<goal>docs</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -300,26 +320,22 @@
</webApp>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<!-- check for the latest version -->
<version>1.26</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
<configuration>

<!-- the directory where to put the docs -->
<docsDir>${project.build.directory}/docs</docsDir>

</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-cxf-plugin</artifactId>
<version>${enunciate.version}</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
<configuration>
<configFile>${basedir}/src/main/enunciate/enunciate.xml</configFile>
<docsDir>${project.build.directory}/docs</docsDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
10 changes: 10 additions & 0 deletions src/main/enunciate/enunciate.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
<modules>
<c disabled="true"/>
<csharp disabled="true"/>
<cxf disabled="true"/>
<jaxws-ri disabled="true"/>
</modules>
</enunciate>
42 changes: 8 additions & 34 deletions src/main/java/org/fcrepo/modeshape/AbstractResource.java
@@ -1,20 +1,15 @@
package org.fcrepo.modeshape;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.jcr.LoginException;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.codehaus.jackson.map.ObjectMapper;
import org.fcrepo.modeshape.identifiers.PidMinter;
Expand All @@ -23,11 +18,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
* Abstract superclass for Fedora JAX-RS Resources, providing convenience fields
* and methods.
Expand All @@ -40,6 +30,12 @@ public abstract class AbstractResource extends Constants {
final private Logger logger = LoggerFactory
.getLogger(AbstractResource.class);

/**
* Useful for constructing URLs
*/
@Context
UriInfo uriInfo;

/**
* Jackson JSON mapper. Should eventually be replaced by the use of proper
* JAX-RS Providers.
Expand All @@ -61,12 +57,6 @@ public abstract class AbstractResource extends Constants {

static protected Workspace ws;

/**
* A Freemarker Configuration for use in generating XML responses. Should
* eventually be replaced by the use of proper JAX-RS Providers.
*/
final static protected Configuration freemarker = new Configuration();

/**
* A convenience object provided by ModeShape for acting against the JCR
* repository.
Expand All @@ -79,10 +69,6 @@ public void initialize() throws LoginException, NoSuchWorkspaceException,

ws = repo.login("fedora").getWorkspace();
ws.getNamespaceRegistry().registerNamespace("test", "info:fedora/test");

freemarker.setObjectWrapper(new BeansWrapper());
// Specify the data source where the template files come from.
freemarker.setClassForTemplateLoading(this.getClass(), "/freemarker");
}

protected synchronized Response deleteResource(final String path)
Expand All @@ -109,16 +95,4 @@ protected synchronized Response deleteResource(final String path)
}
}

protected InputStream renderTemplate(final String templatename,
final Map<String, ?> map) throws RepositoryException, IOException,
TemplateException {

final Template template = freemarker.getTemplate(templatename);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
template.process(map, new OutputStreamWriter(out));
InputStream in = new ByteArrayInputStream(out.toByteArray());
out.close();
return in;
}

}

0 comments on commit 3af4d67

Please sign in to comment.