Re: Class Transformation problem
Yes it works, thank you. Rendy. On Fri, Aug 5, 2011 at 11:27 PM, Josh Canfield joshcanfi...@gmail.comwrote: Right, this is what I was talking about. I use tynamo resteasy in this way. On Fri, Aug 5, 2011 at 12:27 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: I don't think you need ComponentClassTransformationWorker. What you need is, as Josh said, a service advice http://tapestry.apache.org/service-advisors.html Now the tricky part is where to apply it. As Josh said, if you expose your resources as services you will be able to apply advises and even use injection. By exposing as service I mean create an interface and its implementation and bind using ServiceBinder. Then you can add that resource to resteasy as public static void contributeApplication(ConfigurationObject singletons, ObjectLocator locator) { singletons.add(locator.autobuild(MyDomainObjectResource.class)); } Disclaimer: I have never used tynamo-resteasy and this information is based on http://tynamo.org/tapestry-resteasy+guide. On Fri, Aug 5, 2011 at 8:16 AM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi Josh, Might you please elaborate your answer ? I don't get it :) Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.com wrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.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
Re: Class Transformation problem
I don't think you need ComponentClassTransformationWorker. What you need is, as Josh said, a service advice http://tapestry.apache.org/service-advisors.html Now the tricky part is where to apply it. As Josh said, if you expose your resources as services you will be able to apply advises and even use injection. By exposing as service I mean create an interface and its implementation and bind using ServiceBinder. Then you can add that resource to resteasy as public static void contributeApplication(ConfigurationObject singletons, ObjectLocator locator) { singletons.add(locator.autobuild(MyDomainObjectResource.class)); } Disclaimer: I have never used tynamo-resteasy and this information is based on http://tynamo.org/tapestry-resteasy+guide. On Fri, Aug 5, 2011 at 8:16 AM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi Josh, Might you please elaborate your answer ? I don't get it :) Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.comwrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation problem
Thanks Taha Josh, I will give it a try and later post back the result here. Thanks, Rendy. On Fri, Aug 5, 2011 at 2:27 PM, Taha Hafeez tawus.tapes...@gmail.comwrote: I don't think you need ComponentClassTransformationWorker. What you need is, as Josh said, a service advice http://tapestry.apache.org/service-advisors.html Now the tricky part is where to apply it. As Josh said, if you expose your resources as services you will be able to apply advises and even use injection. By exposing as service I mean create an interface and its implementation and bind using ServiceBinder. Then you can add that resource to resteasy as public static void contributeApplication(ConfigurationObject singletons, ObjectLocator locator) { singletons.add(locator.autobuild(MyDomainObjectResource.class)); } Disclaimer: I have never used tynamo-resteasy and this information is based on http://tynamo.org/tapestry-resteasy+guide. On Fri, Aug 5, 2011 at 8:16 AM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi Josh, Might you please elaborate your answer ? I don't get it :) Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.com wrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation problem
Right, this is what I was talking about. I use tynamo resteasy in this way. On Fri, Aug 5, 2011 at 12:27 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: I don't think you need ComponentClassTransformationWorker. What you need is, as Josh said, a service advice http://tapestry.apache.org/service-advisors.html Now the tricky part is where to apply it. As Josh said, if you expose your resources as services you will be able to apply advises and even use injection. By exposing as service I mean create an interface and its implementation and bind using ServiceBinder. Then you can add that resource to resteasy as public static void contributeApplication(ConfigurationObject singletons, ObjectLocator locator) { singletons.add(locator.autobuild(MyDomainObjectResource.class)); } Disclaimer: I have never used tynamo-resteasy and this information is based on http://tynamo.org/tapestry-resteasy+guide. On Fri, Aug 5, 2011 at 8:16 AM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi Josh, Might you please elaborate your answer ? I don't get it :) Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.comwrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.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
Re: Class Transformation problem
Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation problem
Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation problem
Hi Taha, Thanks for your response. This my problem in detail, I am creating a web service using tynamo, in tynamo, they direct us to place Resource class in rest package. In every service inside the resource, I want to put an annotation (like your @xhr - ajax graceful degradation) to every method I want to transform. The transformation itself is simple one, I want to catch every exeception thrown from invocation.proceed and convert it to a string. This string will be used to override the result sent to the caller. Because this package is not the one in controlled package, how do I accomplish this idea ? Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.comwrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation problem
Hi Josh, Might you please elaborate your answer ? I don't get it :) Thanks, Rendy. On Thu, Aug 4, 2011 at 10:29 PM, Josh Canfield joshcanfi...@gmail.comwrote: Also, rest resources can be bound as services to use injection and advice. On Aug 4, 2011 8:05 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Rendy No ComponentClassTransformWorker will not work outside pages/components package. But class transformation is not the only reason to keep a special packages. You sometime need to scan classes for annotations etc and it is easy if you have specific packages which can be contributed to the scanning service. As far as class transformation is concerned, you can transform an existing class or create a new one by using ClassFab etc classes which are based on javassist in 5.2+ (on PlasticClass etc in 5.3+). Can you elaborate on your problem ? On Thu, Aug 4, 2011 at 7:25 PM, Rendy Tapestry rendy.tapes...@gmail.com wrote: Hi all, I have problem with class transformation, my question, will this class transformation work outside from special package (pages for example). I am using restful integration from tynamo which direct me to put my web service in rest package. Is the package name matter with class transformation ? If yes, how could I solve my problem ? Thanks, Rendy. ps. I am using tapestry 5.2.5 (ComponentClassTransformWorker) -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation
On Thu, 17 Feb 2011 11:33:35 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Hi! There is internal support for creating new classes in tapestry ioc using ClassFactory/ClassFab. They're going to be deprecated soon and remved in the future. The replacement will be Howard's Plastic package: https://github.com/hlship/plastic. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation
I know a bit of asm and I am really looking forward to browse its code but I am too busy with migrating our internal wicket applications to Tapestry5. We are also planning to replace front-end of Finacle from jsp to tapestry5. Back to the question. What I really want to do is provide an @Auditable annotation on my domain classes and then add some fields/methods at the time of loading the classes. regards Taha On Thu, Feb 17, 2011 at 8:12 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Thu, 17 Feb 2011 11:33:35 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Hi! There is internal support for creating new classes in tapestry ioc using ClassFactory/ClassFab. They're going to be deprecated soon and remved in the future. The replacement will be Howard's Plastic package: https://github.com/hlship/plastic. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br
Re: Class Transformation
On Thu, 17 Feb 2011 13:15:01 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Back to the question. What I really want to do is provide an @Auditable annotation on my domain classes and then add some fields/methods at the time of loading the classes. Tapestry-IoC doesn't change classes at all. It just creates proxies around existing objects. I guess you need to look at at the Project Lombok (very, very insteresting package, by the way) for some insipiration: http://projectlombok.org/. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation
+1 Lombok. It is awesome and I've used it for some time. On Feb 17, 2011, at 10:38 AM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Thu, 17 Feb 2011 13:15:01 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Back to the question. What I really want to do is provide an @Auditable annotation on my domain classes and then add some fields/methods at the time of loading the classes. Tapestry-IoC doesn't change classes at all. It just creates proxies around existing objects. I guess you need to look at at the Project Lombok (very, very insteresting package, by the way) for some insipiration: http://projectlombok.org/. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - 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
Re: Class Transformation
On Thu, Feb 17, 2011 at 7:15 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Back to the question. What I really want to do is provide an @Auditable annotation on my domain classes and then add some fields/methods at the time of loading the classes. Are you sure that adding the auditing data directly to your domain classes is a good idea? Just asking whether you've considered the trade-offs. If you are using Hibernate, see http://docs.jboss.org/envers/docs/index.html. Kalle On Thu, Feb 17, 2011 at 8:12 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Thu, 17 Feb 2011 11:33:35 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Hi! There is internal support for creating new classes in tapestry ioc using ClassFactory/ClassFab. They're going to be deprecated soon and remved in the future. The replacement will be Howard's Plastic package: https://github.com/hlship/plastic. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation
We did use envers in one of our projects but it makes creating auditing reports a project in itself. Besides the auditing is not of our liking. We, being a financial organization, have to audit every thing and having so many audit tables around is just too much. Also there is less control over the amount of auditing. Also we have a maker-checker concept and implementing it needs some audit data in the domain classes.. Can I do it in Javassist. I know tapestry5 will be migrating to plastic but then I can also make upgrades to my application later. I have a slight idea Something like for(String className: classNameLocator.locateClassNames(packageName)){ CtClass ctClass = classFactoryClassPool.get(className); //Do whatever using javasssist } Am I on the right path ? I will checkout lombok regards Taha On Thu, Feb 17, 2011 at 9:23 PM, Kalle Korhonen kalle.o.korho...@gmail.comwrote: On Thu, Feb 17, 2011 at 7:15 AM, Taha Hafeez tawus.tapes...@gmail.com wrote: Back to the question. What I really want to do is provide an @Auditable annotation on my domain classes and then add some fields/methods at the time of loading the classes. Are you sure that adding the auditing data directly to your domain classes is a good idea? Just asking whether you've considered the trade-offs. If you are using Hibernate, see http://docs.jboss.org/envers/docs/index.html. Kalle On Thu, Feb 17, 2011 at 8:12 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Thu, 17 Feb 2011 11:33:35 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Hi Hi! There is internal support for creating new classes in tapestry ioc using ClassFactory/ClassFab. They're going to be deprecated soon and remved in the future. The replacement will be Howard's Plastic package: https://github.com/hlship/plastic. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class Transformation
On Thu, 17 Feb 2011 14:11:39 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Can I do it in Javassist. You'd need to ensure your Javassist-changed class version is the only one used in your application. This is probably quite hard to do. If I needed to something like you want, I'd study how Projet Lombok works. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Class transformation
Can't you just override the method instead and call the super method at the right time? -Filip Robin Helgelin skrev: On Feb 19, 2008 8:47 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote: I think it's because the code you add is effectively inside a block, i.e. in Java it would be: { int i = 5; } So the scope of the new variable is limited. That means you need to generate all the code that uses the variable as a single body passed to ClassTransformation. Ah, ok. That seems problematic, as I want to both prefix and expand. I guess it could be solved by adding a field to the class instead. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
On Wed, Feb 20, 2008 at 3:35 PM, Filip S. Adamsen [EMAIL PROTECTED] wrote: Can't you just override the method instead and call the super method at the right time? Sure, but currently Tapestry class transformation doesn't support this. Or maybe I'm just blind :) -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
Sorry, my bad. That is indeed not possible at the moment. -Filip Robin Helgelin skrev: On Wed, Feb 20, 2008 at 3:35 PM, Filip S. Adamsen [EMAIL PROTECTED] wrote: Can't you just override the method instead and call the super method at the right time? Sure, but currently Tapestry class transformation doesn't support this. Or maybe I'm just blind :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
On Wed, Feb 20, 2008 at 5:37 PM, Filip S. Adamsen [EMAIL PROTECTED] wrote: Sorry, my bad. That is indeed not possible at the moment. I did post and example in my first message in this thread where I was playing with it, but I couldn't get Tapestry to process my renamed method, so I gave it a rest. -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
Could the extend method be failing because it does not return a value? On Feb 19, 2008 9:31 AM, Robin Helgelin [EMAIL PROTECTED] wrote: Hi, I'm trying to do a simple prefix and extend to a single method, however, it seems that ClassTransformation.extendMethod(), doesn't find variables declared with prefixMethod(). Simple example which throws a javassist.CannotCompileException: transformation.prefixMethod(method, int i = 1;); transformation.extendMethod(method, i += 1;); I also tried expanding the method by wrapping it, but that seems to break @Persist:et members. I attach my attempt. It seems the problem is that Tapestry only scans the new method, not the old one copied, am I correct? public void renameAndExtendMethod(TransformMethodSignature methodSignature, String newMethodName, String methodBody) { failIfFrozen(); CtMethod methodOld = findMethod(methodSignature); methodOld.setName(newMethodName); CtMethod methodNew; try { methodNew = CtNewMethod.copy(methodOld, methodSignature.getMethodName(), _ctClass, null); methodNew.setBody(methodBody); _ctClass.addMethod(methodNew); } catch (CannotCompileException ex) { throw new MethodCompileException(ServicesMessages.methodCompileError( methodSignature, methodBody, ex), methodBody, ex); } addMethodToDescription(renameAndExtend, methodSignature, methodBody); _addedMethods.add(methodOld); } -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
On Feb 19, 2008 7:44 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote: Could the extend method be failing because it does not return a value? I tried returning a value, no change. It barfs on my variable i, backtrace as this: Caused by: org.apache.tapestry.internal.services.MethodCompileException: Error compiling method public java.lang.String onActionFromCounter() (i += 1;): [source error] no such field: i at org.apache.tapestry.internal.services.InternalClassTransformationImpl.extendMethod(InternalClassTransformationImpl.java:625) at nu.localhost.tapestry.acegi.services.internal.AcegiWorker.transformMethod(AcegiWorker.java:112) at nu.localhost.tapestry.acegi.services.internal.AcegiWorker.transform(AcegiWorker.java:46) at $ComponentClassTransformWorker_118330aced0.transform($ComponentClassTransformWorker_118330aced0.java) at $ComponentClassTransformWorker_118330aceca.transform($ComponentClassTransformWorker_118330aceca.java) at org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass(ComponentClassTransformerImpl.java:147) ... 94 more Caused by: javassist.CannotCompileException: [source error] no such field: i at javassist.CtBehavior.insertAfter(CtBehavior.java:703) at javassist.CtBehavior.insertAfter(CtBehavior.java:627) at org.apache.tapestry.internal.services.InternalClassTransformationImpl.extendMethod(InternalClassTransformationImpl.java:621) ... 99 more Caused by: compile error: no such field: i at javassist.compiler.TypeChecker.fieldAccess(TypeChecker.java:812) at javassist.compiler.TypeChecker.atFieldAssign(TypeChecker.java:270) at javassist.compiler.JvstTypeChecker.atFieldAssign(JvstTypeChecker.java:83) at javassist.compiler.TypeChecker.atAssignExpr(TypeChecker.java:229) at javassist.compiler.ast.AssignExpr.accept(AssignExpr.java:38) at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:241) at javassist.compiler.CodeGen.atStmnt(CodeGen.java:329) at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49) at javassist.compiler.Javac.compileStmnt(Javac.java:568) at javassist.CtBehavior.insertAfterAdvice(CtBehavior.java:724) at javassist.CtBehavior.insertAfter(CtBehavior.java:669) ... 101 more -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
I think it's because the code you add is effectively inside a block, i.e. in Java it would be: { int i = 5; } So the scope of the new variable is limited. That means you need to generate all the code that uses the variable as a single body passed to ClassTransformation. On Feb 19, 2008 10:55 AM, Robin Helgelin [EMAIL PROTECTED] wrote: On Feb 19, 2008 7:44 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote: Could the extend method be failing because it does not return a value? I tried returning a value, no change. It barfs on my variable i, backtrace as this: Caused by: org.apache.tapestry.internal.services.MethodCompileException: Error compiling method public java.lang.String onActionFromCounter() (i += 1;): [source error] no such field: i at org.apache.tapestry.internal.services.InternalClassTransformationImpl.extendMethod(InternalClassTransformationImpl.java:625) at nu.localhost.tapestry.acegi.services.internal.AcegiWorker.transformMethod(AcegiWorker.java:112) at nu.localhost.tapestry.acegi.services.internal.AcegiWorker.transform(AcegiWorker.java:46) at $ComponentClassTransformWorker_118330aced0.transform($ComponentClassTransformWorker_118330aced0.java) at $ComponentClassTransformWorker_118330aceca.transform($ComponentClassTransformWorker_118330aceca.java) at org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass(ComponentClassTransformerImpl.java:147) ... 94 more Caused by: javassist.CannotCompileException: [source error] no such field: i at javassist.CtBehavior.insertAfter(CtBehavior.java:703) at javassist.CtBehavior.insertAfter(CtBehavior.java:627) at org.apache.tapestry.internal.services.InternalClassTransformationImpl.extendMethod(InternalClassTransformationImpl.java:621) ... 99 more Caused by: compile error: no such field: i at javassist.compiler.TypeChecker.fieldAccess(TypeChecker.java:812) at javassist.compiler.TypeChecker.atFieldAssign(TypeChecker.java:270) at javassist.compiler.JvstTypeChecker.atFieldAssign(JvstTypeChecker.java:83) at javassist.compiler.TypeChecker.atAssignExpr(TypeChecker.java:229) at javassist.compiler.ast.AssignExpr.accept(AssignExpr.java:38) at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:241) at javassist.compiler.CodeGen.atStmnt(CodeGen.java:329) at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49) at javassist.compiler.Javac.compileStmnt(Javac.java:568) at javassist.CtBehavior.insertAfterAdvice(CtBehavior.java:724) at javassist.CtBehavior.insertAfter(CtBehavior.java:669) ... 101 more -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class transformation
On Feb 19, 2008 8:47 PM, Howard Lewis Ship [EMAIL PROTECTED] wrote: I think it's because the code you add is effectively inside a block, i.e. in Java it would be: { int i = 5; } So the scope of the new variable is limited. That means you need to generate all the code that uses the variable as a single body passed to ClassTransformation. Ah, ok. That seems problematic, as I want to both prefix and expand. I guess it could be solved by adding a field to the class instead. -- regards, Robin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]