public class ClassConfigurator extends Object
Modifier and Type | Field and Description |
---|---|
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) |
protected static void |
alreadyInMagicMap(short magic,
String classname) |
protected static void |
alreadyInProtocolsMap(short prot_id,
String classname) |
protected static void |
checkSameId(Header hdr,
short magic) |
static <T> T |
create(short id) |
static Class |
get(String clazzname) |
static Class |
get(String clazzname,
ClassLoader loader)
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<Triple<Short,String,Boolean>> |
parse(InputStream stream) |
protected static Triple<Short,String,Boolean> |
parseClassData(Node protocol) |
static String |
printClassMap() |
protected static List<Triple<Short,String,Boolean>> |
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)
|
public static final String MAGIC_NUMBER_FILE
public static final String PROTOCOL_ID_FILE
public static void add(short magic, Class clazz)
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 get(String clazzname, ClassLoader loader) throws ClassNotFoundException
clazzname
- a fully classified class name to be loadedClassNotFoundException
public static Class get(String clazzname) throws ClassNotFoundException
ClassNotFoundException
public 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 printClassMap()
protected static void checkSameId(Header hdr, short magic)
protected static void alreadyInMagicMap(short magic, String classname)
protected static void alreadyInProtocolsMap(short prot_id, String classname)
protected static List<Triple<Short,String,Boolean>> readMappings(String name) throws Exception
Exception
protected static List<Triple<Short,String,Boolean>> parse(InputStream stream) throws Exception
Exception
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.