TxInterceptorFactorypublic class TxInterceptorFactory extends Object implements org.jboss.aop.advice.AspectFactoryThis interceptor handles transactions for AOP |
Fields Summary |
---|
protected TxPolicy | policy | protected HashMap | nameMap |
Methods Summary |
---|
public java.lang.Object | createPerClass(org.jboss.aop.Advisor advisor)
throw new IllegalStateException("Scope not allowed");
| public java.lang.Object | createPerInstance(org.jboss.aop.Advisor advisor, org.jboss.aop.InstanceAdvisor instanceAdvisor)
throw new IllegalStateException("Scope not allowed");
| public java.lang.Object | createPerJoinpoint(org.jboss.aop.Advisor advisor, org.jboss.aop.joinpoint.Joinpoint jp)
initialize();
String txType = resolveTxType(advisor, jp);
Object rtn = nameMap.get(txType.toUpperCase());
if (rtn == null) throw new RuntimeException("TX TYPE was null for: " + txType);
return rtn;
| public java.lang.Object | createPerJoinpoint(org.jboss.aop.Advisor advisor, org.jboss.aop.InstanceAdvisor instanceAdvisor, org.jboss.aop.joinpoint.Joinpoint jp)
throw new IllegalStateException("Scope not allowed");
| public java.lang.Object | createPerVM()
throw new IllegalStateException("Scope not allowed");
| public java.lang.String | getName()
return getClass().getName();
| public void | initialize()
if (policy != null) return;
initializePolicy();
nameMap.put("NEVER", new TxInterceptor.Never(TransactionManagerLocator.getInstance().locate(), policy));
nameMap.put("NOTSUPPORTED", new TxInterceptor.NotSupported(TransactionManagerLocator.getInstance().locate(), policy));
nameMap.put("SUPPORTS", new TxInterceptor.Supports(TransactionManagerLocator.getInstance().locate(), policy));
nameMap.put("REQUIRED", new TxInterceptor.Required(TransactionManagerLocator.getInstance().locate(), policy));
nameMap.put("REQUIRESNEW", new TxInterceptor.RequiresNew(TransactionManagerLocator.getInstance().locate(), policy));
nameMap.put("MANDATORY", new TxInterceptor.Mandatory(TransactionManagerLocator.getInstance().locate(), policy));
| protected void | initializePolicy()
policy = new TxPolicy();
| protected java.lang.String | resolveTxType(org.jboss.aop.Advisor advisor, org.jboss.aop.joinpoint.Joinpoint jp)
if (jp instanceof ConstructorJoinpoint)
{
Constructor con = ((ConstructorJoinpoint)jp).getConstructor();
String txType = (String)advisor.getConstructorMetaData().getConstructorMetaData(con, "transaction", "trans-attribute");
if (txType != null) return txType;
txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
if (txType != null) return txType;
Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
if (tx == null)
{
tx = (Tx)advisor.resolveAnnotation(Tx.class);
}
if (tx == null) return "REQUIRED";
return tx.value().name();
}
else if (jp instanceof MethodJoinpoint)
{
Method con = ((MethodJoinpoint)jp).getMethod();
String txType = (String)advisor.getMethodMetaData().getMethodMetaData(con, "transaction", "trans-attribute");
if (txType != null) return txType;
txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
if (txType != null) return txType;
Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
if (tx == null)
{
tx = (Tx)advisor.resolveAnnotation(Tx.class);
}
if (tx == null) return "REQUIRED";
return tx.value().name();
}
else
{
Field con = ((FieldJoinpoint)jp).getField();
String txType = (String)advisor.getFieldMetaData().getFieldMetaData(con, "transaction", "trans-attribute");
if (txType != null) return txType;
txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
if (txType != null) return txType;
Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
if (tx == null)
{
tx = (Tx)advisor.resolveAnnotation(Tx.class);
}
if (tx == null) return "REQUIRED";
return tx.value().name();
}
|
|