Package org.jgroups.conf
Class ClassConfigurator
java.lang.Object
org.jgroups.conf.ClassConfigurator
This class will be replaced with the class that read info
from the magic number configurator that reads info from the xml file.
The name and the relative path of the magic number map file can be specified
as value of the property
org.jgroups.conf.magicNumberFile.
It must be relative to one of the classpath elements, to allow the
classloader to locate the file. If a value is not specified,
MagicNumberReader.MAGIC_NUMBER_FILE is used, which defaults
to "jg-magic-map.xml".- 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 voidaddProtocol(short id, Class protocol) static Classget(short magic) Returns a class for a magic number.static ClassLoads and returns the class from the class namestatic shortgetMagicNumber(Class clazz) Returns the magic number for the class.static ClassgetProtocol(short id) static shortgetProtocolId(Class protocol) protected static voidinit()parse(InputStream stream) parseClassData(Node protocol) static Stringstatic 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)toString()
-
Field Details
-
MAGIC_NUMBER_FILE
- See Also:
-
PROTOCOL_ID_FILE
- See Also:
-
log
-
-
Constructor Details
-
ClassConfigurator
public ClassConfigurator()
-
-
Method Details
-
init
- Throws:
ChannelException
-
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 invalid input: '<'= 1024
-
addProtocol
-
get
Returns a class for a magic number. Returns null if no class is found- Parameters:
magic- the magic number that maps to the class- Returns:
- a Class object that represents a class that implements java.io.Externalizable
-
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
-
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
-
toString
-
printMagicMap
-
printClassMap
-
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
-
parseClassData
- Throws:
IOException
-