public class ClassConfigurator
extends java.lang.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 |
---|---|
static java.lang.String |
MAGIC_NUMBER_FILE |
static java.lang.String |
PROTOCOL_ID_FILE |
Constructor and Description |
---|
ClassConfigurator() |
Modifier and Type | Method and Description |
---|---|
static void |
add(short magic,
java.lang.Class clazz)
Method to register a user-defined header with jg-magic-map at runtime
|
static void |
addProtocol(short id,
java.lang.Class protocol) |
static java.lang.Class<?> |
get(short magic)
Returns a class for a magic number.
|
static java.lang.Class |
get(java.lang.String clazzname) |
static java.lang.Class |
get(java.lang.String clazzname,
java.lang.ClassLoader loader)
Loads and returns the class from the class name
|
static short |
getMagicNumber(java.lang.Class clazz)
Returns the magic number for the class.
|
static java.lang.Class |
getProtocol(short id) |
static short |
getProtocolId(java.lang.Class protocol) |
protected static void |
init() |
protected static java.util.List<Triple<java.lang.Short,java.lang.String,java.lang.Boolean>> |
parse(java.io.InputStream stream) |
protected static Triple<java.lang.Short,java.lang.String,java.lang.Boolean> |
parseClassData(org.w3c.dom.Node protocol) |
static java.lang.String |
printClassMap() |
static java.lang.String |
printMagicMap() |
protected static java.util.List<Triple<java.lang.Short,java.lang.String,java.lang.Boolean>> |
readMappings(java.lang.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)
|
java.lang.String |
toString() |
public static final java.lang.String MAGIC_NUMBER_FILE
public static final java.lang.String PROTOCOL_ID_FILE
protected static void init() throws java.lang.Exception
java.lang.Exception
public static void add(short magic, java.lang.Class clazz) throws java.lang.IllegalArgumentException
magic
- The magic number. Needs to be > 1024clazz
- The class. Usually a subclass of Headerjava.lang.IllegalArgumentException
- If the magic number is already taken, or the magic number is <= 1024public static void addProtocol(short id, java.lang.Class protocol)
public static java.lang.Class<?> get(short magic)
magic
- the magic number that maps to the classpublic static java.lang.Class get(java.lang.String clazzname, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundException
clazzname
- a fully classified class name to be loadedjava.lang.ClassNotFoundException
public static java.lang.Class get(java.lang.String clazzname) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static short getMagicNumber(java.lang.Class clazz)
clazz
- a class object that we want the magic number forpublic static short getProtocolId(java.lang.Class protocol)
public static java.lang.Class getProtocol(short id)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String printMagicMap()
public static java.lang.String printClassMap()
protected static java.util.List<Triple<java.lang.Short,java.lang.String,java.lang.Boolean>> readMappings(java.lang.String name) throws java.lang.Exception
java.lang.Exception
protected static java.util.List<Triple<java.lang.Short,java.lang.String,java.lang.Boolean>> parse(java.io.InputStream stream) throws java.lang.Exception
java.lang.Exception
protected static Triple<java.lang.Short,java.lang.String,java.lang.Boolean> parseClassData(org.w3c.dom.Node protocol)
Copyright © 1998-2020 Red Hat. All Rights Reserved.