KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > management > j2ee > J2EEDomainTarget


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.management.j2ee;
23
24 import javax.management.MalformedObjectNameException JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 /**
30  * Root class of the JBoss JSR-77 implementation of
31  * {@link javax.management.j2ee.J2EEDomain J2EEDomain}.
32  *
33  * @author <a HREF="mailto:andreas@jboss.org">Andreas Schaefer</a>
34  * @author <a HREF="mailto:thomas.diesler@jboss.org">Thomas Diesler</a>
35  * @version $Revision: 40550 $
36  */

37 public class J2EEDomainTarget extends J2EEManagedObject
38 // implements J2EEDomainTargetMBean
39
{
40    // -------------------------------------------------------------------------
41
// Members
42
// -------------------------------------------------------------------------
43

44    private List JavaDoc mServers = new ArrayList JavaDoc();
45    
46    // -------------------------------------------------------------------------
47
// Constructors
48
// -------------------------------------------------------------------------
49

50    /**
51     * @jmx:managed-constructor
52     */

53    public J2EEDomainTarget(String JavaDoc pDomainName)
54            throws
55            MalformedObjectNameException JavaDoc,
56            InvalidParentException
57    {
58       super(pDomainName, "J2EEDomain", "Manager");
59    }
60    
61    // -------------------------------------------------------------------------
62
// Properties (Getters/Setters)
63
// -------------------------------------------------------------------------
64

65    /**
66     * @jmx:managed-attribute description="List of all Servers on this Managment Domain"
67     * access="READ"
68     * persistPolicy="Never"
69     * persistPeriod="30"
70     * currencyTimeLimit="30"
71     */

72    public String JavaDoc[] getservers()
73    {
74       return (String JavaDoc[]) mServers.toArray(new String JavaDoc[mServers.size()]);
75    }
76
77    /**
78     * @jmx:managed-operation description="Returns the requested Server" impact="INFO"
79     */

80    public String JavaDoc getserver(int pIndex)
81    {
82       if (pIndex >= 0 && pIndex < mServers.size())
83       {
84          return (String JavaDoc) mServers.get(pIndex);
85       }
86       return null;
87    }
88
89    public String JavaDoc toString()
90    {
91       return "J2EEDomainTarget { " + super.toString() + " } [ " +
92               ", servers: " + mServers +
93               " ]";
94    }
95
96    /**
97     * @jmx:managed-operation description="adds a new child of this Management Domain" impact="INFO"
98     */

99    public void addChild(ObjectName JavaDoc pChild)
100    {
101       String JavaDoc lType = J2EEManagedObject.getType(pChild);
102       if (J2EETypeConstants.J2EEServer.equals(lType))
103       {
104          mServers.add(pChild.getCanonicalName());
105       }
106    }
107
108    /**
109     * @jmx:managed-operation description="removes a new child of this Management Domain" impact="ACTION"
110     */

111    public void removeChild(ObjectName JavaDoc pChild)
112    {
113       String JavaDoc lType = J2EEManagedObject.getType(pChild);
114       if (J2EETypeConstants.J2EEServer.equals(lType))
115       {
116          mServers.remove(pChild.getCanonicalName());
117       }
118    }
119 }
120
Popular Tags