Interface Element

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
GuiceSdkElement, SharedElement

public interface Element extends AutoCloseable
Represents an instance of an SDK Element, similar to a java Element but with more flexibility at the expense of the rigid encapsulation rules. An Element has the following properties:
  • A unique name, which can be inherited from the package name.
  • A set of exposed or provided services, which may or may not explicitly be defined in the Element itself
  • Its own ClassLoader which isolates it from the rest of the classpath (with some exceptions)
  • A set of properties, defined by Attributes
  • A ServiceLocator which exposes its internally managed services and manages their lifecycle
It is not intended to be a direct replacement for dependency injection or inversion of control, however it has some features. Internally, an Element may be implemented using those. In fact, the default implementation uses Guice to manage the lifecycle. However, those details are kept completely abstract from the author of the particular Element as it is possible to use any library inside of the Element itself. Supported features of Elements:
  • Unlike Java Modules, they may span multiple Jar files or sources so long as there is a single ClassLoader which aggregates all code
  • Parent-child relationships, where children may inherit from the parent and parents may request resources from children.
  • Weak "honor system" encapsulation. There are no restrictions on reflection, so no need to worry about IoC containers needing special consideration.
  • Isolation of dependencies of the core Elements product. You can use whatever third party libraries you wish and it will not break the system.
  • Greater flexibility in structure. Existing applications do not need to reorganize as Modules if they weren't build that way originally.
  • Method Details Link icon

    • getElementRecord Link icon

      ElementRecord getElementRecord()
      Gets the ElementDefinitionRecord which provides
      Returns:
      the name of the element.
    • getServiceLocator Link icon

      ServiceLocator getServiceLocator()
      Gets the ServiceLocator associated with this element.
      Returns:
      the ServiceLocator
    • getElementRegistry Link icon

      ElementRegistry getElementRegistry()
      Gets the ElementRegistry which manages this Element.
      Returns:
      the ElementRegistry
    • publish Link icon

      void publish(Event event)
      Publishes an Event to the Element. All public Element instances will receive the event provided that the arguments match the method, or that the method {}
      Parameters:
      event -
    • close Link icon

      void close()
      Closes the element and releases any resources associated with the element. Future calls to this instance will be undefined and may result in exceptions. The specific behavior is up to the element implementation.
      Specified by:
      close in interface AutoCloseable