org.jdtaus.core.container
Interface Container


public interface Container

Object container.

Version:
$Id: Container.java 8044 2009-07-02 01:29:05Z schulte2005 $
Author:
Christian Schulte
See Also:
ContainerFactory

Method Summary
 Object getDependency(Object object, String dependencyName)
          Gets an instance of a dependency of an object.
 String getMessage(Object object, String messageName, Locale locale, Object arguments)
          Gets an instance of a message of an object for a given locale.
 Object getObject(Class specification)
          Gets an instance of an implementation of a specification.
 Object getObject(Class specification, String implementationName)
          Gets an instance of an implementation of a specification.
 Object getProperty(Object object, String propertyName)
          Gets an instance of a property of an object.
 

Method Detail

getDependency

Object getDependency(Object object,
                     String dependencyName)
Gets an instance of a dependency of an object.

The object to return is resolved based on the multiplicity of the specification defined for the dependency. For a multiplicity equal to Specification.MULTIPLICITY_ONE, the returned object will be an instance of the class of that specification. For a multiplicity equal to Specification.MULTIPLICITY_MANY, the returned object will be a one-dimensional array of instances of the class of that specification.

When creating objects, use of the classloader associated with the class of the given object, as returned by method Class.getClassLoader(), is recommended. Only if that method returns null, indicating the class has been loaded by the bootstrap classloader, use of the bootstrap classloader is recommended.

Parameters:
object - The object to return a dependency instance of.
dependencyName - The logical name of the dependency to return an instance of.
Returns:
An instance of the dependency named dependencyName of object.
Throws:
NullPointerException - if object or dependencyName is null.
MissingImplementationException - if no implementation is defined for object.
MissingDependencyException - if no dependency named dependencyName is defined for object.
MultiplicityConstraintException - if the specification of the dependency has a multiplicity of MULTIPLICITY_ONE without any implementation being available.
InstantiationException - if creating an instance of the dependency fails.
ContainerError - for unrecoverable container errors.
ContextError - for unrecoverable context errors.
ModelError - for unrecoverable model errors.

getMessage

String getMessage(Object object,
                  String messageName,
                  Locale locale,
                  Object arguments)
Gets an instance of a message of an object for a given locale.

When creating objects, use of the classloader associated with the class of the given object, as returned by method Class.getClassLoader(), is recommended. Only if that method returns null, indicating the class has been loaded by the bootstrap classloader, use of the bootstrap classloader is recommended.

Parameters:
object - The object to return a message instance of.
messageName - The logical name of the message to return an instance of.
locale - The locale of the message instance to return.
arguments - Arguments to format the message instance with or null.
Returns:
An instance of the message named messageName of object formatted with arguments for locale.
Throws:
NullPointerException - if object, locale or messageName is null.
MissingImplementationException - if no implementation is defined for object.
MissingMessageException - if no message named messageName is defined for object.
ContainerError - for unrecoverable container errors.
ContextError - for unrecoverable context errors.
ModelError - for unrecoverable model errors.

getObject

Object getObject(Class specification)
Gets an instance of an implementation of a specification.

The object to return is resolved based on the multiplicity of the specification defined for the given class. For a multiplicity equal to Specification.MULTIPLICITY_ONE, the returned object will be an instance of the given class. For a multiplicity equal to Specification.MULTIPLICITY_MANY, the returned object will be a one-dimensional array of instances of the given class.

When creating objects, use of the classloader associated with the given class, as returned by method Class.getClassLoader(), is recommended. Only if that method returns null, indicating the class has been loaded by the bootstrap classloader, use of the bootstrap classloader is recommended.

Parameters:
specification - The class of the specification to return an implementation instance of.
Returns:
An instance of an implementation as specified by the specification defined for class specification.
Throws:
NullPointerException - if specification is null.
MissingSpecificationException - if no specification is defined for specification.
MultiplicityConstraintException - if the multiplicity of the specification defined for specification equals MULTIPLICITY_ONE and the model holds either no or more than one implementation.
InstantiationException - if creating an implementation instance fails.
ContainerError - for unrecoverable container errors.
ContextError - for unrecoverable context errors.
ModelError - for unrecoverable model errors.

getObject

Object getObject(Class specification,
                 String implementationName)
Gets an instance of an implementation of a specification.

When creating objects, use of the classloader associated with the given class, as returned by method Class.getClassLoader(), is recommended. Only if that method returns null, indicating the class has been loaded by the bootstrap classloader, use of the bootstrap classloader is recommended.

Parameters:
specification - The class of the specification to return an implementation instance of.
implementationName - The logical name of the implementation to return an instance of.
Returns:
An instance of the implementation named implementationName as specified by the specification defined for class specification.
Throws:
NullPointerException - if specification or implementationName is null.
MissingSpecificationException - if no specification is defined for specification.
MissingImplementationException - if no implementation named implementationName is defined for the specification for specification.
InstantiationException - if creating an implementation instance fails.
ContainerError - for unrecoverable container errors.
ContextError - for unrecoverable context errors.
ModelError - for unrecoverable model errors.

getProperty

Object getProperty(Object object,
                   String propertyName)
Gets an instance of a property of an object.

When creating objects, use of the classloader associated with the class of the given object, as returned by method Class.getClassLoader(), is recommended. Only if that method returns null, indicating the class has been loaded by the bootstrap classloader, use of the bootstrap classloader is recommended.

Parameters:
object - The object to return a property instance of.
propertyName - The logical name of the property to return an instance of.
Returns:
An instance of the property named propertyName of object.
Throws:
NullPointerException - if object or propertyName is null.
MissingImplementationException - if no implementation is defined for object.
MissingPropertyException - if no property named propertyName is defined for object.
ContainerError - for unrecoverable container errors.
ContextError - for unrecoverable context errors.
ModelError - for unrecoverable model errors.


Copyright © 2005-2009 jDTAUS. All Rights Reserved.