mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
using google guice instead of weld
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -17,11 +17,20 @@
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>java.net2</id>
|
||||
<name>Repository hosting the jee6 artifacts</name>
|
||||
<url>http://download.java.net/maven/2</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>guice-maven</id>
|
||||
<name>guice maven</name>
|
||||
<url>http://guiceyfruit.googlecode.com/svn/repo/releases</url>
|
||||
</repository>
|
||||
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<version>6.0</version>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -40,44 +40,60 @@
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>1.1.0-ea</version>
|
||||
<scope>provided</scope>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<version>1.1.0-ea</version>
|
||||
<scope>provided</scope>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-bundle</artifactId>
|
||||
<version>1.1.0-ea</version>
|
||||
<scope>provided</scope>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-guice</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-servlet</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1-beta-1</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.1.25</version>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>scm-webapp</finalName>
|
||||
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<jersey.version>1.4-ea06</jersey.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
||||
<profile>
|
||||
|
||||
80
scm-webapp/src/main/java/sonia/scm/ContextListener.java
Normal file
80
scm-webapp/src/main/java/sonia/scm/ContextListener.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
|
||||
import sonia.scm.api.rest.UriExtensionsConfig;
|
||||
import sonia.scm.security.Authenticator;
|
||||
import sonia.scm.security.DemoAuthenticator;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import com.sun.jersey.api.core.PackagesResourceConfig;
|
||||
import com.sun.jersey.api.core.ResourceConfig;
|
||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||
import com.sun.jersey.spi.container.servlet.ServletContainer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ContextListener extends GuiceServletContextListener
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String REST_MAPPING = "/api/rest/*";
|
||||
|
||||
/** Field description */
|
||||
public static final String REST_PACKAGE = "sonia.scm.api.rest";
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Injector getInjector()
|
||||
{
|
||||
return Guice.createInjector(new ServletModule()
|
||||
{
|
||||
@Override
|
||||
protected void configureServlets()
|
||||
{
|
||||
bind(Authenticator.class).to(DemoAuthenticator.class);
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
|
||||
/*
|
||||
* params.put("com.sun.jersey.spi.container.ContainerRequestFilters",
|
||||
* "com.sun.jersey.api.container.filter.LoggingFilter");
|
||||
* params.put("com.sun.jersey.spi.container.ContainerResponseFilters",
|
||||
* "com.sun.jersey.api.container.filter.LoggingFilter");
|
||||
* params.put("com.sun.jersey.config.feature.Trace", "true");
|
||||
* params.put("com.sun.jersey.config.feature.TracePerRequest", "true");
|
||||
*/
|
||||
params.put(ResourceConfig.FEATURE_REDIRECT, Boolean.TRUE.toString());
|
||||
params.put(ServletContainer.RESOURCE_CONFIG_CLASS,
|
||||
UriExtensionsConfig.class.getName());
|
||||
params.put(PackagesResourceConfig.PROPERTY_PACKAGES, REST_PACKAGE);
|
||||
serve(REST_MAPPING).with(GuiceContainer.class, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ package sonia.scm.api.rest.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.User;
|
||||
@@ -17,9 +19,6 @@ import sonia.scm.security.Authenticator;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
@@ -36,7 +35,6 @@ import javax.ws.rs.core.Response;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
@Path("authentication")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public class AuthenticationResource
|
||||
|
||||
@@ -16,8 +16,6 @@ import sonia.scm.group.Group;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@@ -26,7 +24,6 @@ import javax.ws.rs.core.MediaType;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
@Path("groups")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public class GroupResource extends AbstractResource<Group>
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
@@ -28,7 +27,6 @@ import javax.ws.rs.core.MediaType;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
@Path("repositories")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public class RepositoryResource extends AbstractResource<Repository>
|
||||
|
||||
@@ -9,6 +9,7 @@ package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import sonia.scm.User;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -17,7 +18,6 @@ import java.io.IOException;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
@@ -25,7 +25,6 @@ import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -34,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@WebFilter(urlPatterns = "/api/rest/*")
|
||||
public class SecurityFilter implements Filter
|
||||
{
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Document : beans.xml
|
||||
Created on : September 3, 2010, 2:32 PM
|
||||
Author : sdorra
|
||||
Description:
|
||||
Purpose of the document follows.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
|
||||
|
||||
<!--
|
||||
<alternatives>
|
||||
<class></class>
|
||||
</alternatives>
|
||||
-->
|
||||
|
||||
</beans>
|
||||
@@ -1,35 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Jersey Web Application</servlet-name>
|
||||
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
|
||||
<init-param>
|
||||
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>com.sun.jersey.config.property.packages</param-name>
|
||||
<param-value>sonia.scm.api.rest</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
|
||||
<param-value>sonia.scm.api.rest.UriExtensionsConfig</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<listener>
|
||||
<listener-class>sonia.scm.ContextListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Jersey Web Application</servlet-name>
|
||||
<url-pattern>/api/rest/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<filter>
|
||||
<filter-name>guiceFilter</filter-name>
|
||||
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>guiceFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
|
||||
Reference in New Issue
Block a user