KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > server > JMXEngineConfigurationFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: JMXEngineConfigurationFactory.java,v 1.4.6.3 2005/03/02 14:19:51 tdiesler Exp $
9

10 package org.jboss.net.axis.server;
11
12 import org.jboss.axis.EngineConfiguration;
13 import org.jboss.axis.EngineConfigurationFactory;
14 import org.jboss.axis.server.AxisServer;
15 import org.jboss.mx.util.MBeanServerLocator;
16
17 import javax.management.JMException JavaDoc;
18 import javax.management.MBeanServer JavaDoc;
19 import javax.management.MalformedObjectNameException JavaDoc;
20 import javax.management.ObjectName JavaDoc;
21
22 /** test
23  * <p> A configuration factory that accesses axis server engines
24  * via JMX attribute access. </p>
25  * @author jung
26  * @version $Revision: 1.4.6.3 $
27  * @since 9.9.2002
28  */

29
30 public class JMXEngineConfigurationFactory
31         implements EngineConfigurationFactory
32 {
33
34    //
35
// Attributes
36
//
37

38    protected ObjectName JavaDoc objectName;
39    protected MBeanServer JavaDoc server;
40
41    //
42
// Constructors
43
//
44

45    /** construct a new factory tied to a particular engine provider mbean */
46
47    protected JMXEngineConfigurationFactory(String JavaDoc name)
48            throws MalformedObjectNameException JavaDoc
49    {
50       server = MBeanServerLocator.locateJBoss();
51       this.objectName = new ObjectName JavaDoc(name);
52    }
53
54    //
55
// Protected Helpers
56
//
57

58    /**
59     * find attribute through JMX server and mbean
60     */

61
62    protected Object JavaDoc getAttribute(String JavaDoc attributeName)
63    {
64       try
65       {
66          return server.getAttribute(objectName, attributeName);
67       }
68       catch (JMException JavaDoc e)
69       {
70          return null;
71       }
72    }
73
74    //
75
// Public API
76
//
77

78    /** return axis server associated with mbean */
79    public AxisServer getAxisServer()
80    {
81       return (AxisServer)getAttribute("AxisServer");
82    }
83
84    /* (non-Javadoc)
85       * @see org.jboss.axis.EngineConfigurationFactory#getClientEngineConfig()
86       */

87    public EngineConfiguration getClientEngineConfig()
88    {
89       return (EngineConfiguration)getAttribute("ClientEngineConfiguration");
90    }
91
92    /* (non-Javadoc)
93       * @see org.jboss.axis.EngineConfigurationFactory#getServerEngineConfig()
94       */

95    public EngineConfiguration getServerEngineConfig()
96    {
97       return (EngineConfiguration)getAttribute("ServerEngineConfiguration");
98    }
99
100    /**
101     * static method to create a new jmx factory
102     * @param param objectname of the server mbean
103     * @return a new factory bound to that mbean, if it exists
104     */

105    public static JMXEngineConfigurationFactory newJMXFactory(String JavaDoc param)
106    {
107       try
108       {
109          return new JMXEngineConfigurationFactory((String JavaDoc)param);
110       }
111       catch (MalformedObjectNameException JavaDoc e)
112       {
113          return null;
114       }
115    }
116
117    /**
118     * static method to create a new factory along the Axis spec
119     * @param param specification of the configuration
120     * @return new factory, if the param represents an mbean object name
121     */

122
123    public static EngineConfigurationFactory newFactory(Object JavaDoc param)
124    {
125       if (param instanceof String JavaDoc)
126       {
127          return newJMXFactory((String JavaDoc)param);
128       }
129       else
130       {
131          return null;
132       }
133    }
134
135 }
136
Popular Tags