- 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 theClassLoaderfor this component.voidclose()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) Componentparent()Gets the parent component.(package private) PropertiesGets theMETA-INF/iu-type.propertiesfor amodular component, orMETA-INF/iu.propertiesfor 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.propertiesfor amodular component, orMETA-INF/iu.propertiesfor 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:IuComponentValidates component archives, all dependency archives, and loads a component that extends this component.- Specified by:
extendin interfaceIuComponent- Parameters:
componentArchiveSource-InputStreamfor 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:IuComponentValidates component archives, all dependency archives, and loads a component that extends this component.- Specified by:
extendin interfaceIuComponent- Parameters:
controllerCallback- receives a reference to theModuleLayer.Controllerfor the component's module layer. This reference may be used to adjust module access rules then discarded; TheModuleLayer.Controllershould not be passed outside the callback invocation boundary.componentArchiveSource-InputStreamfor 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
Description copied from interface:IuComponentGets the kind of component.- Specified by:
kindin interfaceIuComponent- Returns:
IuComponent.Kind
-
version
Description copied from interface:IuComponentGets the component version.- Specified by:
versionin interfaceIuComponent- Returns:
IuComponentVersion
-
classLoader
Description copied from interface:IuComponentGets theClassLoaderfor this component.- Specified by:
classLoaderin interfaceIuComponent- Returns:
ClassLoader
-
moduleLayer
Description copied from interface:IuComponentGets the component'sModuleLayer- Specified by:
moduleLayerin interfaceIuComponent- Returns:
ModuleLayer
-
interfaces
Description copied from interface:IuComponentGets 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
openthe package containing the interface to theiu.util.type.implmodule. A legacy component Must not include interfaces from any dependencies unless the dependency is aIuComponent.Kind.LEGACY_JARthat includes anMETA-INF/iu.propertiesresource.- Specified by:
interfacesin interfaceIuComponent- Returns:
- interface facades
-
annotatedAttributes
public Iterable<? extends IuAttribute<?,?>> annotatedAttributes(Class<? extends Annotation> annotationType) Description copied from interface:IuComponentGets all types in the component annotated by a specific type.- Specified by:
annotatedAttributesin interfaceIuComponent- Parameters:
annotationType- annotation type- Returns:
- annotated type facades
-
annotatedTypes
Description copied from interface:IuComponentGets all types in the component annotated by a specific type.- Specified by:
annotatedTypesin interfaceIuComponent- Parameters:
annotationType- annotation type- Returns:
- annotated type facades
-
resources
Description copied from interface:IuComponentGets component's resources.Includes:
- Static web resources when
IuComponent.kind().isWeb()is true, withtypebyte[]. 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 fromthe 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.typemodule 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 nameof resource type. When the annotated type is anInvocationHandler, then the resource type must be aninterfacein 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, aProxyis created with the resource type as its only interface.Note that resources provided by this method do not have
fieldorpropertybindings applied. That binding behavior would require a fully formed JNDI context be available and is the responsibility JEE Container, via theiu.jee.resourcesmodule, not this base utilities module.- Specified by:
resourcesin interfaceIuComponent- Returns:
- resources
- Static web resources when
-
resourceReferences
Description copied from interface:IuComponentIterates all occurrences of this component's elements referring to a resource.- Specified by:
resourceReferencesin interfaceIuComponent- Returns:
- resource references
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIuComponent- Throws:
Exception
-
toString
-