java.lang.Object
iu.type.ComponentResource<T>
- Type Parameters:
T- resource type
- All Implemented Interfaces:
IuResource<T>,Supplier<T>
Implementation of
IuResource;-
Constructor Summary
ConstructorsConstructorDescriptionComponentResource(boolean needsAuthentication, boolean shared, int priority, String name, TypeTemplate<?, T> type, Supplier<?> factory) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) static ComponentResource<byte[]> createWebResource(String name, byte[] data) Creates a static web resource.Supplier<?> factory()Gets the factory to be used for creating new instances.voidProvides a factory to use for creating new instances of the resource.get()Gets the resource value.(package private) static Iterable<ComponentResource<?>> getResources(Class<?> targetClass) Gets all resources definitions tied to an implementation classname()Gets the resource name.booleanDetermines whether or not the resource should be authenticated before handing off to a managed application.voidPerforms post-construct logic for a shared resource.voidPerforms pre-destroy logic for a shared resource.intpriority()Indicates the initialization priority.booleanshared()Determines whether or not the resource is shared.toString()type()Gets the resource type
-
Constructor Details
-
ComponentResource
ComponentResource(boolean needsAuthentication, boolean shared, int priority, String name, TypeTemplate<?, T> type, Supplier<?> factory) Constructor.- Parameters:
needsAuthentication- whether or not authentication is neededshared- whether or not the resource is sharedpriority- initialization priorityname- resource nametype- resource typefactory- factory for creating new instances
-
-
Method Details
-
createWebResource
Creates a static web resource.- Parameters:
name- namedata- content- Returns:
- static web resource
-
getResources
Gets all resources definitions tied to an implementation class- Parameters:
targetClass- class to check- Returns:
- resource definitions
-
needsAuthentication
public boolean needsAuthentication()Description copied from interface:IuResourceDetermines whether or not the resource should be authenticated before handing off to a managed application.- Specified by:
needsAuthenticationin interfaceIuResource<T>- Returns:
- true if the resource requires authentication; else false
-
priority
public int priority()Description copied from interface:IuResourceIndicates the initialization priority.- Specified by:
priorityin interfaceIuResource<T>- Returns:
- initialization priority
-
name
Description copied from interface:IuResourceGets the resource name.- Specified by:
namein interfaceIuResource<T>- Returns:
- resource name
-
type
Description copied from interface:IuResourceGets the resource type- Specified by:
typein interfaceIuResource<T>- Returns:
- resource type
-
postConstruct
public void postConstruct()Description copied from interface:IuResourcePerforms post-construct logic for a shared resource.- Specified by:
postConstructin interfaceIuResource<T>
-
preDestroy
public void preDestroy()Description copied from interface:IuResourcePerforms pre-destroy logic for a shared resource.- Specified by:
preDestroyin interfaceIuResource<T>
-
factory
Description copied from interface:IuResourceGets the factory to be used for creating new instances.By default, returns a
Supplierthat:- Returns
IuType.autoboxDefault()if theresource typeis an immutable single-value - Invokes
IuExecutable.exec(Object...)on an an internally managed implementation class orInvocationHandlersuitable for representing the resource
- Specified by:
factoryin interfaceIuResource<T>- Returns:
- factory that supplies new instance of the resource, or an
InvocationHandlerfor backing aProxy.
- Returns
-
factory
Description copied from interface:IuResourceProvides a factory to use for creating new instances of the resource.The factory may return:
- A direct instance of the
resource class. - A instance of a class that implements the
resource interface - An
InvocationHandlerto back aProxyfor theresource interface
To selective override default behavior, call
IuResource.factory()first to get a reference to the default factory.- Specified by:
factoryin interfaceIuResource<T>- Parameters:
factory- resource implementation factory.
- A direct instance of the
-
get
Description copied from interface:IuResourceGets the resource value.Provides a new or immutable instance when
IuResource.shared()returns false; may provide the same instance on subsequent calls whenIuResource.shared()returns true. -
toString
-