1 28 29 package com.caucho.ejb.metadata; 30 31 import com.caucho.config.BuilderProgram; 32 import com.caucho.config.ConfigException; 33 import com.caucho.util.L10N; 34 35 import javax.naming.InitialContext ; 36 import java.lang.reflect.InvocationTargetException ; 37 import java.lang.reflect.Method ; 38 39 public class JndiInjectProgram extends BuilderProgram { 40 static final L10N L = new L10N(BuilderProgram.class); 41 42 private String _jndiName; 43 private Method _method; 44 45 JndiInjectProgram(String jndiName, Method method) 46 { 47 _jndiName = jndiName; 48 _method = method; 49 } 50 51 public void configure(Object bean) 52 throws ConfigException 53 { 54 try { 55 Object value = new InitialContext ().lookup(_jndiName); 56 57 _method.invoke(bean, value); 58 } catch (RuntimeException e) { 59 throw e; 60 } catch (InvocationTargetException e) { 61 throw new ConfigException(e.getCause()); 62 } catch (Exception e) { 63 throw new ConfigException(e); 64 } 65 } 66 67 public Object configure(Class type) 68 throws ConfigException 69 { 70 throw new UnsupportedOperationException (); 71 } 72 } 73 | Popular Tags |