use of org.apache.openejb.core.ThreadContext in project tomee by apache.
the class EjbWsContext method getMessageContext.
@Override
public MessageContext getMessageContext() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final MessageContext messageContext = threadContext.get(MessageContext.class);
if (messageContext == null) {
throw new IllegalStateException("Only calls on the service-endpoint have a MessageContext.");
}
return messageContext;
}
use of org.apache.openejb.core.ThreadContext in project tomee by apache.
the class EjbWsContext method getMessageContext.
public MessageContext getMessageContext() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final MessageContext messageContext = threadContext.get(MessageContext.class);
if (messageContext == null) {
throw new IllegalStateException("Only calls on the service-endpoint have a MessageContext.");
}
return messageContext;
}
use of org.apache.openejb.core.ThreadContext in project tomee by apache.
the class EjbWsContext method getAddressingSupport.
private AddressingSupport getAddressingSupport() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
if (wsaSupport == null) {
throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
}
return wsaSupport;
}
use of org.apache.openejb.core.ThreadContext in project tomee by apache.
the class MdbInstanceFactory method freeInstance.
/**
* Frees an instance no longer needed by the resource adapter. This method makes all the necessary lifecycle
* callbacks and decrements the instance count. This method should not be used to disposed of beans that have
* thrown a system exception. Instead the discardInstance method should be called.
*
* @param instance the bean instance to free
* @param ignoredInstanceCount
*/
public void freeInstance(final Instance instance, final boolean ignoredInstanceCount) {
if (instance == null) {
throw new NullPointerException("bean is null");
}
// decrement the instance count
if (!ignoredInstanceCount) {
synchronized (this) {
instanceCount--;
}
}
final ThreadContext callContext = ThreadContext.getThreadContext();
final Operation originalOperation = callContext == null ? null : callContext.getCurrentOperation();
final BaseContext.State[] originalAllowedStates = callContext == null ? null : callContext.getCurrentAllowedStates();
try {
// call post destroy method
if (callContext != null) {
callContext.setCurrentOperation(Operation.PRE_DESTROY);
}
final Method remove = instance.bean instanceof MessageDrivenBean ? MessageDrivenBean.class.getMethod("ejbRemove") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.PRE_DESTROY, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
if (instance.creationalContext != null) {
instance.creationalContext.release();
}
} catch (final Throwable re) {
MdbInstanceFactory.logger.error("The bean instance " + instance.bean + " threw a system exception:" + re, re);
} finally {
if (callContext != null) {
callContext.setCurrentOperation(originalOperation);
callContext.setCurrentAllowedStates(originalAllowedStates);
}
}
}
use of org.apache.openejb.core.ThreadContext in project tomee by apache.
the class AbstractSecurityService method getCallerPrincipal.
@Override
public Principal getCallerPrincipal() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
if (threadContext == null) {
final Identity id = clientIdentity.get();
if (id != null) {
return getCallerPrincipal(id.getSubject().getPrincipals());
}
return null;
}
final SecurityContext securityContext = threadContext.get(SecurityContext.class);
final Set<Principal> principals = securityContext.subject.getPrincipals();
return getCallerPrincipal(principals);
}
Aggregations