KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.security.InvalidParameterException JavaDoc;
25
26 import javax.management.MBeanServer JavaDoc;
27 import javax.management.MalformedObjectNameException JavaDoc;
28 import javax.management.ObjectName JavaDoc;
29
30 import org.jboss.logging.Logger;
31
32 /**
33  * Root class of the JBoss JSR-77 implementation of
34  * {@link javax.management.j2ee.RMI_IIOPResource RMI_IIOPResource}.
35  *
36  * AS Currently CorbaORBService does not support to be restarted therefore no manageability
37  *
38  * @author <a HREF="mailto:andreas@jboss.org">Andreas Schaefer</a>
39  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
40  * @version $Revision: 40550 $
41  */

42 public class RMI_IIOPResource extends J2EEResource
43    implements RMI_IIOPResourceMBean
44 {
45    // Constants -----------------------------------------------------
46

47    // Attributes ----------------------------------------------------
48
private static Logger log = Logger.getLogger(RMI_IIOPResource.class);
49
50    private ObjectName JavaDoc mService;
51
52    // Static --------------------------------------------------------
53

54    public static ObjectName JavaDoc create(MBeanServer JavaDoc mbeanServer, String JavaDoc resName, ObjectName JavaDoc corbaServiceName)
55    {
56       ObjectName JavaDoc lServer = null;
57       try
58       {
59          lServer = (ObjectName JavaDoc) mbeanServer.queryNames(new ObjectName JavaDoc(J2EEDomain.getDomainName() + ":" +
60                  J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," +
61                  "*"),
62                  null).iterator().next();
63       }
64       catch (Exception JavaDoc e)
65       {
66          log.error("Could not find parent J2EEServer", e);
67          return null;
68       }
69       try
70       {
71          RMI_IIOPResource rmiiiopRes = new RMI_IIOPResource(resName, lServer, corbaServiceName);
72          ObjectName JavaDoc jsr77Name = rmiiiopRes.getObjectName();
73          mbeanServer.registerMBean(rmiiiopRes, jsr77Name);
74          log.debug("Created JSR-77 RMI_IIOPResource: " + resName);
75          
76          return jsr77Name;
77       }
78       catch (Exception JavaDoc e)
79       {
80          log.error("Could not create JSR-77 RMI_IIOPResource: " + resName, e);
81          return null;
82       }
83    }
84
85    public static void destroy(MBeanServer JavaDoc mbeanServer, String JavaDoc resName)
86    {
87       try
88       {
89          J2EEManagedObject.removeObject(mbeanServer,
90                  J2EEDomain.getDomainName() + ":" +
91                  J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," +
92                  "name=" + resName + "," +
93                  "*");
94       }
95       catch (Exception JavaDoc e)
96       {
97          log.error("Could not destroy JSR-77 RMI_IIOPResource: " + resName, e);
98       }
99    }
100
101    // Constructors --------------------------------------------------
102

103    /**
104     * @param pName Name of the RMI_IIOPResource
105     * @throws InvalidParameterException If list of nodes or ports was null or empty
106     */

107    public RMI_IIOPResource(String JavaDoc resName, ObjectName JavaDoc pServer, ObjectName JavaDoc corbaServiceName)
108            throws MalformedObjectNameException JavaDoc,
109            InvalidParentException
110    {
111       super(J2EETypeConstants.RMI_IIOPResource, resName, pServer);
112       log.debug("Service name: " + corbaServiceName);
113       mService = corbaServiceName;
114 // mState = new StateManagement( this );
115
}
116
117    // javax.managment.j2ee.EventProvider implementation -------------
118

119
120    public String JavaDoc[] getEventTypes()
121    {
122       return StateManagement.stateTypes;
123    }
124
125    public String JavaDoc getEventType(int pIndex)
126    {
127       if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length)
128       {
129          return StateManagement.stateTypes[pIndex];
130       }
131       else
132       {
133          return null;
134       }
135    }
136
137    public void postCreation()
138    {
139       sendNotification(NotificationConstants.OBJECT_CREATED, "RMI_IIOP Resource created");
140    }
141
142    public void preDestruction()
143    {
144       sendNotification(NotificationConstants.OBJECT_DELETED, "RMI_IIOP Resource deleted");
145    }
146
147    // java.lang.Object overrides ------------------------------------
148

149    public String JavaDoc toString()
150    {
151       return "RMI_IIOPResource { " + super.toString() + " } [ " +
152               "Service name: " + mService +
153               " ]";
154    }
155
156    // Package protected ---------------------------------------------
157

158    // Protected -----------------------------------------------------
159

160    // Private -------------------------------------------------------
161

162    // Inner classes -------------------------------------------------
163
}
164
Popular Tags