Hi all,

I have an interesting puzzle! I have created a subsystem that writes
messages to logs. The subsystem is made up of the following classes:

1.Abstract LogManager - contains all functionality and an abstract method.
The class also contains two inner classes - one is a thread that manages
writing to log files and the other is a basic class for storing a message.

2. A Debug Log Manager class which extends the abstract class.

3.A class which provides an interface to the Debug Log Manager - uses the
facade pattern

4.A servlet class called "tester" which uses the interface and sends
messages.

Okay what happens? It seems that the class tester ends before the Debug Log
Manager has finished its work.  Even if there are messages
in the log buffer which the internal thread must process.
Now if I by pass the interface class and use the debugger manager directly
there is
no problem all objects execute and finish correctly. Makes sense?? If not I
will be happy to send the source.

Here is a basic class def for each:

class logAbstract {

method1
method2
abstract method3

inner class ThreadWritter extends Thread
{

//process messages in queue...

}

inner class messageItem{}

}//end class

class DebugLogManager extends logAbstract{

private BufferedWriter theWriter

method3

}

class interface{

private DebugLogManager theDebugLogManager = null;
private interface singleton;

interface{

theDebugLogManager = new DebugLogManager

}//constructor

methodWrite(String message){

this.theDebugLogManager.write(message)

}//end methodWrite

finalize{

this.theDebugLogManager = null;

}//end finalize

interface getSingleton{

return singleton;

}

}//end Interface

class testerServlet{

doPost(){
//this works - messages are written thread closes correctly.
interface theInterface = new interface();
theInterface.write('message")'

//this does not work - messages are written sometimes but gc or something
seems to remove it before file is closed etc..
interface.getSingleton.write("message");

}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to