本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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<>();
}
示例7: getRouter
import ro.pippo.core.route.Router; //导入依赖的package包/类
public Router getRouter() {
if (router == null) {
router = new DefaultRouter();
}
return router;
}
示例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;
}
示例9: getRouter
import ro.pippo.core.route.Router; //导入依赖的package包/类
protected Router getRouter() {
return router;
}
示例10: WebjarsAtHelper
import ro.pippo.core.route.Router; //导入依赖的package包/类
public WebjarsAtHelper(Router router) {
super(router, WebjarsResourceHandler.class);
}
示例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();
}
示例12: PublicAtHelper
import ro.pippo.core.route.Router; //导入依赖的package包/类
public PublicAtHelper(Router router) {
super(router, PublicResourceHandler.class);
}
示例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<>();
}
示例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<>();
}
示例15: PublicAtExtension
import ro.pippo.core.route.Router; //导入依赖的package包/类
public PublicAtExtension(Router router) {
this.function = new PublicResourceFunction(router);
}