Class 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
    • Constructor Detail

      • CompositeResource

        public CompositeResource()
    • Method Detail

      • setSubjectRef

        public void setSubjectRef​(org.glassfish.jersey.internal.util.collection.Ref<Subject> subjectRef)
      • 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 a WebApplicationException 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)
      • newTemplate

        protected <T extends RestModel> T newTemplate​(Class<T> modelIface)
      • getTypedModel

        protected <T extends RestModel> T getTypedModel​(Class<T> modelIface,
                                                        jakarta.json.JsonObject jsonModel)
                                                 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:
      • getUri

        protected URI getUri​(String path)
      • getSubUri

        protected URI getSubUri​(String name)
      • includeResourceLinks

        protected boolean includeResourceLinks()
      • getCollectionChildParentUri

        protected URI getCollectionChildParentUri()
                                           throws Exception
        Throws:
        Exception
      • executeDeleteCommand

        protected ActionReporter executeDeleteCommand​(String command)
        Execute a delete AdminCommand with no parameters.
        Parameters:
        command -
        Returns:
      • executeDeleteCommand

        protected ActionReporter executeDeleteCommand​(String command,
                                                      ParameterMap parameters)
        Execute a delete AdminCommand with the specified parameters.
        Parameters:
        command -
        parameters -
        Returns:
      • executeDeleteCommandManaged

        protected ActionReporter executeDeleteCommandManaged​(String command,
                                                             ParameterMap parameters)
        Execute a delete AdminCommand with the specified parameters.
        Parameters:
        command -
        parameters -
        Returns:
      • executeWriteCommand

        protected ActionReporter executeWriteCommand​(String command)
        Execute a writing AdminCommand with no parameters.
        Parameters:
        command -
        Returns:
      • executeWriteCommand

        protected ActionReporter executeWriteCommand​(String command,
                                                     ParameterMap parameters)
        Execute a writing AdminCommand with the specified parameters.
        Parameters:
        command -
        parameters -
        Returns:
      • executeWriteCommandManaged

        protected ActionReporter executeWriteCommandManaged​(String command,
                                                            ParameterMap parameters)
        Execute a writing AdminCommand with the specified parameters.
        Parameters:
        command -
        parameters -
        Returns:
      • executeReadCommand

        protected ActionReporter executeReadCommand​(String command)
        Execute a read-only AdminCommand with the specified parameters.
        Parameters:
        command -
        parameters -
        Returns:
      • executeReadCommand

        protected ActionReporter executeReadCommand​(String command,
                                                    ParameterMap parameters)
        Execute a read-only AdminCommand 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 an AdminCommand 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 an AdminCommand via SSE, but provide an ActionReportProcessor that allows the calling resource, via an EntityBuilder instance, to return a ResponseBody 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)
        Execute an AdminCommand 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.
      • 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)
      • 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)
      • 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: