1+ package com .genexus .sap ;
2+
3+ import java .util .Hashtable ;
4+ import java .util .Properties ;
5+
6+ import com .genexus .diagnostics .Log ;
7+ import com .sap .conn .jco .ext .DestinationDataEventListener ;
8+ import com .sap .conn .jco .ext .DestinationDataProvider ;
9+ import com .sap .conn .jco .ext .Environment ;
10+
11+ public class DestinationProvider implements DestinationDataProvider
12+ {
13+
14+ private static DestinationProvider _instance ;
15+ public static DestinationProvider Instance ()
16+ {
17+ if (_instance == null )
18+ {
19+ _instance = new DestinationProvider ();
20+ }
21+ return _instance ;
22+
23+ }
24+
25+ private String SAP_SERVER = "SAP_SERVER" ;
26+ private Properties connectionProperties ;
27+ private Hashtable <String , Properties > connectionList = new Hashtable <String , Properties >();
28+ private DestinationDataEventListener eventListener ;
29+
30+ /*@Override*/
31+ public Properties getDestinationProperties (String sessionName )
32+ {
33+ if (sessionName != null )
34+ {
35+ Properties val = connectionList .get (sessionName );
36+ if (val != null )
37+ {
38+ return val ;
39+ }
40+ else
41+ {
42+ return null ;
43+ }
44+ }
45+ else
46+ {
47+ return null ;
48+ }
49+ }
50+
51+ /*@Override*/
52+ public boolean supportsEvents ()
53+ {
54+ return true ;
55+
56+ }
57+
58+ /*@Override*/
59+ public void setDestinationDataEventListener (DestinationDataEventListener eventListener )
60+ {
61+ this .eventListener = eventListener ;
62+ }
63+
64+ public void removeConnectionProperties (String sessionName )
65+ {
66+ if (eventListener != null )
67+ {
68+ eventListener .deleted (sessionName );
69+ }
70+ connectionProperties = null ;
71+ connectionList .remove (sessionName );
72+ }
73+
74+ public void setConnectionProperties ( String sessionName , Properties properties )
75+ {
76+ if ( sessionName == null || sessionName .equals ("" ))
77+ {
78+ sessionName = SAP_SERVER ;
79+
80+ }
81+ if (!Environment .isDestinationDataProviderRegistered ())
82+ {
83+ Environment .registerDestinationDataProvider (this );
84+ }
85+ if (properties == null )
86+ {
87+ if (eventListener != null )
88+ {
89+ eventListener .deleted ( sessionName );
90+ }
91+ connectionProperties = null ;
92+ connectionList .remove ( sessionName );
93+ }
94+ else
95+ {
96+ Log .info ("GX SAP - Setting Properties : " + sessionName + " total : " + Integer .toString (connectionList .size ()));
97+ connectionProperties = properties ;
98+ connectionList .put ( sessionName , connectionProperties );
99+ if (eventListener != null )
100+ {
101+ eventListener .updated (sessionName );
102+ }
103+ }
104+ }
105+ }
0 commit comments