mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
RESTful support via Jersey.
This commit is contained in:
parent
aa8ebebac8
commit
8b374dd006
@ -26,12 +26,12 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<version>${slf4jVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<version>${slf4jVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
@ -65,5 +65,6 @@
|
||||
<properties>
|
||||
<bootstrap>true</bootstrap>
|
||||
<logbackVersion>1.0.11</logbackVersion>
|
||||
<slf4jVersion>1.7.5</slf4jVersion>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<moduleClass>com.pmease.commons.jersey.PluginModule</moduleClass>
|
||||
<moduleClass>com.pmease.commons.jersey.JerseyPluginModule</moduleClass>
|
||||
<jerseyVersion>1.17</jerseyVersion>
|
||||
</properties>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.pmease.commons.jersey;
|
||||
import java.util.Collection;
|
||||
import com.pmease.commons.loader.AbstractPlugin;
|
||||
|
||||
public class Plugin extends AbstractPlugin {
|
||||
public class JerseyPlugin extends AbstractPlugin {
|
||||
|
||||
@Override
|
||||
public Collection<?> getExtensions() {
|
||||
@ -0,0 +1,25 @@
|
||||
package com.pmease.commons.jersey;
|
||||
|
||||
import com.pmease.commons.loader.AbstractPlugin;
|
||||
import com.pmease.commons.loader.AbstractPluginModule;
|
||||
|
||||
/**
|
||||
* NOTE: Do not forget to rename moduleClass property defined in the pom if
|
||||
* you've renamed this class.
|
||||
*
|
||||
*/
|
||||
public class JerseyPluginModule extends AbstractPluginModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
|
||||
// put your guice bindings here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends AbstractPlugin> getPluginClass() {
|
||||
return JerseyPlugin.class;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
package com.pmease.commons.jersey;
|
||||
|
||||
import com.pmease.commons.loader.AbstractPlugin;
|
||||
import com.pmease.commons.loader.AbstractPluginModule;
|
||||
import com.sun.jersey.guice.JerseyServletModule;
|
||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||
|
||||
/**
|
||||
* NOTE: Do not forget to rename moduleClass property defined in the pom if
|
||||
* you've renamed this class.
|
||||
*
|
||||
*/
|
||||
public class PluginModule extends AbstractPluginModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
|
||||
// put your guice bindings here
|
||||
install(new JerseyServletModule() {
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
// Bind at least one resource here as otherwise Jersey will report error.
|
||||
bind(DummyResource.class);
|
||||
|
||||
// Route all RESTful requests through GuiceContainer
|
||||
serve("/rest/*").with(GuiceContainer.class);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends AbstractPlugin> getPluginClass() {
|
||||
return Plugin.class;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.pmease.commons.jersey;
|
||||
|
||||
import com.sun.jersey.guice.JerseyServletModule;
|
||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||
|
||||
public class RestServletModule extends JerseyServletModule {
|
||||
|
||||
protected void configureServlets() {
|
||||
// Bind at least one resource here as otherwise Jersey will report error.
|
||||
bind(DummyResource.class);
|
||||
|
||||
// Route all RESTful requests through GuiceContainer
|
||||
serve(getRestPath()).with(GuiceContainer.class);
|
||||
}
|
||||
|
||||
protected String getRestPath() {
|
||||
return "/rest/*";
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import org.apache.wicket.protocol.http.WebApplication;
|
||||
|
||||
import com.pmease.commons.bootstrap.Bootstrap;
|
||||
import com.pmease.commons.hibernate.Hibernate;
|
||||
import com.pmease.commons.jersey.RestServletModule;
|
||||
import com.pmease.commons.loader.AbstractPlugin;
|
||||
import com.pmease.commons.loader.AbstractPluginModule;
|
||||
import com.pmease.commons.util.FileUtils;
|
||||
@ -21,6 +22,8 @@ public class PluginModule extends AbstractPluginModule {
|
||||
new File(Bootstrap.installDir, "conf/hibernate.properties"));
|
||||
bind(Properties.class).annotatedWith(Hibernate.class).toInstance(hibernateProps);
|
||||
|
||||
install(new RestServletModule());
|
||||
|
||||
bind(HelloGuice.class);
|
||||
bind(GuicyInterface.class).to(GuicyInterfaceImpl.class);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user