1 22 package org.jboss.injection; 23 24 import org.jboss.naming.Util; 25 26 import javax.naming.LinkRef ; 27 import javax.naming.NamingException ; 28 29 35 public class LinkRefEncInjector implements EncInjector 36 { 37 private String jndiName; 38 private String error; 39 private String encName; 40 41 public LinkRefEncInjector(String name, String mappedName, String error) 42 { 43 this.jndiName = mappedName; 44 this.error = error; 45 this.encName = name; 46 } 47 48 public void inject(InjectionContainer container) 49 { 50 try 51 { 52 Util.rebind(container.getEnc(), encName, new LinkRef (jndiName)); 53 } 54 catch (NamingException e) 55 { 56 throw new RuntimeException (new StringBuilder ().append("could not bind enc name '").append(encName).append("' for ").append(error).append(" for container ").append(container.getIdentifier()).append(e.getMessage()).toString()); 57 } 58 } 59 } 60 | Popular Tags |