org.jtoolkit.essence.app
Interface Container

All Superinterfaces:
java.io.Closeable, Named, Named.Source<java.lang.Object>

public interface Container
extends Closeable, Named.Source<java.lang.Object>

This interface defines methods for Container. A Container manages components, their references, logical processes (which are single theraded) and any customer component builders.

Author:
Peter Lawrey

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jtoolkit.essence.utils.Named
Named.ContextSource<T>, Named.MapSource<T>, Named.Source<T>
 
Field Summary
static java.lang.String COMPONENT
          Adjective to describe a component.
static java.lang.String CONTAINER_NAME
          This property holds the container name for string substitution.
static java.lang.String DEFAULT_CONTAINER
          Default value for a component builders's container.
static java.lang.String DEFAULT_CONTAINER_NAME
          Default value for a component for the container's name.
static java.lang.String DEFAULT_EXECUTOR
          Default value for a component's executor from it logical process..
static java.lang.String DEFAULT_NAME
          Default value for a component's name.
static java.lang.String DEFAULT_PURPOSE
          Default value for a component's purpose.
static java.lang.String EXTERNAL
          The logical process for threads external to the container.
static java.lang.String PROPERTIES_FILES
          This property is examined on startup and these files are loaded into the Containers properties.
static java.lang.String SERVER_HOSTNAME
          The property which has the server's hostname.
static java.lang.String SERVER_PORT
          If set this port exposes access to the Container objects via NetObject.
 
Fields inherited from interface org.jtoolkit.essence.utils.Closeable
CLOSED
 
Fields inherited from interface org.jtoolkit.essence.utils.Named.Source
EMPTY_SOURCE
 
Method Summary
 int call(java.lang.String method, boolean inEachThread)
          Call the method on each component.
<T> T
getComponent(java.lang.String componentName, java.lang.Class<T> type)
          Get a component with a target type in mind.
 java.util.Set<java.lang.String> getNames()
           
 Named.Source<java.lang.String> getProperties()
           
 Named.Source<java.lang.String> getProperties(java.lang.String componentName)
           
 java.lang.String getUrl()
           
 java.lang.Object getValue(java.lang.String componentName)
           
 java.util.Set<java.lang.String> remainingConfig()
           
<T> T[]
removeConfigAs(java.lang.String configName, java.lang.Class<T> clazz)
          This removes and convert a table from the configuration.
 
Methods inherited from interface org.jtoolkit.essence.utils.Closeable
close, isClosed
 
Methods inherited from interface org.jtoolkit.essence.utils.Named
getName
 

Field Detail

SERVER_HOSTNAME

static final java.lang.String SERVER_HOSTNAME
The property which has the server's hostname.

See Also:
Constant Field Values

EXTERNAL

static final java.lang.String EXTERNAL
The logical process for threads external to the container.

See Also:
Constant Field Values

CONTAINER_NAME

static final java.lang.String CONTAINER_NAME
This property holds the container name for string substitution.

See Also:
Constant Field Values

PROPERTIES_FILES

static final java.lang.String PROPERTIES_FILES
This property is examined on startup and these files are loaded into the Containers properties. System properties are set first. Thes eproperties are then set if NOT already set. Lastly ContainerProperties are set if NOT set.

See Also:
Constant Field Values

SERVER_PORT

static final java.lang.String SERVER_PORT
If set this port exposes access to the Container objects via NetObject.

See Also:
Constant Field Values

DEFAULT_CONTAINER_NAME

static final java.lang.String DEFAULT_CONTAINER_NAME
Default value for a component for the container's name.

See Also:
Constant Field Values

DEFAULT_NAME

static final java.lang.String DEFAULT_NAME
Default value for a component's name.

See Also:
Constant Field Values

DEFAULT_PURPOSE

static final java.lang.String DEFAULT_PURPOSE
Default value for a component's purpose.

See Also:
Constant Field Values

DEFAULT_EXECUTOR

static final java.lang.String DEFAULT_EXECUTOR
Default value for a component's executor from it logical process..

See Also:
Constant Field Values

DEFAULT_CONTAINER

static final java.lang.String DEFAULT_CONTAINER
Default value for a component builders's container. Note: this is not available to components by design to stop components wiring themselves.

See Also:
Constant Field Values

COMPONENT

static final java.lang.String COMPONENT
Adjective to describe a component.

See Also:
Constant Field Values
Method Detail

call

int call(@NotNull
         java.lang.String method,
         boolean inEachThread)
Call the method on each component.

Parameters:
method - to call.
inEachThread - if true, the ScheduledExecutorService for the components thread is used, otherwise the method is called using the current thread.
Returns:
the number of components called.

getNames

@NotNull
java.util.Set<java.lang.String> getNames()
Specified by:
getNames in interface Named.Source<java.lang.Object>
Returns:
The name of each component.

getComponent

@Nullable
<T> T getComponent(@NotNull
                            java.lang.String componentName,
                            @NotNull
                            java.lang.Class<T> type)
Get a component with a target type in mind. If a component can present a number of different interfaces, different object could be returned.


getValue

@Nullable
java.lang.Object getValue(@NotNull
                                   java.lang.String componentName)
Specified by:
getValue in interface Named.Source<java.lang.Object>
Parameters:
componentName - of the object.
Returns:
the object in source or null.

getProperties

@NotNull
Named.Source<java.lang.String> getProperties()
Returns:
The global properties for this Container. This is taken from the System.getProperties(), System.getenv(), {container.name}-{hostname}.properties and {container.name}.properties

getProperties

@NotNull
Named.Source<java.lang.String> getProperties(@NotNull
                                                     java.lang.String componentName)
Returns:
The properties for a component.

remainingConfig

@NotNull
java.util.Set<java.lang.String> remainingConfig()
Returns:
The set of unused configurations sections.

removeConfigAs

@NotNull
<T> T[] removeConfigAs(@NotNull
                               java.lang.String configName,
                               @NotNull
                               java.lang.Class<T> clazz)
                   throws java.lang.InstantiationException
This removes and convert a table from the configuration. Note: this can only be called once meaningfully.

Parameters:
configName - to obtain.
clazz - to convert each record to.
Returns:
an array of the records or an empty array.
Throws:
java.lang.InstantiationException

getUrl

@NotNull
java.lang.String getUrl()
Returns:
The URL used to load the Container.


Copyright © Peter Lawrey. All Rights Reserved.