public final class UserDirectiveRegistry extends Object implements DirectiveRegistry
ArtifactInfo or through the use of the context in which it is running.
This class provides two constructors for two different context in which the
user defined directives are loaded.
One context is the service context in which construction of this object
would result in investigating all the different artifacts that are of type
Directive.TYPE and creating a classloader for the same. The classload is
then used to create an instance of plugin, in this case it's a directive and
extract all the DirectiveInfo from the instance of directive created.
Second context is the Transform plugin, were the second constructor of this class in used to initialize. Initializing this class using StageContext provides a way to create an instance of the plugin. The name of the directive is used as the id for the plugin.
| Constructor and Description |
|---|
UserDirectiveRegistry(HttpServiceContext manager)
This constructor should be used when initializing the registry from Service.
|
UserDirectiveRegistry(StageContext context)
This constructor is used when constructing this object in the context of Transform.
|
UserDirectiveRegistry(SystemAppTaskContext systemAppTaskContext)
This constructor is used when creating from remote task
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes any resources acquired during initialization or otherwise.
|
DirectiveInfo |
get(String namespace,
String name)
This method provides information about the directive that is being requested.
|
ArtifactSummary |
getLatestWranglerArtifact()
Retrieve latest Wrangler transform artifact information
|
Iterable<DirectiveInfo> |
list(String namespace)
List the directives in the specified namespace
|
void |
reload(String namespace)
This method reloads the directives from the artifacts into the registry.
|
public UserDirectiveRegistry(HttpServiceContext manager)
Service context implements ArtifactManager interface so it should
be readily assignable.
Using the ArtifactManager, all the artifacts are inspected to check for the artifacts that contain plugins of type Directive#Type. For all those plugins, an instance of the plugin is created to extract the annotated and basic information.
manager - an instance of ArtifactManager.public UserDirectiveRegistry(SystemAppTaskContext systemAppTaskContext)
systemAppTaskContext - SystemAppTaskContextpublic UserDirectiveRegistry(StageContext context)
StageContext is passed to load plugin. Context allows
loading the plugin from the repository. The directive name is used as the plugin id for
loading the class.context - of Stage in Transform.public DirectiveInfo get(String namespace, String name) throws DirectiveLoadException
First, the directive is checked for existence with the internal registry. If the directive does not exits in the registry and the context is not null, then it's attempted to be loaded as a user plugin. If it does not exist there a null is returned. But, if the plugin exists, then it's loaded and an entry is made into the registry.
When invoked through a readable, each plugin is assigned a unique id. The unique
id is generated during the configure phase of the plugin. Those ids are
passed to initialize through the properties.
get in interface DirectiveRegistryname - of the directive to be retrived from the registry.namespace - the namespace of the directiveDirectiveInfo if found, else null.DirectiveLoadExceptionpublic void reload(String namespace) throws DirectiveLoadException
DirectiveRegistryreload in interface DirectiveRegistrynamespace - the namespace to reload directives inDirectiveLoadException - thrown when there are any issues with loading
directives into the registry.@Nullable public ArtifactSummary getLatestWranglerArtifact()
DirectiveRegistrygetLatestWranglerArtifact in interface DirectiveRegistrypublic Iterable<DirectiveInfo> list(String namespace)
DirectiveRegistrylist in interface DirectiveRegistrynamespace - the namespace to list fromDirectiveInfo objects
maintained within the registry.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2022 CDAP Licensed under the Apache License, Version 2.0.