How to Use JNDI to access CICs to connect to the factory com. IBM. connector2.cics. ecimanagedconnectionfactory

Source: Internet
Author: User

Add the following content to Tomcat context. xml:
<Resource Name = "EIS/cicseci" auth = "Container" type = "javax. Resource. CCI. connectionfactory"
Factory = "com. Console. util. CICs. jndiconnectionfactory"
Servername = "testsrv" connectionurl = "Wagner. 0.0.1" portnumber = "2006"
Socketconnecttimeout = "30" tranname = "CPMI"
Username = "cicsuser" Password = "cicsuser"/>

The javax. Naming. SPI. objectfactory interface must be implemented for com. Console. util. CICs. jndieciconnectionfactory.

 

The Code is as follows:

Package com. Console. util. CICs;

Import java. util. enumeration;
Import java. util. hashtable;

Import javax. Naming. context;
Import javax. Naming. Name;
Import javax. Naming. refaddr;
Import javax. Naming. reference;
Import javax. Naming. SPI. objectfactory;

Import com. IBM. connector2.cics. ecimanagedconnectionfactory;

/**
* Generate the connectionfactory object used to call ECI call. This object will be provided to external containers for JNDI binding.
*
*/
Public class jndieciconnectionfactory implements objectfactory {

Public static final string param_user_name = "username ";
Public static final string param_password = "password ";
Public static final string param_connection_url = "connectionurl ";
Public static final string param_port_number = "portnumber ";
Public static final string param_server_name = "servername ";
Public static final string param_tran_name = "tranname ";
Public static final string param_socket_connect_timeout = "socketconnecttimeout ";
Public static final string param_applid = "applid ";
Public static final string param_trace_level = "tracelevel ";
Public static final string param_tpn_name = "tpnname ";
Public static final string param_applid_qualifier = "applidqualifier ";
Public static final string param_key_ring_class = "keyringclass ";
Public static final string param_key_ring_password = "keyringpassword ";
Public static final string param_client_security = "clientsecurity ";
Public static final string param_server_security = "serversecurity ";
Public static final string param_request_exits = "requestexits ";
Public static final string param_cipher_suites = "ciphersuites ";

/**
* Set the parameter to ecimanagedconnectionfactory, and generate the javax. Resource. CCI.
* Connectionfactory interface object
*/
Public object getobjectinstance (Object OBJ, name, context namectx,
Hashtable <?, ?> Environment) throws exception {
Ecimanagedconnectionfactory bean = new ecimanagedconnectionfactory ();

Reference ref = (reference) OBJ;
Enumeration <refaddr> addrs = ref. getall ();
While (addrs. hasmoreelements ()){
Refaddr ADDR = addrs. nextelement ();

String type = ADDR. GetType ();
String value = (string) ADDR. getcontent ();

If (type. Equals (param_user_name )){
Bean. setusername (value );
} Else if (type. Equals (param_password )){
Bean. setpassword (value );
} Else if (type. Equals (param_connection_url )){
Bean. setconnectionurl (value );
} Else if (type. Equals (param_port_number )){
Bean. setportnumber (value );
} Else if (type. Equals (param_server_name )){
Bean. setservername (value );
} Else if (type. Equals (param_tran_name )){
Bean. settranname (value );
} Else if (type. Equals (param_socket_connect_timeout )){
Bean. setsocketconnecttimeout (value );
} Else if (type. Equals (param_applid )){
Bean. setapplid (value );
} Else if (type. Equals (param_trace_level )){
Bean. settracelevel (integer. parseint (value ));
} Else if (type. Equals (param_tpn_name )){
Bean. settpnname (value );
} Else if (type. Equals (param_applid_qualifier )){
Bean. setapplidqualifier (value );
} Else if (type. Equals (param_key_ring_class )){
Bean. setkeyringclass (value );
} Else if (type. Equals (param_key_ring_password )){
Bean. setkeyringpassword (value );
} Else if (type. Equals (param_client_security )){
Bean. setclientsecurity (value );
} Else if (type. Equals (param_server_security )){
Bean. setserversecurity (value );
} Else if (type. Equals (param_request_exits )){
Bean. setrequestexits (value );
} Else if (type. Equals (param_cipher_suites )){
Bean. setciphersuites (value );
}
}

Return bean. createconnectionfactory ();
}

 

How to access JNDI in spring
<Bean id = "ATII. eciconnectionfactory" class = "org. springframework. JNDI. jndiobjectfactorybean">
<Property name = "jndiname" value = "EIS/cicseci"/>
<Property name = "resourceref" value = "true"/>
</Bean>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.