Re: [Nanning-developer] removing pointcuts
"Jon Tirsen" <[email protected]> Mon, 10 May 2004 21:34:13 +0100
| Newsgroups | gmane.comp.java.nanning.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanks! I will try to commit this as soon as I get time. Nanning might be a bit slow, but it's used in several systems that are in production currently. (And it's still faster than EJB.) Nanning is in "mature support mode" which means there probably won't be that many new features but there it's very mature and no probably very few significant bugs. If there are any they will be fixed. We're actually discussing merging the effort with Dynaop. I am currently not that interested in dynamic proxy based AOP (I've moved on to AspectJ) and I don't use AOP at all at work. Hope this answers your questions. Cheers, Jon On Tue, 04 May 2004 15:11:42 +0200, "Andreas Frei" <[email protected]> said: > I added some code to remove interceptors from a Mixin and a pointcut > from an AspectInstance. > > It works for me, haven't done tests with everything else ;-) > > Would it also possible to get a Proxy from the AspectInstance with a > given Classloader. Currently there is only AI.getProxy(). With this I > can specify which classloader has to be used to load the proxy in. This > way I can have the nanning.jar in an indepentent classloader. > > I am using your nanning in a container, a bit slow but it works quite > fine. How is the status of this project? > > regards, > Andreas > > new AI.getProxy(Classloader cl) method > ----------------------------------- > public Object getProxy() > { > // if (proxy == null) { > // proxy = > Proxy.newProxyInstance(getClass().getClassLoader(), > // (Class[]) > interfaces.toArray(new Class[0]), > // this); > // } > // proxy = executeConstructionInterceptors(proxy); > > return getProxy(null); > } > > //>>/andfrei > /** > * Return a Proxy Instance inside the given classloader. > * > * @param cl > * @return > */ > public Object getProxy(ClassLoader cl) > { > if (proxy == null) > { > Set interfaces = getInterfaceClasses(); > > if (cl == null) cl = getClass().getClassLoader(); > > proxy = Proxy.newProxyInstance(cl, (Class[]) interfaces > .toArray(new Class[0]), this); > } > proxy = executeConstructionInterceptors(proxy); > return proxy; > } > > remove interceptors from a Mixin > -------------------------------- > public void removeInterceptor(Method method, MethodInterceptor > interceptor) > { > > if (methodInterceptors != null) > { > List interceptors = (List) methodInterceptors.get(method); > if (interceptors != null) > { > interceptors.remove(interceptor); > > if (interceptors.isEmpty()) > methodInterceptors.remove(method); > } > > if (methodInterceptors.isEmpty()) > methodInterceptors = null; > > } > > } > > remove a pointcut from an AspectInstance: > ----------------------------------------- > public void clear(AspectInstance instance, MethodInterceptor > interceptor, Class interceptorClass) > { > List mixins = instance.getMixins(); > for (Iterator iterator = mixins.iterator(); iterator.hasNext();) > { > Mixin mixin = (Mixin) iterator.next(); > Method[] methods = mixin.getAllMethods(); > for (int i = 0; i < methods.length; i++) { > Method method = methods[i]; > if (adviseMethod(instance, mixin, method)) { > if (interceptor != null) { > mixin.removeInterceptor(method, interceptor); > } else if (interceptorClass != null) { > try { > mixin.removeInterceptor(method, > (MethodInterceptor) interceptorClass.newInstance()); > } catch (Exception e) { > throw new AspectException(e); > } > } else { > throw new AssertionException("interceptor or > class needs to be specified"); > } > } > } > } > } > > Jon Tirsen wrote: > > I don't think there currently is such an API, no. Why do you need to > > remove interceptors? > > It should be really easy to add though. > > > > Andreas Frei wrote: > > > >> Hi > >> > >> How can I remove advised poincuts in an AspectInstance? Is there an > >> API for removing a MethodInterceptor? > >> > >> thanks, > >> Andreas > >> > >> > >> ------------------------------------------------------- > >> This SF.Net email is sponsored by: Oracle 10g > >> Get certified on the hottest thing ever to hit the market... Oracle > >> 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. > >> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > >> _______________________________________________ > >> Nanning-developer mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/nanning-developer > > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: Oracle 10g > > Get certified on the hottest thing ever to hit the market... Oracle 10g. > > Take an Oracle 10g class now, and we'll give you the exam FREE. > > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > > _______________________________________________ > > Nanning-developer mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/nanning-developer > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Nanning-developer mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/nanning-developer -- http://www.fastmail.fm - A fast, anti-spam email service. ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3