Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Modularity

Thread view: 
Paul Selibas - 24 Nov 2005 21:57 GMT
Good day everyone...

I have a question and any bit of advice would be appreciated.

What would be the easiest possible way to implement a scripting system
in a java program so that you can have a core + modules kind of system.
Or even perhaps compile Java code at runtime. Is this even possible?

What i want to do it make a core and other people can program modules
that will just fit in without changing the core program.

Many thanks to those who contribute.

Paul Selibas
NullBock - 24 Nov 2005 22:14 GMT
You've lot's of different ways of implementing this.  And you don't
have to require run-time compilation either, merely realease a public
API that the module creators can use.  We do this fairly extensively
with our products, releasing a fairly large API that users can click
into.

If you do want to go run-time, there are a few things you could
consider.  For instance, the Mozilla orginazation has a great pure-Java
JavaScript engine called Rhino (very stable, been around along
time)--go to http://mozilla.org/rhino.  There are engines for almost
every language around, including Java.  JavaWorld ran a comparison of
different engines a couple years back : http://linkfrog.net/daao

Walter Gildersleeve
Freiburg, Germany

___________________________________________
http://linkfrog.net
URL Shortening
Free and easy, small and green
pkriens@gmail.com - 25 Nov 2005 12:43 GMT
Take a look at Beanshell. It is a lightweight scripting language that
is very close to Java. This closeness makes it work very well with
standard Java objects.

If you want to build such an extendable model, it might also be worth
to take a look at the OSGi specifications. They form the foundation of
the Eclipse IDE. The OSGi specifies a small framework that manages the
modularity and lifecycle issues of a plugin based model.

Kind regards,

  Peter Kriens
ericaro@gmail.com - 25 Nov 2005 14:29 GMT
you can also read at runtime a .properties file that contains a comma
separated list of fully qualified class
Instanciate using reflexion thoses classes (assuming they are in the
classpath), cast them as com.yourpackage.YourPluginInterface, and use
this list in your core program.

To get thoses classes in the classpath at runtime, set a directory for
"plugins", and instanciate an URLClassLoader, that "loads" all jars in.

Its very very basic and simple yet performant as far as your
application is not build upon thousands of  different plugins type.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.