- All Implemented Interfaces:
IuComponent
,AutoCloseable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.iu.type.IuComponent
IuComponent.Kind
-
Constructor Summary
ConstructorsConstructorDescriptionComponent
(Component parent, ClassLoader classLoader, ModuleLayer moduleLayer, Iterable<ComponentArchive> archives, UnsafeRunnable onClose) Constructor for use fromComponentFactory
.Component
(ClassLoader classLoader, ModuleLayer moduleLayer, Path pathEntry) Single entry constructor. -
Method Summary
Modifier and TypeMethodDescriptionIterable
<? extends IuAttribute<?, ?>> annotatedAttributes
(Class<? extends Annotation> annotationType) Gets all types in the component annotated by a specific type.annotatedTypes
(Class<? extends Annotation> annotationType) Gets all types in the component annotated by a specific type.Gets theClassLoader
for this component.void
close()
extend
(InputStream componentArchiveSource, InputStream... providedDependencyArchiveSources) Validates component archives, all dependency archives, and loads a component that extends this component.extend
(Consumer<ModuleLayer.Controller> controllerCallback, InputStream componentArchiveSource, InputStream... providedDependencyArchiveSources) Validates component archives, all dependency archives, and loads a component that extends this component.Gets all of the component's public interfaces.kind()
Gets the kind of component.Gets the component'sModuleLayer
(package private) Component
parent()
Gets the parent component.(package private) Properties
Gets theMETA-INF/iu-type.properties
for amodular component
, orMETA-INF/iu.properties
for a legacy component.Iterable
<? extends IuResourceReference<?, ?>> Iterates all occurrences of this component's elements referring to a resource.Iterable
<? extends IuResource<?>> Gets component's resources.toString()
version()
Gets the component version.(package private) Set
<ComponentVersion> versions()
Gets the version information for this component and all dependencies included in its path.
-
Constructor Details
-
Component
Component(ClassLoader classLoader, ModuleLayer moduleLayer, Path pathEntry) throws IOException Single entry constructor.- Parameters:
classLoader
- class loadermoduleLayer
- module layerpathEntry
- resource root- Throws:
IOException
- if an I/O error occurs scanning the path provided for resources
-
Component
Component(Component parent, ClassLoader classLoader, ModuleLayer moduleLayer, Iterable<ComponentArchive> archives, UnsafeRunnable onClose) Constructor for use fromComponentFactory
.- Parameters:
parent
- parent component, seeextend(InputStream, InputStream...)
classLoader
- component context loadermoduleLayer
- module layerarchives
- archives dedicated to this component, to close and delete when the component is closedonClose
- thunk for tearing down resources after closing the component
-
-
Method Details
-
parent
Component parent()Gets the parent component.- Returns:
- parent component
-
properties
Properties properties()Gets theMETA-INF/iu-type.properties
for amodular component
, orMETA-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 interfaceIuComponent
- Parameters:
componentArchiveSource
-InputStream
for reading the component archive.providedDependencyArchiveSources
-InputStream
s 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 interfaceIuComponent
- Parameters:
controllerCallback
- receives a reference to theModuleLayer.Controller
for the component's module layer. This reference may be used to adjust module access rules then discarded; TheModuleLayer.Controller
should not be passed outside the callback invocation boundary.componentArchiveSource
-InputStream
for reading the component archive.providedDependencyArchiveSources
-InputStream
s 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
Description copied from interface:IuComponent
Gets the kind of component.- Specified by:
kind
in interfaceIuComponent
- Returns:
IuComponent.Kind
-
version
Description copied from interface:IuComponent
Gets the component version.- Specified by:
version
in interfaceIuComponent
- Returns:
IuComponentVersion
-
classLoader
Description copied from interface:IuComponent
Gets theClassLoader
for this component.- Specified by:
classLoader
in interfaceIuComponent
- Returns:
ClassLoader
-
moduleLayer
Description copied from interface:IuComponent
Gets the component'sModuleLayer
- Specified by:
moduleLayer
in interfaceIuComponent
- Returns:
ModuleLayer
-
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 theiu.util.type.impl
module. A legacy component Must not include interfaces from any dependencies unless the dependency is aIuComponent.Kind.LEGACY_JAR
that includes anMETA-INF/iu.properties
resource.- Specified by:
interfaces
in interfaceIuComponent
- 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 interfaceIuComponent
- Parameters:
annotationType
- annotation type- Returns:
- annotated type facades
-
annotatedTypes
Description copied from interface:IuComponent
Gets all types in the component annotated by a specific type.- Specified by:
annotatedTypes
in interfaceIuComponent
- Parameters:
annotationType
- annotation type- Returns:
- annotated type facades
-
resources
Description copied from interface:IuComponent
Gets component's resources.Includes:
- Static web resources when
IuComponent.kind()
.isWeb()
is true, withtype
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 withMETA-INF/iu.properties
, that includes the @Resource or @Resources annotation where either the resource type designated by the annotationis assignable from
the annotated type, or the designated type is an interface and the annotated type is anInvocationHandler
.
Must not include resources available from
ClassLoader.getResources(String)
and related methods. Although the name and functionality are similar, theiu.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 thesimple name
of resource type. When the annotated type is anInvocationHandler
, then the resource type must be aninterface
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 anInvocationHandler
, aProxy
is created with the resource type as its only interface.Note that resources provided by this method do not have
field
orproperty
bindings applied. That binding behavior would require a fully formed JNDI context be available and is the responsibility JEE Container, via theiu.jee.resources
module, not this base utilities module.- Specified by:
resources
in interfaceIuComponent
- Returns:
- resources
- Static web resources when
-
resourceReferences
Description copied from interface:IuComponent
Iterates all occurrences of this component's elements referring to a resource.- Specified by:
resourceReferences
in interfaceIuComponent
- Returns:
- resource references
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceIuComponent
- Throws:
Exception
-
toString
-