Adding services dynamically via plugin

View: New views
4 Messages — Rating Filter:   Alert me  

Adding services dynamically via plugin

by klausb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I wonder, if a plugin could add service artifacts defined in a jar the plugin is loading. So the plugin starts-up, loads the jar and adds all classes in it, satisfying a pattern, to the set of service artifacts.

Is this possible in principle and might there be an example around?

If I can not add to the services directly, I might add a new artifact type that mimics the service behavior.

Thanks,
klaus.

Re: Adding services dynamically via plugin

by Peter Ledbrook :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I wonder, if a plugin could add service artifacts defined in a jar the plugin
> is loading. So the plugin starts-up, loads the jar and adds all classes in
> it, satisfying a pattern, to the set of service artifacts.
>
> Is this possible in principle and might there be an example around?

I don't think this is possible. Why do you want to add services in
this way? Couldn't you simply add the classes as Spring beans instead?

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Adding services dynamically via plugin

by klausb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,

background is, that I see more and more demand to leverage services in other web-apps and I'm looking for ways to achieve this. Reuse via REST WS could be one way, but imposes a large overhead and makes it very hard to surround this kind of service composition by a transaction.

I analyzed the ServicesGrailsPlugin, which is pretty straight forward, but services a deeper woven into the framework, than just via this plugin. I guess my hypothetical plugin will load classes and add them to the spring container, which is similar to placing these classes into the src folder.

My hope is to have two or more grails apps that can make use of the same set of services implementations. Thinking further this leads to an architecture, where each grails app has its own service as a wrapper to business logic defined outside in a lib.

klaus.

Peter Ledbrook wrote:
> I wonder, if a plugin could add service artifacts defined in a jar the plugin
> is loading. So the plugin starts-up, loads the jar and adds all classes in
> it, satisfying a pattern, to the set of service artifacts.
>
> Is this possible in principle and might there be an example around?

I don't think this is possible. Why do you want to add services in
this way? Couldn't you simply add the classes as Spring beans instead?

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Re: Adding services dynamically via plugin

by Graeme Rocher-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is possible yes, you would need to use Spring's
ClassPathBeanDefinitionScanner to scan for beans inside your jar

Cheers

On Tue, Nov 3, 2009 at 1:27 PM, klausb <klaus.baumecker@...> wrote:

>
> I wonder, if a plugin could add service artifacts defined in a jar the plugin
> is loading. So the plugin starts-up, loads the jar and adds all classes in
> it, satisfying a pattern, to the set of service artifacts.
>
> Is this possible in principle and might there be an example around?
>
> If I can not add to the services directly, I might add a new artifact type
> that mimics the service behavior.
>
> Thanks,
> klaus.
> --
> View this message in context: http://old.nabble.com/Adding-services-dynamically-via-plugin-tp26160092p26160092.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Graeme Rocher
Head of Grails Development
SpringSource - Weapons for the War on Java Complexity
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email