KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jcaprops > support > PropertyTestResourceAdapter


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jcaprops.support;
23
24 import javax.management.MBeanServer JavaDoc;
25 import javax.resource.ResourceException JavaDoc;
26 import javax.resource.spi.ActivationSpec JavaDoc;
27 import javax.resource.spi.BootstrapContext JavaDoc;
28 import javax.resource.spi.ResourceAdapter JavaDoc;
29 import javax.resource.spi.ResourceAdapterInternalException JavaDoc;
30 import javax.resource.spi.endpoint.MessageEndpointFactory JavaDoc;
31 import javax.transaction.xa.XAResource JavaDoc;
32
33 import org.jboss.logging.Logger;
34 import org.jboss.mx.util.MBeanServerLocator;
35
36 /**
37  * A PropertyTestResourceAdapter.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 37406 $
41  */

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