KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > ha > jmx > HAServiceMBeanSupportTester


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
23 package org.jboss.test.ha.jmx;
24
25 import java.util.Stack JavaDoc;
26
27 import javax.management.MalformedObjectNameException JavaDoc;
28 import javax.management.Notification JavaDoc;
29 import javax.management.ObjectName JavaDoc;
30
31 import org.jboss.ha.jmx.HAServiceMBeanSupport;
32
33 /**
34  *
35  * @author Ivelin Ivanov <ivelin@apache.org>
36  *
37  */

38 public class HAServiceMBeanSupportTester extends HAServiceMBeanSupport
39 {
40
41   public Stack JavaDoc __invokationStack__ = new Stack JavaDoc();
42
43   public boolean __isDRMMasterReplica__ = false;
44
45   public boolean __isSingletonStarted__ = false;
46
47   public boolean __shouldSendNotificationRemoteFail__ = false;
48
49   protected void setupPartition() throws Exception JavaDoc
50   {
51     __invokationStack__.push("setupPartition");
52   }
53
54   protected void registerRPCHandler()
55   {
56     __invokationStack__.push("registerRPCHandler");
57   }
58
59   protected void unregisterRPCHandler()
60   {
61     __invokationStack__.push("unregisterRPCHandler");
62   }
63
64   protected void registerDRMListener() throws Exception JavaDoc
65   {
66     __invokationStack__.push("registerDRMListener");
67   }
68
69   protected void unregisterDRMListener() throws Exception JavaDoc
70   {
71     __invokationStack__.push("unregisterDRMListener");
72   }
73
74   protected boolean isDRMMasterReplica()
75   {
76     __invokationStack__.push("isDRMMasterReplica");
77     return __isDRMMasterReplica__;
78   }
79
80   public void callMethodOnPartition(String JavaDoc methodName, Object JavaDoc[] args)
81     throws Exception JavaDoc
82   {
83     __invokationStack__.push("callMethodOnCluster:" + methodName);
84   }
85
86   protected void sendNotificationRemote(Notification JavaDoc notification)
87     throws Exception JavaDoc
88   {
89     if (__shouldSendNotificationRemoteFail__)
90       throw new Exception JavaDoc("simulated exception");
91     __invokationStack__.push("sendNotificationRemote");
92     __invokationStack__.push(notification);
93   }
94
95   protected void sendNotificationToLocalListeners(Notification JavaDoc notification)
96   {
97     __invokationStack__.push("sendNotificationToLocalListeners");
98     __invokationStack__.push(notification);
99   }
100
101   public ObjectName JavaDoc getServiceName()
102   {
103     ObjectName JavaDoc oname = null;
104     try
105     {
106       oname = new ObjectName JavaDoc("jboss.examples:name=HAServiceMBeanSupportTester");
107     }
108     catch (MalformedObjectNameException JavaDoc e)
109     {
110       // TODO Auto-generated catch block
111
e.printStackTrace();
112     }
113     return oname;
114   }
115
116 }
117
Popular Tags