Package overit.geocall.platform
Class Factory
java.lang.Object
overit.geocall.platform.Factory
Utility class used to create an instance of an another class. This utility class
is very important because it allows to get an instance of another class by passing
the name of the class or directly the class itself. The name of the class can
be passed if the class lies in the same package of the caller, otherwise it must
have the relative path starting from the layer root. The resolution of the class
depends from the identity package, that can be deducted automatically or can be
explicity passed with a caller .The searching logic is: search inside the package
of the identity and then in all the other levels, the order of the levels depends
from the layers. This allows the possibility to extends other classes with some
specific logic inside that may differ from project to project assuring the creation
of the right class.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic List<JavaResource> Returns a list containing the matched resources, searching all across the layer customizations.static List<JavaResource> Returns a list containing the matched resources, searching all across the layer customizations.static List<JavaResource> collectResources(String res) Deprecated.protected static Class<?> findLibraryComponent(String path, CustomLayer cl) static intReturns the cache dimensionstatic InputStreamopen a stream to the resource object expressed in the parameter.static Class<?> getSubstituted(Class<?> c) Calculate the original class reference in case the class passed as a parameter is aPlatform.Substitute.static voidInvalidates the cachestatic <T> TCreates an instance of an object defined and compatible with the class parameter.static <T> TDeprecated.usemake(java.lang.Class)insteadstatic <T> TCreates an instance of an object defined and compatible with the class parameter.static <T> TCreates an instance of an object defined by a logical position.static <T> TCreates an instance of an object defined by a logical position.static <T> Class<T> Identifies and returns aClassdefined and compatible with the class parameter.static <T> Class<T> Identifies and returns aClassdefined and compatible with the type parameter.static <T> Class<T> Identifies and returns aClassdefined and compatible with the path parameter.static <T> Class<T> Identifies and returns aClassdefined and compatible with the path parameter.static <T> Class<T> Identifies and returns aClassdefined and compatible with the path parameter.static <T> TnewInstance(Class<T> realClz) creates an instance of the class possibly transmitting Identity informationstatic <T> TnewInstance(JavaResource res) creates an instance of a defined path possibly transmitting Identity informationstatic StringpackageFromClass(Class<?> c) Calculates the absolute package of a classstatic StringCalculates the absolute package of a class of this objectstatic StringpackageFromPath(String path) Calculates the absolute package of a resource's pathstatic JavaResourceReturns the physical position of a logical resource searching all across the layer customizations.static StringReturns the physical position of a logical resource searching all across the layer customizations.static JavaResourceReturns the physical position of a logical resource searching all across the layer customizations.static CustomLayerworkingLayer(String from) Extract the identity's layer from the one bind to the thread, otherwise try to infer it by thefrompath
-
Field Details
-
BASIC_PATH
- See Also:
-
APP_PATH
- See Also:
-
-
Method Details
-
getCacheDimension
public static int getCacheDimension()Returns the cache dimension- Returns:
- The cache dimension
-
invalidateCache
public static void invalidateCache()Invalidates the cache -
packageFromObject
Calculates the absolute package of a class of this object- Parameters:
o- the object- Returns:
- null if the object parameter is null, otherwise the package of the class
-
packageFromClass
Calculates the absolute package of a class- Parameters:
c- the class- Returns:
- null if the class parameter is null, otherwise the package of the class
-
packageFromPath
Calculates the absolute package of a resource's path- Parameters:
path- the path of a resource (it can reference whatever resource within the classpath)- Returns:
- the package of the resource
-
getSubstituted
Calculate the original class reference in case the class passed as a parameter is aPlatform.Substitute.- Parameters:
c- the class- Returns:
- the original class or the class passed in if it is not annotated with the
Platform.Substitute.
-
findLibraryComponent
-
realPath
Returns the physical position of a logical resource searching all across the layer customizations.- Parameters:
path- the path. It can be relative to thecalleror absolute depending by the path format. A path starting with // is absolute and already resolved. It will not be changed. A path starting with + will be translated tooverit/geocall/basic/and will be resolved. Otherwise the path will be searched all across all the layer customizations relatively to the position of thecallerIf the caller is null, thepathis meant to be absolute, otherwise thepathcould meant to be absolute if it starts with leading /, or could be referred to thecallerposition. In both cases the path will be resolvedcaller- the object requesting the path used as a starting position. If it is null, thepathis meant to be absolute- Returns:
- the canonical form for the
pathwith reference to thecallerposition.
-
realPath
Returns the physical position of a logical resource searching all across the layer customizations.- Parameters:
path- the path. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved and will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved. Otherwise the path will be searched all across all the layer customizations relatively to the position of thefromIf the from is null, thepathis meant to be absolute, otherwise thepathcould meant to be absolute if it starts with leading /, or could be referred to thecallerposition. In both cases the path will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- the resource form for the
pathwith reference to thecallerposition.
-
realPath
Returns the physical position of a logical resource searching all across the layer customizations.- Parameters:
path- the path. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved and will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations. If the from position is null, thepathis ment to be absolute, otherwise thepathis meant with reference to thefromposition, and will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- the resource form for the
pathinside thefromposition, with a leading "/" to indicate that the resource is already resolved.
-
workingLayer
Extract the identity's layer from the one bind to the thread, otherwise try to infer it by thefrompath- Parameters:
from- the path used to infer the layer belongs to- Returns:
- the layer of the current identity
-
make
Creates an instance of an object defined and compatible with the class parameter. The best implementation will be searched all across the layer customizations andPlatform.Substitute.- Type Parameters:
T- the desired type for the object- Parameters:
path- the absolute path defining the desired resource. The object will be searched all across all the layer customizations and substitutes driven by the currentIdentityand the relativeCustomLayer- Returns:
- the best instance for the requested object.
-
make
Creates an instance of an object defined and compatible with the class parameter. The best implementation will be searched all across the layer customizations andPlatform.Substitute.- Type Parameters:
T- the desired type for the object- Parameters:
clz- the class defining the desired instance. The object will be searched all across all the layer customizations and substitutes driven by the currentIdentityand the relativeCustomLayer- Returns:
- the best instance for the requested object.
-
make
Deprecated.usemake(java.lang.Class)insteadCreates an instance of an object defined and compatible with the class parameter. The best implementation will be searched all across the layer customizations andPlatform.Substitute.- Type Parameters:
T- the desired type for the object- Parameters:
clz- the class defining the desired instance The object will be searched all across all the layer customizations and substitutes driven by the currentIdentityand the relativeCustomLayercaller- useless parameter- Returns:
- the best instance for the requested object
-
make
Creates an instance of an object defined by a logical position. The best implementation will be searched all across the layer customizations andPlatform.Substitute.- Type Parameters:
T- the desired type for the object- Parameters:
path- the path. It can be relative to thecalleror absolute depending by the path format. A path starting with // is absolute and already resolved. It will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations relatively to the position of the caller. If the caller is null, thepathis meant to be absolute, otherwise thepathis meant with reference to thecallerposition, and will be resolvedcaller- the object requesting the the starting position. If it is null, thepathis meant to be absolute- Returns:
- the best instance for the requested object.
-
make
Creates an instance of an object defined by a logical position. The best implementatio will be searched all across the layer customizations.- Type Parameters:
T- the desired type for the object- Parameters:
path- the path. It can be relative to thefromor absolute depending by the path format. A path starting with // is absolute and already resolved. It will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations relatively to the position of thefromIf the from is null, thepathis meant to be absolute, otherwise thepathcould meant to be absolute if it starts with leading /, or could be referred to thefromposition. In both cases the path will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- the best instance for the requested object.
-
makeClass
Identifies and returns aClassdefined and compatible with the class parameter. It can be the same class or an extension.- Type Parameters:
T- the desired type for the object- Parameters:
clz- the class defining the desired instance- Returns:
- the best class for the requested object
-
makeClass
Identifies and returns aClassdefined and compatible with the type parameter. It can be the same type or an extension.- Type Parameters:
T- the desired type for the object- Parameters:
type- the type defining the desired instance- Returns:
- the best class for the requested object
-
makeClass
Identifies and returns aClassdefined and compatible with the path parameter.- Type Parameters:
T- the desired class for the object- Parameters:
path- the absolute path of the class. A path starting with / is already resolved and will not be changed. A path starting with + will be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations.- Returns:
- the best class for the requested object
-
makeClass
Identifies and returns aClassdefined and compatible with the path parameter.- Type Parameters:
T- the desired class for the object- Parameters:
path- the path of the class. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved. It will not be changed. A path starting with + will be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations andPlatform.Substitute. If the from position is null, thepathis meant to be absolute, otherwise thepathis meant with reference to thefromposition, and will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- the best class for the requested object
-
makeClass
Identifies and returns aClassdefined and compatible with the path parameter.- Type Parameters:
T- the desired class for the object- Parameters:
path- the path of the class. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved. It will not be changed. A path starting with + will be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations andPlatform.Substitute. If the from position is null, thepathis meant to be absolute, otherwise thepathis meant with reference to thefromposition, and will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- the best class for the requested object
-
newInstance
creates an instance of a defined path possibly transmitting Identity information- Type Parameters:
T- the desired class for the object- Parameters:
res- the path for the requested class- Returns:
- the instance of the requested class
-
newInstance
creates an instance of the class possibly transmitting Identity information- Type Parameters:
T- the desired class for the object- Parameters:
realClz- the requested class- Returns:
- the instance of the requested class
-
getStream
open a stream to the resource object expressed in the parameter.- Parameters:
realpath- the absolute path to the resource- Returns:
- the stream to the resource object
-
collect
Returns a list containing the matched resources, searching all across the layer customizations.- Parameters:
res- the requested resource. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved and will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations. If the from position is null, theresis meant to be absolute, otherwise theresis meant with reference to thefromposition, and will be resolvedfrom- the starting position. If it is null, thepathis meant to be absolute- Returns:
- a list containing the resolved resources
-
collect
Returns a list containing the matched resources, searching all across the layer customizations.- Parameters:
res- the requested resource. It can be absolute or relative, depending onfromA path starting with // is absolute and already resolved and will not be changed. A path starting with + wil be translated tooverit/geocall/basic/and will be resolved as an absolute path. Otherwise the path will be searched all across all the layer customizations. If the from position is null, theresis meant to be absolute, otherwise theresis meant with reference to thefromposition, and will be resolvedfrom- the starting position. If it is null, theresis meant to be absolute- Returns:
- a list containing the resolved resources
-
collectResources
Deprecated.usecollect(String, Class)insteadReturns a list containing the matched resources, searching all across the layer customizations.- Parameters:
res- the requested resource. It must be relative to the root of the layer.- Returns:
- a list containing the resolved resources
-
collect(String, Class)instead