Sun GlassFish Enterprise Server v3 Administration Guide

ProcedureTo Add a Node to the Tree

  1. Ensure that the server is running.

    Operations on REST resources for Enterprise Server data require a running server.

  2. Determine the acceptable message parameters for the POST method of the resource that represents the parent of the node.

    For information about how to perform this step, see To Determine the Methods and Method Parameters That a Node in the Tree Supports.

  3. Use the POST method on the REST resource that represents the parent of the node that you are adding.

  4. Confirm that the node has been added.

    Perform this step on the resource that represents the node that you have just added, not the parent. For information about how to perform this step, see To Retrieve Data for a Node in the Tree.


Example 2–23 Adding a Node to the Tree

This example uses the cURL utility to add a JDBC resource node to the tree by creating a REST resource to represent the JDBC resource.

In this example, the DAS is running on the local host and the HTTP port for administration is 4848.

Line breaks are added to enhance readability.

  1. This step determines the acceptable message parameters for the POST method of the resource jdbc-resource.


    curl -X OPTIONS -H "Accept: application/json" 
    http://localhost:4848/management/domain/resources/jdbc-resource
    {"JdbcResource":
      {
        "Method":{
          "Name":"POST",
          "Message Parameters":{
            "id":{"Acceptable Values":"", "Default Value":"", "Type":"string", 
                "Optional":"false"},
            "enabled":{"Acceptable Values":"", "Default Value":"true", 
                "Type":"boolean", "Optional":"true"},
            "description":{"Acceptable Values":"", "Default Value":"", 
                "Type":"string", "Optional":"true"},
            "target":{"Acceptable Values":"", "Default Value":"", "Type":"string", 
                "Optional":"true"},
            "property":{"Acceptable Values":"", "Default Value":"", 
                "Type":"string", "Optional":"true"},
            "connectionpoolid":{"Acceptable Values":"", "Default Value":"", 
                "Type":"string", "Optional":"false"}
          }
        },
        "Method":{
          "Name":"GET"
        }
      }
    }
  2. This step adds a resource as a child of the jdbc-resource resource. The -d option of the cURL utility sets the required message parameters as follows:

    • id is set to jdbc/myjdbcresource.

    • connectionpoolid is set to DerbyPool.


    curl -X POST -d "id=jdbc/myjdbcresource&connectionpoolid=DerbyPool" 
    http://localhost:4848/management/domain/resources/jdbc-resource
    "http://localhost:4848/management/domain/resources/jdbc-resource/
    jdbc/myjdbcresource" created successfully.
  3. This step confirms that the node has been added by retrieving data for the REST resource that represents the node.


    curl -X GET -H "Accept: application/json" 
    http://localhost:4848/management/domain/resources/
    jdbc-resource/jdbc-myjdbcresource
    {
    
      "JdbcMyjdbcresource":{"enabled":"true", "pool-name":"DerbyPool", 
          "description":"", "jndi-name":"jdbc/myjdbcresource", "object-type":"user"},
    
      "Methods":{
        "Method":{
          "Name":"POST",
          "Message Parameters":{
            "enabled":{"Key":"false", "Default Value":"true", 
                "Type":"boolean", "Optional":"true"},
            "pool-name":{"Key":"false", "Type":"string", "Optional":"true"},
            "description":{"Key":"false", "Type":"string", "Optional":"true"},
            "jndi-name":{"Key":"true", "Type":"string", "Optional":"true"},
            "object-type":{"Key":"false", "Default Value":"user", 
                "Type":"string", "Optional":"true"}
          }
        },
        "Method":{
          "Name":"GET"
        },
        "Method":{
          "Name":"DELETE",
          "Message Parameters":{
            "target":{"Acceptable Values":"", "Default Value":"", 
                "Type":"string", "Optional":"true"}
          }
        }
      }
    
    }