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.
- Author:
- Filip Hanik, Bela Ban
-
Field Summary
Fields -
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:
-
-
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
-
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:
- a list 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
-
notFound
-
parseNextString
-
parseLines
- Throws:
IOException
-
readTillMatchingParens
- Throws:
IOException
-