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 RestResourceThis 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@Pathand@Serviceannotations 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 classCompositeResource.CommandInvokerclassCompositeResource.CreateCommandInvoker
-
Field Summary
Fields Modifier and Type Field Description protected CompositeUtilcompositeUtilstatic StringCONSUMES_TYPEprotected static StringDETACHEDprotected static StringDETACHED_DEFAULTprotected static StringEXCLUDEprotected static StringINCLUDEprotected static intTHREAD_POOL_COREprotected static intTHREAD_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.Responseaccepted(String message, URI jobUri, URI newItemUri)protected jakarta.ws.rs.core.Responseaccepted(String command, ParameterMap parameters, URI childUri)protected jakarta.ws.rs.core.Responseaccepted(ResponseBody rb, String message, URI jobUri, URI newItemUri)protected jakarta.ws.rs.core.Responseaccepted(ResponseBody rb, URI jobUri, URI newItemUri)protected jakarta.ws.rs.core.Responseact(CompositeResource.CommandInvoker invoker, boolean detached)protected jakarta.ws.rs.core.Responseacted(String message)protected jakarta.ws.rs.core.Responseacted(ResponseBody rb)protected jakarta.ws.rs.core.Responseacted(ResponseBody rb, String message)protected jakarta.ws.rs.core.ResponseactSse(CompositeResource.CommandInvoker invoker)protected voidaddActionResourceLink(ResponseBody rb, String action)protected voidaddResourceLink(ResponseBody rb, String rel)protected jakarta.ws.rs.WebApplicationExceptionbadRequest(String message)protected jakarta.ws.rs.WebApplicationExceptionbadRequest(Throwable cause)protected jakarta.ws.rs.core.ResponsebadRequest(ResponseBody rb)protected jakarta.ws.rs.core.ResponsebadRequest(ResponseBody rb, String message)protected jakarta.ws.rs.core.Responsecreate(CompositeResource.CreateCommandInvoker invoker, boolean detached)protected jakarta.ws.rs.core.Responsecreated(String name, String message)protected jakarta.ws.rs.core.Responsecreated(ResponseBody rb, String name)protected jakarta.ws.rs.core.Responsecreated(ResponseBody rb, String name, String message)protected jakarta.ws.rs.core.Responsecreated(ResponseBody rb, URI uri)protected jakarta.ws.rs.core.ResponsecreateSse(CompositeResource.CreateCommandInvoker invoker)protected jakarta.ws.rs.core.Responsedeleted(String message)protected jakarta.ws.rs.core.Responsedeleted(ResponseBody rb)protected jakarta.ws.rs.core.Responsedeleted(ResponseBody rb, String message)protected ActionReporterexecuteCommand(String command, ParameterMap parameters, jakarta.ws.rs.core.Response.Status status, boolean includeFailureMessage, boolean throwOnWarning)Execute anAdminCommandwith the specified parameters.protected ActionReporterexecuteDeleteCommand(String command)Execute a deleteAdminCommandwith no parameters.protected ActionReporterexecuteDeleteCommand(String command, ParameterMap parameters)Execute a deleteAdminCommandwith the specified parameters.protected ActionReporterexecuteDeleteCommandManaged(String command, ParameterMap parameters)Execute a deleteAdminCommandwith the specified parameters.protected ActionReporterexecuteReadCommand(String command)Execute a read-onlyAdminCommandwith the specified parameters.protected ActionReporterexecuteReadCommand(String command, ParameterMap parameters)Execute a read-onlyAdminCommandwith no parameters.protected org.glassfish.jersey.media.sse.EventOutputexecuteSseCommand(Subject subject, String command, ParameterMap parameters)Execute anAdminCommandwith the specified parameters and return EventOutput suitable for SSE.protected org.glassfish.jersey.media.sse.EventOutputexecuteSseCommand(Subject subject, String command, ParameterMap parameters, ResponseBodyBuilder builder)Execute anAdminCommandvia SSE, but provide anActionReportProcessorthat allows the calling resource, via anEntityBuilderinstance, to return aResponseBodythat extra information such as the newly create entity, as well as any messages returned by the subsystem.protected org.glassfish.jersey.media.sse.EventOutputexecuteSseCommand(Subject subject, String command, ParameterMap parameters, SseCommandHelper.ActionReportProcessor processor)Execute anAdminCommandwith the specified parameters and return EventOutput suitable for SSE.protected ActionReporterexecuteWriteCommand(String command)Execute a writingAdminCommandwith no parameters.protected ActionReporterexecuteWriteCommand(String command, ParameterMap parameters)Execute a writingAdminCommandwith the specified parameters.protected ActionReporterexecuteWriteCommandManaged(String command, ParameterMap parameters)Execute a writingAdminCommandwith 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 StringgenerateDefaultName(String namePrefix, Collection<String> usedNames)TBD - Jason Lee wants to move this into the defaults generators.protected URIgetChildItemUri(String name)Every resource that returns a collection will need to return the URI for each item in the collection.protected URIgetCollectionChildParentUri()CompositeUtilgetCompositeUtil()protected ExecutorServicegetExecutorService()protected JsonFiltergetFilter(String include, String exclude)protected JsonFiltergetFilter(String include, String exclude, String identityAttr)protected jakarta.json.JsonObjectgetJsonModel(RestModel typedModel)protected LocalegetLocale()protected URIgetParentUri()protected StringgetPathParam(String name)Convenience method for getting a path parameter.protected jakarta.ws.rs.core.ResponsegetResponse(jakarta.ws.rs.core.Response.Status status, ResponseBody responseBody)protected jakarta.ws.rs.core.ResponsegetResponse(ResponseBody responseBody)<T> TgetSubResource(Class<T> clazz)This method creates a sub-resource of the specified type.protected URIgetSubUri(String name)protected <T extends RestModel>
TgetTypedModel(Class<T> modelIface, jakarta.json.JsonObject jsonModel)protected URIgetUri(String path)protected booleanincludeResourceLinks()protected URIlaunchDetachedCommand(String command, ParameterMap parameters)protected <T> TnewModel(Class<T> modelIface)protected <T extends RestModel>
TnewTemplate(Class<T> modelIface)protected jakarta.ws.rs.WebApplicationExceptionnotFound(String message)protected jakarta.ws.rs.core.Responseok(ResponseBody rb)protected ParameterMapparameterMap()protected ResponseBodyresponseBody()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)voidsetSubjectRef(org.glassfish.jersey.internal.util.collection.Ref<Subject> subjectRef)protected jakarta.ws.rs.core.Responseupdated(String message)protected jakarta.ws.rs.core.Responseupdated(ResponseBody rb)protected jakarta.ws.rs.core.Responseupdated(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 aWebApplicationExceptionwith 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 deleteAdminCommandwith no parameters.- Parameters:
command-- Returns:
-
executeDeleteCommand
protected ActionReporter executeDeleteCommand(String command, ParameterMap parameters)
Execute a deleteAdminCommandwith the specified parameters.- Parameters:
command-parameters-- Returns:
-
executeDeleteCommandManaged
protected ActionReporter executeDeleteCommandManaged(String command, ParameterMap parameters)
Execute a deleteAdminCommandwith the specified parameters.- Parameters:
command-parameters-- Returns:
-
executeWriteCommand
protected ActionReporter executeWriteCommand(String command)
Execute a writingAdminCommandwith no parameters.- Parameters:
command-- Returns:
-
executeWriteCommand
protected ActionReporter executeWriteCommand(String command, ParameterMap parameters)
Execute a writingAdminCommandwith the specified parameters.- Parameters:
command-parameters-- Returns:
-
executeWriteCommandManaged
protected ActionReporter executeWriteCommandManaged(String command, ParameterMap parameters)
Execute a writingAdminCommandwith the specified parameters.- Parameters:
command-parameters-- Returns:
-
executeReadCommand
protected ActionReporter executeReadCommand(String command)
Execute a read-onlyAdminCommandwith the specified parameters.- Parameters:
command-parameters-- Returns:
-
executeReadCommand
protected ActionReporter executeReadCommand(String command, ParameterMap parameters)
Execute a read-onlyAdminCommandwith 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 anAdminCommandwith 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 anAdminCommandvia SSE, but provide anActionReportProcessorthat allows the calling resource, via anEntityBuilderinstance, to return aResponseBodythat 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 anAdminCommandwith 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 anAdminCommandwith 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
-
-