Clover coverage report - Code Coverage for hivemind-jmx release 1.1-beta-1
Coverage timestamp: Thu Apr 28 2005 19:55:29 EDT
file stats: LOC: 68   Methods: 2
NCLOC: 34   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
JMXConnectorServerFactory.java - 85.7% 100% 88.9%
coverage coverage
 1   
 // Copyright 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.management.impl;
 16   
 
 17   
 import java.util.HashMap;
 18   
 import java.util.Map;
 19   
 
 20   
 import javax.management.MBeanServer;
 21   
 import javax.management.remote.JMXConnectorServer;
 22   
 import javax.management.remote.JMXServiceURL;
 23   
 
 24   
 import org.apache.hivemind.ApplicationRuntimeException;
 25   
 import org.apache.hivemind.ServiceImplementationFactory;
 26   
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 27   
 import org.apache.hivemind.management.ManagementMessages;
 28   
 
 29   
 /**
 30   
  * An implementation of {@link org.apache.hivemind.ServiceImplementationFactory}that creates
 31   
  * JMXConnectorServer instances using {@link javax.management.remote.JMXConnectorServerFactory}
 32   
  * 
 33   
  * @author Achim Huegen
 34   
  * @since 1.1
 35   
  */
 36   
 public class JMXConnectorServerFactory implements ServiceImplementationFactory
 37   
 {
 38  2
     public JMXConnectorServerFactory(MBeanServer beanServer)
 39   
     {
 40   
     }
 41   
 
 42  2
     public Object createCoreServiceImplementation(
 43   
             ServiceImplementationFactoryParameters factoryParameters)
 44   
     {
 45   
         // Read the parameters of the factory call
 46  2
         JMXConnectorServerParameter parameter = (JMXConnectorServerParameter) factoryParameters
 47   
                 .getFirstParameter();
 48   
 
 49  2
         Map env = new HashMap();
 50   
 
 51  2
         try
 52   
         {
 53   
             // Convert the serviceUrl string to instance of JMXServiceURL
 54  2
             JMXServiceURL address = new JMXServiceURL(parameter.getJmxServiceURL());
 55   
 
 56  2
             JMXConnectorServer server = javax.management.remote.JMXConnectorServerFactory
 57   
                     .newJMXConnectorServer(address, env, null);
 58   
 
 59  2
             return server;
 60   
         }
 61   
         catch (Exception e)
 62   
         {
 63  0
             throw new ApplicationRuntimeException(ManagementMessages
 64   
                     .errorInstantiatingConnectorServer(parameter.getJmxServiceURL(), env, e), e);
 65   
         }
 66   
     }
 67   
 
 68   
 }