001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.jcaprops.support;
023:
024: import javax.management.MBeanServer;
025: import javax.resource.ResourceException;
026: import javax.resource.spi.ActivationSpec;
027: import javax.resource.spi.BootstrapContext;
028: import javax.resource.spi.ResourceAdapter;
029: import javax.resource.spi.ResourceAdapterInternalException;
030: import javax.resource.spi.endpoint.MessageEndpointFactory;
031: import javax.transaction.xa.XAResource;
032:
033: import org.jboss.logging.Logger;
034: import org.jboss.mx.util.MBeanServerLocator;
035:
036: /**
037: * A PropertyTestResourceAdapter.
038: *
039: * @author <a href="adrian@jboss.com">Adrian Brock</a>
040: * @version $Revision: 57211 $
041: */
042: public class PropertyTestResourceAdapter implements ResourceAdapter,
043: PropertyTestResourceAdapterMBean {
044: private static final Logger log = Logger
045: .getLogger(PropertyTestResourceAdapter.class);
046:
047: private String stringRAR;
048: private Boolean booleanRAR;
049: private Byte byteRAR;
050: private Character characterRAR;
051: private Short shortRAR;
052: private Integer integerRAR;
053: private Long longRAR;
054: private Float floatRAR;
055: private Double doubleRAR;
056:
057: public String getStringRAR() {
058: return stringRAR;
059: }
060:
061: public void setStringRAR(String string) {
062: this .stringRAR = string;
063: }
064:
065: public Boolean getBooleanRAR() {
066: return booleanRAR;
067: }
068:
069: public void setBooleanRAR(Boolean booleanRAR) {
070: this .booleanRAR = booleanRAR;
071: }
072:
073: public Byte getByteRAR() {
074: return byteRAR;
075: }
076:
077: public void setByteRAR(Byte byteRAR) {
078: this .byteRAR = byteRAR;
079: }
080:
081: public Character getCharacterRAR() {
082: return characterRAR;
083: }
084:
085: public void setCharacterRAR(Character characterRAR) {
086: this .characterRAR = characterRAR;
087: }
088:
089: public Double getDoubleRAR() {
090: return doubleRAR;
091: }
092:
093: public void setDoubleRAR(Double doubleRAR) {
094: this .doubleRAR = doubleRAR;
095: }
096:
097: public Float getFloatRAR() {
098: return floatRAR;
099: }
100:
101: public void setFloatRAR(Float floatRAR) {
102: this .floatRAR = floatRAR;
103: }
104:
105: public Integer getIntegerRAR() {
106: return integerRAR;
107: }
108:
109: public void setIntegerRAR(Integer integerRAR) {
110: this .integerRAR = integerRAR;
111: }
112:
113: public Long getLongRAR() {
114: return longRAR;
115: }
116:
117: public void setLongRAR(Long longRAR) {
118: this .longRAR = longRAR;
119: }
120:
121: public Short getShortRAR() {
122: return shortRAR;
123: }
124:
125: public void setShortRAR(Short shortRAR) {
126: this .shortRAR = shortRAR;
127: }
128:
129: public void start(BootstrapContext ctx)
130: throws ResourceAdapterInternalException {
131: registerMBean();
132: }
133:
134: public void stop() {
135: unregisterMBean();
136: }
137:
138: public void endpointActivation(
139: MessageEndpointFactory endpointFactory, ActivationSpec spec)
140: throws ResourceException {
141: PropertyTestActivationSpec as = (PropertyTestActivationSpec) spec;
142: as.registerMBean();
143: }
144:
145: public void endpointDeactivation(
146: MessageEndpointFactory endpointFactory, ActivationSpec spec) {
147: PropertyTestActivationSpec as = (PropertyTestActivationSpec) spec;
148: as.unregisterMBean();
149: }
150:
151: public XAResource[] getXAResources(ActivationSpec[] specs)
152: throws ResourceException {
153: return new XAResource[0];
154: }
155:
156: protected void registerMBean()
157: throws ResourceAdapterInternalException {
158: MBeanServer server = MBeanServerLocator.locateJBoss();
159: try {
160: server.registerMBean(this , NAME);
161: } catch (Exception e) {
162: throw new ResourceAdapterInternalException(e);
163: }
164: }
165:
166: protected void unregisterMBean() {
167: MBeanServer server = MBeanServerLocator.locateJBoss();
168: try {
169: server.unregisterMBean(NAME);
170: } catch (Exception e) {
171: log.warn("Unable to unregisterMBean", e);
172: }
173: }
174: }
|