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 class
PropertyFileHandleImpl.TypeData
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
defaultInstanceName
private java.lang.String
defaultType
private Hub
hub
private java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>>
lastRead
private java.lang.Object
lock
private static int
MAX_TRIES
private boolean
open
private ClassReflectionHelper
reflectionHelper
private static char
SEPARATOR
private static java.lang.String
SET
private java.lang.String
specificType
-
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 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)
private void
addValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
private java.lang.Object
convertBean(java.lang.String typeName, java.util.Map<java.lang.String,java.lang.String> rawBean)
private java.lang.Object
convertValue(java.lang.String value, java.lang.Class<?> intoMe)
void
dispose()
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.String
emptyNull(java.lang.String input)
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)
private java.lang.reflect.Method
findMethod(java.lang.Class<?> clazz, java.util.Set<java.lang.String> possibleSetterNames)
private java.lang.String
getDefaultInstance(java.lang.String instanceString)
java.lang.String
getDefaultInstanceName()
Gets the default instance name that will be given to instances whose name cannot otherwise be determinedjava.lang.String
getDefaultType()
Returns the default type name if the type cannot be determined from the key of the property.private java.lang.String
getDefaultType(java.lang.String typeString)
private static java.lang.String
getDefaultType(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.String
getSpecificType()
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 void
modifyValues(WriteableBeanDatabase wbd, java.util.HashMap<PropertyFileHandleImpl.TypeData,java.util.Map<java.lang.String,java.lang.String>> allBeans)
void
readProperties(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 void
removeInstances(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:PropertyFileHandle
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).
After reaching the end of the input stream this method will close it
- Specified by:
readProperties
in 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:PropertyFileHandle
Returns the specific type associated with this handle- Specified by:
getSpecificType
in 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:PropertyFileHandle
Returns 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:
getDefaultType
in 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:PropertyFileHandle
Gets the default instance name that will be given to instances whose name cannot otherwise be determined- Specified by:
getDefaultInstanceName
in interfacePropertyFileHandle
- Returns:
- The default instance name. Will not return null
-
dispose
public void dispose()
Description copied from interface:PropertyFileHandle
Will remove any instances added by this handle from the hub, and make it such that this handle can no longer be used- Specified by:
dispose
in interfacePropertyFileHandle
-
-