User: norbert 
  Date: 00/05/30 19:54:31

  Modified:    src/java/org/spyderMQ JMSServer.java JMSServerQueue.java
                        Log.java SessionQueue.java SpyMessageConsumer.java
                        SpySession.java SpyTopicSubscriber.java
  Log:
  Change to the sypderMQ internal log system
  
  Revision  Changes    Path
  1.35      +8 -7      spyderMQ/src/java/org/spyderMQ/JMSServer.java
  
  Index: JMSServer.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/JMSServer.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- JMSServer.java    2000/05/31 00:02:00     1.34
  +++ JMSServer.java    2000/05/31 02:54:29     1.35
  @@ -22,7 +22,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.34 $
  + *   @version $Revision: 1.35 $
    */
   public class JMSServer 
                implements Runnable 
  @@ -72,10 +72,11 @@
   
        // Public --------------------------------------------------------
   
  +     //This is a correct threading system, but this is not ideal... 
  +     //We should let threads cycle through the JMSServerQueue list, and 
synchronized on the queue they are working on.
  +     
        public void run()
        {
  -             Log.log("Hi ! I'm a server thread :)");
  -             
                while (true)
                {
        
  @@ -115,7 +116,7 @@
        
        public SpyTopic newTopic(String name) throws JMSException
        {
  -             Log.log("[JMSServer] new topic : "+name);
  +             Log.notice("[JMSServer] new topic : "+name);
        
                SpyTopic newTopic=new SpyTopic(name);
                if (messageQueue.containsKey(newTopic)) throw new JMSException("This 
topic already exists !");
  @@ -135,7 +136,7 @@
                
        public SpyQueue newQueue(String name) throws JMSException
        {
  -             Log.log("[JMSServer] new queue : "+name);
  +             Log.notice("[JMSServer] new queue : "+name);
        
                SpyQueue newQueue=new SpyQueue(name);
                if (messageQueue.containsKey(newQueue)) throw new JMSException("This 
queue already exists !");
  @@ -176,11 +177,11 @@
        //A connection has send a new message
       public void newMessage(SpyMessage val[],String id) throws JMSException 
        {
  -             if (val.length!=1) Log.log("INCOMING: "+val.length+" messages from 
"+id);
  +             if (val.length!=1) Log.notice("INCOMING: "+val.length+" messages from 
"+id);
                
                for(int i=0;i<val.length;i++) {
                
  -                     Log.log("INCOMING: "+val[i]+" => "+val[i].jmsDestination);
  +                     Log.notice("INCOMING: "+val[i]+" => "+val[i].jmsDestination);
                
                        JMSServerQueue 
queue=(JMSServerQueue)messageQueue.get(val[i].jmsDestination);
                        if (queue==null) throw new JMSException("This destination does 
not exist !");
  
  
  
  1.30      +3 -3      spyderMQ/src/java/org/spyderMQ/JMSServerQueue.java
  
  Index: JMSServerQueue.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/JMSServerQueue.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- JMSServerQueue.java       2000/05/31 00:02:00     1.29
  +++ JMSServerQueue.java       2000/05/31 02:54:29     1.30
  @@ -18,7 +18,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.29 $
  + *   @version $Revision: 1.30 $
    */
   public class JMSServerQueue
   {
  @@ -207,7 +207,7 @@
        void connectionClosing(SpyDistributedConnection dc)
        {
                if (!subscribers.containsKey(dc.getClientID())) return;
  -             Log.log("Warning: The DistributedConnection was still registered for 
"+destination);
  +             Log.notice("Warning: The DistributedConnection was still registered 
for "+destination);
                removeSubscriber(dc);
        }
        
  @@ -274,7 +274,7 @@
                                }
                                if (dc==null||dc.listeners==0) {
                                        listeners=0;
  -                                     Log.log("WARNING: The listeners count was 
invalid !");
  +                                     Log.error("WARNING: The listeners count was 
invalid !");
                                        break;
                                }
                                
  
  
  
  1.5       +28 -32    spyderMQ/src/java/org/spyderMQ/Log.java
  
  Index: Log.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/Log.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Log.java  2000/05/16 00:25:31     1.4
  +++ Log.java  2000/05/31 02:54:30     1.5
  @@ -8,53 +8,49 @@
   
   /**
    * This is a very basic log system,
  - * The only functionnality that we need is to be able to shut down the log.
  - * We may use a better log system later (jBoss one).
  + * the only functionnality that we need is to be able to shut down the log. 
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.4 $
  + *   @version $Revision: 1.5 $
    */
   public class Log
   {
  -     final static int LOG_CONSOLE = 1;
  -     final static int LOG_FILE = 2;
  -     final static int LOG_NOLOG = 3; 
  +     final static int LOG_EVERYTHING = 1;
  +     final static int LOG_NOTICE             = 2;
  +     final static int LOG_ERRORS             = 3;
        
  -     final static int logType = LOG_CONSOLE;
  +     //Change this line change the verbosity level
  +     final static int logType = LOG_EVERYTHING;
        
  -     public static void log(String str)
  +     private static void print(Object obj)
        {
  -             if (logType==LOG_CONSOLE) System.out.println(str);
  +             if (obj instanceof String) System.out.println((String)obj);
  +             else if (obj instanceof Exception) ((Exception)obj).printStackTrace();
  +             else System.out.println(obj.toString());
        }
  -
  -     public static void log(Object e)
  -     {
  -             log(e.toString());
  -     }
  -
  -     public static void log(Exception e)
  -     {
  -             e.printStackTrace();
  -     }
  -
  -     public static void log(int i)
  -     {
  -             log(new Integer(i).toString());
  -     }
  -
  -     public static void error(String str)
  +     
  +     //Logs
  +     
  +     public static void log(Object obj)
        {
  -             System.out.println("[ERROR] "+str);
  +             if (logType>LOG_EVERYTHING) return;
  +             print(obj);
        }
   
  -     public static void error(Exception e)
  +     //Notice
  +     
  +     public static void notice(Object obj)
        {
  -             e.printStackTrace();
  +             if (logType>LOG_NOTICE) return;
  +             print(obj);
        }
  -
  -     public static void error(Object e)
  +     
  +     //Errors
  +     
  +     public static void error(Object obj)
        {
  -             error(e.toString());
  +             print(obj);
        }
  +     
   }
  
  
  
  1.19      +2 -2      spyderMQ/src/java/org/spyderMQ/SessionQueue.java
  
  Index: SessionQueue.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/SessionQueue.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SessionQueue.java 2000/05/30 22:10:17     1.18
  +++ SessionQueue.java 2000/05/31 02:54:30     1.19
  @@ -21,7 +21,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.18 $
  + *   @version $Revision: 1.19 $
    */
   public class SessionQueue
   {
  @@ -193,7 +193,7 @@
                }
                if (receiver==null||!receiver.listening) {
                        NumListeningSubscribers=0;
  -                     Log.log("WARNING: The listeners count was invalid !");
  +                     Log.error("WARNING: The listeners count was invalid !");
                        throw new JMSException("There is no receiver for this queue 
!"); //We should catch this error in the JMSServerQueue object
                }
   
  
  
  
  1.14      +2 -2      spyderMQ/src/java/org/spyderMQ/SpyMessageConsumer.java
  
  Index: SpyMessageConsumer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/SpyMessageConsumer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SpyMessageConsumer.java   2000/05/25 01:18:33     1.13
  +++ SpyMessageConsumer.java   2000/05/31 02:54:30     1.14
  @@ -20,7 +20,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.13 $
  + *   @version $Revision: 1.14 $
    */
   public class SpyMessageConsumer 
        implements MessageConsumer
  @@ -133,7 +133,7 @@
                                        SpyMessage 
mes=(SpyMessage)messages.removeFirst();
                                
                                        if (mes.isOutdated()) {
  -                                             Log.log("SessionQueue: I dropped a 
message (timeout)");
  +                                             Log.notice("SessionQueue: I dropped a 
message (timeout)");
                                                continue;
                                        }
                                                
  
  
  
  1.23      +8 -9      spyderMQ/src/java/org/spyderMQ/SpySession.java
  
  Index: SpySession.java
  ===================================================================
  RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/SpySession.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SpySession.java   2000/05/31 00:02:01     1.22
  +++ SpySession.java   2000/05/31 02:54:30     1.23
  @@ -28,7 +28,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.22 $
  + *   @version $Revision: 1.23 $
    */
   public class SpySession 
        implements Runnable, Session
  @@ -54,8 +54,10 @@
        protected boolean modeStop;
        //Is the session closed ?
        boolean closed;
  -     //This object is the object used to synchronize the session's thread
  +     //This object is the object used to synchronize the session's thread - Need 
fixed / improvement
        public Integer thread;
  +     //Is this session in alpha mode ?
  +     public boolean alphaMode;
   
        // Constructor ---------------------------------------------------             
    
   
  @@ -71,8 +73,9 @@
                messageListener=null;
                closed=false;
                thread=new Integer(0);
  +             alphaMode=true;
                
  -             //Start one thread for each session
  +             //Start my thread 
                Thread oneThread=new Thread(this);
                oneThread.setDaemon(true);
                oneThread.start();
  @@ -198,13 +201,9 @@
                                        }
                                }
                                
  -                             if (outgoingJob!=null) {
  -                                     
  -                                 //NL We should try (if possible) to send grouped 
messages to the server
  -                                 //NL Wait until we have 'local optimisation'
  -
  +                             if (outgoingJob!=null) {                               
         
                                        try {
  -                                             //Check for outdated messages
  +                                             //Check for outdated messages !
                                                connection.sendToServer(outgoingJob);
                                                doneJob=true;
                                        } catch (JMSException e) {
  
  
  
  1.11      +3 -3      spyderMQ/src/java/org/spyderMQ/SpyTopicSubscriber.java
  
  Index: SpyTopicSubscriber.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/SpyTopicSubscriber.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SpyTopicSubscriber.java   2000/05/24 19:17:18     1.10
  +++ SpyTopicSubscriber.java   2000/05/31 02:54:30     1.11
  @@ -20,7 +20,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.10 $
  + *   @version $Revision: 1.11 $
    */
   public class SpyTopicSubscriber 
        extends SpyMessageConsumer 
  @@ -92,7 +92,7 @@
                                if (!session.modeStop) {
                                        Message mes=getMessage();
                                        if (mes!=null) return mes;
  -                             } else Log.log("the connection is stopped !");
  +                             } else Log.notice("the connection is stopped !");
                                
                                try {
                                        waitInReceive=true;
  @@ -127,7 +127,7 @@
                                if (!session.modeStop) {
                                        Message mes=getMessage();
                                        if (mes!=null) return mes;
  -                             } else Log.log("the connection is stopped !");
  +                             } else Log.notice("the connection is stopped !");
                                
                                long att=endTime-((new Date()).getTime());
                                if (att<=0) return null;
  
  
  

Reply via email to