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


Java EventBus类代码示例

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


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

示例1: NagiosNrdpHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public NagiosNrdpHandler(
        final AbstractFilter filter,
        final JsonObject config,
        final EventBus eventBus,
        final JsonArray tags) {

    m_processor = new NagiosNrdpProcessor(
            filter,
            config.getObject(CONF_KEY_NRDP_CONFIG, new JsonObject()),
            eventBus,
            tags);

    try {
        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        m_parser = saxParserFactory.newSAXParser();
    } catch (ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("Failed to create XML parser for NRDP handler", e);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:20,代码来源:NagiosNrdpHandler.java

示例2: AsyncFileWatcher

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public AsyncFileWatcher(
        final EventBus eventBus,
        final FileSystem fileSystem,
        final List<Path> paths,
        final boolean readChunks,
        final int maxReadSize) {

    m_eventBus = eventBus;
    m_fileSystem = fileSystem;
    m_paths = paths;
    m_pointers = new ConcurrentHashMap();
    m_readChunks = readChunks;
    m_maxReadSize = maxReadSize;

    // Populate pointers
    for (Path path : paths) {
        m_pointers.put(path, new FilePointer(null, 0L));
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:20,代码来源:AsyncFileWatcher.java

示例3: VertxFileHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public VertxFileHandler(
        final AbstractFilter filter,
        final EventBus eventBus,
        final String encoding,
        final String delimiter,
        final int minReadSize,
        final int maxReadSize,
        final boolean startAtEof) {

    m_filter = filter;
    m_eventBus = eventBus;
    m_encoding = encoding;
    m_delimiter = delimiter;
    m_minReadSize = minReadSize;
    m_maxReadSize = maxReadSize;
    m_startAtEof = startAtEof;
    m_offset = new ConcurrentHashMap();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:19,代码来源:VertxFileHandler.java

示例4: testForwardSendNoReply

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
@Test
public void testForwardSendNoReply() throws MalformedURLException {
	String address = "testaddress";
	String message = "HelloWorld";
	String responseMediaType = "application/xml";
	long timeout = 60000;
	JsonObject config = createConfig(address, timeout);
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(address, message, null, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	EventBus eventBus = Mockito.mock(EventBus.class);
	when(vertx.eventBus()).thenReturn(eventBus);
	when(eventBus.send(address, message)).thenReturn(eventBus);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.send, vertx, container);
	verify(eventBus, times(1)).sendWithTimeout(eq(address), eq((Object) message), eq(timeout), any(NoOpResponseHandler.class));
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:22,代码来源:HttpEventBusBridgeServiceTest.java

示例5: testForwardSendReply

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
@Test
public void testForwardSendReply() throws MalformedURLException {
	String address = "testaddress";
	String message = "HelloWorld";
	URL responseUrl = new URL("http://localhost:8080/ebbresponse");
	String responseMediaType = "application/xml";
	HttpClient httpClient = Mockito.mock(HttpClient.class);
	long timeout = 60000;
	JsonObject config = createConfig(address, timeout);
	
	HttpEventBusBridgeService service = new HttpEventBusBridgeService();
	EventBusBridgeRequest request = createRequest(address, message, responseUrl, responseMediaType);
	
	Vertx vertx = Mockito.mock(Vertx.class);
	EventBus eventBus = Mockito.mock(EventBus.class);
	when(vertx.eventBus()).thenReturn(eventBus);
	when(eventBus.send(address, message)).thenReturn(eventBus);
	when(vertx.createHttpClient()).thenReturn(httpClient);
	
	Container container = Mockito.mock(Container.class); 
	when(container.config()).thenReturn(config);

	service.forward(request, EventBusInstruction.send, vertx, container);
	verify(eventBus, times(1)).sendWithTimeout(eq(address), eq((Object)message), eq(timeout), any(HttpResponseHandler.class));
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:26,代码来源:HttpEventBusBridgeServiceTest.java

示例6: routeMatcher

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public RouteMatcher routeMatcher(final EventBus eb) {
        RouteMatcher router = new RouteMatcher();
        
        router.get("/command/:id", new Handler<HttpServerRequest>() {
            public void handle(final HttpServerRequest req) {
                System.out.println("Command introduced: " + req.params().get("id"));
                HashMap<String, Object> maps = new HashMap<>();
                maps.put("socketID", "Alienware");
                maps.put("command", req.params().get("id"));
                JsonObject json = new JsonObject(maps);
                eb.publish("send-ws-message", json);
                req.response().end();
//                req.response().putHeader("Content-Type", "application/json");
//                req.response().end(data.encodePrettily());
                // and call the event we want to use
                //eb.send("mongodb-persistor", json, new ReplyHandler(req, data));
            }
        });
        
        return router;
    }
 
开发者ID:jlarriba,项目名称:jdashboard,代码行数:22,代码来源:RestFacade.java

示例7: gridfsReadFile

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public static void gridfsReadFile(String id, final EventBus eb,
		final String gridfsAddress, final Handler<Buffer> handler) {
	JsonObject find = new JsonObject();
	find.putString("action", "findone");
	find.putObject("query", new JsonObject("{ \"_id\": \"" + id + "\"}"));
	byte [] header = null;
	try {
		header = find.toString().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		handler.handle(new Buffer());
	}
	if (header != null) {
		Buffer buf = new Buffer(header);
		buf.appendInt(header.length);
		eb.send(gridfsAddress, buf, new  Handler<Message>() {
		@Override
		public void handle(Message res) {
			if (res.body() instanceof Buffer) {
				handler.handle((Buffer) res.body());
			} else {
				handler.handle(null);
			}
		}
	});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:27,代码来源:FileUtils.java

示例8: send

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
@Override
public EventBus send(String address, Object message,
		final Handler<Message> replyHandler) {
	final String logMessageId = sendLogwithResponse(address, message.toString());
	if (replyHandler != null) {
		return eb.send(address, message, new Handler<Message>() {

			@Override
			public void handle(Message event) {
				responseLog(logMessageId, event.body());
				replyHandler.handle(event);
			}
		});
	} else {
		return eb.send(address, message, null);
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:18,代码来源:EventBusWithLogger.java

示例9: send

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
@Override
public EventBus send(String address, Object message,
		final Handler<Message> replyHandler) {
	final String logMessageId = sendLogwithResponse(address, message);
	if (replyHandler != null) {
		return eb.send(address, message, new Handler<Message>() {

			@Override
			public void handle(Message event) {
				responseLog(logMessageId, event.body());
				replyHandler.handle(event);
			}
		});
	} else {
		return eb.send(address, message, replyHandler);
	}
}
 
开发者ID:web-education,项目名称:mongodb-helper,代码行数:18,代码来源:EventBusWithMongoDBLogger.java

示例10: start

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public void start(final EventBus eventBus) {
    //
    // Build Mustasche templates
    //
    buildTemplates();
    //
    // Start listening for events
    //
    m_logger.info("Listening on local address: {}", m_config.getLocalAddress());
    eventBus.registerLocalHandler(m_config.getLocalAddress(), this);
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:12,代码来源:Notifier.java

示例11: CollectdJsonHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public CollectdJsonHandler(
        final AbstractFilter filter,
        final JsonObject config,
        final EventBus eventBus,
        final JsonArray tags) {

    m_filter = filter;
    m_config = config.getObject(CONF_KEY_COLLECTD_CONFIG, new JsonObject());
    m_eventBus = eventBus;
    m_tags = tags;
    m_parser = new JSONParser();
    m_mappings = new HashMap();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:14,代码来源:CollectdJsonHandler.java

示例12: ThingseeHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public ThingseeHandler(
        final AbstractFilter filter,
        final JsonObject config,
        final EventBus eventBus,
        final JsonArray tags) {

    m_filter = filter;
    m_config = config;
    m_eventBus = eventBus;
    m_tags = tags;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:12,代码来源:ThingseeHandler.java

示例13: NagiosNrdpProcessor

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
public NagiosNrdpProcessor(
        final AbstractFilter filter,
        final JsonObject config,
        final EventBus eventBus,
        final JsonArray tags) {

    m_filter = filter;
    m_config = config;
    m_eventBus = eventBus;
    m_tags = tags;
    m_serviceConfigs = new ArrayList();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:13,代码来源:NagiosNrdpProcessor.java

示例14: NsqMessageHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
private NsqMessageHandler(
        final EventBus eventBus,
        final String address) {

    m_eventBus = eventBus;
    m_address = address;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:8,代码来源:Nsq.java

示例15: JsonHandler

import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
private JsonHandler(
        final AbstractFilter filter,
        final EventBus eventBus,
        final JsonArray tags) {

    m_filter = filter;
    m_eventBus = eventBus;
    m_tags = tags;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:10,代码来源:HttpServer.java


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