Thanks Basile, if you could comment on how to add constructor to generated proxy class, I couldn't find introduceConstructor(...) or PlasticConstructor
On Fri, May 23, 2014 at 2:54 PM, Basile Chandesris <ba...@free.fr> wrote: > http://tawus.wordpress.com/2011/05/22/meeting-plastic-v- > a-method-shadow-builder/ > > Le 23/05/14 00:40, Jigar Joshi a écrit : > > Thank you, >> >> the closest implementation I found is here >> >> PlasticManager plasticManager = >> PlasticManager.withContextClassLoader().create(); >> PlasticClass plasticClass = >> plasticManager.createProxyTransformation(serviceInterface, >> null).getPlasticClass(); >> PlasticField plasticField = >> plasticClass.introduceField(IProvider.class, "_creator"); >> PlasticProxyFactory factory = new >> PlasticProxyFactoryImpl(plasticManager, log); >> >> MethodDescription methodDescription = new >> MethodDescription(serviceInterface.getClass().getName(), >> "_scopeInstance", >> null, null); >> plasticClass.introduceMethod(methodDescription); >> >> this doesn't help me to create class instance on the fly though, it is >> creates PlasticClass also I didn't find flexibility to specify field >> access >> specifiers >> >> I must be looking at wrong set of class it seems, any thoughts ? >> >> >> >> >> >> On Tue, May 20, 2014 at 12:42 AM, Lance Java <lance.j...@googlemail.com> >> wrote: >> >> Tapestry has switched to plastic for its byte code magic. Currently, >>> plastic isn't well documented. I find that the best documentation >>> currently >>> is the test cases. Perhaps you can find your answer here: >>> >>> >>> https://github.com/apache/tapestry-5/tree/master/ >>> plastic/src/test/groovy/org/apache/tapestry5/plastic >>> On 19 May 2014 23:46, "Jigar Joshi" <jiga...@gmail.com> wrote: >>> >>> Hello >>>> >>>> with tapestry 5.3.4 and java 7 with use of >>>> org.apache.tapestry5.ioc.services.ClassFactory >>>> >>>> >>>> >>>> private Class<?> createProxyClass(ServiceResources resources) { >>>> Class<?> serviceInterface = resources.getServiceInterface(); >>>> >>>> ClassFab cf = classFactory.newClass(serviceInterface); >>>> >>>> // add field >>>> cf.addField("_creator", Modifier.PRIVATE | Modifier.FINAL, >>>> SomeClass.class); >>>> >>>> // Constructor takes a ServiceCreator >>>> cf.addConstructor(new Class[] { SomeClass.class }, null, >>>> >>> "_creator >>> >>>> = $1;"); >>>> >>>> // add method >>>> String body = format("return (%s) _creator.get();", >>>> serviceInterface.getName()); >>>> MethodSignature sig = new MethodSignature(serviceInterface, >>>> SCOPE_METHOD_NAME, null, null); >>>> cf.addMethod(Modifier.PRIVATE, sig, body); >>>> String toString = format("<Scoped Proxy for scope(%s): >>>> %s(%s)>", >>>> scope, resources.getServiceId(), >>>> serviceInterface.getName()); >>>> >>>> cf.proxyMethodsToDelegate(serviceInterface, SCOPE_METHOD_NAME >>>> + >>>> "()", toString); >>>> >>>> return cf.createClass(); >>>> } >>>> >>>> >>>> >>>> >>>> >>>> with tapestry 5.4-beta3 this class has been removed (it was depricated) >>>> >>>> I played around a little bit to find related implementation in new >>>> >>> replaced >>> >>>> class >>>> >>>> org.apache.tapestry5.ioc.services.PlasticProxyFactory >>>> >>>> couldn't find it offhand, how to achieve same thing with tapestry 5.4 ? >>>> >>>> Thanks! >>>> Jigar >>>> >>>> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org > For additional commands, e-mail: dev-h...@tapestry.apache.org > > -- -- Jigar