Package iu.type

Class Component

java.lang.Object
iu.type.Component
All Implemented Interfaces:
IuComponent, AutoCloseable

class Component extends Object implements IuComponent
Component Implementation
See Also:
  • Constructor Details

  • Method Details

    • parent

      Component parent()
      Gets the parent component.
      Returns:
      parent component
    • properties

      Properties properties()
      Gets the META-INF/iu-type.properties for a modular component, or META-INF/iu.properties for a legacy component.
      Returns:
      parsed properties
    • versions

      Set<ComponentVersion> versions()
      Gets the version information for this component and all dependencies included in its path.

      The return value is ordered; this component version is the first returned by the iterator.

      Returns:
      version information
    • extend

      public Component extend(InputStream componentArchiveSource, InputStream... providedDependencyArchiveSources) throws IOException, IllegalArgumentException
      Description copied from interface: IuComponent
      Validates component archives, all dependency archives, and loads a component that extends this component.
      Specified by:
      extend in interface IuComponent
      Parameters:
      componentArchiveSource - InputStream for reading the component archive.
      providedDependencyArchiveSources - InputStreams for reading all provided dependency archive.
      Returns:
      component
      Throws:
      IOException - If the component archive or any dependency archives are unreadable.
      IllegalArgumentException - If the component archive or any dependency archives are invalid.
    • extend

      public Component extend(Consumer<ModuleLayer.Controller> controllerCallback, InputStream componentArchiveSource, InputStream... providedDependencyArchiveSources) throws IOException, IllegalArgumentException
      Description copied from interface: IuComponent
      Validates component archives, all dependency archives, and loads a component that extends this component.
      Specified by:
      extend in interface IuComponent
      Parameters:
      controllerCallback - receives a reference to the ModuleLayer.Controller for the component's module layer. This reference may be used to adjust module access rules then discarded; The ModuleLayer.Controller should not be passed outside the callback invocation boundary.
      componentArchiveSource - InputStream for reading the component archive.
      providedDependencyArchiveSources - InputStreams for reading all provided dependency archive.
      Returns:
      component
      Throws:
      IOException - If the component archive or any dependency archives are unreadable.
      IllegalArgumentException - If the component archive or any dependency archives invalid.
    • kind

      public IuComponent.Kind kind()
      Description copied from interface: IuComponent
      Gets the kind of component.
      Specified by:
      kind in interface IuComponent
      Returns:
      IuComponent.Kind
    • version

      public IuComponentVersion version()
      Description copied from interface: IuComponent
      Gets the component version.
      Specified by:
      version in interface IuComponent
      Returns:
      IuComponentVersion
    • classLoader

      public ClassLoader classLoader()
      Description copied from interface: IuComponent
      Gets the ClassLoader for this component.
      Specified by:
      classLoader in interface IuComponent
      Returns:
      ClassLoader
    • moduleLayer

      public ModuleLayer moduleLayer()
      Description copied from interface: IuComponent
      Gets the component's ModuleLayer
      Specified by:
      moduleLayer in interface IuComponent
      Returns:
      ModuleLayer
    • interfaces

      public Set<? extends IuType<?,?>> interfaces()
      Description copied from interface: IuComponent
      Gets all of the component's public interfaces.

      This method is intended to support resource and service discovery of public APIs defined by the applications. A modular component Must not include interfaces from a module that does not open the package containing the interface to the iu.util.type.impl module. A legacy component Must not include interfaces from any dependencies unless the dependency is a IuComponent.Kind.LEGACY_JAR that includes an META-INF/iu.properties resource.

      Specified by:
      interfaces in interface IuComponent
      Returns:
      interface facades
    • annotatedAttributes

      public Iterable<? extends IuAttribute<?,?>> annotatedAttributes(Class<? extends Annotation> annotationType)
      Description copied from interface: IuComponent
      Gets all types in the component annotated by a specific type.
      Specified by:
      annotatedAttributes in interface IuComponent
      Parameters:
      annotationType - annotation type
      Returns:
      annotated type facades
    • annotatedTypes

      public Iterable<? extends IuType<?,?>> annotatedTypes(Class<? extends Annotation> annotationType)
      Description copied from interface: IuComponent
      Gets all types in the component annotated by a specific type.
      Specified by:
      annotatedTypes in interface IuComponent
      Parameters:
      annotationType - annotation type
      Returns:
      annotated type facades
    • resources

      public Iterable<? extends IuResource<?>> resources()
      Description copied from interface: IuComponent
      Gets component's resources.

      Includes:

      • Static web resources when IuComponent.kind().isWeb() is true, with type byte[]. This includes zero-length binary resources for folder entries (IuResource.name() ends with '/').
      • All types in the component and all dependencies declared as part of an package open to iu.util.type.impl, or in a legacy component with META-INF/iu.properties, that includes the @Resource or @Resources annotation where either the resource type designated by the annotation is assignable from the annotated type, or the designated type is an interface and the annotated type is an InvocationHandler.

      Must not include resources available from ClassLoader.getResources(String) and related methods. Although the name and functionality are similar, the iu.util.type module is intended only to simplify, not duplicate, base platform functionality provided by the platform.

      This method discovers resources in a manner that deviates from the behavior described in Jakarta Annotations 2.1 Section 3.3. This deviation from the standard is an important element of IU JEE's self-defining behavior for application resources, and eliminates the need for a deployment descriptor that describes the resources available to a component.

      The standard specification describes the behavior of @Resource on a type as declaring a dependency that must be available for lookup via JNDI and requires that name() be non-empty. That behavior should be preserved for cases when the resource type is not assignable from the annotated type, however when the resource type is assignable or is and interface and the annotated type implements InvocationHandler, the annotated type itself is considered the resource implementation type and the default resource name is the simple name of resource type. When the annotated type is an InvocationHandler, then the resource type must be an interface in order to be discovered, otherwise the default resource type is the first non-platform interface implemented by the resource implementation type, or the resource implementation type itself if no non-platform interfaces are implemented.

      Resources discovered in this manner use IuExecutable.exec(Object...) with no args to create an instance. When shareable(), IuResource.get() returns a pre-constructed single instance; else each invocation returns a new instance. When the annotated type is an InvocationHandler, a Proxy is created with the resource type as its only interface.

      Note that resources provided by this method do not have field or property bindings applied. That binding behavior would require a fully formed JNDI context be available and is the responsibility JEE Container, via the iu.jee.resources module, not this base utilities module.

      Specified by:
      resources in interface IuComponent
      Returns:
      resources
    • resourceReferences

      public Iterable<? extends IuResourceReference<?,?>> resourceReferences()
      Description copied from interface: IuComponent
      Iterates all occurrences of this component's elements referring to a resource.
      Specified by:
      resourceReferences in interface IuComponent
      Returns:
      resource references
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface IuComponent
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class Object