Coverage Report - org.hibersap.execution.jco.JCoEnvironment
 
Classes in this File Line Coverage Branch Coverage Complexity
JCoEnvironment
0%
0/14
N/A
2
 
 1  
 package org.hibersap.execution.jco;
 2  
 
 3  
 /*
 4  
  * Copyright (C) 2008 akquinet tech@spree GmbH
 5  
  * 
 6  
  * This file is part of Hibersap.
 7  
  * 
 8  
  * Hibersap is free software: you can redistribute it and/or modify it under the terms of the GNU
 9  
  * Lesser General Public License as published by the Free Software Foundation, either version 3 of
 10  
  * the License, or (at your option) any later version.
 11  
  * 
 12  
  * Hibersap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 13  
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 14  
  * Lesser General Public License for more details.
 15  
  * 
 16  
  * You should have received a copy of the GNU Lesser General Public License along with Hibersap. If
 17  
  * not, see <http://www.gnu.org/licenses/>.
 18  
  */
 19  
 
 20  
 import java.util.Properties;
 21  
 
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 import org.hibersap.HibersapException;
 25  
 
 26  
 import com.sap.conn.jco.JCoDestination;
 27  
 import com.sap.conn.jco.JCoDestinationManager;
 28  
 import com.sap.conn.jco.JCoException;
 29  
 import com.sap.conn.jco.ext.Environment;
 30  
 
 31  
 /**
 32  
  * This class acts as a wrapper for the ugly static JCo classes.
 33  
  *
 34  
  * @author Carsten Erker
 35  
  */
 36  0
 public class JCoEnvironment
 37  
 {
 38  0
     private static final Log LOG = LogFactory.getLog( JCoEnvironment.class );
 39  
 
 40  
     /**
 41  
      * JCo's Environment class doesn't offer any methods to check if a provider class is already registered,
 42  
      * but we need to dynamically register destinations
 43  
      */
 44  
     private static final JCoDataProvider destinationDataProvider;
 45  
 
 46  
     static
 47  
     {
 48  0
         destinationDataProvider = new JCoDataProvider();
 49  0
         Environment.registerDestinationDataProvider( destinationDataProvider );
 50  0
     }
 51  
 
 52  
     public static void registerDestination( String destinationName, Properties jcoProperties )
 53  
     {
 54  0
         LOG.info( "Registering destination " + destinationName );
 55  0
         destinationDataProvider.addDestination( destinationName, jcoProperties );
 56  0
     }
 57  
 
 58  
     public static void unregisterDestination( String destinationName )
 59  
     {
 60  0
         LOG.info( "Unregistering destination " + destinationName );
 61  0
         destinationDataProvider.removeDestination( destinationName );
 62  0
     }
 63  
 
 64  
     public static JCoDestination getDestination( String destinationName )
 65  
     {
 66  
         try
 67  
         {
 68  0
             return JCoDestinationManager.getDestination( destinationName );
 69  
         }
 70  0
         catch ( JCoException e )
 71  
         {
 72  0
             throw new HibersapException( "Can not get the destination named '" + destinationName + "'" );
 73  
         }
 74  
     }
 75  
 }