本文整理汇总了Java中com.esotericsoftware.reflectasm.ConstructorAccess类的典型用法代码示例。如果您正苦于以下问题:Java ConstructorAccess类的具体用法?Java ConstructorAccess怎么用?Java ConstructorAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorAccess类属于com.esotericsoftware.reflectasm包,在下文中一共展示了ConstructorAccess类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
protected void load(PandaParserPipelineRegistry registry) throws Exception {
Reflections reflections = ReflectionsUtils.REFLECTIONS;
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ParserRegistration.class);
for (Class<?> clazz : annotated) {
ParserRegistration parserRegistration = clazz.getAnnotation(ParserRegistration.class);
ConstructorAccess<? extends UnifiedParser> parserConstructor = ConstructorAccess.get(parserRegistration.parserClass());
UnifiedParser parser = parserConstructor.newInstance();
ConstructorAccess<? extends ParserHandler> handlerConstructor = ConstructorAccess.get(parserRegistration.handlerClass());
ParserHandler handler = handlerConstructor.newInstance();
ParserRepresentation representation = new PandaParserRepresentation(parser, handler, parserRegistration.priority());
for (String target : parserRegistration.target()) {
ParserPipeline pipeline = registry.getOrCreate(target);
pipeline.registerParserRepresentation(representation);
}
}
}
示例2: construct
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
private static <T> T construct(final Class<T> clazz) {
return Fn.getJvm(() -> {
// Reflect Asm
final ConstructorAccess<T> access = ConstructorAccess.get(clazz);
return access.newInstance();
}, clazz);
}
示例3: loadScript
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Function<Bindings, ?> loadScript(String className) {
try {
Class<Function<Bindings, ?>> theClass = (Class<Function<Bindings, ?>>) Class.forName(className);
ConstructorAccess<Function<Bindings, ?>> access = ConstructorAccess.get(theClass);
return access.newInstance();
} catch (ClassNotFoundException e) {
throw new CoreRuntimeException(e.getMessage());
}
}
示例4: handle
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
private Object handle(Request req) throws Throwable {
String className = req.getClassName();
String methodName = req.getMethodName();
Class<?>[] parameterTypes = req.getParameterTypes();
Object[] parameters = req.getParameters();
//new object
Class<?> clazz = Class.forName(className);
ConstructorAccess<?> constructorAccess = ConstructorAccess.get(clazz);
Object invokeObject = constructorAccess.newInstance();
//get method access
MethodAccess methodAccess = MethodAccess.get(clazz);
Object result = methodAccess.invoke(invokeObject, methodName, parameterTypes, parameters);
return result;
}
示例5: GetServer
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public static Server GetServer(String clazzName, PublishModule publishModule) throws ClassNotFoundException {
Class<?> clazz;
try {
clazz = Class.forName(clazzName);
} catch (ClassNotFoundException e) {
throw new ClassNotFoundException(clazzName + " not found");
}
ConstructorAccess access = ConstructorAccess.get(clazz);
Object o = access.newInstance();
return null;
}
示例6: getConstructorAccess
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
private ConstructorAccess<T> getConstructorAccess(final Class<T> cls) throws SecurityException {
ConstructorAccess<?> constructorAccess = clsConstructorPool.get(cls);
if (constructorAccess == null) {
constructorAccess = ConstructorAccess.get(cls);
clsConstructorPool.put(cls, constructorAccess);
}
return (ConstructorAccess<T>) constructorAccess;
}
示例7: ConstructorAccessBenchmark
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public ConstructorAccessBenchmark () throws Exception {
int count = 1000000;
Object[] dontCompileMeAway = new Object[count];
Class type = SomeClass.class;
ConstructorAccess<SomeClass> access = ConstructorAccess.get(type);
for (int i = 0; i < 100; i++)
for (int ii = 0; ii < count; ii++)
dontCompileMeAway[ii] = access.newInstance();
for (int i = 0; i < 100; i++)
for (int ii = 0; ii < count; ii++)
dontCompileMeAway[ii] = type.newInstance();
warmup = false;
for (int i = 0; i < 100; i++) {
start();
for (int ii = 0; ii < count; ii++)
dontCompileMeAway[ii] = access.newInstance();
end("ConstructorAccess");
}
for (int i = 0; i < 100; i++) {
start();
for (int ii = 0; ii < count; ii++)
dontCompileMeAway[ii] = type.newInstance();
end("Reflection");
}
chart("Constructor");
}
示例8: connected
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public void connected(Connection connection) {
ConnectionEventHandler handler = ConstructorAccess.get(connectionEventHandler).newInstance();
User sender = new User();
sender.id = connection.getID();
sender.isAdmin = false;
sender.isItMe = true;
sender.isPlayer = false;
handler.sender = sender;
handler.onConnected();
userManager.map.put(sender.id, sender);
}
示例9: disconnected
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public void disconnected(Connection connection) {
ConnectionEventHandler handler = ConstructorAccess.get(connectionEventHandler).newInstance();
User sender = userManager.map.get(connection.getID());
handler.sender = sender;
handler.onDisconnected();
handler.sendLeaveRoomResponse();
userManager.map.remove(sender.id);
}
示例10:
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public static <T> T $(Class<T> pageObject) {
return ConstructorAccess.get(pageObject).newInstance();
}
示例11: idle
import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public void idle(Connection connection) {
ConnectionEventHandler handler = ConstructorAccess.get(connectionEventHandler).newInstance();
User sender = userManager.map.get(connection.getID());
handler.sender = sender;
handler.onIdle();
}