本文整理汇总了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);
}
}
示例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));
}
}
示例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();
}
示例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));
}
示例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));
}
示例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;
}
示例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);
}
}
});
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
示例14: NsqMessageHandler
import org.vertx.java.core.eventbus.EventBus; //导入依赖的package包/类
private NsqMessageHandler(
final EventBus eventBus,
final String address) {
m_eventBus = eventBus;
m_address = address;
}
示例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;
}