01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: JContainer3Identifier.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.container.management;
25:
26: import org.ow2.easybeans.api.EZBContainer;
27: import org.ow2.easybeans.api.EZBServer;
28: import org.ow2.easybeans.jmx.MBeansException;
29: import org.ow2.easybeans.jmx.MBeansHelper;
30: import org.ow2.easybeans.jsr77.JSR77ManagementIdentifier;
31: import org.ow2.util.ee.deploy.api.archive.ArchiveException;
32:
33: /**
34: * Generates an ObjectName for an EZBContainer MBean.
35: *
36: * @author Guillaume Sauthier
37: */
38: public class JContainer3Identifier extends
39: JSR77ManagementIdentifier<EZBContainer> {
40:
41: /**
42: * JMX MBean Type.
43: */
44: private static final String TYPE = "EJBModule";
45:
46: /**
47: * {@inheritDoc}
48: */
49: public String getAdditionnalProperties(final EZBContainer instance) {
50: StringBuilder sb = new StringBuilder();
51: // J2EEServer=?
52: EZBServer server = instance.getConfiguration().getEZBServer();
53: String parent = null;
54: try {
55: parent = MBeansHelper.getInstance().getObjectName(server);
56: sb.append(getParentNameProperty(parent));
57:
58: // Append the Application
59: sb.append(",J2EEApplication=");
60: sb.append(instance.getApplicationName());
61:
62: } catch (MBeansException e) {
63: getLogger()
64: .warn(
65: "Cannot retrieve parent ObjectName for ''{0}''",
66: sb);
67: }
68:
69: return sb.toString();
70: }
71:
72: /**
73: * {@inheritDoc}
74: */
75: public String getNamePropertyValue(final EZBContainer instance) {
76: try {
77: return shorterName(instance.getArchive().getURL());
78: } catch (ArchiveException e) {
79: getLogger().warn(
80: "Cannot get URL for the container ''{0}''", e);
81: }
82: return instance.getName();
83: }
84:
85: /**
86: * {@inheritDoc}
87: */
88: public String getTypeValue() {
89: return TYPE;
90: }
91:
92: }
|