Hi Josh This might help
http://tawus.wordpress.com/category/plastic/ regards Taha On Fri, Jul 29, 2011 at 11:25 PM, Howard Lewis Ship <hls...@gmail.com> wrote: > On Fri, Jul 29, 2011 at 10:19 AM, Josh Canfield <joshcanfi...@gmail.com> > wrote: >> I'd like to integrate some advice used in a tapestry web project into >> a non-tapestry web project. I can add a dependency on plastic, but not >> a tapestry-ioc. >> >> I'm at the experimental stage at this point and I've hit a snag. I >> figure I can wade around for a couple hours, or Howard can whip up in >> example off the top of his head. >> >> Here's some pieces of code. >> >> plasticManager = PlasticManager >> .withContextClassLoader() >> .packages(Collections.singleton(basePackage)) >> .create(); >> >> >> public <T> T monitor(Class<T> monitoredClass, Object... constructorParams) { >> >> return plasticManager.createClass(monitoredClass, new >> PlasticClassTransformer() { >> >> public void transform(PlasticClass plasticClass) { >> >> // At this point plasticclass has methodNames, but no methods so the >> following fails to find my annotation. >> // Do I need to manually override the methods? >> >> List<PlasticMethod> methods = >> plasticClass.getMethodsWithAnnotation(Monitor.class); >> for (PlasticMethod method : methods) { >> final Stopwatch stopwatch = >> createStopwatch(method.getAnnotation(Monitor.class), method); >> logger.debug("Adding advice for {}", stopwatch.getName()); >> method.addAdvice(new MonitorAdvice(stopwatch)); >> } >> } >> >> }).newInstance(); >> } >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > I think what you are missing is that you don't create a class (that's > for creating proxies and such, the monitoredClass you pass in becomes > the base class). > > What you want to do is wrap your logic up your PlasticClassTransformer > inside a StandardDelegate (a trivial internal class). > > You can then ask the manager to getClassInstantiator() and > newInstance() that to get your advised and instantiated instance. > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > > The source for Tapestry training, mentoring and support. Contact me to > learn how I can get you up and productive in Tapestry fast! > > (971) 678-5210 > http://howardlewisship.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org