Search in sources :

Example 1 with ConstructorInterceptorInvocationContext

use of org.apache.webbeans.intercept.ConstructorInterceptorInvocationContext in project meecrowave by apache.

the class JAXRSFieldInjectionInterceptor method doInject.

private void doInject(final InvocationContext ic) throws Exception {
    final Message current = JAXRSUtils.getCurrentMessage();
    if (current != null) {
        final OperationResourceInfoStack stack = OperationResourceInfoStack.class.cast(current.get(OperationResourceInfoStack.class.getName()));
        if (stack != null && !stack.isEmpty()) {
            final Object instance;
            if (ConstructorInterceptorInvocationContext.class.isInstance(ic)) {
                final ConstructorInterceptorInvocationContext constructorInterceptorInvocationContext = ConstructorInterceptorInvocationContext.class.cast(ic);
                constructorInterceptorInvocationContext.directProceed();
                instance = constructorInterceptorInvocationContext.getNewInstance();
            } else {
                instance = ic.getTarget();
            }
            Application application = null;
            final Object appInfo = current.getExchange().getEndpoint().get(Application.class.getName());
            if (ApplicationInfo.class.isInstance(appInfo)) {
                application = ApplicationInfo.class.cast(appInfo).getProvider();
            }
            synchronized (this) {
                if (injected.get()) {
                    return;
                }
                InjectionUtils.injectContextProxiesAndApplication(stack.lastElement().getMethodInfo().getClassResourceInfo(), instance, application, ProviderFactory.getInstance(current));
                injected.compareAndSet(false, true);
            }
        }
    }
}
Also used : ConstructorInterceptorInvocationContext(org.apache.webbeans.intercept.ConstructorInterceptorInvocationContext) Message(org.apache.cxf.message.Message) OperationResourceInfoStack(org.apache.cxf.jaxrs.model.OperationResourceInfoStack) Application(javax.ws.rs.core.Application)

Aggregations

Application (javax.ws.rs.core.Application)1 OperationResourceInfoStack (org.apache.cxf.jaxrs.model.OperationResourceInfoStack)1 Message (org.apache.cxf.message.Message)1 ConstructorInterceptorInvocationContext (org.apache.webbeans.intercept.ConstructorInterceptorInvocationContext)1