@Override public Route.Collection use(final Class<?> routeClass) { return use("", routeClass); }
/** * Bind the provided type: * * <pre> * { * bind(MyInterface.class); * } * </pre> * * @param type Service interface. * @param <T> Service type. * @return This instance. */ public <T> Jooby bind(final Class<T> type) { use((env, conf, binder) -> { binder.bind(type); }); return this; }
/** * Bind the provided abstract type to the given implementation: * * <pre> * { * bind(MyInterface.class, MyImplementation.class); * } * </pre> * * @param type Service interface. * @param implementation Service implementation. * @param <T> Service type. * @return This instance. */ public <T> Jooby bind(final Class<T> type, final Class<? extends T> implementation) { use((env, conf, binder) -> { binder.bind(type).to(implementation); }); return this; }
/** * Creates a new application and prefix all the names of the routes with the given prefix. Useful, * for dynamic/advanced routing. See {@link Route.Chain#next(String, Request, Response)}. * * @param prefix Route name prefix. */ public Jooby(final String prefix) { this.prefix = prefix; use(server); this.classname = classname(getClass().getName()); }
/** * Set/specify a custom .conf file, useful when you don't want a <code>application.conf</code> * file. * * @param path File system location. * @return This jooby instance. */ public Jooby conf(final File path) { this.confname = path.getName(); use(ConfigFactory.parseFile(path)); return this; }
/** * Set/specify a custom .conf file, useful when you don't want a <code>application.conf</code> * file. * * @param path Classpath location. * @return This jooby instance. */ public Jooby conf(final String path) { this.confname = path; use(ConfigFactory.parseResources(path)); return this; }
/** * Bind the provided abstract type to the given implementation: * * <pre> * { * bind(MyInterface.class, MyImplementation::new); * } * </pre> * * @param type Service interface. * @param implementation Service implementation. * @param <T> Service type. * @return This instance. */ public <T> Jooby bind(final Class<T> type, final Supplier<T> implementation) { use((env, conf, binder) -> { binder.bind(type).toInstance(implementation.get()); }); return this; }
/** * Bind the provided type and object that requires some type of configuration: * * <pre>{@code * { * bind(MyService.class, conf -> new MyService(conf.getString("service.url"))); * } * }</pre> * * @param type Service type. * @param provider Service provider. * @param <T> Service type. * @return This instance. */ public <T> Jooby bind(final Class<T> type, final Function<Config, ? extends T> provider) { use((env, conf, binder) -> { T service = provider.apply(conf); binder.bind(type).toInstance(service); }); return this; }
@Override public Jooby use(final Jooby app) { return use(prefixPath(null), app); }
/** * Bind the provided type: * * <pre> * { * bind(new MyService()); * } * </pre> * * @param service Service. * @return This instance. */ @SuppressWarnings({"rawtypes", "unchecked"}) public Jooby bind(final Object service) { use((env, conf, binder) -> { Class type = service.getClass(); binder.bind(type).toInstance(service); }); return this; }
@Override public Jooby use(final String path, final Jooby app) { return use(prefixPath(path), app); }
/** * Bind the provided type and object that requires some type of configuration: * * <pre>{@code * { * bind(conf -> new MyService(conf.getString("service.url"))); * } * }</pre> * * @param provider Service provider. * @param <T> Service type. * @return This instance. */ @SuppressWarnings({"unchecked", "rawtypes"}) public <T> Jooby bind(final Function<Config, T> provider) { use((env, conf, binder) -> { Object service = provider.apply(conf); Class type = service.getClass(); binder.bind(type).toInstance(service); }); return this; }
app.use(new Jooby.Module() { @Override public void configure(final Env mode, final Config config, final Binder binder) {
@Override public Route.Collection use(final Class<?> routeClass) { return use("", routeClass); }
/** * Bind the provided type: * * <pre> * { * bind(MyInterface.class); * } * </pre> * * @param type Service interface. * @param <T> Service type. * @return This instance. */ public <T> Jooby bind(final Class<T> type) { use((env, conf, binder) -> { binder.bind(type); }); return this; }
/** * Creates a new application and prefix all the names of the routes with the given prefix. Useful, * for dynamic/advanced routing. See {@link Route.Chain#next(String, Request, Response)}. * * @param prefix Route name prefix. */ public Jooby(final String prefix) { this.prefix = prefix; use(server); this.classname = classname(getClass().getName()); }
/** * Set/specify a custom .conf file, useful when you don't want a <code>application.conf</code> * file. * * @param path Classpath location. * @return This jooby instance. */ public Jooby conf(final String path) { this.confname = path; use(ConfigFactory.parseResources(path)); return this; }
/** * Set/specify a custom .conf file, useful when you don't want a <code>application.conf</code> * file. * * @param path File system location. * @return This jooby instance. */ public Jooby conf(final File path) { this.confname = path.getName(); use(ConfigFactory.parseFile(path)); return this; }
@Override public Jooby use(final Jooby app) { return use(prefixPath(null), app); }
@Override public Jooby use(final String path, final Jooby app) { return use(prefixPath(path), app); }