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: SessionFactoryIdentifier.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.container.session.management;
25:
26: import org.ow2.easybeans.api.EZBContainer;
27: import org.ow2.easybeans.container.session.SessionFactory;
28: import org.ow2.easybeans.jmx.MBeansException;
29: import org.ow2.easybeans.jmx.MBeansHelper;
30: import org.ow2.easybeans.jsr77.JSR77ManagementIdentifier;
31:
32: /**
33: * Generates an ObjectName for an session factory MBean.
34: *
35: * @author Guillaume Sauthier
36: * @param <T> SessionFactory subclass
37: */
38: public abstract class SessionFactoryIdentifier<T extends SessionFactory>
39: extends JSR77ManagementIdentifier<T> {
40:
41: /**
42: * {@inheritDoc}
43: */
44: public String getAdditionnalProperties(final T instance) {
45: StringBuilder sb = new StringBuilder();
46: // EJBModule=?
47: EZBContainer container = instance.getContainer();
48: String parent = null;
49: try {
50: parent = MBeansHelper.getInstance()
51: .getObjectName(container);
52: sb.append(getParentNameProperty(parent));
53: sb.append(",");
54: sb.append(getPropertyNameValue(parent, "J2EEServer"));
55: sb.append(",");
56: sb.append(getPropertyNameValue(parent, "J2EEApplication"));
57: } catch (MBeansException e) {
58: getLogger()
59: .warn(
60: "Cannot retrieve parent ObjectName for ''{0}''",
61: sb);
62: }
63:
64: return sb.toString();
65: }
66:
67: /**
68: * {@inheritDoc}
69: */
70: public String getNamePropertyValue(final T instance) {
71: return instance.getClassName();
72: }
73:
74: }
|