@Override protected void initializePolicy() { policy = new Ejb3TxPolicy(); }
public void setRollbackOnly() throws IllegalStateException { TxUtil.setRollbackOnly(); }
public boolean getRollbackOnly() throws IllegalStateException { return TxUtil.getRollbackOnly(); } }
TransactionManagementType type = TxUtil.getTransactionManagementType(advisor); if (type == TransactionManagementType.BEAN) return new NullInterceptor(); TransactionManager tm = this.getTransactionManager(); int timeout = resolveTransactionTimeout(advisor, method); TransactionAttributeType txType = getTxType(advisor, jp); return new TxInterceptor.Never(tm, policy); return new TxInterceptor.NotSupported(tm, policy, timeout); return new TxInterceptor.Mandatory(tm, policy, timeout);
public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) { // We have to do this until AOP supports matching based on annotation attributes TransactionManagementType type = TxUtil.getTransactionManagementType(advisor); if (type != TransactionManagementType.BEAN) return new NullInterceptor(); TransactionManager tm = TxUtil.getTransactionManager(); boolean stateful = advisor.resolveAnnotation(Stateful.class) != null; // Both MessageDriven and Stateless are stateless if(stateful) return new StatefulBMTInterceptor(tm); else return new StatelessBMTInterceptor(tm); } }
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(); }
public SessionSynchronizationInterceptor() { this.tm = TxUtil.getTransactionManager(); }
public void handleExceptionInOurTx(Invocation invocation, Throwable t, Transaction tx) throws Throwable { ApplicationException ae = TxUtil.getApplicationException(t.getClass(), invocation); if (ae != null) { if (ae.rollback()) setRollbackOnly(tx); throw t; } // if it's neither EJBException nor RemoteException if(!(t instanceof EJBException || t instanceof RemoteException)) { // errors and unchecked are wrapped into EJBException if(t instanceof Error) { t = new EJBException(formatException("Unexpected Error", t)); } else if (t instanceof RuntimeException) { t = new EJBException((Exception)t); } else { // an application exception throw t; } } setRollbackOnly(tx); throw t; }
public UserTransactionPropertyInjector(BeanProperty property, InjectionContainer container) { super(property); if (container instanceof EJBContainer) { TransactionManagementType type = TxUtil.getTransactionManagementType(((EJBContainer) container).getAdvisor()); if (type != TransactionManagementType.BEAN) throw new IllegalStateException("Container " + ((Container) container).getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean"); } }
public void inject(Object instance) { UserTransaction ut = new UserTransactionImpl(); property.set(instance, ut); } }
public void begin() throws NotSupportedException, SystemException { // Start the transaction tm.begin(); Transaction tx = tm.getTransaction(); if (log.isDebugEnabled()) log.debug("UserTx begin: " + tx); EJB3UserTransactionProvider.getSingleton().userTransactionStarted(); }
protected TransactionAttributeType getTxType(Advisor advisor, Joinpoint jp) { Method method = ((MethodJoinpoint) jp).getMethod(); return TxUtil.getTxType(advisor, method); }
public static ApplicationException getApplicationException(Class<?> exceptionClass, Invocation invocation) { return AbstractInterceptor.resolveAnnotation(invocation, exceptionClass, ApplicationException.class); }
public UserTransaction getUserTransaction() throws IllegalStateException { return TxUtil.getUserTransaction(beanContext); }
public Object invoke(Invocation invocation) throws Throwable { Transaction oldTx = tm.suspend(); try { return handleInvocation(invocation); } finally { if (oldTx != null) { tm.resume(oldTx); } } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.tm = TxUtil.getTransactionManager(); }
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException { TransactionManagementType mtype = TxUtil.getTransactionManagementType(container.getAdvisor()); if (mtype == javax.ejb.TransactionManagementType.BEAN) return false; // JBPAPP-1668: the method can be called by anybody using the interface method (== unadvised) Method advisedMethod = container.getMethodInfo(method).getAdvisedMethod(); TransactionAttribute attr = (TransactionAttribute)container.resolveAnnotation(advisedMethod, TransactionAttribute.class); if (attr == null) { attr =(TransactionAttribute)container.resolveAnnotation(TransactionAttribute.class); } TransactionAttributeType type = TransactionAttributeType.REQUIRED; if (attr != null) type = attr.value(); return type == javax.ejb.TransactionAttributeType.REQUIRED; }
private static TransactionAttributeType getTxType(Invocation invocation) { // Use the method tx attribute if we're invoking a business method, else the bean attribute Method method = null; if(invocation instanceof MethodInvocation) method = ((MethodInvocation) invocation).getActualMethod(); return getTxType(invocation.getAdvisor(), method); }
/** * Returns the TransactionManager * @return */ private TransactionManager getTransactionManager() { if (this.transactionManager == null) { this.transactionManager = TxUtil.getTransactionManager(); } return this.transactionManager; } }
public UserTransactionImpl() { if (log.isDebugEnabled()) log.debug("new UserTx: " + this); this.tm = TxUtil.getTransactionManager(); }