Class CompositeResource
- java.lang.Object
-
- org.glassfish.admin.rest.resources.AbstractResource
-
- org.glassfish.admin.rest.composite.CompositeResource
-
- All Implemented Interfaces:
RestResource
- Direct Known Subclasses:
JobResource
,JobsResource
,LegacyCompositeResource
@Produces("application/vnd.oracle.glassfish+json") public abstract class CompositeResource extends AbstractResource implements RestResource
This is the base class for all composite resources. It provides all of the basic configuration and utilities needed by composites. For top-level resources, the@Path
and@Service
annotations are still required, though, in order for the resource to be located and configured properly.- Author:
- jdlee
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CompositeResource.CommandInvoker
class
CompositeResource.CreateCommandInvoker
-
Field Summary
Fields Modifier and Type Field Description protected CompositeUtil
compositeUtil
static String
CONSUMES_TYPE
protected static String
DETACHED
protected static String
DETACHED_DEFAULT
protected static String
EXCLUDE
protected static String
INCLUDE
protected static int
THREAD_POOL_CORE
protected static int
THREAD_POOL_MAX
-
Fields inherited from class org.glassfish.admin.rest.resources.AbstractResource
locatorBridge, logger, requestHeaders, securityContext, serviceLocator, subjectRef, uriInfo
-
-
Constructor Summary
Constructors Constructor Description CompositeResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected jakarta.ws.rs.core.Response
accepted(String message, URI jobUri, URI newItemUri)
protected jakarta.ws.rs.core.Response
accepted(String command, ParameterMap parameters, URI childUri)
protected jakarta.ws.rs.core.Response
accepted(ResponseBody rb, String message, URI jobUri, URI newItemUri)
protected jakarta.ws.rs.core.Response
accepted(ResponseBody rb, URI jobUri, URI newItemUri)
protected jakarta.ws.rs.core.Response
act(CompositeResource.CommandInvoker invoker, boolean detached)
protected jakarta.ws.rs.core.Response
acted(String message)
protected jakarta.ws.rs.core.Response
acted(ResponseBody rb)
protected jakarta.ws.rs.core.Response
acted(ResponseBody rb, String message)
protected jakarta.ws.rs.core.Response
actSse(CompositeResource.CommandInvoker invoker)
protected void
addActionResourceLink(ResponseBody rb, String action)
protected void
addResourceLink(ResponseBody rb, String rel)
protected jakarta.ws.rs.WebApplicationException
badRequest(String message)
protected jakarta.ws.rs.WebApplicationException
badRequest(Throwable cause)
protected jakarta.ws.rs.core.Response
badRequest(ResponseBody rb)
protected jakarta.ws.rs.core.Response
badRequest(ResponseBody rb, String message)
protected jakarta.ws.rs.core.Response
create(CompositeResource.CreateCommandInvoker invoker, boolean detached)
protected jakarta.ws.rs.core.Response
created(String name, String message)
protected jakarta.ws.rs.core.Response
created(ResponseBody rb, String name)
protected jakarta.ws.rs.core.Response
created(ResponseBody rb, String name, String message)
protected jakarta.ws.rs.core.Response
created(ResponseBody rb, URI uri)
protected jakarta.ws.rs.core.Response
createSse(CompositeResource.CreateCommandInvoker invoker)
protected jakarta.ws.rs.core.Response
deleted(String message)
protected jakarta.ws.rs.core.Response
deleted(ResponseBody rb)
protected jakarta.ws.rs.core.Response
deleted(ResponseBody rb, String message)
protected ActionReporter
executeCommand(String command, ParameterMap parameters, jakarta.ws.rs.core.Response.Status status, boolean includeFailureMessage, boolean throwOnWarning)
Execute anAdminCommand
with the specified parameters.protected ActionReporter
executeDeleteCommand(String command)
Execute a deleteAdminCommand
with no parameters.protected ActionReporter
executeDeleteCommand(String command, ParameterMap parameters)
Execute a deleteAdminCommand
with the specified parameters.protected ActionReporter
executeDeleteCommandManaged(String command, ParameterMap parameters)
Execute a deleteAdminCommand
with the specified parameters.protected ActionReporter
executeReadCommand(String command)
Execute a read-onlyAdminCommand
with the specified parameters.protected ActionReporter
executeReadCommand(String command, ParameterMap parameters)
Execute a read-onlyAdminCommand
with no parameters.protected org.glassfish.jersey.media.sse.EventOutput
executeSseCommand(Subject subject, String command, ParameterMap parameters)
Execute anAdminCommand
with the specified parameters and return EventOutput suitable for SSE.protected org.glassfish.jersey.media.sse.EventOutput
executeSseCommand(Subject subject, String command, ParameterMap parameters, ResponseBodyBuilder builder)
Execute anAdminCommand
via SSE, but provide anActionReportProcessor
that allows the calling resource, via anEntityBuilder
instance, to return aResponseBody
that extra information such as the newly create entity, as well as any messages returned by the subsystem.protected org.glassfish.jersey.media.sse.EventOutput
executeSseCommand(Subject subject, String command, ParameterMap parameters, SseCommandHelper.ActionReportProcessor processor)
Execute anAdminCommand
with the specified parameters and return EventOutput suitable for SSE.protected ActionReporter
executeWriteCommand(String command)
Execute a writingAdminCommand
with no parameters.protected ActionReporter
executeWriteCommand(String command, ParameterMap parameters)
Execute a writingAdminCommand
with the specified parameters.protected ActionReporter
executeWriteCommandManaged(String command, ParameterMap parameters)
Execute a writingAdminCommand
with the specified parameters.protected <T extends RestModel>
TfilterModel(Class<T> modelIface, T unfilteredModel, String include, String exclude)
protected <T extends RestModel>
TfilterModel(Class<T> modelIface, T unfilteredModel, String include, String exclude, String identityAttr)
protected <T extends RestModel>
TfilterModel(Class<T> modelIface, T unfilteredModel, JsonFilter filter)
protected String
generateDefaultName(String namePrefix, Collection<String> usedNames)
TBD - Jason Lee wants to move this into the defaults generators.protected URI
getChildItemUri(String name)
Every resource that returns a collection will need to return the URI for each item in the collection.protected URI
getCollectionChildParentUri()
CompositeUtil
getCompositeUtil()
protected ExecutorService
getExecutorService()
protected JsonFilter
getFilter(String include, String exclude)
protected JsonFilter
getFilter(String include, String exclude, String identityAttr)
protected jakarta.json.JsonObject
getJsonModel(RestModel typedModel)
protected Locale
getLocale()
protected URI
getParentUri()
protected String
getPathParam(String name)
Convenience method for getting a path parameter.protected jakarta.ws.rs.core.Response
getResponse(jakarta.ws.rs.core.Response.Status status, ResponseBody responseBody)
protected jakarta.ws.rs.core.Response
getResponse(ResponseBody responseBody)
<T> T
getSubResource(Class<T> clazz)
This method creates a sub-resource of the specified type.protected URI
getSubUri(String name)
protected <T extends RestModel>
TgetTypedModel(Class<T> modelIface, jakarta.json.JsonObject jsonModel)
protected URI
getUri(String path)
protected boolean
includeResourceLinks()
protected URI
launchDetachedCommand(String command, ParameterMap parameters)
protected <T> T
newModel(Class<T> modelIface)
protected <T extends RestModel>
TnewTemplate(Class<T> modelIface)
protected jakarta.ws.rs.WebApplicationException
notFound(String message)
protected jakarta.ws.rs.core.Response
ok(ResponseBody rb)
protected ParameterMap
parameterMap()
protected ResponseBody
responseBody()
protected <T extends RestModel>
RestCollectionResponseBody<T>restCollectionResponseBody(Class<T> modelIface, String collectionName)
protected <T extends RestModel>
RestCollectionResponseBody<T>restCollectionResponseBody(Class<T> modelIface, String collectionName, URI parentUri)
protected <T extends RestModel>
RestModelResponseBody<T>restModelResponseBody(Class<T> modelIface)
protected <T extends RestModel>
RestModelResponseBody<T>restModelResponseBody(Class<T> modelIface, URI parentUri)
protected <T extends RestModel>
RestModelResponseBody<T>restModelResponseBody(Class<T> modelIface, URI parentUri, T entity)
void
setSubjectRef(org.glassfish.jersey.internal.util.collection.Ref<Subject> subjectRef)
protected jakarta.ws.rs.core.Response
updated(String message)
protected jakarta.ws.rs.core.Response
updated(ResponseBody rb)
protected jakarta.ws.rs.core.Response
updated(ResponseBody rb, String message)
-
Methods inherited from class org.glassfish.admin.rest.resources.AbstractResource
getAuthenticatedUser, getSubject
-
-
-
-
Field Detail
-
CONSUMES_TYPE
public static final String CONSUMES_TYPE
- See Also:
- Constant Field Values
-
DETACHED
protected static final String DETACHED
- See Also:
- Constant Field Values
-
DETACHED_DEFAULT
protected static final String DETACHED_DEFAULT
- See Also:
- Constant Field Values
-
INCLUDE
protected static final String INCLUDE
- See Also:
- Constant Field Values
-
EXCLUDE
protected static final String EXCLUDE
- See Also:
- Constant Field Values
-
THREAD_POOL_CORE
protected static final int THREAD_POOL_CORE
- See Also:
- Constant Field Values
-
THREAD_POOL_MAX
protected static final int THREAD_POOL_MAX
- See Also:
- Constant Field Values
-
compositeUtil
protected CompositeUtil compositeUtil
-
-
Method Detail
-
setSubjectRef
public void setSubjectRef(org.glassfish.jersey.internal.util.collection.Ref<Subject> subjectRef)
-
getCompositeUtil
public CompositeUtil getCompositeUtil()
-
getSubResource
public <T> T getSubResource(Class<T> clazz)
This method creates a sub-resource of the specified type. Since the JAX-RS does not allow for injection into sub-resources (as it doesn't know or control the lifecycle of the object), this method performs a manual "injection" of the various system objects the resource might need. If the requested Class can not be instantiated (e.g., it does not have a no-arg public constructor), the system will throw aWebApplicationException
with an HTTP status code of 500 (internal server error).- Parameters:
clazz
- The Class of the desired sub-resource- Returns:
-
newModel
protected <T> T newModel(Class<T> modelIface)
-
getTypedModel
protected <T extends RestModel> T getTypedModel(Class<T> modelIface, jakarta.json.JsonObject jsonModel) throws Exception
- Throws:
Exception
-
getJsonModel
protected jakarta.json.JsonObject getJsonModel(RestModel typedModel) throws Exception
- Throws:
Exception
-
getChildItemUri
protected URI getChildItemUri(String name)
Every resource that returns a collection will need to return the URI for each item in the collection. This method handles the creation of that URI, ensuring a correct and consistent URI pattern.- Parameters:
name
-- Returns:
-
addResourceLink
protected void addResourceLink(ResponseBody rb, String rel) throws Exception
- Throws:
Exception
-
addActionResourceLink
protected void addActionResourceLink(ResponseBody rb, String action) throws Exception
- Throws:
Exception
-
includeResourceLinks
protected boolean includeResourceLinks()
-
getCollectionChildParentUri
protected URI getCollectionChildParentUri() throws Exception
- Throws:
Exception
-
executeDeleteCommand
protected ActionReporter executeDeleteCommand(String command)
Execute a deleteAdminCommand
with no parameters.- Parameters:
command
-- Returns:
-
executeDeleteCommand
protected ActionReporter executeDeleteCommand(String command, ParameterMap parameters)
Execute a deleteAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-- Returns:
-
executeDeleteCommandManaged
protected ActionReporter executeDeleteCommandManaged(String command, ParameterMap parameters)
Execute a deleteAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-- Returns:
-
executeWriteCommand
protected ActionReporter executeWriteCommand(String command)
Execute a writingAdminCommand
with no parameters.- Parameters:
command
-- Returns:
-
executeWriteCommand
protected ActionReporter executeWriteCommand(String command, ParameterMap parameters)
Execute a writingAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-- Returns:
-
executeWriteCommandManaged
protected ActionReporter executeWriteCommandManaged(String command, ParameterMap parameters)
Execute a writingAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-- Returns:
-
executeReadCommand
protected ActionReporter executeReadCommand(String command)
Execute a read-onlyAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-- Returns:
-
executeReadCommand
protected ActionReporter executeReadCommand(String command, ParameterMap parameters)
Execute a read-onlyAdminCommand
with no parameters.- Parameters:
command
-parameters
-- Returns:
-
executeCommand
protected ActionReporter executeCommand(String command, ParameterMap parameters, jakarta.ws.rs.core.Response.Status status, boolean includeFailureMessage, boolean throwOnWarning)
Execute anAdminCommand
with the specified parameters.- Parameters:
command
-parameters
-status
-includeFailureMessage
-throwOnWarning
- (vs.ignore warning)- Returns:
-
executeSseCommand
protected org.glassfish.jersey.media.sse.EventOutput executeSseCommand(Subject subject, String command, ParameterMap parameters, ResponseBodyBuilder builder)
Execute anAdminCommand
via SSE, but provide anActionReportProcessor
that allows the calling resource, via anEntityBuilder
instance, to return aResponseBody
that extra information such as the newly create entity, as well as any messages returned by the subsystem.
-
executeSseCommand
protected org.glassfish.jersey.media.sse.EventOutput executeSseCommand(Subject subject, String command, ParameterMap parameters, SseCommandHelper.ActionReportProcessor processor)
Execute anAdminCommand
with the specified parameters and return EventOutput suitable for SSE.
-
executeSseCommand
protected org.glassfish.jersey.media.sse.EventOutput executeSseCommand(Subject subject, String command, ParameterMap parameters)
Execute anAdminCommand
with the specified parameters and return EventOutput suitable for SSE.
-
generateDefaultName
protected String generateDefaultName(String namePrefix, Collection<String> usedNames)
TBD - Jason Lee wants to move this into the defaults generators. Finds an unused name given the list of currently used names and a name prefix.- Parameters:
namePrefix
-usedNames
-- Returns:
- a String containing an unused dname, or an empty string if all candidate names are currently in use.
-
created
protected jakarta.ws.rs.core.Response created(String name, String message) throws Exception
- Throws:
Exception
-
created
protected jakarta.ws.rs.core.Response created(ResponseBody rb, String name, String message) throws Exception
- Throws:
Exception
-
created
protected jakarta.ws.rs.core.Response created(ResponseBody rb, String name) throws Exception
- Throws:
Exception
-
created
protected jakarta.ws.rs.core.Response created(ResponseBody rb, URI uri) throws Exception
- Throws:
Exception
-
updated
protected jakarta.ws.rs.core.Response updated(String message)
-
updated
protected jakarta.ws.rs.core.Response updated(ResponseBody rb, String message)
-
updated
protected jakarta.ws.rs.core.Response updated(ResponseBody rb)
-
deleted
protected jakarta.ws.rs.core.Response deleted(String message)
-
deleted
protected jakarta.ws.rs.core.Response deleted(ResponseBody rb, String message)
-
deleted
protected jakarta.ws.rs.core.Response deleted(ResponseBody rb)
-
acted
protected jakarta.ws.rs.core.Response acted(String message)
-
acted
protected jakarta.ws.rs.core.Response acted(ResponseBody rb, String message)
-
acted
protected jakarta.ws.rs.core.Response acted(ResponseBody rb)
-
accepted
protected jakarta.ws.rs.core.Response accepted(String message, URI jobUri, URI newItemUri)
-
accepted
protected jakarta.ws.rs.core.Response accepted(ResponseBody rb, String message, URI jobUri, URI newItemUri)
-
accepted
protected jakarta.ws.rs.core.Response accepted(ResponseBody rb, URI jobUri, URI newItemUri)
-
accepted
protected jakarta.ws.rs.core.Response accepted(String command, ParameterMap parameters, URI childUri)
-
launchDetachedCommand
protected URI launchDetachedCommand(String command, ParameterMap parameters)
-
ok
protected jakarta.ws.rs.core.Response ok(ResponseBody rb)
-
badRequest
protected jakarta.ws.rs.core.Response badRequest(ResponseBody rb, String message)
-
badRequest
protected jakarta.ws.rs.core.Response badRequest(ResponseBody rb)
-
badRequest
protected jakarta.ws.rs.WebApplicationException badRequest(Throwable cause)
-
badRequest
protected jakarta.ws.rs.WebApplicationException badRequest(String message)
-
notFound
protected jakarta.ws.rs.WebApplicationException notFound(String message)
-
restCollectionResponseBody
protected <T extends RestModel> RestCollectionResponseBody<T> restCollectionResponseBody(Class<T> modelIface, String collectionName, URI parentUri)
-
restCollectionResponseBody
protected <T extends RestModel> RestCollectionResponseBody<T> restCollectionResponseBody(Class<T> modelIface, String collectionName)
-
restModelResponseBody
protected <T extends RestModel> RestModelResponseBody<T> restModelResponseBody(Class<T> modelIface, URI parentUri, T entity)
-
restModelResponseBody
protected <T extends RestModel> RestModelResponseBody<T> restModelResponseBody(Class<T> modelIface, URI parentUri)
-
restModelResponseBody
protected <T extends RestModel> RestModelResponseBody<T> restModelResponseBody(Class<T> modelIface)
-
responseBody
protected ResponseBody responseBody()
-
getResponse
protected jakarta.ws.rs.core.Response getResponse(ResponseBody responseBody)
-
getResponse
protected jakarta.ws.rs.core.Response getResponse(jakarta.ws.rs.core.Response.Status status, ResponseBody responseBody)
-
getFilter
protected JsonFilter getFilter(String include, String exclude) throws Exception
- Throws:
Exception
-
getFilter
protected JsonFilter getFilter(String include, String exclude, String identityAttr) throws Exception
- Throws:
Exception
-
filterModel
protected <T extends RestModel> T filterModel(Class<T> modelIface, T unfilteredModel, String include, String exclude) throws Exception
- Throws:
Exception
-
filterModel
protected <T extends RestModel> T filterModel(Class<T> modelIface, T unfilteredModel, String include, String exclude, String identityAttr) throws Exception
- Throws:
Exception
-
filterModel
protected <T extends RestModel> T filterModel(Class<T> modelIface, T unfilteredModel, JsonFilter filter) throws Exception
- Throws:
Exception
-
getLocale
protected Locale getLocale()
-
getPathParam
protected String getPathParam(String name)
Convenience method for getting a path parameter. Equivalent to uriInfo.getPathParameters().getFirst(name)- Parameters:
name
-- Returns:
-
parameterMap
protected ParameterMap parameterMap()
-
getExecutorService
protected ExecutorService getExecutorService()
-
act
protected jakarta.ws.rs.core.Response act(CompositeResource.CommandInvoker invoker, boolean detached)
-
actSse
protected jakarta.ws.rs.core.Response actSse(CompositeResource.CommandInvoker invoker)
-
create
protected jakarta.ws.rs.core.Response create(CompositeResource.CreateCommandInvoker invoker, boolean detached) throws Exception
- Throws:
Exception
-
createSse
protected jakarta.ws.rs.core.Response createSse(CompositeResource.CreateCommandInvoker invoker) throws Exception
- Throws:
Exception
-
-