public abstract class AbstractLibrary extends 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(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. |
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(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. |
void |
require(Collection<Library.Required> libraries) |
String |
toString() |
protected AbstractLibrary()
protected AbstractLibrary(Class library, 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(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 Set getRequireds()
Library
getRequireds
in interface Library
public Class getLibrary()
getLibrary
in interface Library
Library
class this library is related topublic String getType()
Library
public int getPriority()
Library
getPriority
in interface Library
public final void require(Class library, 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(Class library)
public final void require(Collection<Library.Required> libraries)
protected final void registerAs(Class library, 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(Class library)
library
- the library class we relate toprotected final void registerAsImplementationOf(Class library)
library
- the library class we relate toprotected final void registerAsImplementationOf(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(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 isRequired(Library lib)
Library
isRequired
in interface Library
lib
- the library to check if it is requiredpublic boolean isRequired(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