當前位置: 首頁>>代碼示例>>Java>>正文


Java Router類代碼示例

本文整理匯總了Java中ro.pippo.core.route.Router的典型用法代碼示例。如果您正苦於以下問題:Java Router類的具體用法?Java Router怎麽用?Java Router使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Router類屬於ro.pippo.core.route包,在下文中一共展示了Router類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setup

import ro.pippo.core.route.Router; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public void setup(Languages languages, Messages messages, Router router) {
    this.languages = languages;
    this.messages = messages;
    this.router = router;

    // set global template variables
    getModel().put("contextPath",  router.getContextPath());
    getModel().put("appPath",  router.getApplicationPath());

    String language = (String) getModel().get(PippoConstants.REQUEST_PARAMETER_LANG);
    if (StringUtils.isNullOrEmpty(language)) {
        language = languages.getLanguageOrDefault(language);
    }
    this.language = language;

    // prepare the locale
    Locale locale = (Locale) getModel().get(PippoConstants.REQUEST_PARAMETER_LOCALE);
    if (locale == null) {
        locale = languages.getLocaleOrDefault(language);
    }
    this.locale = locale;
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:24,代碼來源:PippoGroovyTemplate.java

示例2: init

import ro.pippo.core.route.Router; //導入依賴的package包/類
@Override
public void init(Application application) {
    super.init(application);

    Router router = getRouter();
    PippoSettings pippoSettings = getPippoSettings();

    configuration = new JadeConfiguration();
    configuration.setTemplateLoader(new ClassTemplateLoader(JadeTemplateEngine.class, getTemplatePathPrefix()));
    configuration.setMode(Mode.HTML);
    if (pippoSettings.isDev()) {
        configuration.setPrettyPrint(true);
        configuration.setCaching(false); // disable cache
    }

    // set global template variables
    configuration.getSharedVariables().put("contextPath", router.getContextPath());
    configuration.getSharedVariables().put("appPath", router.getApplicationPath());

    // allow custom initialization
    init(application, configuration);
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:23,代碼來源:JadeTemplateEngine.java

示例3: SwaggerBuilder

import ro.pippo.core.route.Router; //導入依賴的package包/類
public SwaggerBuilder(Settings settings, Router router, ContentTypeEngines engines, Messages messages) {
    this.settings = settings;
    this.router = router;
    this.engines = engines;
    this.messages = messages;
    List<String> languages = settings.getStrings("application.languages");
    this.defaultLanguage = languages.isEmpty() ? "en" : languages.get(0);
    this.relativeSwaggerBasePath = Optional.fromNullable(Strings.emptyToNull(settings.getString("swagger.basePath", null))).or("/");
    this.outputSnakeCaseParameters = settings.getBoolean("swagger.outputSnakeCaseParameters", false);
}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:11,代碼來源:SwaggerBuilder.java

示例4: setup

import ro.pippo.core.route.Router; //導入依賴的package包/類
@Override
protected void setup() {
    String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim();
    serve(basePath + "/*").with(RestServlet.class);

    final PippoSettings pippoSettings = getPippoSettings(getSettings());
    final Application application = new Application(pippoSettings);

    // must set context path before starting application
    application.getRouter().setContextPath(getSettings().getContextPath());

    // must set application path before starting application
    String contextPath = application.getRouter().getContextPath();
    String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/");
    application.getRouter().setApplicationPath(applicationPath);

    // start the application which sets up all initializers
    application.init();

    bind(Application.class).toInstance(application);
    bind(Router.class).toInstance(application.getRouter());
    bind(Messages.class).toInstance(application.getMessages());
    bind(Languages.class).toInstance(application.getLanguages());
    bind(MimeTypes.class).toInstance(application.getMimeTypes());
    bind(ErrorHandler.class).toInstance(application.getErrorHandler());
    bind(TemplateEngine.class).toInstance(application.getTemplateEngine());
    bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit());
    bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines());

    bind(RestService.class);

}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:33,代碼來源:RestModule.java

示例5: init

import ro.pippo.core.route.Router; //導入依賴的package包/類
@Override
public void init(Application application) {
    super.init(application);

    Router router = getRouter();
    PippoSettings pippoSettings = getPippoSettings();

    List<Loader<?>> loaders = Lists.newArrayList();
    PippoTemplateLoader templateLoader = new PippoTemplateLoader();

    templateLoader.setCharset(PippoConstants.UTF8);
    templateLoader.setPrefix(getTemplatePathPrefix());
    templateLoader.setSuffix("." + getFileExtension());
    loaders.add(templateLoader);

    PebbleEngine.Builder builder = new PebbleEngine.Builder()
        .loader(new DelegatingLoader(loaders))
        .strictVariables(false)
        .extension(new GlobalVariablesExtension()
            .set("contextPath", router.getContextPath())
            .set("appPath", router.getApplicationPath()))
        .extension(new I18nExtension(application.getMessages()))
        .extension(new FormatTimeExtension())
        .extension(new PrettyTimeExtension())
        .extension(new AngularJSExtension())
        .extension(new WebjarsAtExtension(router))
        .extension(new PublicAtExtension(router));

    if (pippoSettings.isDev()) {
        // do not cache templates in dev mode
        builder.cacheActive(false);
        builder.extension(new DebugExtension());
    }

    // allow custom initialization
    init(application, builder);

    engine = builder.build();
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:40,代碼來源:PebbleTemplateEngine.java

示例6: PippoHelper

import ro.pippo.core.route.Router; //導入依賴的package包/類
public PippoHelper(Messages messages, String language, Locale locale, Router router) {
    this.messages = messages;
    this.language = language;
    this.locale = locale;
    this.router = router;
    this.prettyTime = new PrettyTime(locale);
    this.webjarsPatternRef = new AtomicReference<>();
    this.publicPatternRef = new AtomicReference<>();
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:10,代碼來源:PippoHelper.java

示例7: getRouter

import ro.pippo.core.route.Router; //導入依賴的package包/類
public Router getRouter() {
    if (router == null) {
        router = new DefaultRouter();
    }

    return router;
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:8,代碼來源:Application.java

示例8: setRouter

import ro.pippo.core.route.Router; //導入依賴的package包/類
public void setRouter(Router router, boolean preserveOldTransformers) {
    if (preserveOldTransformers && (router != null)) {
        // preserve route transformers already registered
        List<RouteTransformer> transformers = this.router.getRouteTransformers();
        transformers.forEach(router::addRouteTransformer);
    }

    this.router = router;
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:10,代碼來源:Application.java

示例9: getRouter

import ro.pippo.core.route.Router; //導入依賴的package包/類
protected Router getRouter() {
    return router;
}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:4,代碼來源:RoutesModule.java

示例10: WebjarsAtHelper

import ro.pippo.core.route.Router; //導入依賴的package包/類
public WebjarsAtHelper(Router router) {
    super(router, WebjarsResourceHandler.class);
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:4,代碼來源:WebjarsAtHelper.java

示例11: init

import ro.pippo.core.route.Router; //導入依賴的package包/類
@Override
public void init(Application application) {
    super.init(application);

    this.localeSupport = new ThreadLocalLocaleSupport();

    Router router = getRouter();
    PippoSettings pippoSettings = getPippoSettings();

    MustacheEngineBuilder builder = MustacheEngineBuilder.newBuilder();
    builder.setLocaleSupport(localeSupport);
    builder.setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING, PippoConstants.UTF8);
    builder.registerHelper("ng", new AngularJsHelper());
    builder.registerHelper("i18n", new I18nHelper(application.getMessages()));
    builder.registerHelper("formatTime", new DateTimeFormatHelper());
    builder.registerHelper("prettyTime", new PrettyTimeHelper());
    builder.registerHelper("webjarsAt", new WebjarsAtHelper(router));
    builder.registerHelper("publicAt", new PublicAtHelper(router));
    builder.registerHelpers(HelpersBuilder.extra().build());

    String pathPrefix = getTemplatePathPrefix();
    pathPrefix = StringUtils.removeStart(pathPrefix, "/");
    builder.addTemplateLocator(new ClassPathTemplateLocator(10, pathPrefix, MUSTACHE));

    if (pippoSettings.isDev()) {
        // enable debug mode
        builder.setProperty(EngineConfigurationKey.DEBUG_MODE, true);
    } else {
        // automatically minify pages generated in production/test
        builder.addMustacheListener(Minify.htmlListener());
    }

    // set global template variables
    builder.addGlobalData("contextPath", router.getContextPath());
    builder.addGlobalData("appPath", router.getApplicationPath());

    // allow custom initialization
    init(application, builder);

    engine = builder.build();
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:42,代碼來源:TrimouTemplateEngine.java

示例12: PublicAtHelper

import ro.pippo.core.route.Router; //導入依賴的package包/類
public PublicAtHelper(Router router) {
    super(router, PublicResourceHandler.class);
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:4,代碼來源:PublicAtHelper.java

示例13: ClasspathResourceHelper

import ro.pippo.core.route.Router; //導入依賴的package包/類
protected ClasspathResourceHelper(Router router, Class<T> resourceHandlerClass) {
    this.router = router;
    this.resourceHandlerClass = resourceHandlerClass;
    this.patternRef = new AtomicReference<>();
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:6,代碼來源:ClasspathResourceHelper.java

示例14: ClasspathResourceFunction

import ro.pippo.core.route.Router; //導入依賴的package包/類
protected ClasspathResourceFunction(Router router, Class<T> resourceHandlerClass) {
    this.router = router;
    this.resourceHandlerClass = resourceHandlerClass;
    this.patternRef = new AtomicReference<>();
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:6,代碼來源:ClasspathResourceFunction.java

示例15: PublicAtExtension

import ro.pippo.core.route.Router; //導入依賴的package包/類
public PublicAtExtension(Router router) {
    this.function = new PublicResourceFunction(router);
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:4,代碼來源:PublicAtExtension.java


注:本文中的ro.pippo.core.route.Router類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。