Class PropertyFileHandleImpl
- java.lang.Object
-
- org.glassfish.hk2.configuration.persistence.properties.internal.PropertyFileHandleImpl
-
- All Implemented Interfaces:
PropertyFileHandle
@Service public class PropertyFileHandleImpl extends java.lang.Object implements PropertyFileHandle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPropertyFileHandleImpl.TypeData
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdefaultInstanceNameprivate java.lang.StringdefaultTypeprivate Hubhubprivate java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>>lastReadprivate java.lang.Objectlockprivate static intMAX_TRIESprivate booleanopenprivate ClassReflectionHelperreflectionHelperprivate static charSEPARATORprivate static java.lang.StringSETprivate java.lang.StringspecificType
-
Constructor Summary
Constructors Constructor Description PropertyFileHandleImpl(java.lang.String specificType, java.lang.String defaultType, java.lang.String defaultInstanceName, Hub hub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddMultiValue(java.util.Map<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> buildMe, PropertyFileHandleImpl.TypeData key, java.lang.String param, java.lang.String value)private voidaddValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)private java.lang.ObjectconvertBean(java.lang.String typeName, java.util.Map<java.lang.String,java.lang.String> rawBean)private java.lang.ObjectconvertValue(java.lang.String value, java.lang.Class<?> intoMe)voiddispose()Will remove any instances added by this handle from the hub, and make it such that this handle can no longer be usedprivate static java.lang.StringemptyNull(java.lang.String input)private voidextractData(java.lang.String keyString, java.lang.String value, java.util.Map<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> buildMe)private java.lang.reflect.MethodfindMethod(java.lang.Class<?> clazz, java.util.Set<java.lang.String> possibleSetterNames)private java.lang.StringgetDefaultInstance(java.lang.String instanceString)java.lang.StringgetDefaultInstanceName()Gets the default instance name that will be given to instances whose name cannot otherwise be determinedjava.lang.StringgetDefaultType()Returns the default type name if the type cannot be determined from the key of the property.private java.lang.StringgetDefaultType(java.lang.String typeString)private static java.lang.StringgetDefaultType(java.lang.String typeString, java.lang.String defaultDefault, java.lang.String defaultValue)private static java.util.HashSet<java.lang.String>getInstances(java.lang.String typeName, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> lastRead)private static java.util.Set<java.lang.String>getPossibleSetterNames(java.lang.String key)java.lang.StringgetSpecificType()Returns the specific type associated with this handleprivate static java.util.HashSet<java.lang.String>getTypes(java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> lastRead)private voidmodifyValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)voidreadProperties(java.util.Properties properties)Reads the file associated with this handle and will do the following: Add any type found not previously added by this handle Add any instance found not previously added by this handle Modify any property that has changed value Remove any instance no longer seen in the file but that had previously been added In particular this method will NOT remove a type that was previously added but which has no more instances (other files may be contributing to the same type).private voidremoveInstances(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
-
-
-
Field Detail
-
MAX_TRIES
private static final int MAX_TRIES
- See Also:
- Constant Field Values
-
SEPARATOR
private static final char SEPARATOR
- See Also:
- Constant Field Values
-
lock
private final java.lang.Object lock
-
lastRead
private java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> lastRead
-
open
private boolean open
-
specificType
private final java.lang.String specificType
-
defaultType
private final java.lang.String defaultType
-
defaultInstanceName
private final java.lang.String defaultInstanceName
-
hub
private final Hub hub
-
reflectionHelper
private final ClassReflectionHelper reflectionHelper
-
SET
private static java.lang.String SET
-
-
Constructor Detail
-
PropertyFileHandleImpl
PropertyFileHandleImpl(java.lang.String specificType, java.lang.String defaultType, java.lang.String defaultInstanceName, Hub hub)
-
-
Method Detail
-
emptyNull
private static java.lang.String emptyNull(java.lang.String input)
-
getDefaultType
private static java.lang.String getDefaultType(java.lang.String typeString, java.lang.String defaultDefault, java.lang.String defaultValue)
-
getDefaultType
private java.lang.String getDefaultType(java.lang.String typeString)
-
getDefaultInstance
private java.lang.String getDefaultInstance(java.lang.String instanceString)
-
addMultiValue
private static void addMultiValue(java.util.Map<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> buildMe, PropertyFileHandleImpl.TypeData key, java.lang.String param, java.lang.String value)
-
extractData
private void extractData(java.lang.String keyString, java.lang.String value, java.util.Map<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> buildMe)
-
removeInstances
private void removeInstances(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
-
getPossibleSetterNames
private static java.util.Set<java.lang.String> getPossibleSetterNames(java.lang.String key)
-
findMethod
private java.lang.reflect.Method findMethod(java.lang.Class<?> clazz, java.util.Set<java.lang.String> possibleSetterNames)
-
convertValue
private java.lang.Object convertValue(java.lang.String value, java.lang.Class<?> intoMe)
-
convertBean
private java.lang.Object convertBean(java.lang.String typeName, java.util.Map<java.lang.String,java.lang.String> rawBean)
-
modifyValues
private void modifyValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
-
addValues
private void addValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
-
readProperties
public void readProperties(java.util.Properties properties)
Description copied from interface:PropertyFileHandleReads the file associated with this handle and will do the following:- Add any type found not previously added by this handle
- Add any instance found not previously added by this handle
- Modify any property that has changed value
- Remove any instance no longer seen in the file but that had previously been added
-
In particular this method will NOT remove a type that was previously added but
which has no more instances (other files may be contributing to the same type).
After reaching the end of the input stream this method will close it
- Specified by:
readPropertiesin interfacePropertyFileHandle- Parameters:
properties- The properties object to inspect. May not be null
-
getTypes
private static java.util.HashSet<java.lang.String> getTypes(java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> lastRead)
-
getInstances
private static java.util.HashSet<java.lang.String> getInstances(java.lang.String typeName, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> lastRead)
-
getSpecificType
public java.lang.String getSpecificType()
Description copied from interface:PropertyFileHandleReturns the specific type associated with this handle- Specified by:
getSpecificTypein interfacePropertyFileHandle- Returns:
- The specific type this handle is updating. May return null if this is a multi-type handle
-
getDefaultType
public java.lang.String getDefaultType()
Description copied from interface:PropertyFileHandleReturns the default type name if the type cannot be determined from the key of the property. Will return null if getSpecificType is not null- Specified by:
getDefaultTypein interfacePropertyFileHandle- Returns:
- The default type name if the type cannot be determined, or null if this handle has a specific type
-
getDefaultInstanceName
public java.lang.String getDefaultInstanceName()
Description copied from interface:PropertyFileHandleGets the default instance name that will be given to instances whose name cannot otherwise be determined- Specified by:
getDefaultInstanceNamein interfacePropertyFileHandle- Returns:
- The default instance name. Will not return null
-
dispose
public void dispose()
Description copied from interface:PropertyFileHandleWill remove any instances added by this handle from the hub, and make it such that this handle can no longer be used- Specified by:
disposein interfacePropertyFileHandle
-
-