1 | |
package org.hibersap.execution.jco; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
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 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class JCoEnvironment |
37 | |
{ |
38 | 0 | private static final Log LOG = LogFactory.getLog( JCoEnvironment.class ); |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
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 | |
} |