public abstract class GenericHeaplet extends Object implements Heaplet
If the object created is an instance of GenericHeapObject
, it is then
automatically injected with logger
and storage
objects.
Modifier and Type | Field and Description |
---|---|
protected JsonValue |
config
The heaplet's object configuration object.
|
protected Heap |
heap
Where objects should be put and where object dependencies should be retrieved.
|
protected String |
name
The name of the object to be created and stored in the heap by this heaplet.
|
protected Object |
object
The object created by the heaplet's
create() method. |
protected Name |
qualified
The fully qualified name of the object to be created.
|
Constructor and Description |
---|
GenericHeaplet() |
Modifier and Type | Method and Description |
---|---|
abstract Object |
create()
Called to request the heaplet create an object.
|
Object |
create(Name name,
JsonValue config,
Heap heap)
Called to request the heaplet to create an object.
|
void |
destroy()
Called to indicate that the object created by the heaplet is going to be dereferenced.
|
protected EndpointRegistry |
endpointRegistry()
Returns this object's
EndpointRegistry , creating it lazily when requested for the first time. |
protected Function<JsonValue,JsonValue,JsonValueException> |
evaluatedWithHeapProperties()
Returns a function that will evaluate the expression hold by a
JsonValue using the properties defined in the heap of this
Heaplet. |
protected <T> Function<JsonValue,Expression<T>,JsonValueException> |
expression(Class<T> type)
Returns a function that will create an
Expression from the string by the JsonValue using the
bindings defined in the heap of this Heaplet as initial bindings. |
void |
start()
Called to request the heaplet start an object.
|
protected String name
protected Heap heap
public GenericHeaplet()
public Object create(Name name, JsonValue config, Heap heap) throws HeapException
Heaplet
create
in interface Heaplet
name
- the name of the object to be created.config
- the heaplet's configuration object.heap
- the heap where object dependencies can be retrieved.HeapException
- if an exception occurred during creation of the object or any of its dependencies.protected EndpointRegistry endpointRegistry() throws HeapException
EndpointRegistry
, creating it lazily when requested for the first time.EndpointRegistry
(/objects/[name])HeapException
- should never be thrownpublic void destroy()
Heaplet
public abstract Object create() throws HeapException
Heaplet.create(Name, JsonValue, Heap)
after initializing
the protected field members. Implementations should parse configuration
but not acquire resources, start threads, or log any initialization
messages. These tasks should be performed by the start()
method.HeapException
- if an exception occurred during creation of the heap object
or any of its dependencies.JsonValueException
- if the heaplet (or one of its dependencies) has a malformed
configuration.public void start() throws HeapException
Heaplet.create(Name, JsonValue, Heap)
after creating and
configuring the object and once the object's logger and storage have been
configured. Implementations should override this method if they need to
acquire resources, start threads, or log any initialization messages.HeapException
- if an exception occurred while starting the heap object or
any of its dependencies.protected Function<JsonValue,JsonValue,JsonValueException> evaluatedWithHeapProperties()
JsonValue
using the properties defined in the heap of this
Heaplet.JsonValue
using the properties defined in the heap of
this Heaplet.protected <T> Function<JsonValue,Expression<T>,JsonValueException> expression(Class<T> type)
Expression
from the string by the JsonValue
using the
bindings defined in the heap of this Heaplet as initial bindings.T
- The type of the expression's result.type
- The expected result type of the Expression
Expression
from the string by the JsonValue
using the
bindings defined in the heap of this Heaplet as initial bindings.Copyright 2011-2015 ForgeRock AS.