List of usage examples for io.vertx.core.spi VerticleFactory removePrefix
static String removePrefix(String identifer)
From source file:com.chibchasoft.vertx.spring.SpringVerticleFactory.java
License:Open Source License
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { Objects.requireNonNull(verticleName, "Verticle Name is required"); verticleName = VerticleFactory.removePrefix(verticleName); Objects.requireNonNull(verticleName, "Verticle Name must be more than just the prefix"); ApplicationContext ctx = getApplicationContext(); if (!ctx.containsBean(verticleName)) throw new IllegalArgumentException(String.format("No bean found for %s", verticleName)); if (!ctx.isPrototype(verticleName)) throw new IllegalArgumentException( String.format("Bean %s needs to be of Prototype scope", verticleName)); return (Verticle) ctx.getBean(verticleName); }
From source file:com.dinstone.vertx.verticle.SpringVerticleFactory.java
License:Apache License
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { // Our convention in this example is to give the class name as verticle name String clazz = VerticleFactory.removePrefix(verticleName); return (Verticle) applicationContext.getBean(Class.forName(clazz)); }
From source file:com.englishtown.vertx.guice.GuiceVerticleFactory.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . j av a 2 s .co m*/ */ @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); // Use the provided class loader to create an instance of GuiceVerticleLoader. This is necessary when working with vert.x IsolatingClassLoader @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(GuiceVerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class); if (ctor == null) { throw new IllegalStateException("Could not find GuiceVerticleLoader constructor"); } return ctor.newInstance(verticleName, classLoader); }
From source file:com.englishtown.vertx.hk2.HK2VerticleFactory.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . j av a 2 s . com*/ */ @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); // Use the provided class loader to create an instance of HK2VerticleLoader. This is necessary when working with vert.x IsolatingClassLoader @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); }
From source file:com.jiabangou.ninja.vertx.standalone.guice.GuiceVerticleFactory.java
License:Open Source License
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); // Use the provided class loader to create an instance of GuiceVerticleLoader. This is necessary when working with vert.x IsolatingClassLoader @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(GuiceVerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, Injector.class); if (ctor == null) { throw new IllegalStateException("Could not find GuiceVerticleLoader constructor"); }//from w ww .ja v a 2 s. co m return ctor.newInstance(verticleName, classLoader, getInjector()); }
From source file:io.knotx.launcher.KnotxModuleVerticleFactory.java
License:Apache License
@Override public void resolve(String id, DeploymentOptions deploymentOptions, ClassLoader classLoader, Future<String> resolution) { String identifier = VerticleFactory.removePrefix(id); String descriptorFile = identifier + ".json"; try {/* w w w. j av a 2 s . com*/ JsonObject descriptor = readDescriptor(classLoader, descriptorFile); String main = readVerticleMainClass(descriptor, descriptorFile); // Any options specified in the module config will override anything specified at deployment time // Options and Config specified in knotx starter JSON will override those configurations JsonObject depOptions = deploymentOptions.toJson(); JsonObject depConfig = depOptions.getJsonObject(CONFIG_KEY, new JsonObject()); JsonObject knotOptions = descriptor.getJsonObject(OPTIONS_KEY, new JsonObject()); JsonObject knotConfig = knotOptions.getJsonObject(CONFIG_KEY, new JsonObject()); depOptions.mergeIn(knotOptions); depOptions.put(CONFIG_KEY, JsonObjectUtil.deepMerge(knotConfig, depConfig)); JsonObject serviceDescriptor = new JsonObject().put(OPTIONS_KEY, depOptions); // Any options or config provided by system properties will override anything specified // at deployment time and on starter Json config serviceDescriptor = overrideConfigWithSystemProperties(identifier, serviceDescriptor); deploymentOptions.fromJson(serviceDescriptor.getJsonObject(OPTIONS_KEY)); resolution.complete(main); } catch (Exception e) { resolution.fail(e); } }
From source file:net.kuujo.vertigo.deployment.ComponentFactory.java
License:Apache License
@Override public void resolve(String identifier, DeploymentOptions options, ClassLoader classLoader, Future<String> resolution) { identifier = VerticleFactory.removePrefix(identifier); JsonObject config = Configs.load(identifier); String main = config.getString("identifier"); if (main == null) { throw new VertxException(identifier + " does not contain a identifier field"); }//from ww w . j av a2 s . c o m JsonObject deployment = config.getJsonObject("deployment"); if (deployment != null) { if (deployment.containsKey("worker")) { options.setWorker(deployment.getBoolean("worker")); } if (deployment.containsKey("multi-threaded")) { options.setMultiThreaded(deployment.getBoolean("multi-threaded")); } } resolution.complete(main); }
From source file:org.apache.tamaya.vertx.ConfiguredVerticleFactory.java
License:Apache License
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); Class clazz;/*from www. j av a2s.c o m*/ if (verticleName.endsWith(".java")) { CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, verticleName); String className = compilingLoader.resolveMainClassName(); clazz = compilingLoader.loadClass(className); } else { clazz = classLoader.loadClass(verticleName); } Verticle instance = (Verticle) clazz.getConstructor().newInstance(); ConfigurationInjector.getInstance(classLoader).configure(instance); return instance; }
From source file:org.jacpfx.vertx.spring.SpringVerticleFactory.java
License:Open Source License
@Override public synchronized Verticle createVerticle(final String verticleName, final ClassLoader classLoader) throws Exception { final String className = VerticleFactory.removePrefix(verticleName); Class<?> clazz;//from w w w . j a va 2s .com if (className.endsWith(SUFFIX)) { CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, className); clazz = compilingLoader.loadClass(compilingLoader.resolveMainClassName()); } else { clazz = classLoader.loadClass(className); } return createVerticle(clazz, classLoader); }