本文整理了Java中javax.ws.rs.core.Application.getSingletons()
方法的一些代码示例,展示了Application.getSingletons()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getSingletons()
方法的具体详情如下:
包路径:javax.ws.rs.core.Application
类名称:Application
方法名:getSingletons
[英]Get a set of root resource, provider and Feature instances. Fields and properties of returned instances are injected with their declared dependencies (see Context) by the runtime prior to use.
Implementations should warn about and ignore classes that do not conform to the requirements of root resource or provider classes. Implementations should flag an error if the returned set includes more than one instance of the same class. Implementations MUST NOT modify the returned set.
The default implementation returns an empty set.
[中]获取一组根资源、提供程序和功能实例。返回实例的字段和属性在使用前由运行时注入其声明的依赖项(请参见上下文)。
实现应该警告并忽略不符合根资源或提供程序类要求的类。如果返回的集合包含同一类的多个实例,则实现应标记错误。实现不能修改返回的集。
默认实现返回一个空集。
代码示例来源:origin: jersey/jersey
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: jersey/jersey
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: swagger-api/swagger-core
@Override
public Set<Class<?>> classes() {
Set<Class<?>> output = new HashSet<Class<?>>();
if (application != null) {
Set<Class<?>> clzs = application.getClasses();
if (clzs != null) {
for (Class<?> clz : clzs) {
if (!isIgnored(clz.getName())) {
output.add(clz);
}
}
}
Set<Object> singletons = application.getSingletons();
if (singletons != null) {
for (Object o : singletons) {
if (!isIgnored(o.getClass().getName())) {
output.add(o.getClass());
}
}
}
}
return output;
}
}
代码示例来源:origin: com.sun.jersey/jersey-server
/**
* @param ac the application
*/
public ApplicationAdapter(Application ac) {
if (ac.getClasses() != null)
getClasses().addAll(ac.getClasses());
if (ac.getSingletons() != null)
getSingletons().addAll(ac.getSingletons());
}
}
代码示例来源:origin: swagger-api/swagger-core
@Override
public Set<Class<?>> classes() {
Set<Class<?>> classes = super.classes();
Set<Class<?>> output = new HashSet<Class<?>>();
if (application != null) {
Set<Class<?>> clzs = application.getClasses();
if (clzs != null) {
for (Class<?> clz : clzs) {
if (!isIgnored(clz.getName())) {
output.add(clz);
}
}
}
Set<Object> singletons = application.getSingletons();
if (singletons != null) {
for (Object o : singletons) {
if (!isIgnored(o.getClass().getName())) {
output.add(o.getClass());
}
}
}
}
classes.addAll(output);
return classes;
}
}
代码示例来源:origin: jersey/jersey
final Set<Object> singletons = application.getSingletons();
if (singletons != null) {
registerInstances(
代码示例来源:origin: jersey/jersey
final Set<Object> singletons = application.getSingletons();
if (singletons != null) {
registerInstances(
代码示例来源:origin: com.sun.jersey/jersey-server
private ApplicationHolder(ProviderFactory pf) {
final ComponentProvider cp = pf.getComponentProvider(appClass);
if (cp == null) {
throw new ContainerException("The Application class " + appClass.getName() + " could not be instantiated");
}
this.originalApp = (Application) cp.getInstance();
if ((originalApp.getClasses() == null || originalApp.getClasses().isEmpty())
&& (originalApp.getSingletons() == null || originalApp.getSingletons().isEmpty())) {
LOGGER.info("Instantiated the Application class " + appClass.getName() +
". The following root resource and provider classes are registered: " + defaultClasses);
this.adaptedApp = new DefaultResourceConfig(defaultClasses);
adaptedApp.add(originalApp);
} else {
LOGGER.info("Instantiated the Application class " + appClass.getName());
adaptedApp = null;
}
if (originalApp instanceof ResourceConfig) {
final ResourceConfig rc = (ResourceConfig)originalApp;
getFeatures().putAll(rc.getFeatures());
getProperties().putAll(rc.getProperties());
getExplicitRootResources().putAll(rc.getExplicitRootResources());
getMediaTypeMappings().putAll(rc.getMediaTypeMappings());
getLanguageMappings().putAll(rc.getLanguageMappings());
}
}
代码示例来源:origin: com.sun.jersey/jersey-server
/**
* Add the state of an {@link Application} to this instance.
*
* @param app the application.
*/
public void add(Application app) {
if (app.getClasses() != null)
addAllFirst(getClasses(), app.getClasses());
if (app.getSingletons() != null)
addAllFirst(getSingletons(), app.getSingletons());
if (app instanceof ResourceConfig) {
ResourceConfig rc = (ResourceConfig)app;
getExplicitRootResources().putAll(rc.getExplicitRootResources());
getLanguageMappings().putAll(rc.getLanguageMappings());
getMediaTypeMappings().putAll(rc.getMediaTypeMappings());
getFeatures().putAll(rc.getFeatures());
getProperties().putAll(rc.getProperties());
}
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
final Set<Object> singletons = application.getSingletons();
if (singletons != null) {
registerInstances(
代码示例来源:origin: resteasy/Resteasy
Set<Object> singletons = config.getSingletons();
if (singletons != null)
代码示例来源:origin: resteasy/Resteasy
if (config.getSingletons() != null)
for (Object obj : config.getSingletons())
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
Set<Object> _getSingletons() {
return application.getSingletons();
}
}
代码示例来源:origin: apache/cxf
@Override
public Set<Class<?>> classes() {
Set<Class<?>> allClasses = new HashSet<>();
allClasses.addAll(app.getClasses());
for (Object singleton : app.getSingletons()) {
allClasses.add(singleton.getClass());
}
return allClasses;
}
}
代码示例来源:origin: apache/cxf
@Override
public Set<Object> getInstances() {
return application != null ? application.getProvider().getSingletons()
: Collections.emptySet();
}
代码示例来源:origin: com.sun.jersey/jersey-bundle
/**
* @param ac the application
*/
public ApplicationAdapter(Application ac) {
if (ac.getClasses() != null)
getClasses().addAll(ac.getClasses());
if (ac.getSingletons() != null)
getSingletons().addAll(ac.getSingletons());
}
}
代码示例来源:origin: jersey/jersey-1.x
/**
* @param ac the application
*/
public ApplicationAdapter(Application ac) {
if (ac.getClasses() != null)
getClasses().addAll(ac.getClasses());
if (ac.getSingletons() != null)
getSingletons().addAll(ac.getSingletons());
}
}
内容来源于网络,如有侵权,请联系作者删除!