geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shiva Kumar H R" <shiv...@gmail.com>
Subject Re: Problem in org.apache.geronimo.system.jmx.RealMBeanServerReference
Date Wed, 27 Jun 2007 12:17:19 GMT
On 6/27/07, Vamsavardhana Reddy <c1vamsi1c@gmail.com> wrote:
>
> I see the following constructor:
>
>     public RealMBeanServerReference(String mbeanServerId) throws
> MBeanServerNotFound {
>         ArrayList servers = MBeanServerFactory.findMBeanServer
> (mbeanServerId);
>         if ( servers.size() == 0) {
>             mbeanServer = MBeanServerFactory.createMBeanServer
> ("geronimo");
>         } else if (servers.size() > 1) {
>             throw new MBeanServerNotFound(servers.size() + " MBeanServers
> were found with the agent id " + mbeanServerId);
>         } else {
>             mbeanServer = (MBeanServer) servers.get(0);
>         }
>     }
>
> I guess the intention of this code is to use a single MBeanServer for all
> geronimo MBeans and the default domain for that MBeanServer be "geronimo".
> MBeanServerFactory.createMBeanServer() takes domain as parameter.  Whereas
> MBeanServerFactory.findMBeanServer() takes AgentId.  There is no (easy)
> way to create an MBeanServer with a predefined agentId.  Does this mean
> mbeanServerId parameter is redundant?  Should this code be searching for an
> MBeanServer with default domain "geronimo" and creating one if there is
> none?  In this case, the code should look something like...
>
>    public RealMBeanServerReference(String mbeanServerId) throws
> MBeanServerNotFound {
>         ArrayList servers = MBeanServerFactory.findMBeanServer(null);
>         for(int i = 0; i < servers.size(); ++i) {
>             if("geronimo".equals(((MBeanServer) servers.get
> (i)).getDefaultDomain()))
>                 mbeanServer = (MBeanServer) servers.get(i);


you may break or return from here ;)

        }
>         if(mbeanServer == null) mbeanServer =
> MBeanServerFactory.createMBeanServer("geronimo");
>     }
>
> I am also noticing that if I create a new JMX agent by specifiying the
> system property com.sun.management.jmxremote.port, geronimo hooks up to
> the MBeanServer created with default domain name "DefaultDomain" instead of
> creating a new one for itself with default domain "geronimo".
>
> Vamsi
>

Mime
View raw message