1 25 26 package org.objectweb.earsample.resourceadapters; 27 28 29 import java.net.MalformedURLException ; 30 import java.util.HashMap ; 31 32 import javax.naming.InitialContext ; 33 import javax.naming.NamingException ; 34 import javax.resource.NotSupportedException ; 35 import javax.resource.ResourceException ; 36 import javax.resource.spi.ActivationSpec ; 37 import javax.resource.spi.BootstrapContext ; 38 import javax.resource.spi.ResourceAdapterInternalException ; 39 import javax.resource.spi.endpoint.MessageEndpointFactory ; 40 import javax.transaction.xa.XAResource ; 41 42 47 public class ResourceAdapterImpl implements javax.resource.spi.ResourceAdapter , java.io.Serializable { 48 49 50 53 private static final long serialVersionUID = 3834312812943456568L; 54 55 58 private String eisurl; 59 60 63 private String jndiName; 64 65 68 private InitialContext ictx; 69 70 73 private BootstrapContext bootstrapCtx = null; 75 78 private transient HashMap endpointFactories = new HashMap (); 79 80 81 86 public void start(BootstrapContext bootstrapCtx) throws ResourceAdapterInternalException { 87 this.bootstrapCtx = bootstrapCtx; 88 89 try { 90 ictx = new InitialContext (); 91 ictx.bind(jndiName, eisurl); 92 } catch (NamingException e) { 93 e.printStackTrace(); 94 } 95 96 } 97 98 101 public void stop() { 102 try { 103 ictx.unbind(jndiName); 104 } catch (NamingException e) { 105 e.printStackTrace(); 106 } 107 } 108 109 110 118 public void endpointActivation(MessageEndpointFactory factory, ActivationSpec spec) throws NotSupportedException , 119 ResourceAdapterInternalException { 120 endpointFactories.put(spec, factory); 121 } 122 123 128 public void endpointDeactivation(MessageEndpointFactory factory, ActivationSpec spec) { 129 endpointFactories.remove(spec); 130 } 131 132 138 public XAResource [] getXAResources(ActivationSpec [] specs) throws ResourceException { 139 return null; 140 } 141 142 146 public String getEisURL() { 147 return eisurl.toString(); 148 } 149 150 155 public void setEisURL(String eisURL) throws MalformedURLException { 156 this.eisurl = eisURL; 158 } 159 160 164 public BootstrapContext getBootstrapCtx() { 165 return bootstrapCtx; 166 } 167 168 172 public void setBootstrapCtx(BootstrapContext bootstrapCtx) { 173 this.bootstrapCtx = bootstrapCtx; 174 } 175 176 180 public String getJndiName() { 181 return jndiName; 182 } 183 184 188 public void setJndiName(String jndiName) { 189 this.jndiName = jndiName; 190 } 191 } 192 | Popular Tags |