org.gvsig.tools.library
Class AbstractLibrary

java.lang.Object
  extended by org.gvsig.tools.library.AbstractLibrary
All Implemented Interfaces:
Library
Direct Known Subclasses:
ToolsLibrary, XMLPersistenceLibrary

public abstract class AbstractLibrary
extends Object
implements Library

Base Library implementation, checking that a Library is initialized and postInitialized only once. Also adds initialization logging.

Author:
Cèsar Ordiñana, jjdelcerro

Nested Class Summary
static class AbstractLibrary.Required
          Association between a library class and its type.
 
Nested classes/interfaces inherited from interface org.gvsig.tools.library.Library
Library.TYPE
 
Constructor Summary
protected AbstractLibrary()
          Empty constructor.
protected AbstractLibrary(Class library, int priority)
          Deprecated. to be removed in the 4.x version. Use the AbstractLibrary() empty constructor and override the doRegistration() method instead.
protected AbstractLibrary(Class library, String type)
          Deprecated. to be removed in the 4.x version. Use the AbstractLibrary() empty constructor and override the doRegistration() method instead.
 
Method Summary
protected abstract  void doInitialize()
          Performs all the initializations of the library, only related to himself: register implementation classes through the Locator, start services, etc.
protected abstract  void doPostInitialize()
          Performs all the initializations or validations related to the library dependencies, as getting references to objects through other libraries Locators.
 void doRegistration()
           
 boolean equals(Object obj)
           
 Class getLibrary()
          Returns the name of the current Library
 int getPriority()
          Returns a priority number to range this implementation in case multiple ones are within the libraries initialization.
 Set getRequireds()
          Returns a Set of required libraries and their types.
 String getType()
          Returns the type of the Library.
 int hashCode()
           
 void initialize()
          Performs all the initializations of the library, only related to himself: register implementation classes through the Locator, start services, etc.
 boolean isRequired(Class libClass)
          Returns if a given library class is required.
 boolean isRequired(Library lib)
          Returns if a given library is required.
 void postInitialize()
          Performs all the initializations or validations related to the library dependencies, as getting references to objects through other libraries Locators.
protected  void registerAs(Class library, String type)
          Registers the library with type of library it is: API or implementation of a library.
protected  void registerAsAPI(Class library)
          Registers the library as an API one.
protected  void registerAsImplementationOf(Class library)
          Registers the library as an implementation of an API library, with the default priority.
protected  void registerAsImplementationOf(Class library, int priority)
          Registers the library as an implementation of an API library.
protected  void registerAsServiceOf(Class library)
          Registers the library as a service or provider of an API library.
 void require(Class library)
          Adds a required library, so it is initialized before the current one.
 void require(Class library, String type)
          Deprecated. use the require(Class) method instead, as you may have problems if the type specified is not correct. Moreover, this is not needed.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLibrary

protected AbstractLibrary()
Empty constructor.


AbstractLibrary

protected AbstractLibrary(Class library,
                          String type)
Deprecated. to be removed in the 4.x version. Use the AbstractLibrary() empty constructor and override the doRegistration() method instead.

Creates a new library registering with type of library it is: API or implementation of a library.

When it is an API library, the class will be itself.

Parameters:
library - the library class we relate to
type - the library type. See TYPE.
See Also:
AbstractLibrary()

AbstractLibrary

protected AbstractLibrary(Class library,
                          int priority)
Deprecated. to be removed in the 4.x version. Use the AbstractLibrary() empty constructor and override the doRegistration() method instead.

Creates a new library registering it as an implementation. A priority is also provided just in case there is another implementation available, so the one with the highest priority will be the one used.

Parameters:
library - the library class we relate to
priority - the priority of the library against other implementations of the same library
See Also:
AbstractLibrary()
Method Detail

getRequireds

public Set getRequireds()
Description copied from interface: Library
Returns a Set of required libraries and their types.

Specified by:
getRequireds in interface Library
Returns:
a Set of required libraries

getLibrary

public Class getLibrary()
Returns the name of the current Library

Specified by:
getLibrary in interface Library
Returns:
the Library class this library is related to

getType

public String getType()
Description copied from interface: Library
Returns the type of the Library.

Specified by:
getType in interface Library
Returns:
See Also:
TYPE.

getPriority

public int getPriority()
Description copied from interface: Library
Returns a priority number to range this implementation in case multiple ones are within the libraries initialization.

Specified by:
getPriority in interface Library
Returns:
a priority number, 0 by default.

require

public final void require(Class library,
                          String type)
Deprecated. use the require(Class) method instead, as you may have problems if the type specified is not correct. Moreover, this is not needed.

Adds a required library, so it is initialized before the current one.

Parameters:
library - the required library
type - the type of the required library

require

public final void require(Class library)
Adds a required library, so it is initialized before the current one.

Parameters:
library - the required library

registerAs

protected final void registerAs(Class library,
                                String type)
Registers the library with type of library it is: API or implementation of a library.

When it is an API library, the class will be itself.

Parameters:
library - the library class we relate to
type - the library type. See TYPE.

registerAsAPI

protected final void registerAsAPI(Class library)
Registers the library as an API one.

Parameters:
library - the library class we relate to

registerAsImplementationOf

protected final void registerAsImplementationOf(Class library)
Registers the library as an implementation of an API library, with the default priority.

Parameters:
library - the library class we relate to

registerAsImplementationOf

protected final void registerAsImplementationOf(Class library,
                                                int priority)
Registers the library as an implementation of an API library. A priority is also provided just in case there is another implementation available, so the one with the highest priority will be the one used.

Parameters:
library - the library class we relate to
priority - the priority of the library against other implementations of the same library

registerAsServiceOf

protected final void registerAsServiceOf(Class library)
Registers the library as a service or provider of an API library.

Parameters:
library - the library class we relate to

initialize

public final void initialize()
                      throws LibraryException
Description copied from interface: Library
Performs all the initializations of the library, only related to himself: register implementation classes through the Locator, start services, etc.

Specified by:
initialize in interface Library
Throws:
LibraryException - if there is an error while performing the initialization of the library

postInitialize

public final void postInitialize()
                          throws LibraryException
Description copied from interface: Library
Performs all the initializations or validations related to the library dependencies, as getting references to objects through other libraries Locators.

Specified by:
postInitialize in interface Library
Throws:
LibraryException - if there is an error while loading an implementation of the library

doRegistration

public void doRegistration()
Specified by:
doRegistration in interface Library

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

isRequired

public boolean isRequired(Library lib)
Description copied from interface: Library
Returns if a given library is required.

Specified by:
isRequired in interface Library
Parameters:
lib - the library to check if it is required
Returns:
if is required

isRequired

public boolean isRequired(Class libClass)
Description copied from interface: Library
Returns if a given library class is required.

Specified by:
isRequired in interface Library
Parameters:
libClass - the library Class to check if it is required
Returns:
if is required

doInitialize

protected abstract void doInitialize()
                              throws LibraryException
Performs all the initializations of the library, only related to himself: register implementation classes through the Locator, start services, etc.

Throws:
LibraryException - if there is an error while performing the initialization of the library

doPostInitialize

protected abstract void doPostInitialize()
                                  throws LibraryException
Performs all the initializations or validations related to the library dependencies, as getting references to objects through other libraries Locators.

Throws:
LibraryException - if there is an error while loading an implementation of the library


Copyright © 2004-2011 gvSIG. All Rights Reserved.