本文整理汇总了Java中org.glassfish.jersey.server.mvc.MvcFeature类的典型用法代码示例。如果您正苦于以下问题:Java MvcFeature类的具体用法?Java MvcFeature怎么用?Java MvcFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MvcFeature类属于org.glassfish.jersey.server.mvc包,在下文中一共展示了MvcFeature类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext context) {
final Configuration config = context.getConfiguration();
if (!config.isRegistered(VelocityViewProcessor.class)) {
// Template Processor.
context.register(VelocityViewProcessor.class);
// MvcFeature.
if (!config.isRegistered(MvcFeature.class)) {
context.register(MvcFeature.class);
}
return true;
}
return false;
}
示例2: configure
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext context) {
final Configuration config = context.getConfiguration();
if (!config.isRegistered(FreemarkerViewProcessor.class)) {
// Template Processor.
context.register(FreemarkerViewProcessor.class);
// MvcFeature.
if (!config.isRegistered(MvcFeature.class)) {
context.register(MvcFeature.class);
}
return true;
}
return false;
}
示例3: WebApplicationResourceConfig
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
public WebApplicationResourceConfig() {
packages("com.giorgiosironi.gameoflife.web");
property(MvcFeature.TEMPLATE_BASE_PATH, "templates");
register(FreemarkerMvcFeature.class);
register(new AbstractBinder() {
@Override
protected void configure() {
InMemoryGenerationRepository repository = new InMemoryGenerationRepository();
Generation original = Generation.withAliveCells(
Cell.onXAndY(1, 1),
Cell.onXAndY(1, 2),
Cell.onXAndY(2, 1),
Cell.onXAndY(2, 2),
Cell.onXAndY(7, 1),
Cell.onXAndY(7, 2),
Cell.onXAndY(7, 3),
Cell.onXAndY(7, 8)
);
repository.add("a-block-and-a-bar", 0, original);
bind(repository).to(GenerationRepository.class);
}
});
}
示例4: configure
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
/**
* Property defines output encoding produced by
* {@link org.glassfish.jersey.server.mvc.spi.TemplateProcessor}. The value
* must be a valid encoding defined that can be passed to the
* {@link java.nio.charset.Charset#forName(String)} method.
*
* <p/>
* The default value is {@code UTF-8}.
* <p/>
* The name of the configuration property is <tt>{@value}</tt>.
* <p/>
*
* @param context
* @return
*/
// public static final String ENCODING = MvcFeature.ENCODING + SUFFIX;
@Override
public boolean configure(final FeatureContext context) {
final Configuration config = context.getConfiguration();
if (!config.isRegistered(JasperViewProcessor.class)) {
// Template Processor.
context.register(JasperViewProcessor.class);
// MvcFeature.
if (!config.isRegistered(MvcFeature.class)) {
context.register(MvcFeature.class);
}
return true;
}
return false;
}
示例5: AbstractTemplateProcessor
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
/**
* <p>Constructor for AbstractTemplateProcessor.</p>
*
* @param config a {@link javax.ws.rs.core.Configuration} object.
* @param propertySuffix a {@link java.lang.String} object.
* @param supportedExtensions a {@link java.lang.String} object.
*/
public AbstractTemplateProcessor(Configuration config, String propertySuffix, String... supportedExtensions) {
this.config = config;
this.suffix = '.' + propertySuffix;
Map<String, Object> properties = config.getProperties();
String basePath = TemplateHelper.getBasePath(properties, propertySuffix);
Collection<String> basePaths = TemplateHelper.getBasePaths(basePath);
this.basePath = basePaths.toArray(new String[basePaths.size()]);
Boolean cacheEnabled = PropertiesHelper.getValue(properties,
MvcFeature.CACHE_TEMPLATES + this.suffix, Boolean.class, null);
if (cacheEnabled == null) {
cacheEnabled = PropertiesHelper.getValue(properties, MvcFeature.CACHE_TEMPLATES, false, null);
}
this.cache = cacheEnabled ? DataStructures.createConcurrentMap() : null;
this.encoding = TemplateHelper.getTemplateOutputEncoding(config, this.suffix);
this.supportedExtensions = Sets.newHashSet(Collections2.transform(
Arrays.asList(supportedExtensions), input -> {
input = input.toLowerCase();
return input.startsWith(".") ? input : "." + input;
}));
}
示例6: getTemplateObjectFactory
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
/**
* <p>getTemplateObjectFactory.</p>
*
* @param serviceLocator a {@link org.glassfish.hk2.api.ServiceLocator} object.
* @param type a {@link java.lang.Class} object.
* @param defaultValue a {@link org.glassfish.jersey.internal.util.collection.Value} object.
* @param <F> a F object.
* @return a F object.
*/
@SuppressWarnings("unchecked")
protected <F> F getTemplateObjectFactory(ServiceLocator serviceLocator, Class<F> type, Value<F> defaultValue) {
Object objectFactoryProperty = this.config.getProperty(MvcFeature.TEMPLATE_OBJECT_FACTORY + this.suffix);
if (objectFactoryProperty != null) {
if (type.isAssignableFrom(objectFactoryProperty.getClass())) {
return type.cast(objectFactoryProperty);
}
Class<F> factoryClass = null;
if (objectFactoryProperty instanceof String) {
factoryClass = ReflectionHelper.<F>classForNamePA((String) objectFactoryProperty).run();
} else if (objectFactoryProperty instanceof Class) {
factoryClass = (Class<F>) objectFactoryProperty;
}
if (factoryClass != null) {
if (type.isAssignableFrom(factoryClass)) {
return serviceLocator.create(factoryClass);
}
logger.warn(LocalizationMessages.WRONG_TEMPLATE_OBJECT_FACTORY(factoryClass, type));
}
}
return defaultValue.get();
}
示例7: getTemplateOutputEncoding
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
/**
* Get output encoding from configuration.
*
* @param configuration Configuration.
* @param suffix Template processor suffix of the
* to configuration property {@link org.glassfish.jersey.server.mvc.MvcFeature#ENCODING}.
* @return Encoding read from configuration properties or a default encoding if no encoding is configured.
*/
public static Charset getTemplateOutputEncoding(Configuration configuration, String suffix) {
final String enc = PropertiesHelper.getValue(configuration.getProperties(), MvcFeature.ENCODING + suffix,
String.class, null);
if (enc == null) {
return DEFAULT_ENCODING;
} else {
return Charset.forName(enc);
}
}
示例8: getBasePath
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
/**
* <p>getBasePath.</p>
*
* @param properties a {@link java.util.Map} object.
* @param cfgSuffix a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public static String getBasePath(Map<String, Object> properties, String cfgSuffix) {
String basePath = PropertiesHelper.getValue(properties,
MvcFeature.TEMPLATE_BASE_PATH + "." + cfgSuffix, String.class, null);
if (basePath == null) {
basePath = PropertiesHelper.getValue(properties, MvcFeature.TEMPLATE_BASE_PATH, "", null);
}
return basePath;
}
示例9: PandaJerseyConfig
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
public PandaJerseyConfig() throws JAXBException {
packages("de.fuberlin.panda.api.jersey");
setApplicationName("PANDA");
// Load Resource Map
JAXBContext jaxbContext = JAXBContext.newInstance(ResourceMap.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
File configFile = new File(pandaSettings.getResourceConfFilePath());
pandaSettings.setResourceMap((ResourceMap) unmarshaller.unmarshal(configFile));
// create default settings
register(new AbstractBinder() {
@Override
protected void configure() {
bind(pandaSettings);
}
});
// register class for JSON support
this.register(JacksonFeature.class);
// register JSP support
this.register(JspMvcFeature.class);
this.property(MvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp");
// Custom JAXB marshaller provider
this.register(JaxbMarshallerProvider.class);
// Custom Jackson ObjectMapper provider
this.register(JacksonObjectMapperProvider.class);
}
示例10: configure
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext context) {
if (!context.getConfiguration().isRegistered(MvcFeature.class)) {
context.register(MvcFeature.class);
}
context.register(MustacheViewProcessor.class);
return true;
}
示例11: RallyeApplication
import org.glassfish.jersey.server.mvc.MvcFeature; //导入依赖的package包/类
public RallyeApplication() {
packages("de.rallye.api", "de.rallye.filter.auth", "de.rallye.exceptions.mappers");
register(JacksonSmileProvider.class);
register(JacksonXMLProvider.class);
register(JacksonFeature.class);
//register(EnsureMimeType.class);
register(new RallyeBinder());
register(MultiPartFeature.class);
property(MvcFeature.TEMPLATE_BASE_PATH, "templates");
property(MustacheMvcFeature.CACHE_TEMPLATES, false); //TODO enable caching once templates are no longer being modified
register(MustacheMvcFeature.class);
}