@Override protected void initialize(Class<?> beanClass) { super.initialize(beanClass); }
@Override public T getBeanContext() { return (T) super.getBeanContext(); }
private static boolean isLifecycleCallback(Invocation inv) { return InvocationHelper.isLifecycleCallback(inv); }
private StatefulSessionContainerMethodInvocation _buildNewInvocation(MethodInfo info, StatefulRemoteInvocation statefulInvocation, Class<?>[] initParameterTypes, Object[] initParameterValues) { StatefulSessionContainerMethodInvocation newStatefulInvocation = null; StatefulBeanContext ctx = null; // ENC is required in scope to create a session this.pushEnc(); try { ctx = getCache().create(initParameterTypes, initParameterValues); } finally { // Pop the ENC off the stack this.popEnc(); } Object newId = ctx.getId(); newStatefulInvocation = new StatefulSessionContainerMethodInvocation(info); newStatefulInvocation.setSessionId(newId); newStatefulInvocation.setArguments(statefulInvocation.getArguments()); newStatefulInvocation.setMetaData(statefulInvocation.getMetaData()); newStatefulInvocation.setAdvisor(getAdvisor()); SerializableMethod invokedMethod = new SerializableMethod(info.getUnadvisedMethod()); newStatefulInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION, SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS); return newStatefulInvocation; }
public TimerService getTimerService() throws IllegalStateException { Invocation invocation = CurrentInvocation.getCurrentInvocation(); if(InvocationHelper.isInjection(invocation)) throw new IllegalStateException("getTimerService() not allowed during injection (EJB3 4.5.2)"); return getContainer().getTimerService(); }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return (T) getAdvisor().resolveAnnotation(annotationClass); }
@Override protected void invokeCallback(BeanContext<?> beanContext, Class<? extends Annotation> callbackAnnotationClass) { // normally we would invoke through the BeanContainer, however we want a different stack and // we want to be able to use tx2 interceptors. try { Interceptor interceptors[] = this.getLifecycleInterceptors(callbackAnnotationClass); LifecycleMethodInterceptorsInvocation invocation = new SingletonLifecycleMethodInterceptorsInvocation((LegacySingletonBeanContext) beanContext, interceptors); invocation.setAdvisor(this.getAdvisor()); invocation.invokeNext(); } catch (Throwable t) { throw new RuntimeException(t); } }
protected <C> C getContainer(Invocation invocation) { return (C) AbstractContainer.getContainer(invocation.getAdvisor()); }
@SuppressWarnings("unchecked") public static <C extends EJBContainer> C getEJBContainer(Advisor advisor) { try { return (C) ((ManagedObjectAdvisor<Object, BeanContainer>) advisor).getContainer().getEJBContainer(); } catch(ClassCastException e) { throw new ClassCastException(e.getMessage() + " using " + advisor); } }
@Deprecated public AnnotationRepository getAnnotationRepository() { return getAdvisor().getAnnotations(); }
@Override public void setBeanContext(org.jboss.ejb3.interceptors.container.BeanContext<?> beanCtx) { if(beanCtx != null) { super.setBeanContext(beanCtx); if(callback != null) callback.attached((T) beanCtx); } else { if(callback != null) callback.released(getBeanContext()); super.setBeanContext(beanCtx); } }
private InvocationContext getInvocationContext(LifecycleMethodInterceptorsInvocation invocation) { BeanContext<?> beanContext = (BeanContext<?>) invocation.getBeanContext(); InvocationContext invocationContext = beanContext.createLifecycleInvocation(); invocationContext.setEJBContext(beanContext.getEJBContext()); return invocationContext; } }
@Override protected void createMethodTables() throws Exception { super.createMethodTables(); List<Method> virtualMethods = getVirtualMethods(); if(virtualMethods != null) { for(Method virtualMethod : virtualMethods) { long hash = MethodHashing.methodHash(virtualMethod); advisedMethods.put(hash, virtualMethod); } } }
public static UserTransaction getUserTransaction(BeanContext<?> ctx) { Invocation invocation = CurrentInvocation.getCurrentInvocation(); // TODO: also not allowed during construction if(InvocationHelper.isInjection(invocation)) throw new IllegalStateException("getUserTransaction() not allowed during injection (EJB3 4.4.1 & 4.5.2)"); Advisor advisor = invocation.getAdvisor(); TransactionManagementType type = TxUtil.getTransactionManagementType(advisor); if (type != TransactionManagementType.BEAN) throw new IllegalStateException("Container " + advisor.getName() + ": it is illegal to inject UserTransaction into a CMT bean"); return new UserTransactionImpl(); }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field) { return (T) getAdvisor().resolveAnnotation(field, annotationType); }
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) { return getAdvisor().resolveAnnotation(annotationType) != null; }
@SuppressWarnings("unchecked") // public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz) public <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> annotationType) { if(clazz == getBeanClass()) return (T) getAdvisor().resolveAnnotation(annotationType); // TODO: this is not right return clazz.getAnnotation(annotationType); }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method) { if (clazz == this.getBeanClass()) { return (T) getAdvisor().resolveAnnotation(method, annotationType); } // TODO: this is not right return method.getAnnotation(annotationType); }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field) { if (clazz == this.getBeanClass()) { return (T) getAdvisor().resolveAnnotation(field, annotationType); } return field.getAnnotation(annotationType); }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method) { T annotation = (T) getAdvisor().resolveAnnotation(method, annotationType); if(annotation == null && method.isBridge()) annotation = getBridgedAnnotation(annotationType, method); return annotation; }