public void removeAdvisor(Advisor advisor) { advisors.remove(advisor.getClazz()); }
/** * Interface Introduced methods on the proxy will have the wrong declaring class for the matcher, * use the advisor class if it is an interface */ public Class<?> getDeclaringClass(Advisor advisor, Method m) { final Class<?> methodClass = m.getDeclaringClass(); final Class<?> advisorClass = advisor.getClazz(); if (advisorClass != null && methodClass.isInterface()) { return advisorClass; } return methodClass; }
public void attachAdvisor() { Advisor adv = advisor.get(); advisors.put(adv.getClazz(), new WeakReference<Advisor>(adv)); }
public boolean hasSameMethodAspectLength(Advisor other) { if (this.getClazz() != other.getClazz()) { throw new IllegalArgumentException("The advisors must be of the same type. Mine: " + this.getClazz().getName() + "; other: " + other.getClazz().getName()); } long[] myKeys = this.methodInfos.infos.keys(); long[] otherKeys = other.methodInfos.keys(); return JoinPointComparator.hasSameMethodAspectLength(myKeys, otherKeys, this, other); }
public boolean hasSameConstructorAspectLength(Advisor other) { if (this.getClazz() != other.getClazz()) { throw new IllegalArgumentException("The advisors must be of the same type. Mine: " + this.getClazz().getName() + "; other: " + other.getClazz().getName()); } ConstructorInfo[] myInfos = this.getConstructorInfos(); ConstructorInfo[] otherInfos = other.getConstructorInfos(); return JoinPointComparator.hasSameConstructorAspectLength(myInfos, otherInfos); } }
public void setAdvisor(Advisor advisor) { this.advisor = new WeakReference<Advisor>(advisor); if (getClazz() == null && advisor != null) { this.clazz = new WeakReference<Class<?>>(advisor.getClazz()); } }
public ConByConInfo(Advisor advisor, Class<?> calledClass, Class<?> callingClass, int callingIndex, Constructor<?> called, long calledConHash, Method wrappingMethod, Interceptor[] in) { super(advisor, calledClass, called, calledConHash, wrappingMethod, in, callingClass); this.callingIndex = callingIndex; Advisor tempAdvisor = advisor; if (advisor.getClazz() != callingClass) { tempAdvisor = advisor.manager.getAdvisor(callingClass); } this.calling = tempAdvisor.constructors[callingIndex]; }
public SoftClassMatcher(Advisor advisor, String classname, ASTStart start) { super(start, advisor.getManager()); this.advisor = advisor; this.classname = classname; this.start = start; clazz = advisor.getClazz(); }
public CallerMethodInfo(Advisor advisor, Class<?> calledClass, Method m, long calledMethodHash, Interceptor[] in, Class<?> clazz) { super(advisor, clazz); this.calledClass = calledClass; super.setInterceptors(in); this.method = m; this.calledMethodHash = calledMethodHash; this.callingClass = advisor.getClazz(); }
public MethodByConInfo(Advisor advisor, Class<?> calledClass, Class<?> callingClass, int callingIndex, Method m, long calledMethodHash, Interceptor[] in) { super(advisor, calledClass, m, calledMethodHash, in, callingClass); this.callingIndex = callingIndex; Advisor tempAdvisor = advisor; if (advisor.getClazz() != callingClass) { tempAdvisor = advisor.manager.getAdvisor(callingClass); } calling = tempAdvisor.constructors[callingIndex]; }
public CallerConstructorInfo(Advisor advisor, Class<?> calledClass, Constructor<?> called, long calledConHash, Method wrappingMethod, Interceptor[] in, Class<?> clazz) { super(advisor, clazz); this.calledClass = calledClass; super.setInterceptors(in); this.constructor = called; this.calledConHash = calledConHash; this.callingClass = advisor.getClazz(); this.wrappingMethod = wrappingMethod; }
public Object createPerClass(Advisor advisor) { Class clazz = advisor.getClazz(); ArrayList<Field> fs = new ArrayList<Field>(); ArrayList<Method> ms = new ArrayList<Method>(); search(advisor,clazz, fs, ms); Method[] methods = ms.toArray(new Method[ms.size()]); Field[] fields = fs.toArray(new Field[fs.size()]); if (methods.length == 0) methods = null; if (fields.length == 0) fields = null; return new CurrentMessageInjectorInterceptor(fields, methods); }
public static InstanceProxyContainer createInstanceProxyContainer(Advisor classAdvisor, InterfaceIntroduction introduction, MetaData metaData) { String name = Domain.getDomainName(classAdvisor.getClazz(), true); ProxyAdvisorDomain domain = new ProxyAdvisorDomain(classAdvisor.getManager(), name, classAdvisor.getClazz(), true); if (introduction != null) { domain.addInterfaceIntroduction(introduction); } InstanceProxyContainer ia = new InstanceProxyContainer(classAdvisor.getName(), domain, classAdvisor, metaData); return ia; }
public Object createPerClass(Advisor advisor) { // Must be a separate line (EJBContainer cannot be dereferenced) EJBContainer container = EJBContainer.getEJBContainer(advisor); SecurityDomain securityAnnotation = (SecurityDomain) advisor.resolveAnnotation(SecurityDomain.class); //If there is no annotation, return a null action interceptor if(securityAnnotation == null) return new NullInterceptor(); CodeSource ejbCS = advisor.getClazz().getProtectionDomain().getCodeSource(); String ejbName = container.getEjbName(); return new RoleBasedAuthorizationInterceptorv2(container, ejbCS, ejbName); } }
private Class<?> getClazz(Advisor advisor) { try { ClassLoader cl = null; if (advisor != null) { //Get the correct classloader based on the class of the advisor Class<?> clazz = advisor.getClazz(); cl = SecurityActions.getClassLoader((clazz != null) ? clazz: advisor.getClass()); } if (cl != null) { pushScopedClassLoader(cl); } return loadClass(classname); } catch(ClassNotFoundException e) { throw new RuntimeException(e); } finally { popScopedClassLoader(); } }
public void addClassMetaData(ClassMetaDataBinding meta) { removeClassMetaData(meta.getName()); if (advisor != null) { if (meta.matches(advisor, advisor.getClazz())) { meta.addAdvisor(advisor); } } }
protected void updateAdvisorsForAddedClassMetaData(ClassMetaDataBinding meta) { synchronized (advisors) { Iterator<Class<?>> it = advisors.keySet().iterator(); while (it.hasNext()) { Advisor advisor = getAdvisorFromAdvisorsKeySetIterator(it); if (advisor == null) continue; Class<?> clazz = advisor.getClazz(); addAdvisorToClassMetaDataBinding(meta, clazz, advisor, clazz); } } synchronized (subscribedSubDomains) { copySubDomainsFromQueue(true); boolean newSubscribers = true; while (newSubscribers) { if (subscribedSubDomains.size() > 0) { for (Domain domain : subscribedSubDomains.keySet()) { domain.updateAdvisorsForAddedClassMetaData(meta); } } newSubscribers = copySubDomainsFromQueue(false); } } }
/** * Added to notify interceptor chain observer of interceptor chain garbage collection. */ protected void finalize() { Advisor advisor = getClassAdvisor(); // gc'ed if (advisor == null) { return; } Class<?> advisedClass = advisor.getClazz(); // gc'ed if (advisedClass == null) { return; } ClassLoader classLoader = SecurityActions.getClassLoader(advisedClass); if (this.interceptorChainObserver == null || !AspectManager.getRegisteredCLs().containsKey(classLoader)) { return; } this.interceptorChainObserver.allInstanceInterceptorsRemoved(this); }
private InterfaceIntroduction getInterfaceIntroduction() { int introductionLength = (hasInterfaceIntroductions()) ? interfaces.length : 0; int mixinLength = (hasMixins()) ? mixins.length : 0; if (introductionLength == 0 && mixinLength == 0) { return null; } Class<?> proxiedClass = classAdvisor.getClazz(); if (proxiedClass == null) { proxiedClass = Object.class; } String[] introducedNames = getClassNames(interfaces); InterfaceIntroduction intro = new InterfaceIntroduction("Introduction" + counter++, proxiedClass.getName(), introducedNames); if (mixinLength > 0) { addMixins(intro); } return intro; }
public InstanceProxyContainer(String name, ProxyAdvisorDomain instanceDomain, Advisor classAdvisor, MetaData metaData) { super(name, instanceDomain); this.classAdvisor = classAdvisor; instanceDomain.setAdvisor(this); setMetadata(metaData); delegate = new InstanceAdvisorDelegate(classAdvisor, this); delegate.initialize(); initialise(classAdvisor.getClazz()); }