|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.unboundid.directory.sdk.common.api.VelocityContextProvider
@Extensible @DirectoryServerExtension @DirectoryProxyServerExtension(appliesToLocalContent=true, appliesToRemoteContent=false) @SynchronizationServerExtension(appliesToLocalContent=true, appliesToSynchronizedContent=false) @MetricsEngineExtension @IdentityBrokerExtension @ThreadSafety(level=INTERFACE_THREADSAFE) public abstract class VelocityContextProvider
This class defines an API that must be implemented by extensions which contribute content to server pages authored as Velocity templates. These pages are rendered by the Velocity HTTP Servlet Extension included with the server. During rendering of a Velocity page, the template is merged with a 'context' that provides values for variables, properties, and method references in the template.
A context provider can be restricted to contributing content for certain pages by specifying one or more included or excluded views names. A view name is the URL request path to to a template that does not include the HTTP servlet extension's base context path, nor a starting path separator. So for example if a template was accessible by the URL http://localhost:8080/view/path/to/template the view name would be 'path/to/template'.dsconfig create-virtual-attribute \ --extension-name "{extension}" \ --provider-name "{provider}" \ --type third-party \ --set enabled:true \ --set "extension-class:{class-name}" \ --set "extension-argument:{name=value}"where "{extension}" is the name of the Velocity HTTP servlet extension, ("Velocity" by default) "{provider}" is the name to use for the Velocity context provider instance, "{class-name}" is the fully-qualified name of the Java class that extends
com.unboundid.directory.sdk.common.api.VelocityContextProvider
,
and "{name=value}" represents name-value pairs for any arguments to
provide to the virtual attribute provider. If multiple arguments should be
provided to the virtual attribute provider, then the
"--set extension-argument:{name=value}
" option should be
provided multiple times.
Constructor Summary | |
---|---|
VelocityContextProvider()
|
Method Summary | ||
---|---|---|
com.unboundid.ldap.sdk.ResultCode |
applyConfiguration(VelocityContextProviderConfig config,
com.unboundid.util.args.ArgumentParser parser,
java.util.List<java.lang.String> adminActionsRequired,
java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to this extension. |
|
void |
defineConfigArguments(com.unboundid.util.args.ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments which may be used by this extension. |
|
void |
finalizeVelocityContextProvider()
Performs any cleanup which may be necessary when this virtual attribute provider is to be taken out of service. |
|
abstract java.lang.String[] |
getExtensionDescription()
Retrieves a human-readable description for this extension. |
|
abstract java.lang.String |
getExtensionName()
Retrieves a human-readable name for this extension. |
|
protected
|
getNamedObject(java.lang.String name,
javax.servlet.http.HttpServletRequest request)
Gets an object from the current user session or servlet context depending on the object scope currently configured for this provider. |
|
static
|
getNamedObject(java.lang.String name,
javax.servlet.http.HttpServletRequest request,
VelocityContextProviderConfig.ObjectScope scope)
Gets an object from the current user session or servlet context depending on the object scope currently configured for this provider. |
|
void |
initializeVelocityContextProvider(ServerContext serverContext,
VelocityContextProviderConfig config,
com.unboundid.util.args.ArgumentParser parser)
Initializes this Velocity context provider. |
|
boolean |
isConfigurationAcceptable(VelocityContextProviderConfig config,
com.unboundid.util.args.ArgumentParser parser,
java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument parser is acceptable for use by this extension. |
|
protected void |
setNamedObject(java.lang.String name,
java.lang.Object object,
javax.servlet.http.HttpServletRequest request)
Stores an object in current user request, session or servlet context depending on the object scope currently configured for this provider. |
|
static void |
setNamedObject(java.lang.String name,
java.lang.Object object,
javax.servlet.http.HttpServletRequest request,
VelocityContextProviderConfig.ObjectScope scope)
Stores an object in current user request, session or servlet context depending on the object scope currently configured for this provider. |
|
abstract void |
updateContext(VelocityContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Return an object to be placed into a Velocity context for rending a template. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.unboundid.directory.sdk.common.internal.ExampleUsageProvider |
---|
getExamplesArgumentSets |
Constructor Detail |
---|
public VelocityContextProvider()
Method Detail |
---|
public abstract java.lang.String getExtensionName()
getExtensionName
in interface UnboundIDExtension
public abstract java.lang.String[] getExtensionDescription()
getExtensionDescription
in interface UnboundIDExtension
null
or an empty array if no description should be available.public void defineConfigArguments(com.unboundid.util.args.ArgumentParser parser) throws com.unboundid.util.args.ArgumentException
defineConfigArguments
in interface Configurable
parser
- The argument parser to be updated with the configuration
arguments which may be used by this extension.
com.unboundid.util.args.ArgumentException
- If a problem is encountered while updating the
provided argument parser.public void initializeVelocityContextProvider(ServerContext serverContext, VelocityContextProviderConfig config, com.unboundid.util.args.ArgumentParser parser) throws com.unboundid.ldap.sdk.LDAPException
serverContext
- A handle to the server context for the server in
which this extension is running.config
- The general configuration for this Velocity context
provider.parser
- The argument parser which has been initialized from
the configuration for this Velocity context
provider.
com.unboundid.ldap.sdk.LDAPException
- If a problem occurs while initializing this context
provider.public boolean isConfigurationAcceptable(VelocityContextProviderConfig config, com.unboundid.util.args.ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
isConfigurationAcceptable
in interface Reconfigurable<VelocityContextProviderConfig>
config
- The general configuration for this extension.parser
- The argument parser that has been used to
parse the proposed configuration for this
extension.unacceptableReasons
- A list to which messages may be added to
provide additional information about why the
provided configuration is not acceptable.
true
if the configuration in the provided argument parser
appears to be acceptable, or false
if not.public com.unboundid.ldap.sdk.ResultCode applyConfiguration(VelocityContextProviderConfig config, com.unboundid.util.args.ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
applyConfiguration
in interface Reconfigurable<VelocityContextProviderConfig>
config
- The general configuration for this extension.parser
- The argument parser that has been used to
parse the new configuration for this
extension.adminActionsRequired
- A list to which messages may be added to
provide additional information about any
additional administrative actions that may
be required to apply some of the
configuration changes.messages
- A list to which messages may be added to
provide additional information about the
processing performed by this method.
SUCCESS
should be
used to indicate that all processing completed successfully. Any
other result will indicate that a problem occurred during
processing.public void finalizeVelocityContextProvider()
public abstract void updateContext(VelocityContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
context
- to update.request
- for the the view implemented by a template.response
- to the client.protected <T> T getNamedObject(java.lang.String name, javax.servlet.http.HttpServletRequest request)
T
- the type of object to return. If an object exists in
the current scope with the given name but is not of type
T this method returns null
name
- of the object.request
- current user request.
null
if no object exists by the
provided name or an input parameter is (@code null}.protected void setNamedObject(java.lang.String name, java.lang.Object object, javax.servlet.http.HttpServletRequest request)
name
- of the object.object
- to store.request
- current user request.public static <T> T getNamedObject(java.lang.String name, javax.servlet.http.HttpServletRequest request, VelocityContextProviderConfig.ObjectScope scope)
T
- the type of object to return. If an object exists in
the current scope with the given name but is not of type
T this method returns null
name
- of the object.request
- current user request.scope
- from which to retrieve the object.
null
if no object exists by the
provided name or an input parameter is (@code null}.public static void setNamedObject(java.lang.String name, java.lang.Object object, javax.servlet.http.HttpServletRequest request, VelocityContextProviderConfig.ObjectScope scope)
name
- of the object.object
- to store.request
- current user request.scope
- in which to set the object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |