Interface ResourceTypeMeta<R>
- Type Parameters:
R
- The type that represents this class's config, usually an immutable record class that is naturally Gson-serializable.
- All Known Implementing Classes:
DefaultResourceTypeMeta
public interface ResourceTypeMeta<R>
A ResourceTypeMeta provides metadata and performs delegate actions that pertain to a particular type of configuration
resource.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceAuditDelegate
getCodec()
Get theResourceCodec
that can be used to encode and decode resources of this type.default ResourceEntityDelegate
default Optional<ExtensionPointCollection<?>>
getIconPath
(ResourceId resource) Relative URL to an icon for this resource, e.g.default ResourcePath
Returns the ResourcePath for a resource of this type.default String
The collection name of the preferred storage location for this resource type.default ResourceReferenceDelegate<R>
default ResourceActionSet
Returns a special pseudo-set declaring how to perform various actions for this resource type.getResourceCategoryName
(Locale locale) A human-friendly name for the resources of this type.default String
getResourceDisplayName
(ResourceId id, Locale locale) A human-friendly name for this resource.default Optional<ResourceRouteDelegate<R>>
default Optional<ResourceScriptDelegate>
default ResourceStatusDelegate
default boolean
default boolean
static <T> DefaultResourceTypeMeta.Builder<T>
newBuilder
(Class<T> recordType) Creates a new builder for standard (named or singleton) resources.static <T extends ExtensionPointProfileConfig>
DefaultResourceTypeMeta.ExtensionPointBuilder<T>newExtensionPointBuilder
(Class<T> recordType) Creates a new builder for extension point resources.
-
Method Details
-
getResourceType
ResourceType getResourceType()- Returns:
- The type of the resource that this meta is for
-
getPreferredCollection
The collection name of the preferred storage location for this resource type. In other words, if a user creates a new instance of this resource, which collection should it be stored in by default?Typically, this should be either
ConfigurationManager.CORE
if the resource should be roaming (the default behavior) orConfigurationManager.LOCAL
if the resource is host-local. -
getResourceCategoryName
A human-friendly name for the resources of this type. For example, "Database Connections" or "Devices" -
getResourceDisplayName
A human-friendly name for this resource. -
getIconPath
Relative URL to an icon for this resource, e.g. "/res/my-module/resource.png".- Parameters:
resource
- The resource to get the icon for, or null to get a generic icon for this resource type.
-
isSingleton
default boolean isSingleton()- Returns:
- true if this resource type represents a singleton resource. Default is false.
-
isExtensionPoint
default boolean isExtensionPoint()- Returns:
- true if this resource type represents an extension point. Default is false.
-
getPath
Returns the ResourcePath for a resource of this type. If the resource type is a singleton, the name parameter is ignored and must be null. If the resource is not a singleton, the name parameter is required. -
getExtensionPointCollection
- Returns:
- the ExtensionPointCollection that contains all the extension points of this type, if this resource type is an extension point. Otherwise, return an empty optional.
-
getStatusDelegate
- Returns:
- the ResourceStatusDelegate that can be used to obtain healthchecks and metrics for this resource type and instances of this resource type.
-
getDefaultConfig
- Returns:
- A copy of the resource config object that should be used as the default or prototype for this resource. In other words, it would contain the default or initial settings for a new resource of this type.
-
getCodec
ResourceCodec<R> getCodec()Get theResourceCodec
that can be used to encode and decode resources of this type.If this ResourceTypeMeta provides a
ResourceRouteDelegate
this codec must be a subclass ofJsonResourceCodec
.- Returns:
- The
ResourceCodec
that can be used to encode and decode resources of this type between their serializedResource
form, and the configuration object form represented by<R>
-
getResourceActionSet
Returns a special pseudo-set declaring how to perform various actions for this resource type. This is a meta-capability that can be consumed by downstream sources - at present, the REST API and scripting, via thesystem.config
namespace. -
getRouteDelegate
- Returns:
- the ResourceRouteDelegate that is used to generate routes for this resource type. If this method returns an empty optional, no routes will be generated for this resource type.
-
getScriptDelegate
- Returns:
- the ResourceScriptDelegate that is used to define and handle scripting functions for this resource type. If this method returns an empty optional, no scripting implementations will be available for this type.
-
getReferenceDelegate
- Returns:
- the ResourceReferenceDelegate that is used to define and handle references to other resources from this resource type. By default, no references to other resources are defined.
-
getEntityDelegate
- Returns:
- the ResourceEntityDelegate that is used to generate entities for this resource type.
-
getAuditDelegate
- Returns:
- The
ResourceAuditDelegate
that is used to define and handle auditing events for this resource type.
-
newBuilder
Creates a new builder for standard (named or singleton) resources. You must set the resource type, and you may also configure:- a
ResourceCodec
. If you don't build one - a defaultGsonResourceCodec
will be created automatically. - a
ResourceStatusDelegate
. If you don't build one, an empty one will be used automatically. - a
ResourceRouteDelegate
. You must build one of these if you want your resource to have CRUD routes mounted for it. - a
ResourceReferenceDelegate
. Build one of these if your resource has references to other resources.
- Parameters:
recordType
- The type of the record class that represents the configuration of this resource.- Returns:
- a new
DefaultResourceTypeMeta.Builder
.
- a
-
newExtensionPointBuilder
static <T extends ExtensionPointProfileConfig> DefaultResourceTypeMeta.ExtensionPointBuilder<T> newExtensionPointBuilder(Class<T> recordType) Creates a new builder for extension point resources.- Parameters:
recordType
- the record class used for the extension point profile config.- Returns:
- a new
DefaultResourceTypeMeta.ExtensionPointBuilder
.
-