Package org.glassfish.common.util.admin
Class MapInjectionResolver
- java.lang.Object
-
- org.jvnet.hk2.config.InjectionResolver<Param>
-
- org.glassfish.common.util.admin.MapInjectionResolver
-
- All Implemented Interfaces:
InjectionResolverQuery
public class MapInjectionResolver extends InjectionResolver<Param>
An InjectionResolver that uses a ParameterMap object as the source of the data to inject.
-
-
Field Summary
Fields Modifier and Type Field Description static LocalStringManagerImpl
localStrings
-
Fields inherited from class org.jvnet.hk2.config.InjectionResolver
type
-
-
Constructor Summary
Constructors Constructor Description MapInjectionResolver(CommandModel model, ParameterMap parameters)
MapInjectionResolver(CommandModel model, ParameterMap parameters, org.jvnet.hk2.component.MultiMap<String,File> optionNameToUploadedFileMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Object
convertListToObject(AnnotatedElement target, Class type, List<String> paramValList)
Convert the Listparameter to the specified type. static String
getUploadedFileParamValue(String fieldName, Class fieldType, org.jvnet.hk2.component.MultiMap<String,File> optionNameToFileMap)
Returns the path to the uploaded file if the specified field is of type File and if the field name is the same as one of the option names that was associated with an uploaded File in the incoming command request.static List<String>
getUploadedFileParamValues(String fieldName, Class fieldType, org.jvnet.hk2.component.MultiMap<String,File> optionNameToFileMap)
Returns the paths to the uploaded files if the specified field is of type File[] and if the field name is the same as one of the option names that was associated with an uploaded File in the incoming command request.<V> V
getValue(Object component, AnnotatedElement target, Type genericType, Class<V> type)
Returns the value to inject in the field or method of component annotated with the annotated annotation.boolean
isOptional(AnnotatedElement element, Param annotation)
Returns true if the resolution of this injection identified by the passed annotation instance is optionalvoid
setContext(ExecutionContext context)
Set the context that is passed to the DynamicParamImpl.defaultValue method.-
Methods inherited from class org.jvnet.hk2.config.InjectionResolver
getSetterMethod
-
-
-
-
Field Detail
-
localStrings
public static final LocalStringManagerImpl localStrings
-
-
Constructor Detail
-
MapInjectionResolver
public MapInjectionResolver(CommandModel model, ParameterMap parameters)
-
MapInjectionResolver
public MapInjectionResolver(CommandModel model, ParameterMap parameters, org.jvnet.hk2.component.MultiMap<String,File> optionNameToUploadedFileMap)
-
-
Method Detail
-
setContext
public void setContext(ExecutionContext context)
Set the context that is passed to the DynamicParamImpl.defaultValue method.
-
isOptional
public boolean isOptional(AnnotatedElement element, Param annotation)
Description copied from class:InjectionResolver
Returns true if the resolution of this injection identified by the passed annotation instance is optional- Overrides:
isOptional
in classInjectionResolver<Param>
- Parameters:
element
- is the annotated java elementMethod
orField
annotation
- the injection metadata- Returns:
- true if the {@see getValue()} can return null without generating a faulty injection operation
-
getValue
public <V> V getValue(Object component, AnnotatedElement target, Type genericType, Class<V> type) throws org.glassfish.hk2.api.MultiException
Description copied from interface:InjectionResolverQuery
Returns the value to inject in the field or method of component annotated with the annotated annotation.- Parameters:
component
- injection target instancetarget
- is the annotated java elementMethod
orField
genericType
- the generic type of the expected returntype
- type of the expected return- Returns:
- the resource to be injected
- Throws:
org.glassfish.hk2.api.MultiException
- if the resource cannot be located.
-
getUploadedFileParamValue
public static String getUploadedFileParamValue(String fieldName, Class fieldType, org.jvnet.hk2.component.MultiMap<String,File> optionNameToFileMap)
Returns the path to the uploaded file if the specified field is of type File and if the field name is the same as one of the option names that was associated with an uploaded File in the incoming command request.- Parameters:
fieldName
- name of the field being injectedfieldType
- type of the field being injectedoptionNameToFileMap
- map of field names to uploaded Files- Returns:
- absolute path of the uploaded file for the field; null if no file uploaded for this field
-
getUploadedFileParamValues
public static List<String> getUploadedFileParamValues(String fieldName, Class fieldType, org.jvnet.hk2.component.MultiMap<String,File> optionNameToFileMap)
Returns the paths to the uploaded files if the specified field is of type File[] and if the field name is the same as one of the option names that was associated with an uploaded File in the incoming command request.- Parameters:
fieldName
- name of the field being injectedfieldType
- type of the field being injectedoptionNameToFileMap
- map of field names to uploaded Files- Returns:
- List of absolute paths of the uploaded files for the field; null if no file uploaded for this field
-
convertListToObject
public static Object convertListToObject(AnnotatedElement target, Class type, List<String> paramValList)
Convert the Listparameter to the specified type. - Parameters:
target
- the target fieldtype
- the type of class to convertparamValList
- the List of String values to convert- Returns:
- Object
-
-