KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.jboss.logging.Logger;
25
26 import javax.management.MBeanServer JavaDoc;
27 import javax.management.MalformedObjectNameException JavaDoc;
28 import javax.management.ObjectName JavaDoc;
29 import java.util.Hashtable JavaDoc;
30
31 /**
32  * Root class of the JBoss JSR-77 implementation of JCAManagedConnectionFactory.
33  *
34  * @author <a HREF="mailto:mclaugs@comcast.net">Scott McLaughlin</a>.
35  * @version $Revision: 40550 $
36  */

37 public class JCAManagedConnectionFactory extends J2EEManagedObject
38    implements JCAManagedConnectionFactoryMBean
39 {
40    // Constants -----------------------------------------------------
41
private static Logger log = Logger.getLogger(JCAManagedConnectionFactory.class);
42
43    // Attributes ----------------------------------------------------
44

45    // Static --------------------------------------------------------
46

47    public static ObjectName JavaDoc create(MBeanServer JavaDoc mbeanServer, String JavaDoc resName,
48                                    ObjectName JavaDoc jsr77ParentName)
49    {
50       ObjectName JavaDoc jsr77Name = null;
51       try
52       {
53          JCAManagedConnectionFactory mcf = new JCAManagedConnectionFactory(resName,
54                  jsr77ParentName);
55          jsr77Name = mcf.getObjectName();
56          mbeanServer.registerMBean(mcf, jsr77Name);
57       }
58       catch (Exception JavaDoc e)
59       {
60          log.debug("Could not create JSR-77 JCAManagedConnectionFactory: " + resName, e);
61       }
62       return jsr77Name;
63    }
64
65    public static void destroy(MBeanServer JavaDoc mbeanServer, String JavaDoc resName)
66    {
67       try
68       {
69          // Remove the JCAManagedConnectionFactory associated with resName
70
String JavaDoc mcfName = J2EEDomain.getDomainName() + ":" +
71                  J2EEManagedObject.TYPE + "=" + J2EETypeConstants.JCAManagedConnectionFactory
72                  + ",name=" + resName + ",*";
73          J2EEManagedObject.removeObject(mbeanServer, mcfName);
74       }
75       catch (Exception JavaDoc e)
76       {
77          log.debug("Could not destroy JSR-77 JCAManagedConnectionFactory: " + resName, e);
78       }
79    }
80
81    // Constructors --------------------------------------------------
82

83    /**
84     **/

85    public JCAManagedConnectionFactory(String JavaDoc resName, ObjectName JavaDoc jsr77ParentName)
86            throws MalformedObjectNameException JavaDoc, InvalidParentException
87    {
88       super(J2EETypeConstants.JCAManagedConnectionFactory, resName, jsr77ParentName);
89    }
90
91    // Public --------------------------------------------------------
92

93    // java.lang.Object overrides ------------------------------------
94

95    public String JavaDoc toString()
96    {
97       return "JCAManagedConnectionFactory { " + super.toString() + " } [ " +
98               " ]";
99    }
100
101    /**
102     * @return A hashtable with the JCAResource and J2EEServer
103     */

104    protected Hashtable JavaDoc getParentKeys(ObjectName JavaDoc parentName)
105    {
106       Hashtable JavaDoc keys = new Hashtable JavaDoc();
107       Hashtable JavaDoc nameProps = parentName.getKeyPropertyList();
108       String JavaDoc serverName = (String JavaDoc) nameProps.get(J2EETypeConstants.J2EEServer);
109       keys.put(J2EETypeConstants.J2EEServer, serverName);
110       return keys;
111    }
112
113 }
114
Popular Tags