1 22 package org.jboss.test.jcaprops.support; 23 24 import javax.management.MBeanServer ; 25 import javax.resource.ResourceException ; 26 import javax.resource.spi.ActivationSpec ; 27 import javax.resource.spi.BootstrapContext ; 28 import javax.resource.spi.ResourceAdapter ; 29 import javax.resource.spi.ResourceAdapterInternalException ; 30 import javax.resource.spi.endpoint.MessageEndpointFactory ; 31 import javax.transaction.xa.XAResource ; 32 33 import org.jboss.logging.Logger; 34 import org.jboss.mx.util.MBeanServerLocator; 35 36 42 public class PropertyTestResourceAdapter implements ResourceAdapter , PropertyTestResourceAdapterMBean 43 { 44 private static final Logger log = Logger.getLogger(PropertyTestResourceAdapter.class); 45 46 private String stringRAR; 47 private Boolean booleanRAR; 48 private Byte byteRAR; 49 private Character characterRAR; 50 private Short shortRAR; 51 private Integer integerRAR; 52 private Long longRAR; 53 private Float floatRAR; 54 private Double doubleRAR; 55 56 public String getStringRAR() 57 { 58 return stringRAR; 59 } 60 61 public void setStringRAR(String string) 62 { 63 this.stringRAR = string; 64 } 65 66 public Boolean getBooleanRAR() 67 { 68 return booleanRAR; 69 } 70 71 public void setBooleanRAR(Boolean booleanRAR) 72 { 73 this.booleanRAR = booleanRAR; 74 } 75 76 public Byte getByteRAR() 77 { 78 return byteRAR; 79 } 80 81 public void setByteRAR(Byte byteRAR) 82 { 83 this.byteRAR = byteRAR; 84 } 85 86 public Character getCharacterRAR() 87 { 88 return characterRAR; 89 } 90 91 public void setCharacterRAR(Character characterRAR) 92 { 93 this.characterRAR = characterRAR; 94 } 95 96 public Double getDoubleRAR() 97 { 98 return doubleRAR; 99 } 100 101 public void setDoubleRAR(Double doubleRAR) 102 { 103 this.doubleRAR = doubleRAR; 104 } 105 106 public Float getFloatRAR() 107 { 108 return floatRAR; 109 } 110 111 public void setFloatRAR(Float floatRAR) 112 { 113 this.floatRAR = floatRAR; 114 } 115 116 public Integer getIntegerRAR() 117 { 118 return integerRAR; 119 } 120 121 public void setIntegerRAR(Integer integerRAR) 122 { 123 this.integerRAR = integerRAR; 124 } 125 126 public Long getLongRAR() 127 { 128 return longRAR; 129 } 130 131 public void setLongRAR(Long longRAR) 132 { 133 this.longRAR = longRAR; 134 } 135 136 public Short getShortRAR() 137 { 138 return shortRAR; 139 } 140 141 public void setShortRAR(Short shortRAR) 142 { 143 this.shortRAR = shortRAR; 144 } 145 146 public void start(BootstrapContext ctx) throws ResourceAdapterInternalException 147 { 148 registerMBean(); 149 } 150 151 public void stop() 152 { 153 unregisterMBean(); 154 } 155 156 public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException 157 { 158 PropertyTestActivationSpec as = (PropertyTestActivationSpec) spec; 159 as.registerMBean(); 160 } 161 162 public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) 163 { 164 PropertyTestActivationSpec as = (PropertyTestActivationSpec) spec; 165 as.unregisterMBean(); 166 } 167 168 public XAResource [] getXAResources(ActivationSpec [] specs) throws ResourceException 169 { 170 return new XAResource [0]; 171 } 172 173 protected void registerMBean() throws ResourceAdapterInternalException 174 { 175 MBeanServer server = MBeanServerLocator.locateJBoss(); 176 try 177 { 178 server.registerMBean(this, NAME); 179 } 180 catch (Exception e) 181 { 182 throw new ResourceAdapterInternalException (e); 183 } 184 } 185 186 protected void unregisterMBean() 187 { 188 MBeanServer server = MBeanServerLocator.locateJBoss(); 189 try 190 { 191 server.unregisterMBean(NAME); 192 } 193 catch (Exception e) 194 { 195 log.warn("Unable to unregisterMBean", e); 196 } 197 } 198 } 199 | Popular Tags |