1 16 17 package org.springframework.jndi; 18 19 import javax.naming.NamingException ; 20 21 import org.springframework.beans.factory.InitializingBean; 22 import org.springframework.util.StringUtils; 23 24 48 public abstract class JndiObjectLocator extends JndiLocatorSupport implements InitializingBean { 49 50 private String jndiName; 51 52 private Class expectedType; 53 54 55 61 public void setJndiName(String jndiName) { 62 this.jndiName = jndiName; 63 } 64 65 68 public String getJndiName() { 69 return this.jndiName; 70 } 71 72 76 public void setExpectedType(Class expectedType) { 77 this.expectedType = expectedType; 78 } 79 80 84 public Class getExpectedType() { 85 return this.expectedType; 86 } 87 88 public void afterPropertiesSet() throws IllegalArgumentException , NamingException { 89 if (!StringUtils.hasLength(getJndiName())) { 90 throw new IllegalArgumentException ("Property 'jndiName' is required"); 91 } 92 } 93 94 95 104 protected Object lookup() throws NamingException { 105 return lookup(getJndiName(), getExpectedType()); 106 } 107 108 } 109 | Popular Tags |