public class ClassConfigurator extends Object
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".Modifier and Type | Field and Description |
---|---|
protected static Log |
log |
static String |
MAGIC_NUMBER_FILE |
static String |
PROTOCOL_ID_FILE |
Constructor and Description |
---|
ClassConfigurator() |
Modifier and Type | Method and Description |
---|---|
static void |
add(short magic,
Class clazz)
Method to register a user-defined header with jg-magic-map at runtime
|
static void |
addProtocol(short id,
Class protocol) |
static Class<Address> |
get(short magic)
Returns a class for a magic number.
|
static Class |
get(String clazzname)
Loads and returns the class from the class name
|
static short |
getMagicNumber(Class clazz)
Returns the magic number for the class.
|
static Class |
getProtocol(short id) |
static short |
getProtocolId(Class protocol) |
protected static void |
init() |
protected static List<Tuple<Short,String>> |
parse(InputStream stream) |
protected static Tuple<Short,String> |
parseClassData(Node protocol) |
static String |
printClassMap() |
static String |
printMagicMap() |
protected static List<Tuple<Short,String>> |
readMappings(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)
|
String |
toString() |
public static final String MAGIC_NUMBER_FILE
public static final String PROTOCOL_ID_FILE
protected static final Log log
public static void add(short magic, Class clazz) throws IllegalArgumentException
magic
- The magic number. Needs to be > 1024clazz
- The class. Usually a subclass of HeaderIllegalArgumentException
- If the magic number is already taken, or the magic number is <= 1024public static void addProtocol(short id, Class protocol)
public static Class<Address> get(short magic)
magic
- the magic number that maps to the classpublic static Class get(String clazzname)
clazzname
- a fully classified class name to be loadedpublic static short getMagicNumber(Class clazz)
clazz
- a class object that we want the magic number forpublic static short getProtocolId(Class protocol)
public static Class getProtocol(short id)
public static String printMagicMap()
public static String printClassMap()
protected static List<Tuple<Short,String>> readMappings(String name) throws Exception
Exception
protected static List<Tuple<Short,String>> parse(InputStream stream) throws Exception
Exception
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.