KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > jmx > CacheLegacyJmxWrapper


1 /*
2  * JBoss, Home of Professional Open Source.
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * as indicated by the @author tags. See the copyright.txt file in the
5  * distribution for a 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.cache.jmx;
23
24 import org.jboss.cache.config.BuddyReplicationConfig;
25 import org.jboss.cache.config.CacheLoaderConfig;
26 import org.jboss.cache.config.Configuration;
27 import org.jboss.cache.config.EvictionConfig;
28 import org.jboss.cache.factories.XmlConfigurationParser;
29 import org.jgroups.jmx.JChannelFactoryMBean;
30 import org.w3c.dom.Element JavaDoc;
31
32 import javax.management.NotificationBroadcaster JavaDoc;
33 import javax.transaction.TransactionManager JavaDoc;
34
35 /**
36  * {@link CacheJmxWrapper} subclass that supports building the
37  * {@link Configuration} from MBean attribute injection. Allows
38  * configuration of the cache using the JBoss AS 4.x JMX microkernel.
39  *
40  * @author <a HREF="brian.stansberry@jboss.com">Brian Stansberry</a>
41  * @version $Revision: 1.4 $
42  */

43 public class CacheLegacyJmxWrapper extends CacheJmxWrapper implements CacheLegacyJmxWrapperMBean, NotificationBroadcaster JavaDoc
44 {
45    private Element JavaDoc buddyReplConfig;
46    private Element JavaDoc evictionConfig;
47    private Element JavaDoc cacheLoaderConfig;
48
49    public CacheLegacyJmxWrapper()
50    {
51       super();
52       setConfiguration(new Configuration());
53    }
54
55    public Configuration getConfiguration()
56    {
57       Configuration result = super.getConfiguration();
58       if (result == null)
59       {
60          result = new Configuration();
61          setConfiguration(result);
62       }
63       return result;
64    }
65
66    public Element JavaDoc getBuddyReplicationConfig()
67    {
68       return buddyReplConfig;
69    }
70
71    public Element JavaDoc getCacheLoaderConfiguration()
72    {
73       return cacheLoaderConfig;
74    }
75
76    public String JavaDoc getCacheMode()
77    {
78       return getConfiguration().getCacheModeString();
79    }
80
81    public String JavaDoc getClusterName()
82    {
83       return getConfiguration().getClusterName();
84    }
85
86    public String JavaDoc getClusterProperties()
87    {
88       return getConfiguration().getClusterConfig();
89    }
90
91    public Element JavaDoc getEvictionPolicyConfig()
92    {
93       return evictionConfig;
94    }
95
96    public boolean getExposeManagementStatistics()
97    {
98       return getConfiguration().getExposeManagementStatistics();
99    }
100
101    public boolean getFetchInMemoryState()
102    {
103       return getConfiguration().isFetchInMemoryState();
104    }
105
106    public long getInitialStateRetrievalTimeout()
107    {
108       return getConfiguration().getInitialStateRetrievalTimeout();
109    }
110
111    public String JavaDoc getIsolationLevel()
112    {
113       return getConfiguration().getIsolationLevelString();
114    }
115
116    public long getLockAcquisitionTimeout()
117    {
118       return getConfiguration().getLockAcquisitionTimeout();
119    }
120
121    public String JavaDoc getMultiplexerService()
122    {
123       return getConfiguration().getMultiplexerService();
124    }
125
126    public String JavaDoc getMultiplexerStack()
127    {
128       return getConfiguration().getMultiplexerStack();
129    }
130
131    public JChannelFactoryMBean getMuxChannelFactory()
132    {
133       return getConfiguration().getRuntimeConfig().getMuxChannelFactory();
134    }
135
136    public String JavaDoc getNodeLockingScheme()
137    {
138       return getConfiguration().getNodeLockingSchemeString();
139    }
140
141    public long getReplQueueInterval()
142    {
143       return getConfiguration().getReplQueueInterval();
144    }
145
146    public int getReplQueueMaxElements()
147    {
148       return getConfiguration().getReplQueueMaxElements();
149    }
150
151    public String JavaDoc getReplicationVersion()
152    {
153       return getConfiguration().getReplVersionString();
154    }
155
156    public boolean getSyncCommitPhase()
157    {
158       return getConfiguration().isSyncCommitPhase();
159    }
160
161    public long getSyncReplTimeout()
162    {
163       return getConfiguration().getSyncReplTimeout();
164    }
165
166    public boolean getSyncRollbackPhase()
167    {
168       return getConfiguration().isSyncRollbackPhase();
169    }
170
171    public TransactionManager JavaDoc getTransactionManager()
172    {
173       return getConfiguration().getRuntimeConfig().getTransactionManager();
174    }
175
176    public String JavaDoc getTransactionManagerLookupClass()
177    {
178       return getConfiguration().getTransactionManagerLookupClass();
179    }
180
181    public boolean getUseRegionBasedMarshalling()
182    {
183       return getConfiguration().isUseRegionBasedMarshalling();
184    }
185
186    public boolean getUseReplQueue()
187    {
188       return getConfiguration().isUseReplQueue();
189    }
190
191    public boolean isInactiveOnStartup()
192    {
193       return getConfiguration().isInactiveOnStartup();
194    }
195
196    public void setBuddyReplicationConfig(Element JavaDoc config)
197    {
198       BuddyReplicationConfig brc = null;
199       if (config != null)
200       {
201          brc = XmlConfigurationParser.parseBuddyReplicationConfig(config);
202       }
203       getConfiguration().setBuddyReplicationConfig(brc);
204    }
205
206    public void setCacheLoaderConfiguration(Element JavaDoc cache_loader_config)
207    {
208       CacheLoaderConfig clc = null;
209       if (cache_loader_config != null)
210       {
211          clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
212       }
213       getConfiguration().setCacheLoaderConfig(clc);
214    }
215
216    public void setCacheMode(String JavaDoc mode) throws Exception JavaDoc
217    {
218       getConfiguration().setCacheModeString(mode);
219    }
220
221    public void setClusterConfig(Element JavaDoc config)
222    {
223       String JavaDoc props = null;
224       if (config != null)
225       {
226          props = XmlConfigurationParser.parseClusterConfigXml(config);
227       }
228       getConfiguration().setClusterConfig(props);
229    }
230
231    public void setClusterName(String JavaDoc name)
232    {
233       getConfiguration().setClusterName(name);
234    }
235
236    public void setClusterProperties(String JavaDoc cluster_props)
237    {
238       getConfiguration().setClusterConfig(cluster_props);
239    }
240
241    public void setEvictionPolicyConfig(Element JavaDoc config)
242    {
243       EvictionConfig ec = null;
244       if (config != null)
245       {
246          ec = XmlConfigurationParser.parseEvictionConfig(config, null);
247       }
248       getConfiguration().setEvictionConfig(ec);
249    }
250
251    public void setExposeManagementStatistics(boolean expose)
252    {
253       getConfiguration().setExposeManagementStatistics(expose);
254    }
255
256    public void setFetchInMemoryState(boolean flag)
257    {
258       getConfiguration().setFetchInMemoryState(flag);
259    }
260
261    public void setInactiveOnStartup(boolean inactiveOnStartup)
262    {
263       getConfiguration().setInactiveOnStartup(inactiveOnStartup);
264    }
265
266    public void setInitialStateRetrievalTimeout(long timeout)
267    {
268       getConfiguration().setInitialStateRetrievalTimeout(timeout);
269    }
270
271    public void setIsolationLevel(String JavaDoc level)
272    {
273       getConfiguration().setIsolationLevelString(level);
274    }
275
276    public void setLockAcquisitionTimeout(long timeout)
277    {
278       getConfiguration().setLockAcquisitionTimeout(timeout);
279    }
280
281    public void setMultiplexerService(String JavaDoc serviceName)
282    {
283       getConfiguration().setMultiplexerService(serviceName);
284    }
285
286    public void setMultiplexerStack(String JavaDoc stackName)
287    {
288       getConfiguration().setMultiplexerStack(stackName);
289    }
290
291    public void setMuxChannelFactory(JChannelFactoryMBean factory)
292    {
293       getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
294    }
295
296    public void setNodeLockingScheme(String JavaDoc nodeLockingScheme)
297    {
298       getConfiguration().setNodeLockingSchemeString(nodeLockingScheme);
299    }
300
301    public void setReplQueueInterval(long interval)
302    {
303       getConfiguration().setReplQueueInterval(interval);
304    }
305
306    public void setReplQueueMaxElements(int max_elements)
307    {
308       getConfiguration().setReplQueueMaxElements(max_elements);
309    }
310
311    public void setReplicationVersion(String JavaDoc version)
312    {
313       getConfiguration().setReplVersionString(version);
314    }
315
316    public void setSyncCommitPhase(boolean sync_commit_phase)
317    {
318       getConfiguration().setSyncCommitPhase(sync_commit_phase);
319    }
320
321    public void setSyncReplTimeout(long timeout)
322    {
323       getConfiguration().setSyncReplTimeout(timeout);
324    }
325
326    public void setSyncRollbackPhase(boolean sync_rollback_phase)
327    {
328       getConfiguration().setSyncRollbackPhase(sync_rollback_phase);
329    }
330
331    public void setTransactionManager(TransactionManager JavaDoc manager)
332    {
333       getConfiguration().getRuntimeConfig().setTransactionManager(manager);
334    }
335
336    public void setTransactionManagerLookupClass(String JavaDoc cl) throws Exception JavaDoc
337    {
338       getConfiguration().setTransactionManagerLookupClass(cl);
339    }
340
341    public void setUseRegionBasedMarshalling(boolean isTrue)
342    {
343       getConfiguration().setUseRegionBasedMarshalling(isTrue);
344    }
345
346    public void setUseReplQueue(boolean flag)
347    {
348       getConfiguration().setUseReplQueue(flag);
349    }
350
351 }
352
Popular Tags