On 6/27/07, Shiva Kumar H R <[EMAIL PROTECTED]> wrote:



On 6/27/07, Vamsavardhana Reddy <[EMAIL PROTECTED]> 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 ;)


You are right ;)


       }
>         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
>


Reply via email to