Jun 16th, 2006, 08:36 AM
How to package and access my classes from spring
Hi Spring enthusiasts,
i hope someone can help me with a question that might be easy. I 'm new to spring and read nearly whole spring doc but couldn't find an answer.
I use spring in a standalone non-web application and want to load my classes from jar files.
All my modules are in a modules folder zipped as jar.
Furthermore I have a second folder with several context files in which my jars are wired together in different ways.
What is the best way to make spring find the classes in my jars that represent my plugin modules? Is there a template for packaging spring beans?
I want to be able to put different jars i my modules dir and wire them up by my context so i can access these jars later via rmi. Do I need a special resource loader or do i have to unpack these jars first?
I would be very glad if someone can help me,
Jun 17th, 2006, 07:26 AM
As long as the jar and application context definitions are on the classpath, there should be no problems. You can also use several forms of resource loaders if you don't want to use the classpath. But, using the classpath is easier in my view. Of course, one place in your program must load the Spring context in the main app loader.
I have done a few stand alone non-web Spring based apps this way.
Jun 22nd, 2006, 04:43 AM
i use a File context to load the jars from an external directory and will try out if it works for my plugins.
Jun 22nd, 2006, 10:09 AM
another tactics to simplify the operation would be to set up an env. variable, poiniting to the context files' location, and then use it along with popertyplaceholderconfigurer.
Thus, you abstract the path details from the spring ctx.