当前位置: 首页>>代码示例>>Java>>正文


Java ConstructorAccess类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:Panda-Programming-Language,项目名称:Panda,代码行数:22,代码来源:ParserRegistrationLoader.java

示例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);
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:8,代码来源:Instance.java

示例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());
    }
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:11,代码来源:NativeScript.java

示例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;
}
 
开发者ID:Yaccc,项目名称:xRPC,代码行数:16,代码来源:NettyServerHander.java

示例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;
}
 
开发者ID:Yaccc,项目名称:xRPC,代码行数:13,代码来源:SimpleStrategyServerFactory.java

示例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;
}
 
开发者ID:landawn,项目名称:AbacusUtil,代码行数:11,代码来源:ReflectASM.java

示例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");
}
 
开发者ID:EsotericSoftware,项目名称:reflectasm,代码行数:31,代码来源:ConstructorAccessBenchmark.java

示例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);
}
 
开发者ID:macalimlim,项目名称:kryonet-server,代码行数:12,代码来源:KryonetServerListener.java

示例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);
}
 
开发者ID:macalimlim,项目名称:kryonet-server,代码行数:9,代码来源:KryonetServerListener.java

示例10:

import com.esotericsoftware.reflectasm.ConstructorAccess; //导入依赖的package包/类
public static <T> T $(Class<T> pageObject) {
	return ConstructorAccess.get(pageObject).newInstance();
}
 
开发者ID:sskorol,项目名称:selenium-camp-samples,代码行数:4,代码来源:PageObjectSupplier.java

示例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();
}
 
开发者ID:macalimlim,项目名称:kryonet-server,代码行数:7,代码来源:KryonetServerListener.java


注:本文中的com.esotericsoftware.reflectasm.ConstructorAccess类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。