Clover coverage report - JFox Service-Oriented Application Framework - 1.0
Coverage timestamp: 星期一 八月 21 2006 22:56:01 CST
file stats: LOC: 122   Methods: 6
NCLOC: 48   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
NamingServiceImpl.java - 46.2% 16.7% 36.8%
coverage coverage
 1   
 /**
 2   
  * @(#)NamingServiceImpl.java
 3   
  * 
 4   
  * JFoxSOAF, Service-Oriented Application Framework
 5   
  * 
 6   
  * Copyright(c) JFoxSOAF Team
 7   
  * 
 8   
  * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
 9   
  * you may not use this file except in compliance with the License. 
 10   
  * You may obtain a copy of the License at  
 11   
  * 
 12   
  * http://www.gnu.org/copyleft/lesser.html
 13   
  * 
 14   
  * Unless required by applicable law or agreed to in writing, software
 15   
  * distributed under the License is distributed on an "AS IS" BASIS, 
 16   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 17   
  * See the License for the specific language governing permissions and 
 18   
  * limitations under the License. 
 19   
  * 
 20   
  * For more information, please visit:
 21   
  * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
 22   
  * http://www.huihoo.org/jfox/jfoxsoaf
 23   
  */
 24   
 
 25   
 package org.huihoo.jfox.soaf.services.naming;
 26   
 
 27   
 import java.io.IOException;
 28   
 import java.net.URL;
 29   
 
 30   
 import javax.naming.Context;
 31   
 import javax.naming.InitialContext;
 32   
 import javax.naming.NamingException;
 33   
 
 34   
 import org.apache.commons.logging.Log;
 35   
 import org.apache.commons.logging.LogFactory;
 36   
 import org.huihoo.jfox.soaf.util.resource.ResourceHelper;
 37   
 import org.objectweb.carol.util.configuration.ConfigurationException;
 38   
 import org.objectweb.carol.util.configuration.ConfigurationRepository;
 39   
 import org.picocontainer.Startable;
 40   
 
 41   
 /**
 42   
  * <p>
 43   
  * JNDI service implementation.
 44   
  * </p>
 45   
  * 
 46   
  * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
 47   
  * @version $Revision: 1.1 $ $Date: 2006/02/15 08:27:46 $
 48   
  * @version Revision: 1.0
 49   
  */
 50   
 
 51   
 public class NamingServiceImpl implements NamingService, Startable {
 52   
 
 53   
     private static final String JNDI_PROPERTIES = "carol.properties";
 54   
 
 55   
     private final Log logger = LogFactory.getLog(getClass());
 56   
 
 57   
     private URL jndiURL;
 58   
 
 59   
     private Context ctx;
 60   
 
 61   
     /**
 62   
      * @see org.huihoo.jfox.soaf.services.naming.NamingService#bind(java.lang.String,
 63   
      *      java.lang.Object)
 64   
      */
 65  0
     public void bind(String name, Object obj) throws NamingException {
 66  0
         ctx.bind(name, obj);
 67   
 
 68   
     }
 69   
 
 70   
     /**
 71   
      * @see org.huihoo.jfox.soaf.services.naming.NamingService#lookup(java.lang.String)
 72   
      */
 73  0
     public Object lookup(String name) throws NamingException {
 74  0
         return ctx.lookup(name);
 75   
     }
 76   
 
 77   
     /**
 78   
      * @see org.huihoo.jfox.soaf.services.naming.NamingService#rebind(java.lang.String,
 79   
      *      java.lang.Object)
 80   
      */
 81  0
     public void rebind(String name, Object obj) throws NamingException {
 82  0
         ctx.rebind(name, obj);
 83   
     }
 84   
 
 85   
     /**
 86   
      * @see org.huihoo.jfox.soaf.services.naming.NamingService#unbind(java.lang.String)
 87   
      */
 88  0
     public void unbind(String name) throws NamingException {
 89  0
         ctx.unbind(name);
 90   
     }
 91   
 
 92   
     /**
 93   
      * @see org.picocontainer.Startable#start()
 94   
      */
 95  9
     public void start() {
 96   
         // initialize Carol
 97  9
         try {
 98  9
             jndiURL = ResourceHelper.getResourceURL(JNDI_PROPERTIES);
 99  9
             ConfigurationRepository.init(jndiURL);
 100   
         } catch (IOException e) {
 101  0
             logger.error("Failed to load jndi property file " + e.getMessage());
 102   
         } catch (ConfigurationException e) {
 103  0
             logger.error("Failed to init carol configuraion file "
 104   
                     + e.getMessage());
 105   
         }
 106   
 
 107   
         // init jndi context
 108  9
         try {
 109  9
             ctx = new InitialContext();
 110   
         } catch (NamingException e) {
 111  0
             logger.error("Failed to init jndi context " + e.getMessage());
 112   
         }
 113  9
         logger.info("Start Naming Service Successful");
 114   
     }
 115   
 
 116   
     /**
 117   
      * @see org.picocontainer.Startable#stop()
 118   
      */
 119  0
     public void stop() {
 120   
     }
 121   
     
 122   
 }