Re: [t4] How do I inject arbitrary services into a custom service encoder?
Hi, My problems has nothing to do with Spring. The problem is that the HiveMind's Lightweight Instance Initialization ( http://hivemind.apache.org/hivemind1/instance-initialization.html) simply is not usable in cases like this. So I rewrote hivemodule.xml this way: service-point id=CurrentFooEncoder Encode/decode current foo in request URLs invoke-factory construct class=CurrentFooEncoder set-service property=contextFactory service-id=SpringContextFactory / /construct /invoke-factory /service-point contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=service:CurrentFooEncoder before=* / /contribution Now it works. Regards, Olle 2007/8/7, Lutz Hühnken [EMAIL PROTECTED]: Hi there, to me it seems the error message indicates that you don't have a method setSpringContext in your CurrentFooEncoder. I think hivemind will try to set that property using that method. Or maybe you need a constructor with an argument of that type. For a slightly different approach you might want to look at the tapestry-spring library at http://howardlewisship.com/tapestry-javaforge/tapestry-spring/. That will allow you to reference objects defined in your spring application context in your hivemodule.xml using the spring: - prefix. I'm not sure how the syntax would be for your encoders, though. I think you could just create an instance, and within the class you can inject spring objects using the @InjectSpring annotation. I use it in some places, works great, just can't seem to remember the syntactical sugar.. Hope this helps anyway, Lutz On 8/7/07, Olle Hallin [EMAIL PROTECTED] wrote: Hi again, I tried your suggestion, but I get an ApplicationRuntimeException: No property editor exists for property springContext of class foo.web.CurrentFooEncoder. What else must I do? It smells writing some glue code... Regards, Olle 2007/8/7, Richard Kirby [EMAIL PROTECTED]: Hi Olle, Try encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder,springContext=spring:springContext / Basically the instance: allows for properties to be set using comma separated property=value Hope that works for you Richard Olle Hallin wrote: Hi! I have written a simple (Tapestry4) custom service encoder (CurrentFooEncoder) which works ok for now. It inserts/removes /foo first in the encoding.getServletPath(). It is declared in hivemodule.xml like contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder before=* / /contribution Now I wan't my CurrentFooEncoder to do some useful work, for which it needs my Spring context. How do I achieve that? I have already have a HiveMind service-point called SpringContextFactory. I guess that I shall write something magic in the object attribute, but what? Regards, Olle Hallin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Olle Hallin M.Sc. +46 70 6653071 [EMAIL PROTECTED] www.hit.se - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Olle Hallin M.Sc. +46 70 6653071 [EMAIL PROTECTED] www.hit.se
[t4] How do I inject arbitrary services into a custom service encoder?
Hi! I have written a simple (Tapestry4) custom service encoder (CurrentFooEncoder) which works ok for now. It inserts/removes /foo first in the encoding.getServletPath(). It is declared in hivemodule.xml like contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder before=* / /contribution Now I wan't my CurrentFooEncoder to do some useful work, for which it needs my Spring context. How do I achieve that? I have already have a HiveMind service-point called SpringContextFactory. I guess that I shall write something magic in the object attribute, but what? Regards, Olle Hallin
Re: [t4] How do I inject arbitrary services into a custom service encoder?
Hi Olle, Try encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder,springContext=spring:springContext / Basically the instance: allows for properties to be set using comma separated property=value Hope that works for you Richard Olle Hallin wrote: Hi! I have written a simple (Tapestry4) custom service encoder (CurrentFooEncoder) which works ok for now. It inserts/removes /foo first in the encoding.getServletPath(). It is declared in hivemodule.xml like contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder before=* / /contribution Now I wan't my CurrentFooEncoder to do some useful work, for which it needs my Spring context. How do I achieve that? I have already have a HiveMind service-point called SpringContextFactory. I guess that I shall write something magic in the object attribute, but what? Regards, Olle Hallin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [t4] How do I inject arbitrary services into a custom service encoder?
Hi again, I tried your suggestion, but I get an ApplicationRuntimeException: No property editor exists for property springContext of class foo.web.CurrentFooEncoder. What else must I do? It smells writing some glue code... Regards, Olle 2007/8/7, Richard Kirby [EMAIL PROTECTED]: Hi Olle, Try encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder,springContext=spring:springContext / Basically the instance: allows for properties to be set using comma separated property=value Hope that works for you Richard Olle Hallin wrote: Hi! I have written a simple (Tapestry4) custom service encoder (CurrentFooEncoder) which works ok for now. It inserts/removes /foo first in the encoding.getServletPath(). It is declared in hivemodule.xml like contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder before=* / /contribution Now I wan't my CurrentFooEncoder to do some useful work, for which it needs my Spring context. How do I achieve that? I have already have a HiveMind service-point called SpringContextFactory. I guess that I shall write something magic in the object attribute, but what? Regards, Olle Hallin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Olle Hallin M.Sc. +46 70 6653071 [EMAIL PROTECTED] www.hit.se
Re: [t4] How do I inject arbitrary services into a custom service encoder?
Hi there, to me it seems the error message indicates that you don't have a method setSpringContext in your CurrentFooEncoder. I think hivemind will try to set that property using that method. Or maybe you need a constructor with an argument of that type. For a slightly different approach you might want to look at the tapestry-spring library at http://howardlewisship.com/tapestry-javaforge/tapestry-spring/. That will allow you to reference objects defined in your spring application context in your hivemodule.xml using the spring: - prefix. I'm not sure how the syntax would be for your encoders, though. I think you could just create an instance, and within the class you can inject spring objects using the @InjectSpring annotation. I use it in some places, works great, just can't seem to remember the syntactical sugar.. Hope this helps anyway, Lutz On 8/7/07, Olle Hallin [EMAIL PROTECTED] wrote: Hi again, I tried your suggestion, but I get an ApplicationRuntimeException: No property editor exists for property springContext of class foo.web.CurrentFooEncoder. What else must I do? It smells writing some glue code... Regards, Olle 2007/8/7, Richard Kirby [EMAIL PROTECTED]: Hi Olle, Try encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder,springContext=spring:springContext / Basically the instance: allows for properties to be set using comma separated property=value Hope that works for you Richard Olle Hallin wrote: Hi! I have written a simple (Tapestry4) custom service encoder (CurrentFooEncoder) which works ok for now. It inserts/removes /foo first in the encoding.getServletPath(). It is declared in hivemodule.xml like contribution configuration-id=tapestry.url.ServiceEncoders page-service-encoder id=page extension=html service=page / page-service-encoder id=external extension=ehtml service=external / direct-service-encoder id=direct stateless-extension=direct stateful-extension=sdirect / asset-encoder id=asset path=/assets / extension-encoder id=extension extension=svc after=* / encoder id=CurrentFooEncoder object=instance:CurrentFooEncoder before=* / /contribution Now I wan't my CurrentFooEncoder to do some useful work, for which it needs my Spring context. How do I achieve that? I have already have a HiveMind service-point called SpringContextFactory. I guess that I shall write something magic in the object attribute, but what? Regards, Olle Hallin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Olle Hallin M.Sc. +46 70 6653071 [EMAIL PROTECTED] www.hit.se - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]