1 16 17 package org.apache.naming.core; 18 19 import javax.naming.Binding ; 20 import javax.naming.Context ; 21 import javax.naming.NamingException ; 22 23 29 public class ServerBinding extends Binding { 30 public ServerBinding( String name, Context ctx, boolean isRelative ) { 31 super( name, null ); 32 this.ctx=ctx; 33 this.name = name; 34 this.isRel=isRelative; 35 } 36 37 public void recycle() { 38 } 39 40 private Context ctx; 41 private Object boundObj; 42 private String name; 43 private boolean isRel = true; 44 private String className; 45 46 private void lookup() { 47 try { 48 boundObj=ctx.lookup(name); 49 } catch( NamingException ex ) { 50 ex.printStackTrace(); 51 } 52 } 53 54 public String getClassName() { 55 if( className!=null ) return className; 56 if( boundObj==null ) lookup(); 57 58 if( boundObj!=null ) 59 className=boundObj.getClass().getName(); 60 return className; 61 } 62 63 public String getName() { 64 return name; 65 } 66 67 public void setName(String name) { 68 this.name = name; 69 } 70 71 public void setClassName(String name) { 72 this.className = name; 73 } 74 75 public boolean isRelative() { 76 return isRel; 77 } 78 79 public void setRelative(boolean r) { 80 isRel = r; 81 } 82 83 92 public String toString() { 93 return (isRelative() ? "" : "(not relative)") + getName() + ": " + 94 getClassName(); 95 } 96 97 98 public Object getObject() { 99 if( boundObj!=null ) 100 return boundObj; 101 lookup(); 102 return boundObj; 103 } 104 105 public void setObject(Object obj) { 106 boundObj = obj; 107 } 108 } 109 | Popular Tags |