Administered objects are objects that encapsulate provider-specific configuration and naming information. For endpoint objects, you have the choice either to instantiate such an object or to create an administered object and associate it with an endpoint object instance.
The main benefit of creating an endpoint through a JNDI lookup is to isolate endpoint URLs from the code, allowing the application to switch the destination without recompiling the code. A secondary benefit is provider independence.
Creating an administered object for a SOAP element is the same as creating an administered object in Message Queue: you use the Object Manager (imqobjmgr) utility to specify the lookup name of the object, its attributes, and its type.
Table 5–2 lists and describes the attributes and other information that you need to specify when you create an endpoint administered object. Remember to specify all attributes as strings.
Table 5–2 SOAP Administered Object Information
Example 5–2 shows how you use the imqobjmgr command to create an administered object for an endpoint and add it to an object store. The -i option specifies the name of an input file that defines object store attributes (-j option).
imqobjmgr add -t e -l "cn=myEndpoint" -o "imqSOAPEndpointList=http://www.myServlet/ http://www.myServlet2/" -o "imqEndpointName=MyBroadcastEndpoint" -i MyObjStoreAttrs |
Having created the administered object and added it to an object store, you can now use it when you want to use an endpoint in your SAAJ application. In Example 5–3, you first create an initial context for the JNDI lookup and then you look up the desired object.
Hashtable env = new Hashtable(); env.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put (Context.PROVIDER_URL, "file:///c:/imq_admin_objects"); Context ctx = new InitialContext(env); Endpoint mySOAPEndpoint = (Endpoint) ctx.lookup("cn=myEndpoint"); |
You can also list, delete, and update administered objects. For additional information, please see Chapter 8, Managing Administered Objects, in Sun Java System Message Queue 3.7 UR1 Administration Guide.