User: hiram   
  Date: 01/03/01 23:04:53

  Added:       src/main/org/jbossmq/cluster/transport
                        InvalidConfigurationException.java
                        InvalidStateException.java NodeId.java
                        SerializerUtil.java Transport.java
                        TransportListener.java
  Log:
  - Changed Source references of GPL to LGPL.
  - The cluster work that I had been doing is now accesible via a Pub-Sub JMS api.
  - Take a look at the Cluster* examples in the sample directory to test it out.
  
  Revision  Changes    Path
  1.1                  
jbossmq/src/main/org/jbossmq/cluster/transport/InvalidConfigurationException.java
  
  Index: InvalidConfigurationException.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.cluster.transport;
  
  import java.lang.Exception;
  
  /**
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public class InvalidConfigurationException extends Exception {
  
        /**
         * InvalidConfigurationException constructor comment.
         */
        public InvalidConfigurationException() {
                super();
        }
  
        /**
         * InvalidConfigurationException constructor comment.
         * @param s java.lang.String
         */
        public InvalidConfigurationException(String s) {
                super(s);
        }
  }
  
  
  1.1                  
jbossmq/src/main/org/jbossmq/cluster/transport/InvalidStateException.java
  
  Index: InvalidStateException.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.cluster.transport;
  
  import java.lang.Exception;
  
  /**
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public class InvalidStateException extends Exception {
  
        /**
         * InvalidConfigurationException constructor comment.
         */
        public InvalidStateException() {
                super();
        }
  
        /**
         * InvalidConfigurationException constructor comment.
         * @param s java.lang.String
         */
        public InvalidStateException(String s) {
                super(s);
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/cluster/transport/NodeId.java
  
  Index: NodeId.java
  ===================================================================
  package org.jbossmq.cluster.transport;
  
  import java.lang.Object;
  
  /**
   * 
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public interface NodeId {
  }
  
  
  1.1                  
jbossmq/src/main/org/jbossmq/cluster/transport/SerializerUtil.java
  
  Index: SerializerUtil.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.cluster.transport;
  
  import java.lang.Object;
  
  /**
   * This is a utility class which hold functions useful for converting from
   * Java primitive types to byte[]s
   *
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public class SerializerUtil {
  
        /**
         * This is used for unit testing the class
         * @param args java.lang.String[]
         */
        public static void main(String[] args) {
  
                byte data[] = new byte[8];
  
                for (int i = -10; i < 150; i++) {
                        writeIntTo(i, data, 0);
                        int r = readIntFrom(data, 0);
                        System.out.println("Int :" + i + "==" + r);
                }
                for (long i = -10; i < 150; i++) {
                        writeLongTo(i, data, 0);
                        long r = readLongFrom(data, 0);
                        System.out.println("Long :" + i + "==" + r);
                }
  
        }
        
        public static int readIntFrom(byte[] data, int offset) {
                return (
                        ((data[offset] & 0xFF) << 24)
                                | ((data[offset + 1] & 0xFF) << 16)
                                | ((data[offset + 2] & 0xFF) << 8)
                                | ((data[offset + 3] & 0xFF) << 0));
        }
        
        public static long readLongFrom(byte[] data, int offset) {
                return (
                        ((long) (data[offset] & 0xFF) << 56)
                                | ((long) (data[offset + 1] & 0xFF) << 48)
                                | ((long) (data[offset + 2] & 0xFF) << 40)
                                | ((long) (data[offset + 3] & 0xFF) << 32)
                                | ((long) (data[offset + 4] & 0xFF) << 24)
                                | ((long) (data[offset + 5] & 0xFF) << 16)
                                | ((long) (data[offset + 6] & 0xFF) << 8)
                                | ((long) (data[offset + 7] & 0xFF) << 0));
        }
        
        public static short readShortFrom(byte[] data, int offset) {
                return (short)
                        (((data[offset] << 8) & 0xFF) | ((data[offset + 1] << 0) & 
0xFF));
        }
        
        static public void writeIntTo(int v, byte[] data, int pos) {
                data[pos] = (byte) ((v >>> 24) & 0xFF);
                data[pos + 1] = (byte) ((v >>> 16) & 0xFF);
                data[pos + 2] = (byte) ((v >>> 8) & 0xFF);
                data[pos + 3] = (byte) ((v >>> 0) & 0xFF);
        }
        
        static public void writeLongTo(long v, byte data[], int pos) {
                data[pos] = (byte) ((v >>> 56) & 0xFF);
                data[pos + 1] = (byte) ((v >>> 48) & 0xFF);
                data[pos + 2] = (byte) ((v >>> 40) & 0xFF);
                data[pos + 3] = (byte) ((v >>> 32) & 0xFF);
                data[pos + 4] = (byte) ((v >>> 24) & 0xFF);
                data[pos + 5] = (byte) ((v >>> 16) & 0xFF);
                data[pos + 6] = (byte) ((v >>> 8) & 0xFF);
                data[pos + 7] = (byte) ((v >>> 0) & 0xFF);
        }
        
        public static void writeShortTo(short v, byte[] data, int pos) {
                data[pos] = (byte) ((v >>> 8) & 0xFF);
                data[pos + 1] = (byte) ((v >>> 0) & 0xFF);
        }
  
        public static int readUShortFrom(byte[] data, int offset) {
                return (
                              ((data[offset + 0] & 0xFF) << 8)
                                | ((data[offset + 1] & 0xFF) << 0)
                           );
        }
  
        static public void writeUShortTo(int v, byte[] data, int pos) {
                data[pos + 0] = (byte) ((v >>> 8) & 0xFF);
                data[pos + 1] = (byte) ((v >>> 0) & 0xFF);
        }
  }
  
  
  1.1                  jbossmq/src/main/org/jbossmq/cluster/transport/Transport.java
  
  Index: Transport.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.cluster.transport;
  
  import java.io.IOException;
  import java.util.Properties;
  
  /**
   * This is the interface any Transport class must implement.
   *
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   *
   */
  public interface Transport {
  
        public void setTransportListener(TransportListener c);
        public void send(short channelId, byte data[], boolean droppable, boolean 
keepOrder) throws IOException, InterruptedException;  
        public NodeId getLocalNodeId();
        public void send(NodeId dest, short channelId, byte data[], boolean droppable, 
boolean keepOrder) throws IOException, InterruptedException;
        public void setProperties(Properties t) throws InvalidConfigurationException, 
InvalidStateException;
        // Starts the transport 
        public void start() throws InvalidStateException;
        // Stops the transport 
        public void stop() throws InterruptedException;
        // closes the transport, cannot be restarted
        public void close() throws InterruptedException;
        
  }
  
  
  1.1                  
jbossmq/src/main/org/jbossmq/cluster/transport/TransportListener.java
  
  Index: TransportListener.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jbossmq.cluster.transport;
  
  import java.lang.Object;
  
  /**
   * This class is used by the Transport interface to signal the
   * the cluster that a message has arrived from the network.
   * 
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public interface TransportListener {
  
        public boolean isListeningOn(short topic);
        public void messageArrivedEvent( short channelId, NodeId senderId, byte 
message[] ) throws InterruptedException;
        
  }
  
  

Reply via email to