Skip to content

Instantly share code, notes, and snippets.

final Context ctx = vertx.currentContext();
otherLibrary.doSomethingAsync("foo", new Runnable() {
public void run() {
// This will be executed on the other library's thread so we need to make sure the result is done on the correct context
ctx.runOnContext(new Handler<Void>() {
public void handle(Void v) {
// Now we are on the right context - use the Vert.x API as normal
request.response().end("blah");
}
Consider this sequence of events (this is what we currently do)
1. Construct a map M
2. Create a JsonObject J1 that backs the map M
3. Send J1 on the event bus
4. Vert.x calls copy() which makes a deep copy of J1, called J2
5. J2 is passed to the handler in another verticle
6. J2 is mutated in the other verticle (e.g. setString("foo", "bar");
7. That change is not visible to J1 since they do not back the same map
import org.vertx.java.core.Handler;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClientResponse;
import org.vertx.java.core.http.HttpClient;
import org.vertx.java.platform.Verticle;
public class ClientExample extends Verticle {
public void start() {
HttpClient client = vertx.createHttpClient().setPort(8080).setHost("localhost").setKeepAlive(false);
Plan for actually getting shit done
===================================
1. Do not read emails or answer forum questions until 5pm every day. That way they don't piss me off for the rest of the day.
2. Set aside Friday afternoons for shitty process stuff that I can't completely avoid or delegate. That way it doesn't intrude on important work or make me depressed and not want to do anything for the rest of the week.
3. Spend rest of time actually getting shit done and creating cool stuff.
4. Profit!
http://www.patheos.com/blogs/friendlyatheist/2014/06/25/what-made-saudi-arabia-panic-at-the-un-human-rights-council/
package foo;
import org.mvel2.templates.TemplateRuntime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class CompilerBug {
public static void main(String[] args) {
jjs> var set = new java.util.HashSet();
jjs> set.add("one");
true
jjs> set.add("two");
true
jjs> set.add("three");
true
jjs> set[0];
null
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>sample.plugin</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Sample Parameter-less Maven Plugin</name>
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
RouteMatcher rm = new RouteMatcher();
rm.post("/" + PRIMARY_RESOURCE + "/" + VERSION + "/"
+ SECONDARY_RESOURCE, new Handler<HttpServerRequest>() {
@Override
public void handle(final HttpServerRequest req) {
MultiMap params = req.headers();
boolean isuserValidated = false;
try {