tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jigar Joshi <jiga...@gmail.com>
Subject Re: tapestry-ioc & java 8
Date Fri, 13 Jun 2014 07:15:28 GMT
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 <jigarjm@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 <based@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" <jigarjm@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message