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


Java Handler类代码示例

本文整理汇总了Java中se.sics.kompics.Handler的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Handler类属于se.sics.kompics包,在下文中一共展示了Handler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RespawnerComponent

import se.sics.kompics.Handler; //导入依赖的package包/类
public RespawnerComponent(RespawnerInit init) {
    final Positive<Network> net = requires(Network.class);

    self = init.self;

    Handler<Start> startHandler = new Handler<Start>() {
        @Override
        public void handle(Start event) {
            System.out.println("Started (" + netAddr + ").");
            byte id = self.getId()[0];
            byte newId = (byte) (id + 1);
            if (newId < NUM_SPAWNS) {
                trigger(new StartVNode(self, netAddr, new byte[]{newId}, schema), net);
                TestUtil.submit(SPAWN_SENT);
            }
            trigger(new StopVNode(self, self), net);
        }
    };
    subscribe(startHandler, control);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:21,代码来源:LauncherTest.java

示例2: ComponentBodyAdapter

import se.sics.kompics.Handler; //导入依赖的package包/类
ComponentBodyAdapter(ResolutionContext context, JDefinedClass clazz) {
    super(context, clazz);
    initBlock = clazz.instanceInit();
    handlerType = (JClass) context.unit._ref(Handler.class);
    posPortType = (JClass) context.unit._ref(Positive.class);
    negPortType = (JClass) context.unit._ref(Negative.class);
    componentType = (JClass) context.unit._ref(Component.class);
    initType = (JClass) context.unit._ref(Init.class);
}
 
开发者ID:kompics,项目名称:kola,代码行数:10,代码来源:ComponentBodyAdapter.java

示例3: startBootstrapClient

import se.sics.kompics.Handler; //导入依赖的package包/类
private void startBootstrapClient() {
    final Component bootstrapClient = create(BootstrapClient.class, new BootstrapCInit(netSelf, config));
    connect(bootstrapClient.getNegative(Timer.class), sharedComponents.getTimer());
    sharedComponents.connectNetwork(bootstrapClient);
    connect(bootPort.getPair(), bootstrapClient.getPositive(Bootstrap.class));
    
    Handler<Bootstrapped> bootHandler = new Handler<Bootstrapped>() {
        @Override
        public void handle(Bootstrapped event) {
            
            trigger(Stop.event, bootstrapClient.control());
            sharedComponents.disconnectNetwork(bootstrapClient);
            disconnect(bootPort.getPair(), bootstrapClient.getPositive(Bootstrap.class));
            disconnect(bootstrapClient.getNegative(Timer.class), sharedComponents.getTimer());
            unsubscribe(this, bootPort);
            
            LOG.debug("{} is bootstrapped", netSelf);
            
            startLUTManager(event);
        }
    };
    subscribe(bootHandler, bootPort);

    // CLIENT only
    for (ComponentHook hook : config.getHostHooks(SystemPhase.BOOTSTRAP_CLIENT)) {
        hook.setUp(sharedComponents, proxy);
    }
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:29,代码来源:HostManager.java

示例4: startBootstrapServer

import se.sics.kompics.Handler; //导入依赖的package包/类
private void startBootstrapServer() {
    final Component bootstrapServer = create(BootstrapServer.class, new BootstrapSInit(netSelf, config));
    connect(bootstrapServer.getNegative(Timer.class), sharedComponents.getTimer());
    sharedComponents.connectNetwork(bootstrapServer);
    connect(bootPort.getPair(), bootstrapServer.getPositive(Bootstrap.class));
    
    Handler<Bootstrapped> bootHandler = new Handler<Bootstrapped>() {
        @Override
        public void handle(Bootstrapped event) {

            trigger(Stop.event, bootstrapServer.control());
            sharedComponents.disconnectNetwork(bootstrapServer);
            disconnect(bootPort.getPair(), bootstrapServer.getPositive(Bootstrap.class));
            disconnect(bootstrapServer.getNegative(Timer.class), sharedComponents.getTimer());
            unsubscribe(this, bootPort);
            
            LOG.debug("{} is bootstrapped", netSelf);
            
            startLUTManager(event);
        }
    };
    subscribe(bootHandler, bootPort);

    // SERVER only
    for (ComponentHook hook : config.getHostHooks(SystemPhase.BOOTSTRAP_SERVER)) {
        hook.setUp(sharedComponents, proxy);
    }
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:29,代码来源:HostManager.java

示例5: SenderComponent

import se.sics.kompics.Handler; //导入依赖的package包/类
public SenderComponent(SenderInit init) {
    final Positive<Network> net = requires(Network.class);

    self = init.self;

    Handler<Start> startHandler = new Handler<Start>() {
        @Override
        public void handle(Start event) {
            System.out.println("Started (" + self + ").");
            trigger(new TestMsg(self, self), net);
            TestUtil.submit(MSG_SENT);
        }
    };
    subscribe(startHandler, control);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:16,代码来源:LauncherTest.java

示例6: doSubscribe

import se.sics.kompics.Handler; //导入依赖的package包/类
@Override
public <E extends KompicsEvent, P extends PortType> void doSubscribe(Handler<E> handler, Port<P> port) {
    subscribe(handler, port);
}
 
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:5,代码来源:MsgRetryComponent.java

示例7: doSubscribe

import se.sics.kompics.Handler; //导入依赖的package包/类
@Override
public <E extends KompicsEvent, P extends PortType> void doSubscribe(Handler<E> handler, Port<P> port) {
 }
 
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:4,代码来源:VodComponentTestCase.java

示例8: doSubscribe

import se.sics.kompics.Handler; //导入依赖的package包/类
public <E extends KompicsEvent, P extends PortType> void doSubscribe(Handler<E> handler, Port<P> port); 
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:2,代码来源:ComponentDelegator.java


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