|
|
|
Re: Cannot set the request filter to my JaxRsApplication [message #1703309 is a reply to message #1703087] |
Thu, 30 July 2015 09:29  |
Eclipse User |
|
|
|
Hi,
I had the same issue.
My soltion was
public class JaxRsAppExt extends JaxRsApplication {
private ContextServiceInjectableProvider contextServiceInjector;
private InjectServiceInjectableProvider injectServiceInjector;
private final Bundle bundle;
public JaxRsAppExt(final String id, final IRuntimeContext context, final Bundle bundle) {
super(id, context);
this.bundle = bundle;
}
@SuppressWarnings("unchecked")
@Override
protected Application createJaxRsApplication() {
final Application app = super.createJaxRsApplication();
if (null != this.contextServiceInjector) {
app.getSingletons().add(this.contextServiceInjector);
}
if (null != this.injectServiceInjector) {
app.getSingletons().add(this.injectServiceInjector);
}
((ResourceConfig) app).getContainerRequestFilters().add(0, APIAuthFilter.class);
((ResourceConfig) app).getContainerResponseFilters().add(0, APIAuthFilter.class);
((ResourceConfig) app).getResourceFilterFactories().add(0, RolesAllowedResourceFilterFactory.class);
return app;
}
@Override
protected void doDestroy() {
try {
// call super
super.doDestroy();
} finally {
if (null != this.contextServiceInjector) {
this.contextServiceInjector.dispose();
this.contextServiceInjector = null;
}
if (null != this.injectServiceInjector) {
this.injectServiceInjector.dispose();
this.injectServiceInjector = null;
}
}
}
@Override
protected void doInit() throws IllegalStateException, Exception {
// create service injector
this.contextServiceInjector = new ContextServiceInjectableProvider(this.bundle.getBundleContext());
this.injectServiceInjector = new InjectServiceInjectableProvider(this.bundle.getBundleContext());
// call super
super.doInit();
}
@Override
protected Set<Class<?>> getJaxRsClasses() {
return new BundleScanningResourceConfig(this.bundle).getClasses();
}
}
Then you adding over porperties ir
[Updated on: Thu, 30 July 2015 09:31] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03020 seconds