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.ha.jmx;
023:
024: import java.util.Stack;
025:
026: import javax.management.MalformedObjectNameException;
027: import javax.management.Notification;
028: import javax.management.ObjectName;
029:
030: import org.jboss.ha.jmx.HAServiceMBeanSupport;
031:
032: /**
033: *
034: * @author Ivelin Ivanov <ivelin@jboss.org>
035: *
036: */
037: public class HAServiceMBeanSupportTester extends HAServiceMBeanSupport {
038:
039: public Stack __invokationStack__ = new Stack();
040:
041: public boolean __isDRMMasterReplica__ = false;
042:
043: public boolean __isSingletonStarted__ = false;
044:
045: public boolean __shouldSendNotificationRemoteFail__ = false;
046:
047: protected void setupPartition() throws Exception {
048: __invokationStack__.push("setupPartition");
049: }
050:
051: protected void registerRPCHandler() {
052: __invokationStack__.push("registerRPCHandler");
053: }
054:
055: protected void unregisterRPCHandler() {
056: __invokationStack__.push("unregisterRPCHandler");
057: }
058:
059: protected void registerDRMListener() throws Exception {
060: __invokationStack__.push("registerDRMListener");
061: }
062:
063: protected void unregisterDRMListener() throws Exception {
064: __invokationStack__.push("unregisterDRMListener");
065: }
066:
067: protected boolean isDRMMasterReplica() {
068: __invokationStack__.push("isDRMMasterReplica");
069: return __isDRMMasterReplica__;
070: }
071:
072: public void callMethodOnPartition(String methodName, Object[] args)
073: throws Exception {
074: __invokationStack__.push("callMethodOnCluster:" + methodName);
075: }
076:
077: protected void sendNotificationRemote(Notification notification)
078: throws Exception {
079: if (__shouldSendNotificationRemoteFail__)
080: throw new Exception("simulated exception");
081: __invokationStack__.push("sendNotificationRemote");
082: __invokationStack__.push(notification);
083: }
084:
085: protected void sendNotificationToLocalListeners(
086: Notification notification) {
087: __invokationStack__.push("sendNotificationToLocalListeners");
088: __invokationStack__.push(notification);
089: }
090:
091: public ObjectName getServiceName() {
092: ObjectName oname = null;
093: try {
094: oname = new ObjectName(
095: "jboss.examples:name=HAServiceMBeanSupportTester");
096: } catch (MalformedObjectNameException e) {
097: // TODO Auto-generated catch block
098: e.printStackTrace();
099: }
100: return oname;
101: }
102:
103: }
|