jersey2-toolkit
A collection of useful Jersey2 Features
This project contains a collection of mix-and-match Jersey2 Features which can enhance and accelerate your web service development. Features can be loaded wholesale, or can be assembled on an as-needed basis.
<dependency>
<groupId>net.krotscheck.jersey2</groupId>
<artifactId>jersey2-toolkit</artifactId>
<version>2.1.1</version>
</dependency>
Basic Usage
Each feature is a distinct submodule, to isolate dependencies. Each submodule contains one feature class which includes all components of that feature, which may be used as follows:
import net.krotscheck.jersey2.hibernate.HibernateFeature;
import org.glassfish.jersey.server.ResourceConfig;
public class YourApplication extends ResourceConfig {
public YourApplication() {
register(HibernateFeature.class);
}
}
Advanced Usage
In all cases, each component is dependent on an injection chain from the other components, and is kept relatively isolated. Furthermore, every component injector contains a public internal class called Binder which may be used to construct your own feature. Therefore, if you have a custom implementation of a particular component that you would rather use, or you would like to exclude some feature, you may construct your own as follows:
public final class CustomHibernateFeature implements Feature {
@Override
public boolean configure(final FeatureContext context) {
// Custom Binders
context.register(new MyCustomSessionFactoryFactory.Binder());
// Library Provided Binders
context.register(new HibernateSessionFactory.Binder());
context.register(new HibernateServiceRegistryFactory.Binder());
// Disable search indexing
// context.register(new FulltextSearchFactoryFactory.Binder());
// context.register(new FulltextSessionFactory.Binder());
// context.register(new SearchIndexContextListener.Binder());
return true;
}
}