The GlassFish Server REST interfaces represent resources in the following formats:
XML
HTML
How to specify the resource representation depends on how you are accessing the GlassFish Server REST interfaces. For example, if you are using the cURL utility, specify the resource representation through the -H option as follows:
For JSON, specify -H "Accept: application/json".
For XML, specify -H "Accept: application/xml".
For HTML, omit the -H option.
The general format for the JSON representation of a resource is as follows:
{ "resource":{attributes}, "Methods": { method-list } "Child Resources":[urls] }
The replaceable items in this format are as follows:
The name of the resource.
Zero or more name-value pairs separated by a comma (,). Each name-value pair is specified as "name":value.
One or more metadata sets separated by a comma (,) that represent the methods that the resource supports. For the format of each metadata set, see JSON Representation of a Method in a Method List.
Zero or more URLs to child resources separated by a comma (,).
The JSON representation of a method in a method list is as follows:
Method":{ "Name":"method-name", "Message Parameters":{ message-parameter-list } "Query Parameters":{ queryparameter- list } }
The replaceable items in this format are as follows:
The name of the method, which is GET, POST, or DELETE.
Zero or more metadata sets separated by a comma (,) that represent the message parameters that are allowed for the method. For the format of each metadata set, see JSON Representation of a Message Parameter or a Query Parameter.
Zero or more metadata sets separated by a comma (,) that represent the query parameters that are allowed for the method. For the format of each metadata set, see JSON Representation of a Message Parameter or a Query Parameter.
The JSON representation of a message parameter or a query parameter is as follows:
"parameter-name":{attribute-list}
The replaceable items in this format are as follows:
The name of the parameter.
A comma-separated list of name-value pairs of attributes for the parameter. Each pair is in the following format:
"name":"value"
Possible attributes are as follows:
The default value of the parameter.
The set or range of acceptable values for the parameter.
The data type of the parameter, which is one of the following types:
boolean
int
string
Indicates whether the parameter is optional. If true, the parameter is optional. If false, the parameter is required.
Indicates whether the parameter is key. If true, the parameter is key. If false, the parameter is not key.
This example shows the JSON representation of the resource for managing a domain. In this example, the DAS is running on the local host and the HTTP port for administration is 4848. The URL to the resource in this example is http://localhost:4848/management/domain.
Line breaks are added to enhance readability.
{ "Domain":{"log-root":"${com.sun.aas.instanceRoot}/logs", "application-root":"${com.sun.aas.instanceRoot}/applications", "locale":"", "version":"73"}, "Methods":{ "Method":{ "Name":"POST", "Message Parameters":{ "log-root":{"Key":"false", "Type":"string", "Optional":"true"}, "application-root":{"Key":"false", "Type":"string", "Optional":"true"}, "locale":{"Key":"false", "Type":"string", "Optional":"true"}, "version":{"Key":"false", "Type":"string", "Optional":"true"} } }, "Method":{ "Name":"GET" } }, "Child Resources":[ "http://localhost:4848/management/domain/configs", "http://localhost:4848/management/domain/resources", "http://localhost:4848/management/domain/servers", "http://localhost:4848/management/domain/property", "http://localhost:4848/management/domain/applications", "http://localhost:4848/management/domain/system-applications", "http://localhost:4848/management/domain/stop", "http://localhost:4848/management/domain/restart", "http://localhost:4848/management/domain/uptime", "http://localhost:4848/management/domain/version", "http://localhost:4848/management/domain/rotate-log", "http://localhost:4848/management/domain/host-port" ] } |
The general format for the XML representation of a resource is as follows:
<resource attributes> <Methods> method-list </Methods> children </type>
The replaceable items in this format are as follows:
The name of the resource.
Zero or more name-value pairs separated by a space. Each name-value pair is specified as name="value".
One or more XML elements that represent the methods that the resource supports. For the format of each element, see XML Representation of a Resource Method.
Zero or more XML elements that specify the URLs of child resources. Each element is specified as <child-resource>url</child-resource>, where child-resource is the name of the child resource and url is the URL to the child resource.
The XML representation of a method in a method list is as follows:
<Method name="method-name"> <Message-Parameters> message-parameter-list </Message-Parameters> <Query-Parameters> query-parameter-list </Query-Parameters> </Method>
The replaceable items in this format are as follows:
The name of the method, which is GET, POST, or DELETE.
Zero or more XML elements separated by a line feed that represent the message parameters that are allowed for the method. For the format of each element, see XML Representation of a Message Parameter or a Query Parameter.
Zero or more XML elements separated by a line feed that represent the query parameters that are allowed for the method. For the format of each element, see XML Representation of a Message Parameter or a Query Parameter.
The XML representation of a message parameter or a query parameter is as follows:
<parameter-name attribute-list/>
The replaceable items in this format are as follows:
The name of the parameter.
A space-separated list of name-value pairs of attributes for the parameter. Each pair is in the following format:
name="value"
Possible attributes are as follows:
The default value of the parameter.
The set or range of acceptable values for the parameter.
The data type of the parameter, which is one of the following types:
boolean
int
string
Indicates whether the parameter is optional. If true, the parameter is optional. If false, the parameter is required.
Indicates whether the parameter is key. If true, the parameter is key. If false, the parameter is not key.
This example shows the XML representation of the resource for managing a domain. In this example, the DAS is running on the local host and the HTTP port for administration is 4848. The URL to the resource in this example is http://localhost:4848/management/domain.
Line breaks are added to enhance readability.
<Domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" locale="" version="73"> <Methods> <Method name="POST"> <Message-Parameters> <log-root Key="false" Type="string" Optional="true"/> <application-root Key="false" Type="string" Optional="true"/> <locale Key="false" Type="string" Optional="true"/> <version Key="false" Type="string" Optional="true"/> </Message-Parameters> </Method> <Method name="GET"> </Method> </Methods> <Child-Resources> <Child-Resource>http://localhost:4848/management/domain/configs</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/resources</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/servers</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/property</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/applications</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/system-applications</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/stop</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/restart</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/uptime</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/version</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/rotate-log</Child-Resource> <Child-Resource>http://localhost:4848/management/domain/host-port</Child-Resource> </Child-Resources> </Domain> |
The format for the HTML representation of a resource is a web page that provides the following information about the resource:
A list of the attributes of the resource and their values.
A list of the methods and method parameters that the resource supports. Each method and its parameters are presented as a field of the appropriate type in an HTML form.
A list of hypertext links to the children of the resource.
For a sample web page, see Figure 2–1. In this example, the DAS is running on the local host and the HTTP port for administration is 4848. The URL to the resource in this example is http://localhost:4848/management/domain.