/** * Creates a WorkContext for the request. * <p/> * client that is wired to it. Otherwise, it is null. * * @param header the serialized work context header * @return the work context */ @SuppressWarnings({"unchecked"}) protected WorkContext setWorkContext(byte[] header) { try { WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext(); if (header == null || header.length == 0) { return workContext; } List<CallbackReference> stack = CallbackReferenceSerializer.deserialize(header); // add the last callback twice as it will be needed when the callback is made back through the binding if (!stack.isEmpty()) { stack.add(stack.get(stack.size() - 1)); } workContext.addCallbackReferences(stack); return workContext; } catch (IOException e) { throw new ServiceRuntimeException("Error deserializing callback references", e); } }
public <T> T getHeader(Class<T> type, String name) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getHeader(type, name); }
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { req = new HttpServletRequestWrapper(req); ClassLoader old = Thread.currentThread().getContextClassLoader(); WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); workContext.setHeader("fabric3.httpRequest", req); workContext.setHeader("fabric3.httpResponse", res); servlet.service(req, res); } catch (ServletException se) { se.printStackTrace(); throw se; } catch (IOException ie) { ie.printStackTrace(); throw ie; } catch (Throwable t) { t.printStackTrace(); throw new ServletException(t); } finally { Thread.currentThread().setContextClassLoader(old); workContext.reset(); } }
public SecuritySubject getCurrentSubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject(); }
public T call() throws Exception { WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext(); try { workContext.setSubject(subject); workContext.addHeaders(headers); workContext.addCallbackReferences(stack); return delegate.call(); } finally { workContext.reset(); } } }
public void removeHeader(String name) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); workContext.removeHeader(name); } }
WorkContextCache.getAndResetThreadWorkContext(); ClassLoader old = Thread.currentThread().getContextClassLoader(); try {
public void removeHeader(String name) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); workContext.removeHeader(name); } }
public void destroy() throws ShutdownException { // destroy system components WorkContextCache.getAndResetThreadWorkContext(); scopeContainer.stopAllContexts(); try { repository.shutdown(); } catch (RepositoryException e) { throw new ShutdownException(e); } }
public void setHeader(String name, Object value) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); workContext.setHeader(name, value); }
public void run() { WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext(); try { workContext.setSubject(subject); workContext.addHeaders(headers); workContext.addCallbackReferences(stack); delegate.run(); } finally { workContext.reset(); } } }
public SecuritySubject getCurrentSubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject(); }
Object invoke(Method method, Object[] args) throws MBeanException, ReflectionException { WorkContext workContext = WorkContextCache.getAndResetThreadWorkContext(); try { T instance = objectFactory.getInstance(); return method.invoke(instance, args); } catch (ObjectCreationException e) { throw new ReflectionException(e); } catch (IllegalAccessException e) { throw new AssertionError(e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); cause.printStackTrace(); if (cause instanceof Exception) { throw new MBeanException((Exception) e.getCause()); } else { throw new ReflectionException(e); } } finally { workContext.reset(); } } }
public void setHeader(String name, Object value) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); workContext.setHeader(name, value); }
public void onLeaderElected(String name) { if (topologyService != null && !topologyService.isZoneLeader()) { // this runtime is not the leader, ignore return; } activated = true; // this runtime was elected leader, start the components synchronized (deferredContexts) { WorkContextCache.getAndResetThreadWorkContext(); for (QName deployable : deferredContexts) { try { super.startContext(deployable); } catch (GroupInitializationException e) { monitor.leaderElectionError(e); } } deferredContexts.clear(); } }
public <T> T getHeader(Class<T> type, String name) { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getHeader(type, name); }
public void handle(Object event, boolean endOfBatch) { WorkContextCache.getAndResetThreadWorkContext(); Object instance; try { instance = component.getInstance(); } catch (InstanceLifecycleException e) { throw new InvocationRuntimeException(e); } try { invoke(event, instance); } finally { try { component.releaseInstance(instance); } catch (InstanceDestructionException e) { throw new InvocationRuntimeException(e); } } }
public Subject getSecuritySubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject().getJaasSubject(); }
public void execute(StopContextCommand command) throws ExecutionException { QName deployable = command.getDeployable(); WorkContextCache.getAndResetThreadWorkContext(); try { compositeScopeContainer.stopContext(deployable); if (domainScopeContainer != null) { // domain scope not available during bootstrap domainScopeContainer.stopContext(deployable); } } catch (ComponentException e) { throw new ExecutionException(e); } channelManager.stopContext(deployable); if (monitor != null && command.isLog()) { monitor.undeployed(deployable); } }
public Subject getSecuritySubject() { WorkContext workContext = WorkContextCache.getThreadWorkContext(); return workContext.getSubject().getJaasSubject(); }