Using own classloader inside J2EE to load and unload own classes.

S

Stefan Siegl

Hello it's me again,

I am currently writing my master thesis about a customer relationship
management (CRM) system. The special thing about this component is that
the model (the way the CRM data is described) can be changed at runtime.
That means I do not have the model at compile time. I already posted
here to get general hints from you guys (sry don't know how to link to
the other news message, but the name was: Compile java sources inside
J2EE component)

I specified the component in more detail and am currently trying to
integrate a persistence layer to persist data. My approach is to create
classes at runtime that reflect the current model and use instances of
these classes to represent data entered according to this model.

The classes are loaded by an own classloader and are not part of the
classpath of the J2EE container. If the model changes, new classes are
created internally and a new classloader instance is used to load these
classes. The old instance of my own classloader will not be used
anymore. Therefore the old classes will not be used anymore. Is this
possible or will I face problems with the J2EE container?


Another question is the integration of persistence:

What I need is a persistence framework that can deal with this changing
of the classes at runtime. I thought that it might be possible with an
JDO implementation. As far as i understand, the PersistenceManager is
the central point of any JDO implementation and is responsible for
persisting objects. I wanted to use JDO with the JCA adapter inside a
J2EE application and provide the PersistenceManager with my own
classloader to provide the JDO implementation with the needed classes
that are created at runtime. The JDO specification defines that the
class should be loaded by a classForName method. Do you think it is
feasible (or possible) to change this method to use my own classloader
instead?

Thanks for your advice :)
Stefan
 
A

abhishek.khuntia

Hello it's me again,

I am currently writing my master thesis about a customer relationship
management (CRM) system. The special thing about this component is that
the model (the way the CRM data is described) can be changed at runtime.
That means I do not have the model at compile time. I already posted
here to get general hints from you guys (sry don't know how to link to
the other news message, but the name was: Compile java sources inside
J2EE component)

I specified the component in more detail and am currently trying to
integrate a persistence layer to persist data. My approach is to create
classes at runtime that reflect the current model and use instances of
these classes to represent data entered according to this model.

The classes are loaded by an own classloader and are not part of the
classpath of the J2EE container. If the model changes, new classes are
created internally and a new classloader instance is used to load these
classes. The old instance of my own classloader will not be used
anymore. Therefore the old classes will not be used anymore. Is this
possible or will I face problems with the J2EE container?


Another question is the integration of persistence:

What I need is a persistence framework that can deal with this changing
of the classes at runtime. I thought that it might be possible with an
JDO implementation. As far as i understand, the PersistenceManager is
the central point of any JDO implementation and is responsible for
persisting objects. I wanted to use JDO with the JCA adapter inside a
J2EE application and provide the PersistenceManager with my own
classloader to provide the JDO implementation with the needed classes
that are created at runtime. The JDO specification defines that the
class should be loaded by a classForName method. Do you think it is
feasible (or possible) to change this method to use my own classloader
instead?

Thanks for your advice :)
Stefan

Hi Stefan,

This is a old mail chain. I hope you have found a solution :) If so can youshare with me ? I have a similar problem to load/unload set of classes when needed in a j2ee environment. I am looking at osgi and implementing it inside the business logic. Is there any other way ?

Thanks,
Abhishek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top