1 22 package org.jboss.aspects.concurrent; 23 24 import org.jboss.aop.advice.AspectFactory; 25 import org.jboss.aop.Advisor; 26 import org.jboss.aop.InstanceAdvisor; 27 import org.jboss.aop.joinpoint.Joinpoint; 28 import org.jboss.aop.joinpoint.MethodJoinpoint; 29 30 35 public class MutexAspectFactory implements AspectFactory 36 { 37 public Object createPerVM() 38 { 39 throw new IllegalStateException ("THIS SCOPE NOT USABLE"); 40 } 41 42 public Object createPerClass(Advisor advisor) 43 { 44 throw new IllegalStateException ("THIS SCOPE NOT USABLE"); 45 } 46 47 public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor) 48 { 49 throw new IllegalStateException ("THIS SCOPE NOT USABLE"); 50 } 51 52 public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) 53 { 54 MethodJoinpoint mj = (MethodJoinpoint)jp; 55 MutexLocked props = (MutexLocked)advisor.resolveAnnotation(mj.getMethod(), MutexLocked.class); 56 if (props.timeout() < 0) 57 { 58 return new MutexAspect.BlockingMutex(); 59 } 60 else if (props.timeout() == 0) 61 { 62 return new MutexAspect.TryLockMutex(); 63 } 64 else 65 { 66 return new MutexAspect.TimeoutMutex(props); 67 } 68 } 69 70 public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp) 71 { 72 throw new IllegalStateException ("THIS SCOPE NOT USABLE"); 73 } 74 75 public String getName() 76 { 77 return MutexAspectFactory.class.getName(); 78 } 79 } 80 | Popular Tags |