You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Jigar Joshi <ji...@gmail.com> on 2014/06/13 09:15:28 UTC
Re: tapestry-ioc & java 8
your article helped @Baslie, @Thiago I had some old code to convert which
used constructor injection to set delegate
Thanks again!
On Wed, May 28, 2014 at 6:27 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Tue, 27 May 2014 19:14:25 -0300, Jigar Joshi <ji...@gmail.com> wrote:
>
> Thanks Basile, if you could comment on how to add constructor to generated
>> proxy class, I couldn't find introduceConstructor(...) or
>> PlasticConstructor
>>
>
> Why do you need a constructor for a proxy?
>
>
>
>>
>> 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.java@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" <ji...@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-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: dev-help@tapestry.apache.org
>>>
>>>
>>>
>>
>>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>
--
--
Jigar