User: hiram   
  Date: 00/12/29 12:18:36

  Added:       src/java/org/spydermq/referenceable ObjectRefAddr.java
                        SpyConnectionFactoryObjectFactory.java
                        SpyDestinationObjectFactory.java
  Log:
  Feature Add: JMS Spec stated that the managed objects needed to implement 
javax.naming.Refrenceable.
  
  Revision  Changes    Path
  1.1                  spyderMQ/src/java/org/spydermq/referenceable/ObjectRefAddr.java
  
  Index: ObjectRefAddr.java
  ===================================================================
  /*
   * spyderMQ, the OpenSource JMS implementation
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.spydermq.referenceable;
  
  import javax.naming.RefAddr;
  
  /**
   *    This class is used to store a serializable object in
   *    a RefAddr object. 
   * 
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class ObjectRefAddr extends RefAddr {
  
        private Object content;
        
        /**
         * ObjectRefAddr constructor comment.
         * @param arg1 java.lang.String
         */
        public ObjectRefAddr(String arg1, Object content) {
                super(arg1);
                this.content = content;
        }
        
        /**
         * getContent method comment.
         */
        public Object getContent() {
                return content;
        }
  }
  
  
  
  1.1                  
spyderMQ/src/java/org/spydermq/referenceable/SpyConnectionFactoryObjectFactory.java
  
  Index: SpyConnectionFactoryObjectFactory.java
  ===================================================================
  /*
   * spyderMQ, the OpenSource JMS implementation
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.spydermq.referenceable;
  
  import javax.naming.spi.ObjectFactory;
  
  import org.spydermq.Log;
  import org.spydermq.distributed.interfaces.DistributedConnectionFactory;
  
  /**
   *    This class is used to create instances of of:
   *            SpyTopicConnectionFactory
   *            SpyQueueConnectionFactory
   *            SpyXATopicConnectionFactory
   *            SpyXAQueueConnectionFactory
   *    classes from a javax.naming.Reference instance.
   * 
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class SpyConnectionFactoryObjectFactory implements ObjectFactory {
        
        /**
         * SpyTopicObjectFactory constructor.
         */
        public SpyConnectionFactoryObjectFactory() {
                super();
        }
        
        /**
         * getObjectInstance method.
         */
        public java.lang.Object getObjectInstance(java.lang.Object reference, 
javax.naming.Name name, javax.naming.Context contex, java.util.Hashtable properties)
                throws java.lang.Exception {
  
                Log.log("SpyConnectionFactoryObjectFactory->getObjectInstance()");
  
                try {
  
                        javax.naming.Reference ref = (javax.naming.Reference) 
reference;
                        if 
(ref.getClassName().equals("org.spydermq.SpyTopicConnectionFactory")) {
  
                                DistributedConnectionFactory dcf = 
(DistributedConnectionFactory) ref.get("DCF").getContent();
                                return new org.spydermq.SpyTopicConnectionFactory(dcf);
  
                        } else if 
(ref.getClassName().equals("org.spydermq.SpyQueueConnectionFactory")) {
  
                                DistributedConnectionFactory dcf = 
(DistributedConnectionFactory) ref.get("DCF").getContent();
                                return new org.spydermq.SpyQueueConnectionFactory(dcf);
  
                        } else if 
(ref.getClassName().equals("org.spydermq.SpyXATopicConnectionFactory")) {
  
                                DistributedConnectionFactory dcf = 
(DistributedConnectionFactory) ref.get("DCF").getContent();
                                return new 
org.spydermq.SpyXATopicConnectionFactory(dcf);
  
                        } else if 
(ref.getClassName().equals("org.spydermq.SpyXAQueueConnectionFactory")) {
  
                                DistributedConnectionFactory dcf = 
(DistributedConnectionFactory) ref.get("DCF").getContent();
                                return new 
org.spydermq.SpyXAQueueConnectionFactory(dcf);
                        }
  
                } catch (Throwable ignore) {
                        // This method should not throw an exception since
                        // It would prevent another ObjectFactory from attempting
                        // to create an instance of the object.
                }
                return null;
        }
  }
  
  
  
  1.1                  
spyderMQ/src/java/org/spydermq/referenceable/SpyDestinationObjectFactory.java
  
  Index: SpyDestinationObjectFactory.java
  ===================================================================
  /*
   * spyderMQ, the OpenSource JMS implementation
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.spydermq.referenceable;
  
  import javax.naming.spi.ObjectFactory;
  
  import org.spydermq.Log;
  
  /**
   *    This class is used to create instances of of:
   *            SpyTopic
   *            SpyQueue
   *    classes from a javax.naming.Reference instance.
   * 
   *    @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   *    @version $Revision: 1.1 $
   */
  public class SpyDestinationObjectFactory implements ObjectFactory {
        
        /**
         * SpyTopicObjectFactory constructor
         */
        public SpyDestinationObjectFactory() {
                super();
        }
        
        /**
         * getObjectInstance method 
         */
        public java.lang.Object getObjectInstance(java.lang.Object reference, 
javax.naming.Name name, javax.naming.Context contex, java.util.Hashtable properties)
                throws java.lang.Exception {
  
                Log.log("SpyDestinationObjectFactory->getObjectInstance()");
  
                try {
  
                        javax.naming.Reference ref = (javax.naming.Reference) 
reference;
                        if (ref.getClassName().equals("org.spydermq.SpyTopic")) {
  
                                String dest = (String) ref.get("name").getContent();
                                return new org.spydermq.SpyTopic(dest);
  
                        } else if (ref.getClassName().equals("org.spydermq.SpyQueue")) 
{
  
                                String dest = (String) ref.get("name").getContent();
                                return new org.spydermq.SpyQueue(dest);
  
                        }
  
                } catch (RuntimeException ignore) {
                } catch (Exception ignore) {
                        // This method should not throw an exception since
                        // It would prevent another ObjectFactory from attempting
                        // to create an instance of the object.
                }
                return null;
        }
  }
  
  
  

Reply via email to