Class CustomPackage

java.lang.Object
overit.geocall.platform.Package
overit.geocall.platform.CustomPackage
All Implemented Interfaces:
Serializable

public class CustomPackage extends Package
This class defines a custom package, i.e. a package that extends or overwrites the defined functionality in a package belonging to a overlayer. Customizations allow you to redefine the components contained in a package of another layer by adapting them to the customer's needs. For example, you can change the graphical interface of a page defined in another layer, rather than overwriting the behavior of a BusinessTask or DAO.
It is possible to define a custom package by creating a CustomPackage extension by defining the position of the original package (those whose will be customized) and eventually the position of the customizing package. Remember to annotate the class with the @Package annotation.

 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/.
Or you can define a custom package programmatically by creating a new instance of CustomPackage and registering it by calling the Layer.addCustomization(CustomPackage) method.

 CustomPackage customPackage = new CustomPackage("overit/geocallapp/wfm/managing/", "overit/geocall/basic/managing/");
 layer.addCustomization(customPackage);
 
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
See Also:
  • Field Details

    • original

      protected final String original
    • owner

      protected Layer owner
  • Constructor Details

    • CustomPackage

      protected CustomPackage(String original)
      Create a new custom package by specifying the path of the original package to be customize. The path directories must be separated with the / character, the domain must start without the / character and must end with. This constructor can be called from class extensions, instead of CustomPackage(String, String), because it is easier to use since the package containing the customizations is automatically calculated according to the subclass package.
      Parameters:
      original - path that identifies the position of the original package, i.e. the package that will be customized. Null value is not allowed.
    • CustomPackage

      public CustomPackage(String custom, String original)
      Create a new custom package by specifying the current customizing path and the path of the original package to be customize. The paths directories must be separated with the / character, they must start without the / character and must end with.
      The following example shows the definition of a new custom package, positioned under overit.geocallapp.wfm.managing, that customize the overit.geocall.basic.managing package.
      
       CustomPackage customPackage = new CustomPackage("overit/geocallapp/wfm/managing/", "overit/geocall/basic/managing/");
       
      Parameters:
      custom - path that identifies the position of the custom package, i.e. the package that contains the customizations. Null value is not allowed.
      original - path that identifies the position of the original package, i.e. the package that will be customized. Null value is not allowed.
  • Method Details

    • getPosition

      public String getPosition()
      Overrides:
      getPosition in class Package
      Returns:
      the position of the custom package, i.e. the package that contains the customizations.
    • getOriginal

      public String getOriginal()
      Returns:
      the position of the original package, i.e. the package that will be customized.
    • getOwner

      public Layer getOwner()
      Returns:
      the layer that this package belongs to or null if the package has not yet been registered to any layer
    • setOwner

      protected void setOwner(Layer owner)
      Set the layer that this package belongs to.
      Parameters:
      owner - the owner layer
    • containsCustom

      public final boolean containsCustom(JavaResource resource)
      Checks if the resource, passed as a parameter, belongs to the custom package
      Parameters:
      resource - resource's instance. Null value is not allowed.
      Returns:
      true if the resource's package is contained within the current custom package, false otherwise.
    • containsOrigin

      public final boolean containsOrigin(JavaResource resource)
      Checks if the resource, passed as a parameter, belongs to the original package
      Parameters:
      resource - resource's instance. Null value is not allowed.
      Returns:
      true if the resource's package is contained within the original package, false otherwise.
    • toCustom

      public final JavaResource toCustom(JavaResource resource)
      Transforms a resource from the original package, passed as a parameter, into the equivalent of the custom package. A null value returns if the resource does not belong to the original package.
      Parameters:
      resource - the instance to transform. Null value is not allowed.
      Returns:
      the converted resource or null if it doesn't belongs to the original package
    • toOrigin

      public final JavaResource toOrigin(JavaResource resource)
      Transforms a resource from the custom package, passed as a parameter, into the equivalent of the original package. A null value returns if the resource does not belong to the custom package.
      Parameters:
      resource - the instance to transform. Null value is not allowed.
      Returns:
      the converted resource or null if it doesn't belongs to the custom package
    • composeUp

      protected final CustomPackage composeUp(CustomPackage other)
    • composeDown

      protected final CustomPackage composeDown(CustomPackage other)
    • invariant

      protected void invariant()
      Overrides:
      invariant in class Package
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Package
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Package