ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); Object target; if (Modifier.isStatic(method.getModifiers())) { target = null; } else { target = ((ManagedReference) componentInstance.getInstanceData(targetKey)).getInstance(); if (target == null) { throw EeLogger.ROOT_LOGGER.injectionTargetNotFound(); ManagedReference reference = factory.getReference(); if (reference == null && optional) { return context.proceed(); componentInstance.setInstanceData(valueKey, reference); final InvocationType invocationType = context.getPrivateData(InvocationType.class); try { context.putPrivateData(InvocationType.class, InvocationType.DEPENDENCY_INJECTION); method.invoke(target, reference.getInstance()); } finally { context.putPrivateData(InvocationType.class, invocationType); } finally { if (!ok) { componentInstance.setInstanceData(valueKey, null); reference.release();
@Override public String getInstanceClassName() { if(factory instanceof ContextListManagedReferenceFactory) { return ((ContextListManagedReferenceFactory) factory).getInstanceClassName(); } ManagedReference ref = getReference(); try { final Object value = ref.getInstance(); return value != null ? value.getClass().getName() : ContextListManagedReferenceFactory.DEFAULT_INSTANCE_CLASS_NAME; } finally { ref.release(); } }
public Object processInvocation(final InterceptorContext context) throws Exception { final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); final ManagedReference existing = (ManagedReference) componentInstance.getInstanceData(contextKey); if (existing == null) { final ManagedReference reference = componentFactory.create(context); boolean ok = false; try { componentInstance.setInstanceData(contextKey, reference); if (setTarget) { context.setTarget(reference.getInstance()); } Object result = context.proceed(); ok = true; return result; } finally { if (!ok) { reference.release(); componentInstance.setInstanceData(contextKey, reference); } } } else { return context.proceed(); } }
@Override public Object run() { final ManagedReference managedReference = ManagedReferenceFactory.class.cast(object).getReference(); return managedReference != null ? managedReference.getInstance() : null; } });
@Override public Object processInvocation(final InterceptorContext context) throws Exception { WeldInjectionContext injectionContext = context.getPrivateData(WeldInjectionContext.class); ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(BasicComponentInstance.INSTANCE_KEY); if (reference != null) { injectionContext.inject(reference.getInstance()); } return context.proceed(); } }
final ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(contextKey); final Object instance = reference.getInstance(); try { final Method method = this.method; if (withContext) { final Method oldMethod = context.getMethod(); try { if (this.lifecycleMethod) { context.setMethod(null); return method.invoke(instance, context.getInvocationContext()); } else if (this.changeMethod) {
@Override public T getInstance() { return (T) reference.getInstance(); }
public Object processInvocation(final InterceptorContext context) throws Exception { final ManagedReference existing = referenceReference.get(); if (existing == null) { final ManagedReference reference = componentInstantiator.getReference(); boolean ok = false; try { referenceReference.set(reference); context.setTarget(reference.getInstance()); Object result = context.proceed(); ok = true; return result; } finally { context.setTarget(null); if (!ok) { reference.release(); referenceReference.set(null); } } } else { return context.proceed(); } } }
target = null; } else { target = targetReference.get().getInstance(); if (target == null) { throw MESSAGES.injectionTargetNotFound(); ManagedReference reference = factory.getReference(); if (reference == null && optional) { return context.proceed(); final InvocationType invocationType = context.getPrivateData(InvocationType.class); try { context.putPrivateData(InvocationType.class, InvocationType.DEPENDENCY_INJECTION); method.invoke(target, reference.getInstance()); } finally { context.putPrivateData(InvocationType.class, invocationType); if (!ok) { valueReference.set(null); reference.release();
/** * {@inheritDoc} */ public Object processInvocation(final InterceptorContext context) throws Exception { final ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(contextKey); final Object instance = reference.getInstance(); try { return method.invoke(instance, context.getParameters()); } catch (IllegalAccessException e) { final IllegalAccessError n = new IllegalAccessError(e.getMessage()); n.setStackTrace(e.getStackTrace()); throw n; } catch (InvocationTargetException e) { throw Interceptors.rethrow(e.getCause()); } } }
@Override public Object processInvocation(final InterceptorContext interceptorContext) throws Exception { final WSComponent wsComponent = (WSComponent)interceptorContext.getPrivateData(Component.class); BasicComponentInstance pojoComponentInstance = null; if (interceptorContext.getPrivateData(ManagedReference.class) != null) { ManagedReference reference = interceptorContext.getPrivateData(ManagedReference.class); pojoComponentInstance = (BasicComponentInstance)wsComponent.createInstance(reference.getInstance()); } else { pojoComponentInstance = wsComponent.getComponentInstance(); } interceptorContext.putPrivateData(ComponentInstance.class, pojoComponentInstance); return interceptorContext.proceed(); } }
/** * {@inheritDoc} */ public Object processInvocation(final InterceptorContext context) throws Exception { try { return context.proceed(); } finally { final ManagedReference managedReference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(contextKey); if (managedReference != null) { managedReference.release(); } } } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final ComponentView view = viewToCreate.getValue(); try { INIT_METHOD.set(method); INIT_PARAMETERS.set(context.getParameters()); final ManagedReference instance = view.createInstance(); return instance.getInstance(); } finally { INIT_METHOD.remove(); INIT_PARAMETERS.remove(); } } };
/** * {@inheritDoc} */ public Object processInvocation(final InterceptorContext context) throws Exception { // get the container-interceptor instance final Object interceptorInstance = interceptorInstanceRef.getInstance(); try { final Method method = this.method; return method.invoke(interceptorInstance, context.getInvocationContext()); } catch (IllegalAccessException e) { final IllegalAccessError n = new IllegalAccessError(e.getMessage()); n.setStackTrace(e.getStackTrace()); throw n; } catch (InvocationTargetException e) { throw Interceptors.rethrow(e.getCause()); } } }
@Override public void release() { reference.release(); } }
/** * {@inheritDoc} */ public final void destroy() { if (doneUpdater.compareAndSet(this, 0, 1)) try { preDestroy(); final ManagedReference reference = instanceReference.get(); if (reference != null) { final InterceptorContext interceptorContext = prepareInterceptorContext(); interceptorContext.setTarget(reference.getInstance()); interceptorContext.putPrivateData(InvocationType.class, InvocationType.PRE_DESTROY); preDestroy.processInvocation(interceptorContext); } } catch (Exception e) { ROOT_LOGGER.componentDestroyFailure(e, this); } finally { component.finishDestroy(); } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final EntityBeanComponentInstance instance = (EntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class); try { return viewToCreate.getValue().createInstance().getInstance(); } finally { instance.getComponent().getCache().release(instance, true); } } };
public Object getObjectInstance(final Object serviceValue, final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> environment) throws Exception { final ManagedReferenceFactory managedReferenceFactory = ManagedReferenceFactory.class.cast(serviceValue); return managedReferenceFactory.getReference().getInstance(); } }
@Override public Object processInvocation(InterceptorContext context) throws Exception { ManagedReference reference = (ManagedReference) context.getPrivateData(ComponentInstance.class).getInstanceData(BasicComponentInstance.INSTANCE_KEY); if (reference != null) { run(reference.getInstance()); } return context.proceed(); }