本文整理了Java中javax.ws.rs.core.Application.getClasses()
方法的一些代码示例,展示了Application.getClasses()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getClasses()
方法的具体详情如下:
包路径:javax.ws.rs.core.Application
类名称:Application
方法名:getClasses
[英]Get a set of root resource, provider and Feature classes. The default life-cycle for resource class instances is per-request. The default life-cycle for providers (registered directly or via a feature) is singleton.
Implementations should warn about and ignore classes that do not conform to the requirements of root resource or provider/feature classes. Implementations should warn about and ignore classes for which #getSingletons() returns an instance. Implementations MUST NOT modify the returned set.
The default implementation returns an empty set.
[中]获取一组根资源、提供程序和要素类。资源类实例的默认生命周期为每个请求。提供者(直接注册或通过功能注册)的默认生命周期为singleton。
实现应该警告并忽略不符合根资源或提供者/要素类要求的类。实现应该警告并忽略#getSingleton()返回实例的类。实现不能修改返回的集。
默认实现返回一个空集。
代码示例来源:origin: jersey/jersey
@Override
Set<Class<?>> _getClasses() {
final Set<Class<?>> result = new HashSet<>();
final Set<Class<?>> applicationClasses = application.getClasses();
result.addAll(applicationClasses == null ? new HashSet<Class<?>>() : applicationClasses);
if (result.isEmpty() && getSingletons().isEmpty()) {
result.addAll(defaultClasses);
}
// if the application is not an instance of ResourceConfig, handle scanning triggered via properties
if (!(application instanceof ResourceConfig)) {
result.addAll(super._getClasses());
}
return result;
}
代码示例来源:origin: jersey/jersey
@Override
Set<Class<?>> _getClasses() {
final Set<Class<?>> result = new HashSet<>();
final Set<Class<?>> applicationClasses = application.getClasses();
result.addAll(applicationClasses == null ? new HashSet<Class<?>>() : applicationClasses);
if (result.isEmpty() && getSingletons().isEmpty()) {
result.addAll(defaultClasses);
}
// if the application is not an instance of ResourceConfig, handle scanning triggered via properties
if (!(application instanceof ResourceConfig)) {
result.addAll(super._getClasses());
}
return result;
}
代码示例来源: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<Class<?>> classes = application.getClasses();
if (classes != null) {
registerClasses(classes.stream()
代码示例来源:origin: jersey/jersey
final Set<Class<?>> classes = application.getClasses();
if (classes != null) {
registerClasses(classes.stream()
代码示例来源: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<Class<?>> _getClasses() {
final Set<Class<?>> result = new HashSet<>();
final Set<Class<?>> applicationClasses = application.getClasses();
result.addAll(applicationClasses == null ? new HashSet<Class<?>>() : applicationClasses);
if (result.isEmpty() && getSingletons().isEmpty()) {
result.addAll(defaultClasses);
}
// if the application is not an instance of ResourceConfig, handle scanning triggered via properties
if (!(application instanceof ResourceConfig)) {
result.addAll(super._getClasses());
}
return result;
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
final Set<Class<?>> classes = application.getClasses();
if (classes != null) {
registerClasses(classes.stream()
代码示例来源:origin: resteasy/Resteasy
Set<Class<?>> classes = config.getClasses();
if (classes != null)
代码示例来源:origin: resteasy/Resteasy
ArrayList<Object> resources = new ArrayList<>();
ArrayList<Object> providers = new ArrayList<>();
if (config.getClasses() != null)
for (Class clazz : config.getClasses())
代码示例来源:origin: minnal/minnal
/**
* @param resourceClass
*/
protected void addResource(Class<?> resourceClass) {
application.getClasses().add(resourceClass);
}
代码示例来源: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<Class<?>> getClasses() {
return application != null ? application.getProvider().getClasses()
: Collections.<Class<?>>emptySet();
}
代码示例来源:origin: org.apache.openejb/openejb-rest
private void addEjbToApplication(final Application application, final Map<String, EJBRestServiceInfo> restEjbs) {
for (final Map.Entry<String, EJBRestServiceInfo> ejb : restEjbs.entrySet()) {
application.getClasses().add(ejb.getValue().context.getBeanClass());
}
}
代码示例来源: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());
}
}
代码示例来源:origin: org.tiogasolutions.runners/tioga-runners-jersey-spring
public ResourceConfigAdapter(Application application) {
application.getClasses().forEach(this::register);
application.getSingletons().forEach(this::register);
addProperties(application.getProperties());
}
}
内容来源于网络,如有侵权,请联系作者删除!