本文整理匯總了Java中org.vertx.java.core.Vertx類的典型用法代碼示例。如果您正苦於以下問題:Java Vertx類的具體用法?Java Vertx怎麽用?Java Vertx使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vertx類屬於org.vertx.java.core包,在下文中一共展示了Vertx類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Variables
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public Variables(
final JsonObject nodeConfig,
final Vertx vertx) {
//
m_systemEnv = new ConcurrentHashMap();
m_systemEnv.putAll(System.getenv());
//
m_systemProps = new ConcurrentHashMap();
Properties props = System.getProperties();
for (Entry<Object, Object> entry : props.entrySet()) {
m_systemProps.put(entry.getKey(), entry.getValue());
}
//
m_vertx = vertx;
//
m_nodeName = nodeConfig.getString(CONF_KEY_NODE_NAME, "");
m_clusterName = nodeConfig.getString(CONF_KEY_CLUSTER_NAME, "");
m_spikexHome = nodeConfig.getString(CONF_KEY_HOME_PATH, "");
m_spikexConf = nodeConfig.getString(CONF_KEY_CONF_PATH, "");
m_spikexData = nodeConfig.getString(CONF_KEY_DATA_PATH, "");
m_spikexTmp = nodeConfig.getString(CONF_KEY_TMP_PATH, "");
m_chainName = nodeConfig.getString(CONF_KEY_CHAIN_NAME, "");
m_hostName = HostOs.hostName();
}
示例2: EPLiteConnection
import org.vertx.java.core.Vertx; //導入依賴的package包/類
/**
* Initializes a new org.etherpad_lite_client.EPLiteConnection object.
* @param vertx vertx
* @param url an absolute url, including protocol, to the EPL api
* @param apiKey the API Key
* @param apiVersion the API version
*/
public EPLiteConnection(Vertx vertx, String url, String apiKey, String apiVersion, Boolean trustAll) {
this.uri = URI.create(url);
this.apiKey = apiKey;
this.apiVersion = apiVersion;
final int port = (uri.getPort() > 0) ? uri.getPort() : ("https".equals(uri.getScheme()) ? 443 : 80);
this.httpClient = vertx.createHttpClient()
.setHost(uri.getHost())
.setPort(port)
.setVerifyHost(false)
// fixme Warning jvm knows no AC, trusted parameter used, but MITM attacks are feasible
.setTrustAll(trustAll)
.setMaxPoolSize(16)
.setSSL("https".equals(uri.getScheme()))
.setKeepAlive(false);
}
示例3: EtherpadHelper
import org.vertx.java.core.Vertx; //導入依賴的package包/類
/**
* Constructor
* @param collection Mongo collection to request
* @param etherpadUrl Etherpad service internal URL
* @param etherpadApiKey Etherpad API key
* @param etherpadPublicUrl Etherpad service public URL
*/
public EtherpadHelper(Vertx vertx, String collection, String etherpadUrl, String etherpadApiKey, String etherpadPublicUrl, Boolean trustAll, String domain) {
super(collection);
this.etherpadCrudService = new MongoDbCrudService(collection);
if (null == etherpadUrl || etherpadUrl.trim().isEmpty()) {
log.error("[Collaborative Editor] Error : Module property 'etherpad-url' must be defined");
}
if (null == etherpadApiKey || etherpadApiKey.trim().isEmpty()) {
log.error("[Collaborative Editor] Error : Module property 'etherpad-api-key' must be defined");
}
if (null == etherpadPublicUrl || etherpadPublicUrl.trim().isEmpty()) {
this.etherpadPublicUrl = etherpadUrl;
log.error("[Collaborative Editor] Warning : Module property 'etherpad-public-url' is not defined. Using 'etherpad-url'...");
} else {
this.etherpadPublicUrl = etherpadPublicUrl;
}
if (null == domain || domain.trim().isEmpty()) {
log.error("[Collaborative Editor] Error : Module property 'etherpad-domain' must be defined");
}
this.domain = domain;
this.client = new EPLiteClient(vertx, etherpadUrl, etherpadApiKey, trustAll);
}
示例4: checkAndCreateHttpServer
import org.vertx.java.core.Vertx; //導入依賴的package包/類
private HttpServer checkAndCreateHttpServer(String host, int port) {
if (isAddressAlreadyInUse(host, port)) {
System.err.println(host + ":" + port + " isAddressAlreadyInUse!");
System.exit(1);
return null;
}
try {
this.host = host;
this.port = port;
Vertx vertx = VertxFactory.newVertx();
return vertx.createHttpServer();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例5: testForwardSendNoReply
import org.vertx.java.core.Vertx; //導入依賴的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));
}
示例6: testForwardSendReply
import org.vertx.java.core.Vertx; //導入依賴的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));
}
示例7: testForwardSendInvalidAddress
import org.vertx.java.core.Vertx; //導入依賴的package包/類
@Test(expected = WebApplicationException.class)
public void testForwardSendInvalidAddress() throws MalformedURLException {
String invalidAddress = "illegaladdress";
String allowedAddress = "validaddress";
String message = "HelloWorld";
String responseMediaType = "application/xml";
long timeout = 60000;
JsonObject config = createConfig(allowedAddress, timeout);
HttpEventBusBridgeService service = new HttpEventBusBridgeService();
EventBusBridgeRequest request = createRequest(invalidAddress, message, null, responseMediaType);
Vertx vertx = Mockito.mock(Vertx.class);
Container container = Mockito.mock(Container.class);
when(container.config()).thenReturn(config);
service.forward(request, EventBusInstruction.send, vertx, container);
}
示例8: testForwardPublish
import org.vertx.java.core.Vertx; //導入依賴的package包/類
@Test
public void testForwardPublish() 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.publish, vertx, container);
verify(eventBus, times(1)).publish(address, (Object) message);
}
示例9: testForwardPublishInvalidAddress
import org.vertx.java.core.Vertx; //導入依賴的package包/類
@Test(expected = WebApplicationException.class)
public void testForwardPublishInvalidAddress() throws MalformedURLException {
String invalidAddress = "illegaladdress";
String allowedAddress = "validaddress";
String message = "HelloWorld";
String responseMediaType = "application/xml";
long timeout = 60000;
JsonObject config = createConfig(allowedAddress, timeout);
HttpEventBusBridgeService service = new HttpEventBusBridgeService();
EventBusBridgeRequest request = createRequest(invalidAddress, message, null, responseMediaType);
Vertx vertx = Mockito.mock(Vertx.class);
Container container = Mockito.mock(Container.class);
when(container.config()).thenReturn(config);
service.forward(request, EventBusInstruction.publish, vertx, container);
}
示例10: SendInBlueSender
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public SendInBlueSender(Vertx vertx, Container container, JsonObject config)
throws InvalidConfigurationException, URISyntaxException {
super(vertx, container);
if (config != null && isNotEmpty(config.getString("uri")) && isNotEmpty(config.getString("api-key"))) {
URI uri = new URI(config.getString("uri"));
httpClient = vertx.createHttpClient()
.setHost(uri.getHost())
.setPort(uri.getPort())
.setMaxPoolSize(16)
.setSSL("https".equals(uri.getScheme()))
.setKeepAlive(false);
apiKey = config.getString("api-key");
dedicatedIp = config.getString("ip");
splitRecipients = config.getBoolean("split-recipients", false);
mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
} else {
throw new InvalidConfigurationException("missing.parameters");
}
}
示例11: NotificationHelper
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public NotificationHelper(Vertx vertx, Container container) {
this.log = container.logger();
this.render = new Renders(vertx, container);
final Object encodedEmailConfig = vertx.sharedData().getMap("server").get("emailConfig");
String defaultMail = "[email protected]";
String defaultHost = "http://localhost:8009";
if(encodedEmailConfig != null){
JsonObject emailConfig = new JsonObject(encodedEmailConfig.toString());
defaultMail = emailConfig.getString("email", defaultMail);
defaultHost = emailConfig.getString("host", defaultHost);
}
this.senderEmail = container.config().getString("email", defaultMail);
this.host = container.config().getString("host", defaultHost);
}
示例12: sendFile
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public static void sendFile(Vertx vertx, String uri, int port, String content,
MultiMap headers, String filename,
String contentType, Handler<HttpClientResponse> handler) {
HttpClientRequest req = vertx.createHttpClient().setPort(port).post(uri, handler);
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";
Buffer buffer = new Buffer();
final String body = "--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\""+ filename +"\"\r\n" +
"Content-Type: " + contentType + "\r\n" +
"\r\n" +
content + "\r\n" +
"--" + boundary + "--\r\n";
buffer.appendString(body);
req.headers().add(headers);
req.headers().set("content-length", String.valueOf(buffer.length()));
req.headers().set("content-type", "multipart/form-data; boundary=" + boundary);
req.write(buffer).end();
}
示例13: init
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public void init(Vertx vertx, Container container, RouteMatcher rm,
Map<String, SecuredAction> securedActions) {
super.vertx = vertx;
super.container = container;
super.rm = rm;
super.securedActions = securedActions;
super.eb = Server.getEventBus(vertx);
if (pathPrefix == null) {
super.pathPrefix = Server.getPathPrefix(container.config());
}
if (rm != null) {
loadRoutes();
} else {
log.error("RouteMatcher is null.");
}
}
示例14: TTLSet
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public TTLSet(final long ttl, Vertx vertx, long clearPeriod) {
this.ttl = ttl;
if (vertx != null && clearPeriod > 0l) {
vertx.setPeriodic(clearPeriod, new Handler<Long>() {
@Override
public void handle(Long aLong) {
final long now = System.currentTimeMillis();
final Map<T, Long> copyMap = (Map<T, Long>) map.clone();
for (Map.Entry<T, Long> e: copyMap.entrySet()) {
if (now > (e.getValue() + ttl)) {
map.remove(e.getKey());
}
}
}
});
}
}
示例15: PersistantBuffer
import org.vertx.java.core.Vertx; //導入依賴的package包/類
public PersistantBuffer(Vertx vertx, Buffer buffer, String id, String destination) {
this.buffer = buffer;
this.vertx = vertx;
this.filePath = destination + File.separator + PersistantBuffer.class.getSimpleName() + "-" + id;
this.length = buffer.length();
if (buffer.length() > persistanceThreshold) {
persist(new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
if (ar.failed()) {
log.error("Error persisting buffer", ar.cause());
}
}
});
}
}