Class Layer

java.lang.Object
overit.geocall.platform.Package
overit.geocall.platform.Layer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LoggerLayer, UXLayer

public class Layer extends Package
This class defines an application layer, 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 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. Remember to annotate the class with the @Package annotation.
Or you can define a layer programmatically by creating a new instance of Layer and registering it by calling the CustomLayer.addLayer(Layer) method.

 Layer layer = new Layer("name", "layer/domain/path");
 CustomLayer.addLayer(layer);
 
Each layer already defines a level in which you can define your business objects such as: BusinessTask, DAO, interface pages; however you can extend or overwrite the functionality defined in the dependent layers, defining customizations. Customizations allow you to redefine the components contained in a package of another layer by adapting them to the customer's needs.

 package overit.geocallapp.wfm.managing;

 {@literal @}Package
 public class ManagingPackage extends CustomPackage {
   public ManagingPackage() {
       super("overit/geocall/basic/managing/");
   }
 }
 
The above example shows how to make the components contained in the package overit.geocallapp.wfm.managing customize the same name components declared in the package overit/geocall/basic/managing/.
In the same way it's possible to define packages containing the language files

 package overit.geocallapp.wfm.lang;

 {@literal @}Package
 public class WFMLangPackage extends LangPackage {
   public WFMLangPackage() {}
 }
 
the themes

 package overit.geocallapp.wfm.theme;

 {@literal @}Package
 public class WFMThemePackage extends ThemePackage {
   public WFMThemePackage() {}
 }
 
or the SQL scripts needed to configure the database.

 package overit.geocallapp.wfm.install.script;

 {@literal @}Package
 public class WFMScriptPackage extends ScriptPackage {
   public WFMScriptPackage() {
       super("");
   }
 }
 
The association between CustomPackage and Layer occurs automatically as long as the class that defines its implementation:
  • is positioned within the domain defined by the Layer
  • contains the annotation @Package

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 Details

  • Constructor Details

    • Layer

      protected Layer(String name)
      Create a new layer by specifying its name. This constructor can be called from layer extensions, instead of Layer(String, String), because it is easier to use since the domain is automatically calculated according to the subclass package.
      Parameters:
      name - string that uniquely identifies the layer. Null value is not allowed.
    • Layer

      public Layer(String name, String domain)
      Create a new layer by specifying its name and domain. The domain directories must be separated with the / character, the domain must start without the / character and must end with.
      The following example shows the definition of a new layer, called wfm, whose domain is the overit.geocallapp.wfm package
      
       Layer layer = new Layer("wfm", "overit/geocallapp/wfm/");
       
      Parameters:
      name - string that uniquely identifies the layer. Null value is not allowed.
      domain - path that identifies the position of the layer, i.e. the root from which to solve any components, customizations. Null value is not allowed.
  • Method Details

    • addOver

      @SafeVarargs public final void addOver(Class<? extends Layer>... classes)
      Adds the dependency of the current layer to the layers identified by the classes passed as a parameter. Any class for which there is no correspondence with any other registered layer will not be taken into account.
      Parameters:
      classes - classes of the layers towards which to define a dependency
    • addOver

      public final void addOver(String... names)
      Adds the dependency of the current layer to the layers identified by the names passed as a parameter. Any names for which there is no correspondence with any other registered layer will not be taken into account.
      Parameters:
      names - names of the layers towards which to define a dependency
    • addCustomization

      public final void addCustomization(CustomPackage customPackage)
      Adds a package that customizes the components defined in another package belonging to some overlay.
      Parameters:
      customPackage - the instance that points to the package containing the component's customizations. Null value are not allowed.
      Throws:
      InvalidParameterException - if the package's position refers to a location positioned outside the current layer
    • addCustomization

      public final void addCustomization(String originalPath, Class<?> custom)
      Adds a class as customization of another resource identified by the originalPath path.
      Parameters:
      originalPath - path of the original resource you want to customize. directories must be separated with the / character, the string must not start with / and must end with /. Null value are not allowed.
      custom - the class that contains the customization. Null value are not allowed.
      Throws:
      InvalidParameterException - if the class refers to a resource positioned outside the current layer
    • addComponent

      public final void addComponent(String name, Class<?> component)
      Register a new library component (e.g. a graphics component) within the current layer. If there's another component with the same name, it will be overwritten.
      Parameters:
      name - the component's name
      component - the component's class
      Throws:
      InvalidParameterException - if the class refers to a location positioned outside the current layer
    • addScriptPackage

      public final void addScriptPackage(ScriptPackage scriptPackage)
      Adds a package containing SQL scripts to the current layer.
      Parameters:
      scriptPackage - the instance that points to the package containing the sql script files. Null value * are not allowed.
      Throws:
      InvalidParameterException - if the package's position refers to a location positioned outside the current layer
      IllegalArgumentException - in case there are multiple script packages registered with this class
    • setThemePackage

      public final void setThemePackage(ThemePackage themePackage)
      Sets the package that contains the css files used for the thematization. Each layer has only one package containing the themes; it is not possible, therefore, to define files with the partial css to be added up to those of another layer.
      Parameters:
      themePackage - the instance that points to the package containing the themes files. Null value * are not allowed.
      Throws:
      InvalidParameterException - if the package's position refers to a location positioned outside the current layer
    • setLangPackage

      public final void setLangPackage(LangPackage langPackage)
      Sets the package that contains the language files used for the translations. Each layer has only one package containing the translations; it is not possible, therefore, to define files with the partial translations to be added up to those of another layer.
      Parameters:
      langPackage - the instance that points to the package containing the translation files. Null value * are not allowed.
      Throws:
      InvalidParameterException - if the package's position refers to a location positioned outside the current layer
    • addPermissions

      public final void addPermissions(Permissions ff)
      Adds a collection of functions. The functions added to a layer are intendend to have different names otherwise the conflict resolution in not defined.
      Parameters:
      ff - the instance of functions to be added. Null value is not allowed.
    • addGrants

      public final void addGrants(Grants gg)
      Adds a collection of functions. The functions added to a layer are intendend to have different names otherwise the conflict resolution in not defined.
      Parameters:
      gg - the instance of grants to be added. Null value is not allowed.
    • addLanding

      public final void addLanding(Landing l)
      Adds a Landing page. The landing added to a layer are intended to have different names otherwise the conflict resolution in not defined.
      Parameters:
      l - the instance of landing to be added. Null value is not allowed.
    • addLandingTree

      public final void addLandingTree(LandingTree lt)
      Adds a LandingTree instance from which will extract the landing pages related to an XML resource.
      Parameters:
      lt - the instance of LandingTree to be added. Null value is not allowed.
    • getPermissions

      public Permissions getPermissions()
      retrieves the Permission collection of functions possibly used inside the layer.
      Returns:
      the layer's functions.
    • getGrants

      public Grants getGrants()
      retrieves the functions granted by this layer.
      Returns:
      the layer's grants.
    • getOvers

      public List<Class<? extends Layer>> getOvers()
      Method used to retrieve the classes of the layer from which this depends.
      Returns:
      the over layer's classes. The empty list means that this layer doesn't depends from any other layer.
    • getCustomPackages

      public Set<CustomPackage> getCustomPackages()
      Method used to retrieve the packages that customize an over layer's package.
      Returns:
      the custom packages of this layer. The empty list means that this layer has no customizations.
    • getCustomClasses

      public Map<String,Class<?>> getCustomClasses()
      Method used to retrieve the classes that customize an over layer's resource.
      Returns:
      the custom classes defined by this layer. The empty map means that this layer has no class customizations.
    • getComponents

      public Map<String,Class<?>> getComponents()
      Method used to retrieve the classes of the library components registered into this layer (e.g. a graphics component)
      Returns:
      the map containing the names and the classes of the components registered into this layer. The empty list means that this layer has library components.
    • getScriptPackages

      public Set<ScriptPackage> 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.
    • getScriptPackage

      public ScriptPackage getScriptPackage(String name)
      Retrieves the instance of the script package from its name.
      Parameters:
      name - name of the script package you want to get the instance of
      Returns:
      the instance of the script package or null in case there is no package associated with this name
    • getScriptPackage

      public ScriptPackage getScriptPackage(Class<? extends ScriptPackage> cls)
      Retrieves the instance of the script package from its class.
      Parameters:
      cls - class of the script package you want to get the instance of
      Returns:
      the instance of the script package or null in case there is no package associated with this class
      Throws:
      IllegalArgumentException - in case there are multiple script package registered with this class
    • getThemePackage

      public ThemePackage 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

      public LangPackage 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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Package
    • equals

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