The Artima Developer Community
Sponsored Link

Modular Server

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Modular Server

Posted by Emil Eifrem on 19 Dec 1998, 3:36 PM

Boy was I surprised when I checked JavaWorld's frontpage the
other day. I had just spent a couple of days fiddling with
dynamic class loading and, more importantly, dynamic class
*ditching*.

I am programming a multi-user game server in Java. This is indeed
one of those 24/7 applications your article mentioned -- in fact,
after we've gone live, we don't intend to ever reboot.

One of the instruments to achieve this goal is a modular design.
We'll have a static kernel that does little more than module
management, and every other functionality will be in the
NetworkModule, the WorldModule, the CommandModule, the
ParserModule, the DatabaseModule, etc -- all of which can be
loaded and unloaded at runtime. Thus class loading and ditching.

I wish the modules to reside in a base dir, let's call it
'modules/'. Each module would then have its own package under
that dir. So the NetworkModule's fully qualified name would be
'network.NetworkModule' and the file would be in
'modules/network/NetworkModule.class'.

When I load the modules from the server, I cast them all to their
superclass 'Module', which defines the interface for basic
operations such as loading/unloading/report status/etc. Here
(finally) comes my problem:

The file Module.class is in package 'core'. I need it when I
compile my modules, since they all extend the abstract Module
super class. My modules are of necessity moved out of my
classpath (thus a custom class loader similar, but not identical
(mine supports loading from a class from a DB too), to your
'holeloader') so I can't simply say
'class NetworkModule extends core.Module' or likewise.

I also need it in my core package (the kernel) for obvious
reasons. Any good solutions to this problem? There are ugly
workarounds, like constructing a script that copies
core/Module.java to modules/ and strips out the line
'package core;', but those are just that: ugly workarounds, and I'd
rather avoid them.

This message is probably a bit lengthier than most postings in
these forums, and I apologize for that. There may be a simple
solution to my problem (I haven't really looked at it since last
night) but this also gives me a reason to flaunt my scheme in
public for an experienced audience that may see flaws that I have
overlooked.

Thank you.

-EE



Replies:
  • Hmm... Bill Venners 21 Dec 1998, 1:59 AM (1)
    • Thank ya Emil Eifrem 21 Dec 1998, 3:32 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us