Class ConfigModularityUtils


  • @Service
    public final class ConfigModularityUtils
    extends Object
    Contains utility methods for zero-config
    Author:
    Masoud Kalali
    • Constructor Detail

      • ConfigModularityUtils

        public ConfigModularityUtils()
    • Method Detail

      • getConfigurationFileUrl

        public <U extends org.jvnet.hk2.config.ConfigBeanProxy> URL getConfigurationFileUrl​(Class<U> configBeanClass,
                                                                                            String baseFileName,
                                                                                            String runtimeType)
      • getDefaultConfigurations

        public List<ConfigBeanDefaultValue> getDefaultConfigurations​(Class configBeanClass,
                                                                     String runtimeType)
        If exists, locate and return a URL to the configuration snippet for the given config bean class.
        Parameters:
        configBeanClass - the config bean type we want to check for its configuration snippet
        Returns:
        A url to the file or null of not exists
      • hasCustomConfig

        public boolean hasCustomConfig​(Class configBeanClass)
      • findSuitableCollectionGetter

        public Method findSuitableCollectionGetter​(Class owner,
                                                   Class typeToSet)
        Find a getter method that returns a collection of the type we want to put set.
        Parameters:
        owner - The class we want to search to find a method that returns a Collection typed with toSetType
        typeToSet - The type we want to find a matching collection fo
        Returns:
        The Method that
      • findDeeperSuitableCollectionGetter

        public Method findDeeperSuitableCollectionGetter​(Class owner,
                                                         Class typeToSet)
      • checkInterfaces

        public boolean checkInterfaces​(Class[] ifs,
                                       Type actualGenericParameter)
      • getOwningClassForLocation

        public Class getOwningClassForLocation​(String location)
      • getOwningObject

        public org.jvnet.hk2.config.ConfigBeanProxy getOwningObject​(String location)
      • getExtensions

        public <U extends org.jvnet.hk2.config.ConfigBeanProxy> List<U> getExtensions​(org.jvnet.hk2.config.ConfigBeanProxy parent)
      • setConfigBean

        public <T extends org.jvnet.hk2.config.ConfigBeanProxy> T setConfigBean​(T finalConfigBean,
                                                                                ConfigBeanDefaultValue configBeanDefaultValue,
                                                                                org.jvnet.hk2.config.ConfigBeanProxy parent)
      • stackPositionHigher

        public <T extends org.jvnet.hk2.config.ConfigBeanProxy> boolean stackPositionHigher​(T finalConfigBean,
                                                                                            org.jvnet.hk2.config.ConfigBeanProxy itemToRemove)
      • applyCustomTokens

        public <T extends org.jvnet.hk2.config.ConfigBeanProxy> void applyCustomTokens​(ConfigBeanDefaultValue configBeanDefaultValue,
                                                                                       T finalConfigBean,
                                                                                       org.jvnet.hk2.config.ConfigBeanProxy parent)
                                                                                throws org.jvnet.hk2.config.TransactionFailure,
                                                                                       PropertyVetoException
        Throws:
        org.jvnet.hk2.config.TransactionFailure
        PropertyVetoException
      • convertConfigElementNameToClassName

        public String convertConfigElementNameToClassName​(String name)
        convert a configuration element name to representing class name
        Parameters:
        name - the configuration element name we want to convert to class name
        Returns:
        the class name which the configuration element represent.
      • getClassFor

        public Class getClassFor​(String serviceName)
      • getClassFromInjector

        public Class getClassFromInjector​(org.jvnet.hk2.config.ConfigInjector injector)
      • getServiceTypeNameIfNamedComponent

        public String getServiceTypeNameIfNamedComponent​(String serviceName)
      • resolveExpression

        public String resolveExpression​(String expression)
      • serializeConfigBeanByType

        public String serializeConfigBeanByType​(Class configBeanType)
      • getConfigBeanInstanceFor

        public org.jvnet.hk2.config.ConfigBeanProxy getConfigBeanInstanceFor​(Class configBeanType)
      • serializeConfigBean

        public String serializeConfigBean​(org.jvnet.hk2.config.ConfigBeanProxy configBean)
      • getMatchingGetterMethod

        public Method getMatchingGetterMethod​(Class classToQuery,
                                              Class methodReturnType)
        Find a suitable getter method in the given class. the returned method represent a method that will return back a type of methodReturnType.
        Parameters:
        classToQuery - The class we want to find the getter in
        methodReturnType - the type we want to find the getter for
        Returns:
        A Method object for a getter method in the classToQuery which returns the methodReturnType
      • getMatchingSetterMethod

        public Method getMatchingSetterMethod​(Class classToQuery,
                                              Class typeToSet)
        Finds and return the setter method matching the class identified by typeToSet
        Parameters:
        classToQuery - The ConfigLoader we want to inspect for presence of a setter method accepting class of type fqcn.
        typeToSet - the type we want to find a setter for
        Returns:
        the matching Method object or null if not present.
      • getDuckClass

        public Class getDuckClass​(Class configBeanType)
      • getGetDefaultValuesMethod

        public Method getGetDefaultValuesMethod​(Class configBeanType)
      • deleteConfigurationForConfigBean

        public boolean deleteConfigurationForConfigBean​(org.jvnet.hk2.config.ConfigBeanProxy configBean,
                                                        Collection col,
                                                        ConfigBeanDefaultValue defaultValue)
      • getClassForFullName

        public Class getClassForFullName​(String configBeanClassName)
      • getClassFromDescriptor

        public Class getClassFromDescriptor​(org.glassfish.hk2.api.ActiveDescriptor<?> descriptor)
      • getRuntimeTypePrefix

        public String getRuntimeTypePrefix​(com.sun.enterprise.module.bootstrap.StartupContext startupContext)
      • getAnnotatedConfigBeans

        public List<Class> getAnnotatedConfigBeans​(Class annotationType)
      • isIgnorePersisting

        public boolean isIgnorePersisting()
      • setIgnorePersisting

        public void setIgnorePersisting​(boolean ignorePersisting)
      • isCommandInvocation

        public boolean isCommandInvocation()
      • setCommandInvocation

        public void setCommandInvocation​(boolean commandInvocation)
      • getInstalledExtensions

        public List<Class> getInstalledExtensions​(Class extensionType)