public abstract class AbstractLibrary extends java.lang.Object implements Library
Modifier and Type | Class and Description |
---|---|
static class |
AbstractLibrary.DefaultRequired
Association between a library class and its type.
|
Library.Required, Library.TYPE
Modifier | Constructor and Description |
---|---|
protected |
AbstractLibrary()
Empty constructor.
|
protected |
AbstractLibrary(java.lang.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(java.lang.Class library,
java.lang.String type)
Deprecated.
to be removed in the 4.x version. Use the
AbstractLibrary() empty constructor and override the
doRegistration() method instead. |
Modifier and Type | Method and Description |
---|---|
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(java.lang.Object obj) |
java.lang.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.
|
java.util.Set |
getRequireds()
Returns a Set of required libraries and their types.
|
java.lang.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(java.lang.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(java.lang.Class library,
java.lang.String type)
Registers the library with type of library it is: API or
implementation of a library.
|
protected void |
registerAsAPI(java.lang.Class library)
Registers the library as an API one.
|
protected void |
registerAsImplementationOf(java.lang.Class library)
Registers the library as an implementation of an API library, with the
default priority.
|
protected void |
registerAsImplementationOf(java.lang.Class library,
int priority)
Registers the library as an implementation of an API library.
|
protected void |
registerAsServiceOf(java.lang.Class library)
Registers the library as a service or provider of an API library.
|
void |
require(java.lang.Class library)
Adds a required library, so it is initialized before the current one.
|
void |
require(java.lang.Class library,
java.lang.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. |
void |
require(java.util.Collection<Library.Required> libraries) |
java.lang.String |
toString() |
protected AbstractLibrary()
protected AbstractLibrary(java.lang.Class library, java.lang.String type)
AbstractLibrary()
empty constructor and override the
doRegistration()
method instead.When it is an API library, the class will be itself.
library
- the library class we relate totype
- the library type. See TYPE
.AbstractLibrary()
protected AbstractLibrary(java.lang.Class library, int priority)
AbstractLibrary()
empty constructor and override the
doRegistration()
method instead.library
- the library class we relate topriority
- the priority of the library against other implementations
of the same libraryAbstractLibrary()
public java.util.Set getRequireds()
Library
getRequireds
in interface Library
public java.lang.Class getLibrary()
getLibrary
in interface Library
Library
class this library is related topublic java.lang.String getType()
Library
public int getPriority()
Library
getPriority
in interface Library
public final void require(java.lang.Class library, java.lang.String type)
require(Class)
method instead, as you may
have problems if the type specified is not correct. Moreover,
this is not needed.library
- the required librarytype
- the type of the required librarypublic final void require(java.lang.Class library)
public final void require(java.util.Collection<Library.Required> libraries)
protected final void registerAs(java.lang.Class library, java.lang.String type)
When it is an API library, the class will be itself.
library
- the library class we relate totype
- the library type. See TYPE
.protected final void registerAsAPI(java.lang.Class library)
library
- the library class we relate toprotected final void registerAsImplementationOf(java.lang.Class library)
library
- the library class we relate toprotected final void registerAsImplementationOf(java.lang.Class library, int priority)
library
- the library class we relate topriority
- the priority of the library against other implementations
of the same libraryprotected final void registerAsServiceOf(java.lang.Class library)
library
- the library class we relate topublic final void initialize() throws LibraryException
Library
initialize
in interface Library
LibraryException
- if there is an error while performing the
initialization of the librarypublic final void postInitialize() throws LibraryException
Library
postInitialize
in interface Library
LibraryException
- if there is an error while loading an
implementation of the librarypublic void doRegistration()
doRegistration
in interface Library
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isRequired(Library lib)
Library
isRequired
in interface Library
lib
- the library to check if it is requiredpublic boolean isRequired(java.lang.Class libClass)
Library
isRequired
in interface Library
libClass
- the library Class to check if it is requiredprotected abstract void doInitialize() throws LibraryException
LibraryException
- if there is an error while performing the initialization of
the libraryprotected abstract void doPostInitialize() throws LibraryException
LibraryException
- if there is an error while loading an implementation of the
library