Now you can build on the previous example by accessing a Nucleus component property.

The example that follows makes a request for all the properties of a Nucleus component using the RestComponentHelper class. This class has several static convenience methods which assist in creating the requests and issuing them to the server. The getComponent() method take the path to a Nucleus component, a map of optional parameters, and the RestSession object and returns a RestResult object.

The RestResult object can be used to access the data from the response. The following sample calls readInputStream() to return a String of the response data. In this case, you can assume that the server is using the default output format which is JSON. The string in response data will contain the JSON output. A JSON object is then constructed and output.

Another alternative is to simply output responseData, but this sample illustrates how you might use the output. Similarly, if the output format was XML, you could create an XML document object using dom4j.

The finally block includes a call to close the result. Doing this will release the underlying connection resources. If this call is omitted, the next call to the server using the same RestSession object will close the result.

 protected void execute() throws RestClientException {
 RestResult result = null;

 mSession = RestSession.createSession(mHost, mPort, mUsername, mPassword);
 mSession.setUseHttpsForLogin(false);

 try {
mSession.login();
println("Login Successful");

result = RestComponentHelper.getComponent("/atg/dynamo/Configuration", null,
mSession);
String responseData = result.readInputStream();
if (responseData != null) {
 JSONObject json = new JSONObject(responseData);
 println(json.toString());
}
 }
 catch (Throwable t) {
println(t);
 }
 finally {
if (result != null)
 result.close();

try {
 mSession.logout();
 println("Logout Successful");
}
catch (RestClientException e) {
 println(e);
}
 }
 }