Package org.jgroups.conf
Class ClassConfigurator
java.lang.Object
org.jgroups.conf.ClassConfigurator
Maintains a mapping between magic IDs and classes (defined in jg-magic-map.xml), and between protocol IDs and
protocol classes (defined in jg-protocol-ids.xml). The first mapping is used to for fast serialization, whereas
the second is used to assign protocol IDs to protocols at startup time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprivate static final intprivate static final intprivate static final shortprivate static final shortprotected static final Stringstatic final StringContains data read from jg-protocol-ids.xmlprivate static final IntHashMap<Class<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidMethod to register a user-defined header with jg-magic-map at runtimestatic voidaddIfAbsent(short magic, Class<?> clazz) static voidaddProtocol(short id, Class<?> protocol) protected static voidalreadyInMagicMap(short magic, String classname) protected static voidalreadyInProtocolsMap(short prot_id, String classname) protected static voidcheckSameId(Header hdr, short magic) static <T> Tcreate(short id) static Class<?> static Class<?> get(String clazzname, ClassLoader loader) Loads and returns the class from the class namestatic shortgetMagicNumber(Class<?> clazz) Returns the magic number for the class.static Class<?> getProtocol(short id) static shortgetProtocolId(Class<?> protocol) protected static voidinit()protected static voidparse(InputStream in) protected static StringparseNextString(String line, int index) static StringreadMappings(String name) try to read the magic number configuration file as a Resource form the classpath using getResourceAsStream if this fails this method tries to read the configuration file from mMagicNumberFile using a FileInputStream (not in classpath but somewhere else in the disk)protected static String
-
Field Details
-
MAGIC_NUMBER_FILE
- See Also:
-
PROTOCOL_ID_FILE
- See Also:
-
CLASS
- See Also:
-
ID
- See Also:
-
NAME
- See Also:
-
EXTERNAL
- See Also:
-
MAX_MAGIC_VALUE
private static final int MAX_MAGIC_VALUE- See Also:
-
MAX_PROT_ID_VALUE
private static final int MAX_PROT_ID_VALUE- See Also:
-
MIN_CUSTOM_MAGIC_NUMBER
private static final short MIN_CUSTOM_MAGIC_NUMBER- See Also:
-
MIN_CUSTOM_PROTOCOL_ID
private static final short MIN_CUSTOM_PROTOCOL_ID- See Also:
-
classMap
-
magicMap
-
magicMapUser
-
protocol_ids
Contains data read from jg-protocol-ids.xml -
protocol_names
-
-
Constructor Details
-
ClassConfigurator
public ClassConfigurator()
-
-
Method Details
-
addIfAbsent
-
add
Method to register a user-defined header with jg-magic-map at runtime- Parameters:
magic- The magic number. Needs to be > 1024clazz- The class. Usually a subclass of Header- Throws:
IllegalArgumentException- If the magic number is already taken, or the magic number is <= 1024
-
addProtocol
-
create
- Throws:
ClassNotFoundException
-
get
Loads and returns the class from the class name- Parameters:
clazzname- a fully classified class name to be loaded- Returns:
- a Class object that represents a class that implements java.io.Externalizable
- Throws:
ClassNotFoundException
-
get
- Throws:
ClassNotFoundException
-
getMagicNumber
Returns the magic number for the class.- Parameters:
clazz- a class object that we want the magic number for- Returns:
- the magic number for a class, -1 if no mapping is available
-
getProtocolId
-
getProtocol
-
printClassMap
-
init
- Throws:
Exception
-
checkSameId
-
alreadyInMagicMap
-
alreadyInProtocolsMap
-
readMappings
try to read the magic number configuration file as a Resource form the classpath using getResourceAsStream if this fails this method tries to read the configuration file from mMagicNumberFile using a FileInputStream (not in classpath but somewhere else in the disk)- Returns:
- an array of ClassMap objects that where parsed from the file (if found) or an empty array if file not found or had en exception
- Throws:
Exception
-
parse
- Throws:
Exception
-
notFound
-
parseNextString
-
parseLines
- Throws:
IOException
-
readTillMatchingParens
- Throws:
IOException
-