Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SC-24 - made tapestry-jersey able to take class providers. This is ma…

…inly used for registering ExceptionMapper(s).
  • Loading branch information...
commit b1761ab33ece97610a81fbd51bce0aef5d1a8954 1 parent 312a4c5
@yunglin authored
View
11 pom.xml
@@ -4,9 +4,9 @@
<artifactId>tapestry-jersey</artifactId>
<version>1.0.6-SNAPSHOT</version>
<parent>
- <groupId>org.sonatype.oss</groupId>
- <artifactId>oss-parent</artifactId>
- <version>2</version>
+ <groupId>com.bluetangstudio.common</groupId>
+ <artifactId>masterpom</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</parent>
<description>Jersey/JAX-RS Tapestry5 Integration</description>
@@ -92,6 +92,11 @@
<dependencies>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<version>${tapestry.version}</version>
View
42 src/main/java/com/bluetangstudio/shared/jersey/services/JerseyModule.java
@@ -14,34 +14,34 @@
package com.bluetangstudio.shared.jersey.services;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.ws.rs.core.Application;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
-import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.annotations.Service;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ScopeConstants;
import org.apache.tapestry5.ioc.annotations.EagerLoad;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.annotations.Primary;
import org.apache.tapestry5.ioc.annotations.Scope;
-import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.ApplicationGlobals;
import org.apache.tapestry5.services.HttpServletRequestFilter;
-import org.apache.tapestry5.services.SessionPersistedObjectAnalyzer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.ws.rs.core.Application;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
public class JerseyModule {
+ private static final Logger LOG = LoggerFactory.getLogger(JerseyModule.class);
+
/**
* Contribute the default value of {@link JerseySymbols.REQUEST_PATH_PREFIX} to Tapestry.
*
@@ -70,7 +70,19 @@ public void contributeHttpServletRequestHandler(OrderedConfiguration<HttpServlet
@Scope(ScopeConstants.DEFAULT)
@EagerLoad
public static Application buildJerseyRootResources(Collection<Object> configurations) {
- return new TapestryEnabledApplication(configurations);
+ List singletons = new LinkedList();
+ List classes = new LinkedList();
+
+ for(Object provider: configurations) {
+ if (provider instanceof Class<?>) {
+ classes.add(provider);
+ }else {
+ singletons.add(provider);
+ }
+ }
+
+ LOG.info("Start Jersey Application with singletons providers:({})\n and classes providers:({})", singletons, classes);
+ return new TapestryEnabledApplication(singletons, classes);
}
@Scope(ScopeConstants.DEFAULT)
View
18 src/main/java/com/bluetangstudio/shared/jersey/services/TapestryEnabledApplication.java
@@ -15,7 +15,6 @@
package com.bluetangstudio.shared.jersey.services;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -28,7 +27,9 @@
public class TapestryEnabledApplication extends Application {
private Set<Object> _singletons;
-
+
+ private Set<Class<?>> _classes;
+
/**
*
* @param singletons collection of Tapestry managed services and/or any thread-safe services.
@@ -36,12 +37,19 @@
* collection too.
*
*/
- public TapestryEnabledApplication(Collection<?> singletons) {
- _singletons = Collections.unmodifiableSet(new HashSet<Object>(singletons));
+ public TapestryEnabledApplication(Collection<?> singletons, Collection<Class<?>> classes) {
+ _singletons = new HashSet<Object>(singletons);
+ _classes = new HashSet<Class<?>>(classes);
}
-
+
+ @Override
public Set<Object> getSingletons() {
return _singletons;
}
+
+ @Override
+ public Set<java.lang.Class<?>> getClasses() {
+ return _classes;
+ }
}

0 comments on commit b1761ab

Please sign in to comment.
Something went wrong with that request. Please try again.