Mutli process C program to Java Design
I am currently in the midst of migrating my existing C apps to sit on a Java platform. The app is legacy and interfaces largely with numerous hardware devices via RS232 with a main controlling program that sequences the business logic. Imagine a manufacturing system with many conveyor belts, each conveyer belt having tons of hardware (each a C process) and each belt has main controlling program - All in C. Communicatoin between the numerous processes via shared memory queue mechanism (unix based)
My initial thought is to develop some sort of main property file to denote per suite of hardware devices per belt. Each suite will then be loaded into some storage(perhaps a hash table). A thread-base controller is developed to handle request, which will load a "suite" of supporting classes for that belt, based on the configuration file.
Sounds reasonable? Folks out there with similar requirements or any best practices?
First post, hope to gain and learn! Cheers
[993 byte] By [
stdouta] at [2007-10-2 20:06:50]

You should probably look at using XML for your configuration information.
Checkout the the Factory pattern for constructing your support classes and the Command pattern for implementing them. This approach can be easily driven by XML.
The best advice I can give for best practice for somebody new to OO is look up the principle of a single and _stick_ to it. It may seem counter productive at first but will pay off very quickly.
Thanks for the reply
i believe i did something similar before, but its based on that of a property file, an abstract class and handler extending from it. Basically loading all of it into a hash table and than defining the keys associating to each class. That way, i jus load the handler class using a generic handleMesg() method....it looks similar to the Factory pattern description...pardon me if i am wrong .. :)
for (Enumeration e = properties.propertyNames() ; e.hasMoreElements() ;)
{
String msgType = (String) e.nextElement();
String handlerName = properties.getProperty(msgType);
//create handler class
try
{
Class handlerClass = Class.forName(handlerName);
Object handler = handlerClass.newInstance();
mesgHandlerHashTable.put(msgType, handler);
}
catch (Exception exp)
{
log.info("Error in instantiating Handler=" +exp.getMessage());
}
}
Anyway i am more concerned with the how to make the thread access the correct support classes. Bear in mind i will have suites of supporting classes for different belts
(for e.g belt 1 - Componet A1/B1/C1,
belt 2 - Componet A2/B2/C2)
so how am i going to ensure that thread spun to handle belt 1 correctly calls and accesses the methods for Belt 1 suit (A1,B1,C1)