1 16 17 package org.apache.naming.ant; 18 19 import javax.naming.InitialContext ; 20 21 import org.apache.tools.ant.Task; 22 import org.apache.tools.ant.TaskAdapter; 23 24 25 30 public class JndiSet extends Task { 31 private static org.apache.commons.logging.Log log= 32 org.apache.commons.logging.LogFactory.getLog( JndiSet.class ); 33 String refId; 34 String value; 35 36 String contextName; 37 String attributeName; 38 39 public JndiSet() { 40 } 41 42 44 public void setRefId( String refId ) { 45 this.refId=refId; 46 } 47 48 50 public void setValue( String val ) { 51 this.value=val; 52 } 53 54 56 public void setContext( String ctx ) { 57 this.contextName=ctx; 58 } 59 60 public void setAttribute( String att ) { 61 this.attributeName=att; 62 } 63 64 65 public void execute() { 66 try { 67 InitialContext ic=new InitialContext (); 68 Object o=null; 69 70 if( refId != null ) { 71 o=project.getReference( refId ); 72 if( o instanceof TaskAdapter ) 73 o=((TaskAdapter)o).getProxy(); 74 } 75 if( o==null ) 76 o=value; 77 log.info( "Binding " + contextName + " " + o ); 79 ic.bind( contextName, o ); 80 81 } catch( Exception ex ) { 82 ex.printStackTrace(); 83 } 84 } 85 86 } 87 | Popular Tags |