The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: Adding code dynamically

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Mar 4, 2008 12:27 PM by: Kristian Rink
ols

Posts: 10
Adding code dynamically
Posted: Mar 4, 2008 12:50 AM
  Click to reply to this thread Reply

Hello,

We are starting developing an application that will run in GlassFish.
In big lines, this application will process (transform) messages.
Each message type will have a corresponding processing type.
Associations between message types and processing types will be maintain in a kind of table.

My questions are:
Is it possible to create a mechanism that allows users to add dynamically new processing code, by adding somewhere some java or jar files ?
How to maintain the associations table ?

Thanks,

Olivier

Sahoo
Re: Adding code dynamically
Posted: Mar 4, 2008 7:01 AM   in response to: ols
  Click to reply to this thread Reply

A wild thought:
You can store the bytes as a blob in a database. You can have your own
ClassLoader that knows about the mappings and uses it to find the bytes
to load classes.

Sahoo
glassfish@javadesktop.org wrote:
> Hello,
>
> We are starting developing an application that will run in GlassFish.
> In big lines, this application will process (transform) messages.
> Each message type will have a corresponding processing type.
> Associations between message types and processing types will be maintain in a kind of table.
>
> My questions are:
> Is it possible to create a mechanism that allows users to add dynamically new processing code, by adding somewhere some java or jar files ?
> How to maintain the associations table ?
>
> Thanks,
>
> Olivier
> [Message sent by forum member 'ols' (ols)]
>
> http://forums.java.net/jive/thread.jspa?messageID=262129
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


marrs

Posts: 5
Re: Adding code dynamically
Posted: Mar 4, 2008 7:43 AM   in response to: ols
  Click to reply to this thread Reply

You could use the OSGi framework to dynamically plug in such extensions. OSGi "modules" (called bundles) are JAR files and can by dynamically loaded, updated and unloaded. It's not too difficult to embed such a framework in you application either. As an example of that, check out this piece of documentation on embedding Apache Felix (one of the open source implementations that exist):

http://felix.apache.org/site/launching-and-embedding-apache-felix.html

If you want to learn a bit more about how to maintain a kind of table of your processing types, check out this demonstration which discusses two models (the classical OSGi service model and the extender model) for doing so:

http://felix.apache.org/site/apache-felix-application-demonstration.html

Greetings, Marcel

samkass

Posts: 7
Re: Adding code dynamically
Posted: Mar 4, 2008 12:27 PM   in response to: marrs
  Click to reply to this thread Reply

I'm in the same boat, and OSGi looks pretty nice. Although Felix looks a lot easier to get started with, the Equinox folks have done a lot of work lately to get a complete, deployable server-side modularity framework together. And since Equinox underlies Eclipse, there's some nice IDE tools to maintain the plug-ins.

I would recommend looking at OSGi R4's Declarative Services as the way to go for specifying module dependencies. It has very dynamic binding (unlike extension points), a nice declarative XML specification (unlike raw services), and is a standard instead of a Not-Invented-Here-Syndrome re-implementation of the functionality (unlike Spring).

Kristian Rink
Re: Adding code dynamically
Posted: Mar 4, 2008 12:27 PM   in response to: samkass
  Click to reply to this thread Reply

Jumping in here:

glassfish@javadesktop.org schrieb:
> I'm in the same boat, and OSGi looks pretty nice. Although Felix
> looks a lot easier to get started with, the Equinox folks have done a
> lot of work lately to get a complete, deployable server-side
> modularity framework together. And since Equinox underlies Eclipse,
> there's some nice IDE tools to maintain the plug-ins.

Do you folks so far have any experiences to report about bundling
OSGi/felix with glassfish, possibly especially while really tightly
integrating the OSGi environment with the Java EE container, making
services in OSGi available to, say, EJB components and vice versa?
Surely looking for some comments on that... :)

Cheers & best,
Kristian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net





 XML java.net RSS