- All Implemented Interfaces:
Provider
AbstractProvider that is capable of proxying certain
interfaces and supplying them as environmental objects.- Author:
- Laird Nelson
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringDecapitalizes the suppliedCharSequenceaccording to the rules of the Java Beans specification.protected Supplier<?>protected booleanisIndexLike(Class<?> parameterType) Returnstrueif the suppliedClassrepresenting a method parameter is index-like, i.e.booleanisProxiable(Type type) Returnstrueif the suppliedTypecan be proxied.booleanisProxiable(Loader<?> requestor, Path<? extends Type> absolutePath) Returnstrueif the type identified by the suppliedabsolutePathcan be proxied.protected ObjectnewProxyInstance(Loader<?> requestor, Path<? extends Type> absolutePath, Class<?> interfaceToProxy) Invokes theProxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)method with appropriate arguments and returns the result.static final StringpropertyName(CharSequence cs, boolean methodReturnsBoolean) Given aCharSequencenormally representing the name of a "getter" method, and abooleanindicating whether the method in question returns aboolean, applies the rules declared by the Java Beans specification to the name and yields the result.Methods inherited from class org.microbean.loader.spi.AbstractProvider
get, lowerBound
-
Constructor Details
-
ProxyingProvider
Deprecated.This constructor should be invoked by subclasses andServiceLoaderinstances only.Creates a newProxyingProvider.
-
-
Method Details
-
find
Description copied from class:AbstractProviderReturns aSuppliersuitable for the suppliedLoaderandPath, ornullif there is no suchSuppliernow and if there never will be such aSupplierfor the supplied arguments.Overrides of this method must not call the
AbstractProvider.get(Loader, Path)method or undefined behavior (such as an infinite loop) may result.- Specified by:
findin classAbstractProvider- Parameters:
requestor- theLoaderseeking aValue(as originally passed to theAbstractProvider.get(Loader, Path)method); must not benullabsolutePath- an absolutePathfor which the suppliedLoaderis seeking a value (as originally passed to theAbstractProvider.get(Loader, Path)method); must not benull- Returns:
- a
Suppliermore or less suitable for the combination of the suppliedLoaderandPath, ornullif there is no suchSuppliernow and if there never will be such aSupplierfor the supplied arguments - See Also:
-
isProxiable
Returnstrueif the type identified by the suppliedabsolutePathcan be proxied.A type can be proxied by this
ProxyingProviderif its type erasure:- is an interface
- is not hidden
- is not sealed
In addition, the default implementation of this method rules out interfaces that declare or inherit
publicinstance methods with either exactly one parameter that does not pass the test codified by theisIndexLike(Class)method or more than one parameter.- Parameters:
requestor- theLoaderseeking an environmental object; must not benull; ignored by the default implementation of this methodabsolutePath- thePathidentifying the interface to be proxied; must not benull; must be absolute- Returns:
trueif the type identified by the suppliedabsolutePathcan be proxied;falseotherwise- Throws:
NullPointerException- if either argument isnullIllegalArgumentException- ifabsolutePathis not absolute- See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-
isProxiable
Returnstrueif the suppliedTypecan be proxied.A
Typecan be proxied if it:- is not
null - represents an interface
- is not hidden
- is not sealed
In addition, the default implementation of this method rules out interfaces that declare or inherit
publicinstance methods with either exactly one parameter that does not pass the test codified by theisIndexLike(Class)method or more than one parameter.This method does not, and its overrides must not, call the
isProxiable(Loader, Path)method or undefined behavior (such as an infinite loop) may result.- Parameters:
type- theTypeto test; may benullin which casefalsewill be returned- Returns:
trueif the suppliedTypecan be proxied;falseotherwise- See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
- is not
-
path
- Overrides:
pathin classAbstractProvider- Type Parameters:
T- the type of the requested and returnedPaths- Parameters:
requestor- theLoaderissuing the current request; must not benull; ignored by this implementationabsolutePath- the absolutePathrepresenting the current request; must not benull- Returns:
- a non-
nullPathwith which anyValueprovided by thisProxyingProviderwill be associated - See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent but not necessarily deterministic.
- Nullability:
- This method does not, and its overrides must not,
return
null. - Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-
isIndexLike
Returnstrueif the suppliedClassrepresenting a method parameter is index-like, i.e. if it is something typically used as an index into a larger collection or map.The default implementation of this method returns
trueifparameterTyperepresents either anint, anInteger, or aCharSequence.This method is called by the default implementation of the
isProxiable(Loader, Path)method.- Parameters:
parameterType- the method parameter type to test; may benullin which casefalsewill be returned- Returns:
trueif the suppliedClassrepresenting a method parameter is index-like, i.e. if it is something typically used as an index into a larger collection or map- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-
newProxyInstance
protected Object newProxyInstance(Loader<?> requestor, Path<? extends Type> absolutePath, Class<?> interfaceToProxy) Invokes theProxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)method with appropriate arguments and returns the result.The
Proxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)method is invoked with the following arguments:interfaceToProxy.getClassLoader()new Class<?>[] { interfaceToProxy }- a special
InvocationHandlerbacked by the suppliedLoaderandPath
- Parameters:
requestor- theLoaderperforming the current request; must not benullabsolutePath- an absolutePathrepresenting the current request; must not benullinterfaceToProxy- the single interface the new proxy instance will implement; must not benull; must be an interface- Returns:
- a new proxy instance as produced by the
Proxy.newProxyInstance(ClassLoader, Class[], InvocationHandler)method; nevernull - Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if any argument is unsuitable- See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Nullability:
- This method does not, and its overrides must not,
return
null. - Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-
propertyName
Given aCharSequencenormally representing the name of a "getter" method, and abooleanindicating whether the method in question returns aboolean, applies the rules declared by the Java Beans specification to the name and yields the result.- Parameters:
cs- aCharSequencenaming a "getter" method; may benullin which casenullwill be returnedmethodReturnsBoolean-trueif the method named by the suppliedCharSequencehasbooleanas its return type- Returns:
- the property name corresponding to the supplied method
name, according to the rules of the Java Beans specification, or
null(only ifcsisnull) - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method may return
nullbut only whencsisnull. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
decapitalize
Decapitalizes the suppliedCharSequenceaccording to the rules of the Java Beans specification.- Parameters:
cs- theCharSequenceto decapitalize; may benullin which casenullwill be returned- Returns:
- the decapitalized
Stringornull - Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method may return
nullbut only whencsisnull. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
ServiceLoaderinstances only.