package io.vertx.core.impl;
import io.vertx.core.Verticle;
import io.vertx.core.impl.verticle.CompilingClassLoader;
import io.vertx.core.spi.VerticleFactory;
public class JavaVerticleFactory implements VerticleFactory {
@Override
public String prefix() {
return "java";
}
@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
verticleName = VerticleFactory.removePrefix(verticleName);
Class clazz;
if (verticleName.endsWith(".java")) {
CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, verticleName);
String className = compilingLoader.resolveMainClassName();
clazz = compilingLoader.loadClass(className);
} else {
clazz = classLoader.loadClass(verticleName);
}
return (Verticle) clazz.newInstance();
}
}