1 22 package org.jboss.aspects.versioned; 23 24 import org.jboss.aop.Advisor; 25 import org.jboss.aop.InstanceAdvisor; 26 import org.jboss.aop.joinpoint.Joinpoint; 27 import org.jboss.util.NestedRuntimeException; 28 29 import javax.naming.InitialContext ; 30 import javax.transaction.TransactionManager ; 31 32 37 public class VersionedObjectInterceptorFactory implements org.jboss.aop.advice.AspectFactory 38 { 39 private static VersionedObjectInterceptor instance = null; 40 41 42 public static synchronized VersionedObjectInterceptor getInstance() 43 { 44 try 45 { 46 if (instance == null) 47 { 48 InitialContext ctx = new InitialContext (); 49 TransactionManager tm = (TransactionManager )ctx.lookup("java:/TransactionManager"); 50 instance = new VersionedObjectInterceptor(tm); 51 } 52 return instance; 53 } 54 catch (Exception ex) 55 { 56 throw new NestedRuntimeException(ex); 57 } 58 } 59 60 public Object createPerVM() 61 { 62 return getInstance(); 63 } 64 65 public Object createPerClass(Advisor advisor) 66 { 67 return getInstance(); 68 } 69 70 public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor) 71 { 72 return getInstance(); 73 } 74 75 public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) 76 { 77 return getInstance(); 78 } 79 80 public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp) 81 { 82 return getInstance(); 83 } 84 85 public String getName() 86 { 87 return getClass().getName(); 88 } 89 90 } 91 | Popular Tags |