User: starksm
Date: 01/11/27 22:15:31
Modified: src/main/org/jboss/mq/il/oil Tag: Branch_2_4
OILClientIL.java OILClientILService.java
OILServerILService.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 +56 -34 jbossmq/src/main/org/jboss/mq/il/oil/OILClientIL.java
Index: OILClientIL.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/il/oil/OILClientIL.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- OILClientIL.java 2001/08/23 03:57:10 1.2.2.1
+++ OILClientIL.java 2001/11/28 06:15:31 1.2.2.2
@@ -17,9 +17,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;
@@ -29,94 +30,115 @@
* @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 OILClientIL implements ClientIL, java.io.Serializable {
-
+public class OILClientIL implements ClientIL, java.io.Serializable
+{
+ private static Logger log = Logger.getLogger( OILClientIL.class );
private InetAddress addr;
private transient ObjectInputStream in;
private transient ObjectOutputStream out;
private int port;
private transient Socket socket;
- static org.apache.log4j.Category cat = org.apache.log4j.Category.getInstance(
OILClientIL.class );
final static int m_close = 2;
final static int m_deleteTemporaryDestination = 1;
final static int m_receive = 3;
-
- OILClientIL( InetAddress addr, int port ) {
+
+ OILClientIL( InetAddress addr, int port )
+ {
this.addr = addr;
this.port = port;
}
-
+
public void close()
- throws Exception {
+ throws Exception
+ {
checkSocket();
out.writeByte( m_close );
waitAnswer();
}
-
+
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 ( socket == null ) {
+ throws Exception
+ {
+ if ( socket == null )
+ {
createConnection();
}
}
-
+
protected void createConnection()
- throws RemoteException {
- try {
- cat.info( "ConnectionReceiverOILClient is connecting to: " +
addr.getHostAddress() + ":" + port );
+ throws RemoteException
+ {
+ try
+ {
+ log.debug( "ConnectionReceiverOILClient is connecting to: " +
addr.getHostAddress() + ":" + port );
socket = new Socket( addr, port );
out = new ObjectOutputStream( new BufferedOutputStream(
socket.getOutputStream() ) );
out.flush();
in = new ObjectInputStream( new BufferedInputStream(
socket.getInputStream() ) );
- } catch ( Exception e ) {
- cat.debug( e );
+ }
+ catch ( Exception e )
+ {
+ log.debug( 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 +108 -63 jbossmq/src/main/org/jboss/mq/il/oil/OILClientILService.java
Index: OILClientILService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/il/oil/OILClientILService.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- OILClientILService.java 2001/08/23 03:57:10 1.2.2.1
+++ OILClientILService.java 2001/11/28 06:15:31 1.2.2.2
@@ -17,9 +17,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;
@@ -30,9 +31,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 OILClientILService implements Runnable,
org.jboss.mq.il.ClientILService {
+public class OILClientILService implements Runnable, org.jboss.mq.il.ClientILService
+{
+ static Logger log = Logger.getLogger( OILClientILService.class );
//the client IL
OILClientIL clientIL;
//The thread that is doing the Socket reading work
@@ -44,13 +47,12 @@
private boolean running;
//The server socket we listen for a connection on
private ServerSocket serverSocket;
-
- static org.apache.log4j.Category cat = org.apache.log4j.Category.getInstance(
OILClientILService.class );
+
// Attributes ----------------------------------------------------
final static int m_close = 2;
final static int m_deleteTemporaryDestination = 1;
final static int m_receive = 3;
-
+
/**
* getClientIL method comment.
*
@@ -58,63 +60,78 @@
* @exception java.lang.Exception Description of Exception
*/
public org.jboss.mq.il.ClientIL getClientIL()
- throws java.lang.Exception {
+ throws java.lang.Exception
+ {
return clientIL;
}
-
-
+
+
/**
* start method comment.
*
* @exception java.lang.Exception Description of Exception
*/
public void start()
- throws java.lang.Exception {
-
+ throws java.lang.Exception
+ {
+
running = true;
worker = new Thread( connection.threadGroup, this, "OILClientILService" );
worker.setDaemon( true );
worker.start();
-
+
}
-
+
/**
* @exception java.lang.Exception Description of Exception
*/
public void stop()
- throws java.lang.Exception {
+ throws java.lang.Exception
+ {
running = false;
worker.interrupt();
- if ( serverSocket != null ) {
+ if ( serverSocket != null )
+ {
serverSocket.close();
}
- if ( socket != null ) {
+ if ( socket != null )
+ {
socket.close();
}
}
-
- public void run() {
+
+ public void run()
+ {
int code = 0;
ObjectOutputStream out = null;
ObjectInputStream in = null;
socket = null;
-
- try {
- cat.debug( "Waiting for the server to connect to me" );
+
+ boolean trace = log.isTraceEnabled();
+ try
+ {
+ if( trace )
+ log.trace( "Waiting for the server to connect to me" );
// We may close() before we get a connection so we need to
// periodicaly check to see if we were !running.
serverSocket.setSoTimeout( 1000 );
- while ( socket == null ) {
- try {
+ while ( socket == null )
+ {
+ try
+ {
socket = serverSocket.accept();
- } catch ( java.io.InterruptedIOException e ) {
- } catch ( IOException e ) {
- if ( running ) {
+ } catch ( java.io.InterruptedIOException e )
+ {
+ } catch ( IOException e )
+ {
+ if ( running )
+ {
connection.asynchFailure( "Error accepting connection from server
in OILClientILService.", e );
}
return;
}
- if ( !running ) {
+ if ( !running )
+ {
return;
}
}
@@ -122,36 +139,52 @@
out = new ObjectOutputStream( new BufferedOutputStream(
socket.getOutputStream() ) );
out.flush();
in = new ObjectInputStream( new BufferedInputStream(
socket.getInputStream() ) );
-
- } catch ( IOException e ) {
+
+ }
+ catch ( IOException e )
+ {
connection.asynchFailure( "Could not initialize the OILClientIL Service.",
e );
return;
- } finally {
- try {
+ }
+ finally
+ {
+ try
+ {
serverSocket.close();
serverSocket = null;
- } catch ( IOException e ) {
+ }
+ catch ( IOException e )
+ {
}
}
-
- 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 );
}
@@ -166,52 +199,63 @@
default:
throw new RemoteException( "Bad method code !" );
}
-
+
//Everthing was OK
-
- try {
+
+ try
+ {
out.writeByte( 0 );
out.flush();
- } catch ( IOException e ) {
+ } catch ( IOException e )
+ {
connection.asynchFailure( "Connection failure", e );
return;
}
-
- } catch ( Exception e ) {
- if ( !running ) {
+
+ } catch ( Exception e )
+ {
+ if ( !running )
+ {
break;
}
-
- try {
- cat.error( e );
+
+ try
+ {
+ log.error( e );
out.writeByte( 1 );
out.writeObject( e );
out.reset();
out.flush();
- } catch ( IOException e2 ) {
+ } catch ( IOException e2 )
+ {
connection.asynchFailure( "Connection failure", e2 );
return;
}
-
+
}
-
+
}
-
- try {
- cat.debug( "Closing receiver connections." );
+
+ try
+ {
+ if( trace )
+ log.trace( "Closing receiver connections." );
out.close();
in.close();
- if ( socket != null ) {
+ if ( socket != null )
+ {
;
}
socket.close();
socket = null;
- } catch ( IOException e ) {
+ }
+ catch ( IOException e )
+ {
connection.asynchFailure( "Connection failure", e );
return;
}
}
-
+
/**
* init method comment.
*
@@ -220,7 +264,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 java.lang.Exception
+ {
this.connection = connection;
serverSocket = new ServerSocket( 0 );
clientIL = new OILClientIL( java.net.InetAddress.getLocalHost(),
serverSocket.getLocalPort() );
1.2.2.6 +7 -4 jbossmq/src/main/org/jboss/mq/il/oil/OILServerILService.java
Index: OILServerILService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/il/oil/OILServerILService.java,v
retrieving revision 1.2.2.5
retrieving revision 1.2.2.6
diff -u -r1.2.2.5 -r1.2.2.6
--- OILServerILService.java 2001/11/20 09:25:34 1.2.2.5
+++ OILServerILService.java 2001/11/28 06:15:31 1.2.2.6
@@ -50,9 +50,10 @@
*
* @author Hiram Chirino ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.2.2.5 $
+ * @version $Revision: 1.2.2.6 $
*/
-public class OILServerILService extends org.jboss.mq.il.ServerILJMXService
implements Runnable, OILServerILServiceMBean {
+public class OILServerILService extends org.jboss.mq.il.ServerILJMXService
implements Runnable, OILServerILServiceMBean
+{
protected ServerSocket serverSocket;
OILServerIL serverIL;
@@ -211,10 +212,12 @@
Object result = null;
- switch ( code ) {
+ switch ( code )
+ {
case m_setSpyDistributedConnection:
connectionToken = ( ConnectionToken )in.readObject();
- log.debug( "The OILClientIL Connection is set up" );
+ if( log.isTraceEnabled() )
+ log.trace( "The OILClientIL Connection is set up" );
break;
case m_acknowledge:
AcknowledgementRequest ack = new AcknowledgementRequest();
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development