本文整理汇总了Java中org.jvnet.hk2.annotations.Optional类的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Optional类属于org.jvnet.hk2.annotations包,在下文中一共展示了Optional类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: VelocityDefaultConfigurationFactory
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public VelocityDefaultConfigurationFactory(@Optional final ServletContext servletContext) {
String loader = "class";
Velocity.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
if (servletContext != null) {
Velocity.setProperty("webapp.resource.loader.class", WebappResourceLoader.class.getName());
Velocity.setProperty("webapp.resource.loader.path", "/");
Velocity.setApplicationAttribute("javax.servlet.ServletContext", servletContext);
loader += ",webapp";
}
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, loader);
configuration = new Configuration();
}
开发者ID:Feng-Zihao,项目名称:jersey-mvc-velocity,代码行数:17,代码来源:VelocityDefaultConfigurationFactory.java
示例2: VelocityViewProcessor
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public VelocityViewProcessor(final javax.ws.rs.core.Configuration config, final ServiceLocator serviceLocator,
@Optional final ServletContext servletContext) {
super(config, servletContext, "velocity", "vm");
this.factory = getTemplateObjectFactory(serviceLocator, VelocityConfigurationFactory.class,
new Value<VelocityConfigurationFactory>() {
@Override
public VelocityConfigurationFactory get() {
Configuration configuration = getTemplateObjectFactory(serviceLocator, Configuration.class,
Values.<Configuration>empty());
if (configuration == null) {
return new VelocityDefaultConfigurationFactory(servletContext);
} else {
return new VelocitySuppliedConfigurationFactory(configuration);
}
}
});
Velocity.init();
}
开发者ID:Feng-Zihao,项目名称:jersey-mvc-velocity,代码行数:21,代码来源:VelocityViewProcessor.java
示例3: FreemarkerViewProcessor
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
/**
* Create an instance of this processor with injected {@link javax.ws.rs.core.Configuration config} and
* (optional) {@link javax.servlet.ServletContext servlet context}.
*
* @param config config to configure this processor from.
* @param serviceLocator service locator to initialize template object factory if needed.
* @param servletContext (optional) servlet context to obtain template resources from.
*/
@Inject
public FreemarkerViewProcessor(final javax.ws.rs.core.Configuration config, final ServiceLocator serviceLocator,
@Optional final ServletContext servletContext) {
super(config, servletContext, "freemarker", getSupportedExtensions(config, servletContext));
this.factory = getTemplateObjectFactory(serviceLocator, FreemarkerConfigurationFactory.class,
new Value<FreemarkerConfigurationFactory>() {
@Override
public FreemarkerConfigurationFactory get() {
Configuration configuration = getTemplateObjectFactory(serviceLocator, Configuration.class,
Values.<Configuration>empty());
if (configuration == null) {
return new FreemarkerDefaultConfigurationFactory(servletContext);
} else {
return new FreemarkerSuppliedConfigurationFactory(configuration);
}
}
});
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:29,代码来源:FreemarkerViewProcessor.java
示例4: FlexibleConfiguration
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public FlexibleConfiguration(final javax.ws.rs.core.Configuration config, @Optional final ServletContext servletContext) {
super();
final List<TemplateLoader> loaders = new ArrayList<>();
if (servletContext != null) {
loaders.add(new WebappTemplateLoader(servletContext));
}
loaders.add(new ClassTemplateLoader(FlexibleConfiguration.class, "/"));
// Create Factory.
this.setTemplateLoader(new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()])));
try {
settingConfiguration(config);
} catch (TemplateException e) {
throw new RuntimeException(e);
}
}
开发者ID:kamegu,项目名称:git-webapp,代码行数:19,代码来源:FlexibleConfiguration.java
示例5: UserTokenFilter
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public UserTokenFilter(
TokenServiceClient tokenServiceClient,
UserTokenFilterAddon configuration,
@Optional UserTokenAuthenticatedHandler authenticatedHandler)
{
this.tokenServiceClient = tokenServiceClient;
this.configuration = configuration;
this.authenticatedHandler = authenticatedHandler;
}
开发者ID:code-obos,项目名称:servicebuilder,代码行数:11,代码来源:UserTokenFilter.java
示例6: TaggedMetricRegistry
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public TaggedMetricRegistry(
@NonNull MetricRegistry registry, @NonNull @Optional Provider<MetricNameService> metricNameServiceProvider
) {
this.delegate = registry;
this.metricNameServiceProvider = metricNameServiceProvider;
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:8,代码来源:TaggedMetricRegistry.java
示例7: ClientNameFilter
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public ClientNameFilter(@Named(CLIENT_APPNAME) @Optional String clientAppName) {
this.clientAppName = clientAppName;
}
开发者ID:code-obos,项目名称:servicebuilder,代码行数:5,代码来源:ClientNameFilter.java
示例8: DefaultMetricNameService
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
@Inject
public DefaultMetricNameService(@NonNull IterableProvider<MetricNameFilter> filters, @Optional MetricNameFormatter formatter) {
this.filters = filters;
this.formatter = formatter == null ? new DefaultMetricNameFormatter() : formatter;
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:6,代码来源:DefaultMetricNameService.java
示例9: BeanParamModel
import org.jvnet.hk2.annotations.Optional; //导入依赖的package包/类
public BeanParamModel(@PathParam("path-value") @Optional String pathValue,
@QueryParam("param1") @Optional String param1) {
this.pathValue = pathValue;
this.param1 = param1;
}
开发者ID:geekmj,项目名称:jersey-jax-rs-examples,代码行数:6,代码来源:BeanParamModel.java
注:本文中的org.jvnet.hk2.annotations.Optional类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论