User: starksm 
  Date: 01/05/09 01:16:40

  Modified:    src/main/org/jboss/metadata EnvEntryMetaData.java
  Log:
  Add static utility method for binding the env entry into a JNDI context.
  
  Revision  Changes    Path
  1.3       +61 -20    jboss/src/main/org/jboss/metadata/EnvEntryMetaData.java
  
  Index: EnvEntryMetaData.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/EnvEntryMetaData.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EnvEntryMetaData.java     2000/12/07 15:45:01     1.2
  +++ EnvEntryMetaData.java     2001/05/09 08:16:40     1.3
  @@ -6,23 +6,27 @@
    */
   package org.jboss.metadata;
   
  +import javax.naming.Context;
  +import javax.naming.NamingException;
  +
   import org.w3c.dom.Element;
   
   import org.jboss.ejb.DeploymentException;
  +import org.jboss.naming.Util;
   
   /**
    *   <description> 
    *      
    *   @see <related>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini</a>
  - *   @version $Revision: 1.2 $
  + *   @version $Revision: 1.3 $
    */
   public class EnvEntryMetaData extends MetaData {
       // Constants -----------------------------------------------------
       
       // Attributes ----------------------------------------------------
  -     private String name;
  -     private String type;
  +    private String name;
  +    private String type;
       private String value;
       // Static --------------------------------------------------------
       
  @@ -31,24 +35,61 @@
        }
        
       // Public --------------------------------------------------------
  -     
  -     public String getName() { return name; }
  -     
  -     public String getType() { return type; }
        
  -     public String getValue() { return value; }
  +    public String getName() { return name; }
  +
  +    public String getType() { return type; }
  +
  +    public String getValue() { return value; }
       
       public void importEjbJarXml(Element element) throws DeploymentException {
  -             name = getElementContent(getUniqueChild(element, "env-entry-name"));
  -             type = getElementContent(getUniqueChild(element, "env-entry-type"));
  -             value = getElementContent(getUniqueChild(element, "env-entry-value"));
  -     }               
  -    
  -     // Package protected ---------------------------------------------
  -    
  -    // Protected -----------------------------------------------------
  -    
  -    // Private -------------------------------------------------------
  -    
  -    // Inner classes -------------------------------------------------
  +        name = getElementContent(getUniqueChild(element, "env-entry-name"));
  +        type = getElementContent(getUniqueChild(element, "env-entry-type"));
  +        value = getElementContent(getUniqueChild(element, "env-entry-value"));
  +    }
  +    
  +    public static void bindEnvEntry(Context ctx, EnvEntryMetaData entry)
  +        throws ClassNotFoundException, NamingException
  +    {
  +        ClassLoader loader = EnvEntryMetaData.class.getClassLoader();
  +        Class type = loader.loadClass(entry.getType());
  +        if( type == String.class )
  +        {
  +            Util.bind(ctx, entry.getName(), entry.getValue());
  +        }
  +        else if( type == Integer.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Integer(entry.getValue()));
  +        }
  +        else if( type == Long.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Long(entry.getValue()));
  +        }
  +        else if( type == Double.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Double(entry.getValue()));
  +        }
  +        else if( type == Float.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Float(entry.getValue()));
  +        }
  +        else if( type == Byte.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Byte(entry.getValue()));
  +        }
  +        else if( type == Short.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Short(entry.getValue()));
  +        }
  +        else if( type == Boolean.class )
  +        {
  +            Util.bind(ctx, entry.getName(), new Boolean(entry.getValue()));
  +        }
  +        else
  +        {
  +            // Default to a String type
  +            Util.bind(ctx, entry.getName(), entry.getValue());
  +        }
  +    }
  +
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to