Create the IdcContext based on an application resource connection

In the previous post I showed how to use get_file with the RIDC protocol. You create an IdcClient & IdcContext and use this to set up the connection. However, it is also possible to use the application resource connection for this.

First set up the connection in JDeveloper:

This will result in an entry in the connections.xml in your META-INF:

Now you can create an AdfConnectionFacade based on the name of this connection.
Then you create the IdcClient & IdcContext based on the AdfConnectionFacade:
      //Use the defined WebCenterContent connection
      AdfConnectionFacade acf = new AdfConnectionFacade("WebCenterContent");
      IdcClient idcClient = acf.getIdcClient();
      //Create an idcContext based on the Credentials.
      IdcContext idcContext = new IdcContext(acf.getUserCredentials("user"));
The parameter “user” in getUserCredentials refers to the user you see in the connections.xml. 

No comments:

Post a Comment