User: starksm
Date: 01/11/27 22:15:31
Modified: src/main/org/jboss/mq/il/uil Tag: Branch_2_4
UILClientIL.java UILClientILService.java
Log:
Complete switch to org.jboss.logging.Logger and use trace to reduce default
logging
Add support for package version manifest headers
Revision Changes Path
No revision
No revision
1.2.2.2 +53 -31 jbossmq/src/main/org/jboss/mq/il/uil/UILClientIL.java
Index: UILClientIL.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/il/uil/UILClientIL.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- UILClientIL.java 2001/08/23 03:57:10 1.2.2.1
+++ UILClientIL.java 2001/11/28 06:15:31 1.2.2.2
@@ -15,9 +15,10 @@
import javax.jms.Destination;
import javax.jms.JMSException;
+
+import org.jboss.logging.Logger;
import org.jboss.mq.Connection;
import org.jboss.mq.ReceiveRequest;
-
import org.jboss.mq.SpyDestination;
import org.jboss.mq.il.ClientIL;
import org.jboss.mq.il.uil.multiplexor.SocketMultiplexor;
@@ -28,82 +29,103 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.2.2.1 $
+ * @version $Revision: 1.2.2.2 $
*/
-public class UILClientIL implements ClientIL, java.io.Serializable {
+public class UILClientIL implements ClientIL, java.io.Serializable
+{
+ static Logger log = Logger.getLogger( UILClientIL.class );
transient SocketMultiplexor mSocket;
private transient ObjectInputStream in;
private transient ObjectOutputStream out;
-
- static org.apache.log4j.Category cat = org.apache.log4j.Category.getInstance(
UILClientIL.class );
+
final static int m_close = 2;
final static int m_deleteTemporaryDestination = 1;
final static int m_receive = 3;
-
-
+
+
public void close()
- throws Exception {
+ throws Exception
+ {
}
-
+
public synchronized void deleteTemporaryDestination( SpyDestination dest )
- throws Exception {
+ throws Exception
+ {
checkSocket();
out.writeByte( m_deleteTemporaryDestination );
out.writeObject( dest );
waitAnswer();
}
-
+
public synchronized void receive( ReceiveRequest messages[] )
- throws Exception {
- cat.debug( "Checking socket" );
+ throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace( "Checking socket" );
checkSocket();
- cat.debug( "Writing request" );
+ if( trace )
+ log.trace( "Writing request" );
out.writeByte( m_receive );
out.writeInt( messages.length );
- for ( int i = 0; i < messages.length; ++i ) {
+ for ( int i = 0; i < messages.length; ++i )
+ {
messages[i].writeExternal( out );
}
- cat.debug( "Waiting for awnser" );
+ if( trace )
+ log.trace( "Waiting for awnser" );
waitAnswer();
- cat.debug( "Done" );
+ if( trace )
+ log.trace( "Done" );
}
-
+
protected void checkSocket()
- throws Exception {
- if ( out == null ) {
+ throws Exception
+ {
+ if ( out == null )
+ {
createConnection();
}
}
-
+
protected void createConnection()
- throws RemoteException {
- try {
+ throws RemoteException
+ {
+ try
+ {
in = new ObjectInputStream( new BufferedInputStream(
mSocket.getInputStream( 2 ) ) );
out = new ObjectOutputStream( new BufferedOutputStream(
mSocket.getOutputStream( 2 ) ) );
out.flush();
- } catch ( Exception e ) {
+ }
+ catch ( Exception e )
+ {
throw new RemoteException( "Cannot connect to the
ConnectionReceiver/Server" );
}
}
-
+
protected void waitAnswer()
- throws Exception {
+ throws Exception
+ {
Exception throwException = null;
- try {
+ try
+ {
out.reset();
out.flush();
int val = in.readByte();
- switch ( val ) {
+ switch ( val )
+ {
case 1:
Exception e = ( Exception )in.readObject();
throwException = new RemoteException( "", e );
break;
}
- } catch ( IOException e ) {
+ } catch ( IOException e )
+ {
throw new RemoteException( "Cannot contact the remote object", e );
}
-
- if ( throwException != null ) {
+
+ if ( throwException != null )
+ {
throw throwException;
}
}
1.2.2.2 +92 -58 jbossmq/src/main/org/jboss/mq/il/uil/UILClientILService.java
Index: UILClientILService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/il/uil/UILClientILService.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- UILClientILService.java 2001/08/23 03:57:10 1.2.2.1
+++ UILClientILService.java 2001/11/28 06:15:31 1.2.2.2
@@ -16,9 +16,10 @@
import javax.jms.Destination;
import javax.jms.JMSException;
+
+import org.jboss.logging.Logger;
import org.jboss.mq.Connection;
import org.jboss.mq.ReceiveRequest;
-
import org.jboss.mq.SpyDestination;
import org.jboss.mq.il.ClientIL;
import org.jboss.mq.il.ClientILService;
@@ -29,9 +30,11 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.2.2.1 $
+ * @version $Revision: 1.2.2.2 $
*/
-public class UILClientILService implements Runnable,
org.jboss.mq.il.ClientILService {
+public class UILClientILService implements Runnable, ClientILService
+{
+ static Logger log = Logger.getLogger( UILClientILService.class );
//the client IL
UILClientIL clientIL;
//The thread that is doing the Socket reading work
@@ -40,90 +43,108 @@
private Connection connection;
//Should this service be running ?
private boolean running;
-
- static org.apache.log4j.Category cat = org.apache.log4j.Category.getInstance(
UILClientILService.class );
+
// Attributes ----------------------------------------------------
final static int m_close = 2;
final static int m_deleteTemporaryDestination = 1;
final static int m_receive = 3;
-
+
/**
* getClientIL method comment.
*
* @return The ClientIL value
* @exception java.lang.Exception Description of Exception
*/
- public org.jboss.mq.il.ClientIL getClientIL()
- throws java.lang.Exception {
+ public ClientIL getClientIL()
+ throws Exception
+ {
return clientIL;
}
-
-
+
+
/**
* start method comment.
*
* @exception java.lang.Exception Description of Exception
*/
public void start()
- throws java.lang.Exception {
-
+ throws Exception
+ {
running = true;
worker = new Thread( connection.threadGroup, this, "UILClientILService" );
worker.setDaemon( true );
worker.start();
-
+
}
-
+
/**
* @exception java.lang.Exception Description of Exception
*/
public void stop()
- throws java.lang.Exception {
+ throws Exception
+ {
running = false;
worker.interrupt();
}
-
- public void run() {
- cat.debug( "UILClientILService.run()" );
-
+
+ public void run()
+ {
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace( "UILClientILService.run()" );
+
Socket socket = null;
int code = 0;
-
+
ObjectOutputStream out = null;
ObjectInputStream in = null;
-
- try {
- cat.debug( "getting streams" );
+
+ try
+ {
+ if( trace )
+ log.trace( "getting streams" );
UILServerIL serverIL = ( UILServerIL )connection.getServerIL();
-
+
out = new ObjectOutputStream( new BufferedOutputStream(
serverIL.mSocket.getOutputStream( 2 ) ) );
out.flush();
in = new ObjectInputStream( new BufferedInputStream(
serverIL.mSocket.getInputStream( 2 ) ) );
-
- } catch ( IOException e ) {
+
+ }
+ catch ( IOException e )
+ {
connection.asynchFailure( "Could not initialize the UILClientIL Service.",
e );
running = false;
return;
}
-
- while ( running ) {
-
- try {
- cat.debug( "Waiting for a messgage from the server" );
+
+ while ( running )
+ {
+
+ try
+ {
+ if( trace )
+ log.trace( "Waiting for a messgage from the server" );
code = in.readByte();
- } catch ( java.io.InterruptedIOException e ) {
+ }
+ catch ( java.io.InterruptedIOException e )
+ {
continue;
- } catch ( IOException e ) {
+ }
+ catch ( IOException e )
+ {
break;
}
-
- try {
-
- switch ( code ) {
+
+ try
+ {
+
+ switch ( code )
+ {
case m_receive:
int numReceives = in.readInt();
org.jboss.mq.ReceiveRequest[] messages = new
org.jboss.mq.ReceiveRequest[numReceives];
- for ( int i = 0; i < numReceives; ++i ) {
+ for ( int i = 0; i < numReceives; ++i )
+ {
messages[i] = new ReceiveRequest();
messages[i].readExternal( in );
}
@@ -140,51 +161,63 @@
connection.asynchFailure( "UILClientIL invocation contained a bad
method code.", e );
throw e;
}
-
+
//Everthing was OK
-
- try {
+
+ try
+ {
out.writeByte( 0 );
out.flush();
- } catch ( IOException e ) {
- if ( running ) {
+ }
+ catch ( IOException e )
+ {
+ if ( running )
+ {
break;
}
-
+
connection.asynchFailure( "Connection failure", e );
break;
}
-
- } catch ( Exception e ) {
-
- if ( running ) {
+
+ }
+ catch ( Exception e )
+ {
+
+ if ( running )
+ {
break;
}
-
- try {
+
+ try
+ {
out.writeByte( 1 );
out.writeObject( e );
out.reset();
out.flush();
- } catch ( IOException e2 ) {
+ } catch ( IOException e2 )
+ {
connection.asynchFailure( "Connection failure", e2 );
break;
}
-
+
}
-
+
}
-
+
running = false;
- try {
+ try
+ {
out.close();
in.close();
- } catch ( IOException e ) {
+ }
+ catch ( IOException e )
+ {
connection.asynchFailure( "Error whle closing UILClientIL connection", e );
return;
}
}
-
+
/**
* init method comment.
*
@@ -193,7 +226,8 @@
* @exception java.lang.Exception Description of Exception
*/
public void init( org.jboss.mq.Connection connection, java.util.Properties props
)
- throws java.lang.Exception {
+ throws Exception
+ {
this.connection = connection;
clientIL = new UILClientIL();
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development