001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2006 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ClusterFactory.java 9397 2006-08-08 12:48:39Z durieuxp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.management.cluster;
025:
026: import java.util.Collection;
027:
028: import javax.management.MBeanServer;
029:
030: import org.objectweb.jonas.common.Log;
031: import org.objectweb.jonas.jmx.JmxService;
032: import org.objectweb.jonas.management.monitoring.DomainMonitor;
033: import org.objectweb.jonas.management.monitoring.ServerProxy;
034: import org.objectweb.jonas.service.ServiceManager;
035:
036: import org.objectweb.util.monolog.api.Logger;
037:
038: /**
039: * Factory for Cluster
040: * @author durieuxp
041: */
042: public abstract class ClusterFactory {
043:
044: /**
045: * logger for traces
046: */
047: protected static Logger logger = Log
048: .getLogger("org.objectweb.jonas.domain.management");
049:
050: /**
051: * ref to the Jmx Service
052: */
053: protected JmxService jmx = (JmxService) ServiceManager
054: .getInstance().getJmxService();
055:
056: /**
057: * The MBeanServer used for registering new MBeans
058: */
059: protected MBeanServer mbeanServer;
060:
061: /**
062: * ref to the DomainMonitor
063: */
064: protected DomainMonitor dm;
065:
066: /**
067: * Domain name
068: */
069: protected String domainName;
070:
071: public ClusterFactory(DomainMonitor dm) {
072: this .dm = dm;
073: mbeanServer = jmx.getJmxServer();
074: domainName = dm.getDomainName();
075: }
076:
077: /**
078: * A new Server has been detected by the DomainManager.
079: * Look if it can be added in a cluster. This cluster could
080: * be created if necessary.
081: * @param proxy The new ServerProxy object just created.
082: * @return True if server was added in a Cluster.
083: */
084: public abstract boolean notifyServer(ServerProxy proxy);
085:
086: /**
087: * @return a reference to the DomainMonitor
088: */
089: public DomainMonitor getDomainMonitor() {
090: return dm;
091: }
092:
093: /**
094: * @return The MBeanServer used to register MBeans
095: */
096: public MBeanServer getMBeanServer() {
097: return mbeanServer;
098: }
099:
100: /**
101: * Look for a cluster by its name
102: * @param name fo the cluster
103: * @return The cluster or null if not found
104: */
105: public abstract BaseCluster getCluster(String name);
106:
107: /**
108: * @return A list of all Clusters managed by this ClusterFactory
109: */
110: public abstract Collection getClusterList();
111: }
|