本文整理了Java中org.glassfish.jersey.server.model.Resource.getHandlerInstances
方法的一些代码示例,展示了Resource.getHandlerInstances
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getHandlerInstances
方法的具体详情如下:
包路径:org.glassfish.jersey.server.model.Resource
类名称:Resource
方法名:getHandlerInstances
[英]Get the method handler (singleton) instances for the resource methods registered on the resource.
[中]获取资源上注册的资源方法的方法处理程序(单例)实例。
代码示例来源:origin: jersey/jersey
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: jersey/jersey
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: jersey/jersey
/**
* Determines whether the given methods can enhance the resource.
*
* @param resource resource to add the methods to.
* @param methods methods to add.
* @return {@code true} if methods can enhance the resource, {@code false} otherwise.
*/
private static boolean methodsSuitableForResource(final Resource resource, final List<Method> methods) {
if (!resource.getResourceMethods().isEmpty()) {
return true;
}
// If there are no handler classes/instances we want to add only non-HEAD / non-OPTIONS methods.
if (resource.getHandlerInstances().isEmpty() && resource.getHandlerClasses().isEmpty()) {
for (final Method method : methods) {
if (!HttpMethod.HEAD.equals(method.httpMethod) && !HttpMethod.OPTIONS.equals(method.httpMethod)) {
return true;
}
}
}
return false;
}
}
代码示例来源:origin: jersey/jersey
/**
* Determines whether the given methods can enhance the resource.
*
* @param resource resource to add the methods to.
* @param methods methods to add.
* @return {@code true} if methods can enhance the resource, {@code false} otherwise.
*/
private static boolean methodsSuitableForResource(final Resource resource, final List<Method> methods) {
if (!resource.getResourceMethods().isEmpty()) {
return true;
}
// If there are no handler classes/instances we want to add only non-HEAD / non-OPTIONS methods.
if (resource.getHandlerInstances().isEmpty() && resource.getHandlerClasses().isEmpty()) {
for (final Method method : methods) {
if (!HttpMethod.HEAD.equals(method.httpMethod) && !HttpMethod.OPTIONS.equals(method.httpMethod)) {
return true;
}
}
}
return false;
}
}
代码示例来源:origin: jersey/jersey
private void bindEnhancingResourceClasses(
InjectionManager injectionManager,
ServerBootstrapBag bootstrapBag,
ResourceModel resourceModel,
ResourceBag resourceBag,
ResourceConfig runtimeConfig) {
Set<Class<?>> newClasses = new HashSet<>();
Set<Object> newInstances = new HashSet<>();
for (final Resource res : resourceModel.getRootResources()) {
newClasses.addAll(res.getHandlerClasses());
newInstances.addAll(res.getHandlerInstances());
}
newClasses.removeAll(resourceBag.classes);
newInstances.removeAll(resourceBag.instances);
ComponentBag emptyComponentBag = ComponentBag.newInstance(input -> false);
bindProvidersAndResources(injectionManager, bootstrapBag, emptyComponentBag, newClasses, newInstances, runtimeConfig);
}
代码示例来源:origin: jersey/jersey
@Override
public Void call() {
for (final Object handlerInstance : resource.getHandlerInstances()) {
final Class<?> handlerInstanceClass = handlerInstance.getClass();
if (!resource.getHandlerClasses().contains(handlerInstanceClass)) {
createEnhancingMethods(handlerInstanceClass, handlerInstance, newMethods);
} else {
Errors.warning(resource,
LocalizationMessages.TEMPLATE_HANDLER_ALREADY_ENHANCED(handlerInstanceClass));
}
}
return null;
}
});
代码示例来源:origin: jersey/jersey
private void bindEnhancingResourceClasses(
InjectionManager injectionManager,
ServerBootstrapBag bootstrapBag,
ResourceModel resourceModel,
ResourceBag resourceBag,
ResourceConfig runtimeConfig) {
Set<Class<?>> newClasses = new HashSet<>();
Set<Object> newInstances = new HashSet<>();
for (final Resource res : resourceModel.getRootResources()) {
newClasses.addAll(res.getHandlerClasses());
newInstances.addAll(res.getHandlerInstances());
}
newClasses.removeAll(resourceBag.classes);
newInstances.removeAll(resourceBag.instances);
ComponentBag emptyComponentBag = ComponentBag.newInstance(input -> false);
bindProvidersAndResources(injectionManager, bootstrapBag, emptyComponentBag, newClasses, newInstances, runtimeConfig);
}
代码示例来源:origin: jersey/jersey
if (resource.getHandlerClasses().isEmpty() && resource.getHandlerInstances().isEmpty()) {
for (String resourceName : resource.getNames()) {
final Class<Object> resourceClass = AccessController
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
/**
* Determines whether the given methods can enhance the resource.
*
* @param resource resource to add the methods to.
* @param methods methods to add.
* @return {@code true} if methods can enhance the resource, {@code false} otherwise.
*/
private static boolean methodsSuitableForResource(final Resource resource, final List<Method> methods) {
if (!resource.getResourceMethods().isEmpty()) {
return true;
}
// If there are no handler classes/instances we want to add only non-HEAD / non-OPTIONS methods.
if (resource.getHandlerInstances().isEmpty() && resource.getHandlerClasses().isEmpty()) {
for (final Method method : methods) {
if (!HttpMethod.HEAD.equals(method.httpMethod) && !HttpMethod.OPTIONS.equals(method.httpMethod)) {
return true;
}
}
}
return false;
}
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
private void bindEnhancingResourceClasses(
InjectionManager injectionManager,
ServerBootstrapBag bootstrapBag,
ResourceModel resourceModel,
ResourceBag resourceBag,
ResourceConfig runtimeConfig) {
Set<Class<?>> newClasses = new HashSet<>();
Set<Object> newInstances = new HashSet<>();
for (final Resource res : resourceModel.getRootResources()) {
newClasses.addAll(res.getHandlerClasses());
newInstances.addAll(res.getHandlerInstances());
}
newClasses.removeAll(resourceBag.classes);
newInstances.removeAll(resourceBag.instances);
ComponentBag emptyComponentBag = ComponentBag.newInstance(input -> false);
bindProvidersAndResources(injectionManager, bootstrapBag, emptyComponentBag, newClasses, newInstances, runtimeConfig);
}
代码示例来源:origin: org.glassfish.ozark/ozark
/**
* Determines if a resource is a controller.
*
* @param resource resource to test.
* @return outcome of controller test.
*/
private static boolean isController(Resource resource) {
final Boolean b1 = resource.getHandlerClasses().stream()
.map(c -> c.isAnnotationPresent(Controller.class))
.reduce(Boolean.FALSE, Boolean::logicalOr);
final Boolean b2 = resource.getHandlerInstances().stream()
.map(o -> o.getClass().isAnnotationPresent(Controller.class))
.reduce(Boolean.FALSE, Boolean::logicalOr);
return b1 || b2;
}
}
代码示例来源:origin: org.glassfish.jersey.bundles/jaxrs-ri
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
/**
* Register a new programmatically created resource model.
*
* @param resourceModel programmatically created resource model.
*/
void registerProgrammaticResource(Resource resourceModel) {
registerModel(resourceModel);
classes.addAll(resourceModel.getHandlerClasses());
instances.addAll(resourceModel.getHandlerInstances());
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
public Void call() {
for (final Object handlerInstance : resource.getHandlerInstances()) {
final Class<?> handlerInstanceClass = handlerInstance.getClass();
if (!resource.getHandlerClasses().contains(handlerInstanceClass)) {
createEnhancingMethods(handlerInstanceClass, handlerInstance, newMethods);
} else {
Errors.warning(resource,
LocalizationMessages.TEMPLATE_HANDLER_ALREADY_ENHANCED(handlerInstanceClass));
}
}
return null;
}
});
代码示例来源:origin: org.glassfish.jersey.ext/jersey-mvc
@Override
public Void call() {
for (final Object handlerInstance : resource.getHandlerInstances()) {
final Class<?> handlerInstanceClass = handlerInstance.getClass();
if (!resource.getHandlerClasses().contains(handlerInstanceClass)) {
createEnhancingMethods(handlerInstanceClass, handlerInstance, newMethods);
} else {
Errors.warning(resource,
LocalizationMessages.TEMPLATE_HANDLER_ALREADY_ENHANCED(handlerInstanceClass));
}
}
return null;
}
});
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
@Override
public Void call() {
for (final Object handlerInstance : resource.getHandlerInstances()) {
final Class<?> handlerInstanceClass = handlerInstance.getClass();
if (!resource.getHandlerClasses().contains(handlerInstanceClass)) {
createEnhancingMethods(handlerInstanceClass, handlerInstance, newMethods);
} else {
Errors.warning(resource,
LocalizationMessages.TEMPLATE_HANDLER_ALREADY_ENHANCED(handlerInstanceClass));
}
}
return null;
}
});
代码示例来源:origin: org.glassfish.jersey.bundles/jaxrs-ri
private void bindEnhancingResourceClasses(
InjectionManager injectionManager,
ServerBootstrapBag bootstrapBag,
ResourceModel resourceModel,
ResourceBag resourceBag,
ResourceConfig runtimeConfig) {
Set<Class<?>> newClasses = new HashSet<>();
Set<Object> newInstances = new HashSet<>();
for (final Resource res : resourceModel.getRootResources()) {
newClasses.addAll(res.getHandlerClasses());
newInstances.addAll(res.getHandlerInstances());
}
newClasses.removeAll(resourceBag.classes);
newInstances.removeAll(resourceBag.instances);
ComponentBag emptyComponentBag = ComponentBag.newInstance(input -> false);
bindProvidersAndResources(injectionManager, bootstrapBag, emptyComponentBag, newClasses, newInstances, runtimeConfig);
}
内容来源于网络,如有侵权,请联系作者删除!