Package overit.geocall.platform
Class CustomLayer
java.lang.Object
overit.geocall.platform.CustomLayer
- All Implemented Interfaces:
Serializable
This class allows easy access to the application layers, i.e. the software layer that will contain the various
application components (Task, DAO, graphics components, ...) and any customizations that will help to create the
solution for the customer.
It is possible to define a layer by creating a
Or you can define a layer programmatically by creating a new instance of
Registering a layer and correctly defining its name and domain is essential for correct resolution of the components. Failure to register may result in several problems; a reference to a component defined in an unregistered layer will not take into account any customizations, or worse, may raise an exception if the referenced component is not contained in any of the other layers.
It is possible to define a layer by creating a
Layer extension by assigning it a name and, eventually, a
domain in case the layer root does not match the package in which the class is located.
Or you can define a layer programmatically by creating a new instance of
Layer and registering it by
calling the addLayer(Layer) method.
Layer layer = new Layer("name", "layer/domain/path");
CustomLayer.addLayer(layer);
Registering a layer and correctly defining its name and domain is essential for correct resolution of the components. Failure to register may result in several problems; a reference to a component defined in an unregistered layer will not take into account any customizations, or worse, may raise an exception if the referenced component is not contained in any of the other layers.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name under which the base layer was registered and under which it can be retrievedprotected final CustomTreethis instance is used to search for resources within the various custom layersprotected final Layerthis instance contains the layer information as well as allowing the actual registration ofScriptPackage,LangPackageandThemePackageprotected final Lazy<LinkedHashSet<CustomLayer>> this object allows you to retrieve, on demand, the list of dependent layersprotected final Lazy<Permissions> -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAllows you to record a new layer among those registered.protected static voidstatic Set<JavaResource> collectResources(JavaResource resource) Method that collects all the customizations of a givenJavaResourceby searching within all the registeredCustomLayer.booleangetAlias()Returns the layer's aliasMethod used to retrieve the grants defined in the current layer and all the 'over' layers.Method used to retrieve the permissions defined in the current layer and all the 'over' layers.static CustomLayergetByClass(Class<Layer> cls) Retrieves the instance of the layer from its class.static CustomLayerRetrieves the instance of the layer from its name.Method used to retrieve the packages containing the resources that will customize the ones refered by the original positiongetLanding(String name, String params) Method used to retrieve the package containing the translation files that belong to this layerstatic IntegergetLayerIndex(CustomLayer customLayer) Returns the index of the current layer from a static table of layers in which the lower layers represent the layers imported as dependency.static List<CustomLayer> Class<?> getLibraryComponent(String name) Method used to retrieve the class of a library component (e.g. a graphics component)getName()Returns the layer's namestatic CustomLayerMethod used to obtain dependent layers The order depends on the dependencies between the registered layers; the customized resources will be the first ones.static CustomLayergetOwnerLayer(Class clz) Deducts the layer to which the class, passed as a parameter, belongsstatic CustomLayerDeducts the layer to which the resource passed as a parameter, belongsMethod used to retrieve the packages containing the SQL script that belong to this layerstatic List<CustomLayer> Method used to retrieve the packages containing the SQL script that belong to this layer, sorted by dependencies between packagesprotected JavaResourcegetSubstitute(JavaResource resource) Search if there is a direct customization (by annotation) of the resource passed in input.Method used to retrieve the package containing the themes that belong to this layergetURL(JavaResource resource) This method looks for the resource passed in input by searching through the various custom layers, and returns the URL of the real resource, or null in case the resource does not exist in any of the registered layers.inthashCode()booleanbooleanisOwner(JavaResource pos) Checks if the class, passed to input, belongs to the current layer or notloadClass(JavaResource resource) This method looks for the resource passed in input by searching through the various custom layers, and returns the reference to its class, or null in case the resource does not exist in any of the registered layers.static voidprotected voidonCustom(JavaResource resource, BiConsumer<JavaResource, CustomPackage> register) search if there is a customization of the resource passed in input.toString()
-
Field Details
-
BASIC_LAYER_NAME
The name under which the base layer was registered and under which it can be retrieved- See Also:
-
layer
this instance contains the layer information as well as allowing the actual registration ofScriptPackage,LangPackageandThemePackage -
customTree
this instance is used to search for resources within the various custom layers -
overLayers
this object allows you to retrieve, on demand, the list of dependent layers -
permissions
-
grants
-
-
Method Details
-
getByName
Retrieves the instance of the layer from its name.- Parameters:
name- name of the layer you want to get the instance of- Returns:
- the instance of the layer or null in case there is no layer associated with this name
-
getByClass
Retrieves the instance of the layer from its class.- Parameters:
cls- class of the layer you want to get the instance of- Returns:
- the instance of the layer or null in case there is no layer associated with this class
- Throws:
IllegalArgumentException- in case there are multiple layers registered with this class
-
getOriginal
- Returns:
- the basic application layer
-
addLayer
Allows you to record a new layer among those registered.- Parameters:
layer- instance of the layer to be registered. Null value will throws a precondition exception.- Throws:
IllegalArgumentException- in case another layer with the same name has already been registered
-
clearLayers
protected static void clearLayers() -
getLayers
- Returns:
- the list of the registered layer
-
getSortedLayers
- Returns:
- the list of registered layers sorted by dependencies between layers. First the over layers, i.e. those on which other layers depend.
-
getLayerIndex
Returns the index of the current layer from a static table of layers in which the lower layers represent the layers imported as dependency.- Parameters:
customLayer- TheCustomLayer- Returns:
- the index of the current layer from a static table of layers in which the lower layers represent the layers imported as dependency.
-
getOwnerLayer
Deducts the layer to which the resource passed as a parameter, belongs- Parameters:
pos- the resource- Returns:
- the instance of the layer to which the component, associated with the class passed to input, belongs or null in case there is no layer associated with that class
-
getOwnerLayer
Deducts the layer to which the class, passed as a parameter, belongs- Parameters:
clz- the class- Returns:
- the instance of the layer to which the component, associated with the class passed to input, belongs or null in case there is no layer associated with that class
-
collectResources
Method that collects all the customizations of a givenJavaResourceby searching within all the registeredCustomLayer. The order of the resources contained into the result set depends by the dependencies between the registered layers; the customized resources will be the first ones.- Parameters:
resource- the resource to collect- Returns:
- the set of the collected resources
-
getName
Returns the layer's name- Returns:
- the layer's name
-
getAlias
Returns the layer's alias- Returns:
- the layer's alias or null if not defined
-
getLibraryComponent
Method used to retrieve the class of a library component (e.g. a graphics component)- Parameters:
name- the name of the component- Returns:
- the class of the registered component whose name match with the name passed in or null if the name is not associated with any component
-
getOverLayers
Method used to obtain dependent layers The order depends on the dependencies between the registered layers; the customized resources will be the first ones.- Returns:
- the dependent layer list. The empty list means that this layer has no dependency from any other layer.
-
getScriptPackages
Method used to retrieve the packages containing the SQL script that belong to this layer- Returns:
- the script packages of this layer. The empty list means that this layer has no sql script packages.
-
getSortedScriptPackages
Method used to retrieve the packages containing the SQL script that belong to this layer, sorted by dependencies between packages- Returns:
- the script packages of this layer. The empty list means that this layer has no sql script packages.
-
getCustomPackages
Method used to retrieve the packages containing the resources that will customize the ones refered by the original position- Returns:
- the custom packages of this layer. The empty list means that this layer has no custom packages.
-
getThemePackage
Method used to retrieve the package containing the themes that belong to this layer- Returns:
- the theme package of this layer or null if this layer has no themes.
-
getLangPackage
Method used to retrieve the package containing the translation files that belong to this layer- Returns:
- the language package of this layer or null if this layer has no translation.
-
getAllPermissions
Method used to retrieve the permissions defined in the current layer and all the 'over' layers.- Returns:
- the permissions defined in this layer and all the 'over' layers. The union is computed matching the permission name and with priority for the customizing layer.
-
getAllGrants
Method used to retrieve the grants defined in the current layer and all the 'over' layers.- Returns:
- the grants defined in this layer and all the 'over' layers. All the grants must be namespaced so that there will be non conflicts.
-
getPosition
-
isOriginal
public boolean isOriginal()- Returns:
trueif the layer is the basic framework layer,falseotherwise
-
isOwner
Checks if the class, passed to input, belongs to the current layer or not- Parameters:
pos- the class object- Returns:
trueif the class belongs to the current layer,falseotherwise.
-
loadClass
This method looks for the resource passed in input by searching through the various custom layers, and returns the reference to its class, or null in case the resource does not exist in any of the registered layers.- Parameters:
resource- the resource to find- Returns:
- the class of the real resource or null if the resource does not exist in any of the registered layers.
-
getURL
This method looks for the resource passed in input by searching through the various custom layers, and returns the URL of the real resource, or null in case the resource does not exist in any of the registered layers.- Parameters:
resource- the resource to find- Returns:
- the URL of the real resource or null if the resource does not exist in any of the registered layers.
-
getSubstitute
Search if there is a direct customization (by annotation) of the resource passed in input. The search is done only within the current layer, not in the overlayers.- Parameters:
resource- the resource to find- Returns:
- the customized resource or null it it doesn't exists whitin the current layer
-
onCustom
search if there is a customization of the resource passed in input. the search is done only within the custom packages of the current layer, not in the over layers. the found resources are hypothetical, no test is done on the actual existence of the resource in the classpath- Parameters:
resource- the resource to findregister- object used to record the custom resources found
-
hashCode
public int hashCode() -
equals
-
toString
-
main
-
getLanding
-