@Override public T get() { return ThreadLocalInvoker.this.get(); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // if no instance yet exists for the current thread then look one up // and stash it if (this.get() == null) { Context ctx = new InitialContext(); T t = (T) ctx.lookup(name); this.set(t); } return super.invoke(proxy,method,args); } }
public GrizzlyContainer(ResourceConfig rc, WebApplication app) throws ContainerException { this.application = app; setAllowEncodedSlash(rc.getFeature(GrizzlyServerFactory.FEATURE_ALLOW_ENCODED_SLASH)); GenericEntity<ThreadLocal<GrizzlyRequest>> requestThreadLocal = new GenericEntity<ThreadLocal<GrizzlyRequest>>(requestInvoker.getImmutableThreadLocal()) {}; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<GrizzlyRequest>>( requestThreadLocal.getType(), requestThreadLocal.getEntity())); GenericEntity<ThreadLocal<GrizzlyResponse>> responseThreadLocal = new GenericEntity<ThreadLocal<GrizzlyResponse>>(responseInvoker.getImmutableThreadLocal()) {}; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<GrizzlyResponse>>( responseThreadLocal.getType(), responseThreadLocal.getEntity())); }
/** * Creates a new Grizzly container. * * @param resourceConfig * The resource configuration. * @param application * The Web application the container delegates to for the handling of * HTTP requests. */ GrizzlyContainer(final ResourceConfig resourceConfig, final WebApplication application) { this.application = application; setAllowEncodedSlash(resourceConfig.getFeature(GrizzlyServerFactory.FEATURE_ALLOW_ENCODED_SLASH)); final GenericEntity<ThreadLocal<Request>> requestThreadLocal = new GenericEntity<ThreadLocal<Request>>( requestInvoker.getImmutableThreadLocal()) { }; resourceConfig.getSingletons().add( new ContextInjectableProvider<ThreadLocal<Request>>( requestThreadLocal.getType(), requestThreadLocal.getEntity())); final GenericEntity<ThreadLocal<Response>> responseThreadLocal = new GenericEntity<ThreadLocal<Response>>( responseInvoker.getImmutableThreadLocal()) { }; resourceConfig.getSingletons().add( new ContextInjectableProvider<ThreadLocal<Response>>( responseThreadLocal.getType(), responseThreadLocal.getEntity())); }
/** * Creates a new Grizzly container. * * @param resourceConfig * The resource configuration. * @param application * The Web application the container delegates to for the handling of * HTTP requests. */ GrizzlyContainer(final ResourceConfig resourceConfig, final WebApplication application) { this.application = application; setAllowEncodedSlash(resourceConfig.getFeature(GrizzlyServerFactory.FEATURE_ALLOW_ENCODED_SLASH)); final GenericEntity<ThreadLocal<Request>> requestThreadLocal = new GenericEntity<ThreadLocal<Request>>( requestInvoker.getImmutableThreadLocal()) { }; resourceConfig.getSingletons().add( new ContextInjectableProvider<ThreadLocal<Request>>( requestThreadLocal.getType(), requestThreadLocal.getEntity())); final GenericEntity<ThreadLocal<Response>> responseThreadLocal = new GenericEntity<ThreadLocal<Response>>( responseInvoker.getImmutableThreadLocal()) { }; resourceConfig.getSingletons().add( new ContextInjectableProvider<ThreadLocal<Response>>( responseThreadLocal.getType(), responseThreadLocal.getEntity())); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // if no instance yet exists for the current thread then look one up // and stash it if (this.get() == null) { Context ctx = new InitialContext(); T t = (T) ctx.lookup(name); this.set(t); } return super.invoke(proxy,method,args); } }
@Override public T get() { return ThreadLocalInvoker.this.get(); }
new GenericEntity<ThreadLocal<HttpServletRequest>>(requestInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletRequest>>( new GenericEntity<ThreadLocal<HttpServletResponse>>(responseInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletResponse>>(
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // if no instance yet exists for the current thread then look one up // and stash it if (this.get() == null) { Context ctx = new InitialContext(); T t = (T) ctx.lookup(name); this.set(t); } return super.invoke(proxy,method,args); } }
@Override public T get() { return ThreadLocalInvoker.this.get(); }
new GenericEntity<ThreadLocal<HttpServletRequest>>(requestInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletRequest>>( new GenericEntity<ThreadLocal<HttpServletResponse>>(responseInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletResponse>>(
new GenericEntity<ThreadLocal<HttpServletRequest>>(requestInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletRequest>>( new GenericEntity<ThreadLocal<HttpServletResponse>>(responseInvoker.getImmutableThreadLocal()) { }; rc.getSingletons().add(new ContextInjectableProvider<ThreadLocal<HttpServletResponse>>(