Class MapInjectionResolver

  • All Implemented Interfaces:
    org.jvnet.hk2.config.InjectionResolverQuery

    public class MapInjectionResolver
    extends org.jvnet.hk2.config.InjectionResolver<org.glassfish.api.Param>
    An InjectionResolver that uses a ParameterMap object as the source of the data to inject.
    • Constructor Detail

      • MapInjectionResolver

        public MapInjectionResolver​(org.glassfish.api.admin.CommandModel model,
                                    org.glassfish.api.admin.ParameterMap parameters)
      • MapInjectionResolver

        public MapInjectionResolver​(org.glassfish.api.admin.CommandModel model,
                                    org.glassfish.api.admin.ParameterMap parameters,
                                    org.jvnet.hk2.component.MultiMap<String,​File> optionNameToUploadedFileMap)
    • Method Detail

      • setContext

        public void setContext​(org.glassfish.api.ExecutionContext context)
        Set the context that is passed to the DynamicParamImpl.defaultValue method.
      • isOptional

        public boolean isOptional​(AnnotatedElement element,
                                  org.glassfish.api.Param annotation)
        Overrides:
        isOptional in class org.jvnet.hk2.config.InjectionResolver<org.glassfish.api.Param>
      • getValue

        public <V> V getValue​(Object component,
                              AnnotatedElement target,
                              Type genericType,
                              Class<V> type)
                       throws org.glassfish.hk2.api.MultiException
        Throws:
        org.glassfish.hk2.api.MultiException
      • 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 injected
        fieldType - type of the field being injected
        optionNameToFileMap - 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 injected
        fieldType - type of the field being injected
        optionNameToFileMap - 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 List parameter to the specified type.
        Parameters:
        target - the target field
        type - the type of class to convert
        paramValList - the List of String values to convert
        Returns:
        Object