Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jannehietamaki/vert.x
...
head fork: jannehietamaki/vert.x
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
View
3  vertx-examples/src/main/java/sourcemod/mods/test-mod-v1.0/mod.json
@@ -0,0 +1,3 @@
+{
+ "main": "org/foo/MyMain.java"
+}
View
17 vertx-examples/src/main/java/sourcemod/mods/test-mod-v1.0/org/foo/MyMain.java
@@ -0,0 +1,17 @@
+package org.foo;
+
+import org.vertx.java.core.Handler;
+import org.vertx.java.core.net.NetSocket;
+import org.vertx.java.core.streams.Pump;
+import org.vertx.java.deploy.Verticle;
+
+public class MyMain extends Verticle {
+
+ public void start() {
+ vertx.createNetServer().connectHandler(new Handler<NetSocket>() {
+ public void handle(final NetSocket socket) {
+ Pump.createPump(socket, socket).start();
+ }
+ }).listen(1234);
+ }
+}
View
32 vertx-lang/vertx-lang-java/src/main/java/org/vertx/java/deploy/impl/java/JavaSourceContext.java
@@ -37,23 +37,25 @@
public class JavaSourceContext {
private static final String FILE_SEP = System.getProperty("file.separator");
private final static String REMOVE_COMMENTS_REGEXP = "(?://.*)|(/\\*(?:.|[\\n\\r])*?\\*/)";
-
+
private final String className;
private final File sourceRoot;
-
+
public JavaSourceContext(File file) {
String packageName = parsePackage(file);
File rootDirectory = file.getParentFile();
if(packageName != null) {
- for(String token : packageName.split("\\.")) {
- if(!token.equals(rootDirectory.getName())) {
- throw new RuntimeException("Package structure does not match directory structure: " + token + " != " + rootDirectory.getName());
- }
- rootDirectory = rootDirectory.getParentFile();
- }
+ String[] pathTokens = packageName.split("\\.");
+ for(int i = pathTokens.length - 1; i >= 0; i--) {
+ String token = pathTokens[i];
+ if(!token.equals(rootDirectory.getName())) {
+ throw new RuntimeException("Package structure does not match directory structure: " + token + " != " + rootDirectory.getName());
+ }
+ rootDirectory = rootDirectory.getParentFile();
+ }
}
sourceRoot = rootDirectory;
-
+
String fileName = file.getName();
String className = fileName.substring(0, fileName.length() - Kind.SOURCE.extension.length());
if(packageName != null) {
@@ -61,20 +63,20 @@ public JavaSourceContext(File file) {
}
this.className = className;
}
-
+
public File getSourceRoot() {
return sourceRoot;
}
-
+
public String getClassName() {
return className;
}
-
- /*
+
+ /*
* Parse package definition from a Java source file:
* First remove all comments, split file into lines, find first non-empty line
* Then, if the line starts with keyword "package", parse the package definition from it.
- *
+ *
*/
private String parsePackage(File file) {
try {
@@ -95,4 +97,4 @@ private String parsePackage(File file) {
throw new RuntimeException(e);
}
}
-}
+}

No commit comments for this range

Something went wrong with that request. Please try again.