public class CloudResource extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CONTENT_TYPE
MIME content type of the cloud resource.
|
static String |
CONTENT_TYPE_UTF8 |
static PrintStream |
DEBUG
If set to non-null, the request and the response details are sent to this stream
|
static org.codehaus.jackson.map.ObjectMapper |
MAPPER |
static Capability |
READ_CAPABILITY
Capability required to retrieve the state of
CloudResource. |
| Constructor and Description |
|---|
CloudResource(URL url,
Credential credential) |
| Modifier and Type | Method and Description |
|---|---|
<T extends CloudResourceFacet> |
as(Class<T> facet)
Creates a client-side wrapper to access this cloud resource through the specified cloud resource type.
|
<T extends CloudResourceFacet> |
coerce(Class<T> facet)
Creates a client-side wrapper to access this cloud resource through the specified cloud resource type.
|
HttpURLConnection |
connect() |
CloudResource |
create(String path,
Object request)
Makes a POST request with the specified request payload, then expect 201 status that reports the location
of the newly created resource.
|
void |
delete() |
boolean |
equals(Object o) |
static CloudResource |
fromOAuthToken(URL url,
OauthToken token) |
static CloudResource |
fromOAuthToken(URL url,
String oauthAccessToken)
A cloud resource is identified by its URL, and to talk to it we need an OAuth access token
|
Credential |
getCredential() |
URL |
getUrl()
URL of this cloud resource.
|
int |
hashCode() |
<T extends CloudResourceFacet> |
hasType(Class<T> facet)
Does this cloud resource implement the specified type?
|
boolean |
hasType(String fullyQualifiedTypeName)
Does this cloud resource implement the specified type?
|
<T> T |
post(String path,
Object request,
Class<T> responseType)
Makes a POST request with the specified request payload, then return the data-bound JSON object in the specified 'response' type.
|
org.codehaus.jackson.node.ObjectNode |
retrieve() |
org.codehaus.jackson.node.ObjectNode |
retrieve(boolean force)
Retrieves the current state of the CloudResource object as JSON DOM node.
|
<T> T |
retrieve(Class<T> type) |
<T> T |
retrieve(Class<T> type,
boolean force)
Retrieves the current state of the cloud resource and data-bind it to the given object via Jackson
|
void |
setTypes(Collection<String> types)
Under some limited circumstances, you get a list of types of another cloud resource
when you get a reference to it.
|
String |
toString() |
static Set<String> |
typesOf(Class<?> bean)
Recursively list up all the
CloudResourceType annotations on the given class
and return them. |
public static final org.codehaus.jackson.map.ObjectMapper MAPPER
public static final String CONTENT_TYPE
public static final String CONTENT_TYPE_UTF8
public static Capability READ_CAPABILITY
CloudResource.public static PrintStream DEBUG
public CloudResource(URL url, Credential credential)
public static CloudResource fromOAuthToken(URL url, String oauthAccessToken)
public static CloudResource fromOAuthToken(URL url, OauthToken token)
public URL getUrl()
public Credential getCredential()
public <T extends CloudResourceFacet> T as(Class<T> facet) throws IOException
IOExceptionpublic <T extends CloudResourceFacet> T coerce(Class<T> facet) throws IOException
as(Class), this version does not check if the cloud resource
actually advertises the specified cloud resource type.IOExceptionpublic <T extends CloudResourceFacet> boolean hasType(Class<T> facet) throws IOException
IOExceptionpublic boolean hasType(String fullyQualifiedTypeName) throws IOException
IOExceptionpublic void setTypes(Collection<String> types)
CloudResource
about its types. This will save an unnecessary roundtrip.public org.codehaus.jackson.node.ObjectNode retrieve(boolean force)
throws IOException
force - if false, cached value is used if available.IOExceptionpublic org.codehaus.jackson.node.ObjectNode retrieve()
throws IOException
IOExceptionpublic <T> T retrieve(Class<T> type, boolean force) throws IOException
IOExceptionpublic <T> T retrieve(Class<T> type) throws IOException
IOExceptionpublic void delete()
throws IOException
IOExceptionpublic <T> T post(String path, Object request, Class<T> responseType) throws IOException
path - Normally relative URL (from the URL of the cloud resource) that indicates the endpoint to POST to.IOExceptionpublic CloudResource create(String path, Object request) throws IOException
path - Normally relative URL (from the URL of the cloud resource) that indicates the endpoint to POST to.IOExceptionpublic HttpURLConnection connect() throws IOException
IOExceptionpublic static Set<String> typesOf(Class<?> bean)
CloudResourceType annotations on the given class
and return them.Copyright © 2011-2015. All Rights Reserved.