@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(); } } };
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final Handle handle = (Handle) context.getParameters()[0]; handle.getEJBObject().remove(); return null; } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { if ((context.getMethod().getName().equals("equals")) || context.getMethod().getName().equals("isIdentical")) { final Object other = context.getParameters()[0]; if (other == null) { return false; } final Class<?> proxyType = componentView.getProxyClass(); return proxyType.isAssignableFrom(other.getClass()); } else if (context.getMethod().getName().equals("hashCode")) { //use the identity of the component view as a hash code return componentView.hashCode(); } else { return context.proceed(); } } }
/** * {@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 context) throws Exception { if (context.getMethod().getName().equals("equals") || context.getMethod().getName().equals("isIdentical")) { final Object other = context.getParameters()[0]; final ComponentView componentView = context.getPrivateData(ComponentView.class); final Class<?> proxyType = componentView.getProxyClass(); final SessionID sessionId = context.getPrivateData(SessionID.class); if( proxyType.isAssignableFrom(other.getClass())) { //now we know that this is an ejb for the correct component view //as digging out the session id from the proxy object is not really //a viable option, we invoke equals() for the other instance with a //SessionIdHolder as the other side return other.equals(new SessionIdHolder(sessionId)); } else if(other instanceof SessionIdHolder) { return sessionId.equals( ((SessionIdHolder)other).sessionId); } else { return false; } } else if (context.getMethod().getName().equals("hashCode")) { final SessionID sessionId = context.getPrivateData(SessionID.class); //use the identity of the component view as a hash code return sessionId.hashCode(); } else { return context.proceed(); } }
@Override public ManagedReference create(final InterceptorContext context) { final ConstructionHandle<?> ctx = context.getPrivateData(ConstructionHandle.class); final WeldInjectionContext weldCtx = context.getPrivateData(WeldInjectionContext.class); if (ctx != null) { // @AroundConstructor interception enabled Object instance = ctx.proceed(context.getParameters(), context.getContextData()); // let Weld create the instance now return new WeldManagedReference(weldCtx.getContext(), instance); } else { // @AroundConstructor interception handled by Weld alone - no integration with EJB interceptors return new WeldManagedReference(weldCtx.getContext(), weldCtx.produce()); } }
public Object[] getParameters() { final Object[] parameters = InterceptorContext.this.getParameters(); if (parameters == null) { throw new IllegalStateException("Cannot call InvocationContext.getParameters() in a lifecycle interceptor method"); } return parameters; }
/** {@inheritDoc} */ public Object processInvocation(final InterceptorContext context) throws Exception { try { return method.invoke(target, (Object[]) context.getParameters()); } catch (InvocationTargetException e) { throw rethrow(e.getCause()); } } }
@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(); } } };
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final Handle handle = (Handle) context.getParameters()[0]; handle.getEJBObject().remove(); return null; } }
public Object processInvocation(final InterceptorContext interceptorContext) throws Exception { final Handle handle = (Handle) interceptorContext.getParameters()[0]; handle.getEJBObject().remove(); return null; } };
@Override public Object processInvocation(final InterceptorContext context) throws Exception { if ((context.getMethod().getName().equals("equals")) || context.getMethod().getName().equals("isIdentical")) { final Object other = context.getParameters()[0]; if (other == null) { return false; } final Class<?> proxyType = componentView.getProxyClass(); return proxyType.isAssignableFrom(other.getClass()); } else if (context.getMethod().getName().equals("hashCode")) { //use the identity of the component view as a hash code return componentView.hashCode(); } else { return context.proceed(); } } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final ComponentView view = viewToCreate.getValue(); final HashMap<Object, Object> ctx = new HashMap<Object, Object>(); ctx.put(EJB_CREATE_METHOD_KEY, ejbCreate); ctx.put(EJB_POST_CREATE_METHOD_KEY, ejbPostCreate); ctx.put(PARAMETERS_KEY, context.getParameters()); try { final ManagedReference instance = view.createInstance(ctx); return instance.getInstance(); } catch (RuntimeException e) { //throw the correct exception type Throwable cause = e.getCause(); if (cause instanceof CreateException) { throw (CreateException) cause; } throw e; } } };
/** * {@inheritDoc} */ public Object processInvocation(final InterceptorContext context) throws Exception { final ManagedReference reference = instanceRef.get(); 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()); } } }
public Object processInvocation(final InterceptorContext context) throws Exception { final EntityBeanComponent component = getComponent(context, EntityBeanComponent.class); if(remote) { component.getEJBObject(context.getParameters()[0]).remove(); } else { component.getEJBLocalObject(context.getParameters()[0]).remove(); } return null; } };
public Object processInvocation(final InterceptorContext context) throws Exception { final Object primaryKey = context.getPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY); if (context.getMethod().getName().equals("equals") && context.getParameters().length == 1 && context.getMethod().getParameterTypes()[0] == Object.class) { final Object other = context.getParameters()[0]; final Class<?> proxyType = componentView.getProxyClass(); if( proxyType.isAssignableFrom(other.getClass())) { //now we know that this is an ejb for the correct component view //as digging out the session id from the proxy object is not really //a viable option, we invoke equals() for the other instance with a //PrimaryKeyHolder as the other side return other.equals(new PrimaryKeyHolder(primaryKey)); } else if(other instanceof PrimaryKeyHolder) { return primaryKey.equals(((PrimaryKeyHolder) other).primaryKey); } else { return false; } } else if (context.getMethod().getName().equals("hashCode")) { //use the identity of the component view as a hash code return primaryKey.hashCode(); } else { return context.proceed(); } } }
/** * {@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()); } } }
/** * {@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()); } } }
public Object processInvocation(final InterceptorContext context) throws Exception { final Method method = context.getMethod(); if (method == null) { return null; } try { Object target = context.getTarget(); if (target == null) { throw msg.nullProperty("target", context); } return method.invoke(target, 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 context) throws Exception { final EntityBeanComponentInstance instance = (EntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class); try { final Object primaryKey = context.getPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY); final Object other = context.getParameters()[0]; if (!componentView.getViewClass().isAssignableFrom(other.getClass())) { return false; } if (context.getMethod().getParameterTypes()[0].equals(EJBLocalObject.class)) { return ((EJBLocalObject) other).getPrimaryKey().equals(primaryKey); } else { return ((EJBObject) other).getPrimaryKey().equals(primaryKey); } } finally { instance.getComponent().getCache().release(instance, true); } } }