本文整理了Java中org.springframework.beans.factory.annotation.Autowired.required()
方法的一些代码示例,展示了Autowired.required()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Autowired.required()
方法的具体详情如下:
包路径:org.springframework.beans.factory.annotation.Autowired
类名称:Autowired
方法名:required
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given dependency declares an autowired annotation,
* checking its required flag.
* @see Autowired#required()
*/
@Override
public boolean isRequired(DependencyDescriptor descriptor) {
if (!super.isRequired(descriptor)) {
return false;
}
Autowired autowired = descriptor.getAnnotation(Autowired.class);
return (autowired == null || autowired.required());
}
代码示例来源:origin: org.springframework/spring-beans
/**
* Determine whether the given dependency declares an autowired annotation,
* checking its required flag.
* @see Autowired#required()
*/
@Override
public boolean isRequired(DependencyDescriptor descriptor) {
if (!super.isRequired(descriptor)) {
return false;
}
Autowired autowired = descriptor.getAnnotation(Autowired.class);
return (autowired == null || autowired.required());
}
代码示例来源:origin: jersey/jersey
@Override
public Object resolve(Injectee injectee) {
AnnotatedElement parent = injectee.getParent();
String beanName = null;
if (parent != null) {
Qualifier an = parent.getAnnotation(Qualifier.class);
if (an != null) {
beanName = an.value();
}
}
boolean required = parent != null ? parent.getAnnotation(Autowired.class).required() : false;
return getBeanFromSpringContext(beanName, injectee, required);
}
代码示例来源:origin: spring-projects/spring-framework
boolean required = (autowired == null || autowired.required());
代码示例来源:origin: OpenNMS/opennms
/**
* Check that all fields that are marked with @Autowired are not null.
* This will identify classes that have been loaded by Spring but have
* not been autowired via {@code <context:annotation-config />}.
*/
public static <T> void assertAutowiring(T instance) {
for (Field field : instance.getClass().getDeclaredFields()) {
Autowired autowired = field.getAnnotation(Autowired.class);
Inject inject = field.getAnnotation(Inject.class);
Resource resource = field.getAnnotation(Resource.class);
if (
(autowired != null && autowired.required()) ||
(inject != null) ||
(resource != null)
) {
try {
field.setAccessible(true);
notNull(field.get(instance), "@Autowired/@Inject/@Resource field " + field.getName() + " cannot be null");
LOG.debug("{} is not null", field.getName());
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Illegal access to @Autowired/@Resource field " + field.getName());
}
}
}
}
}
代码示例来源:origin: org.glassfish.jersey.ext/jersey-spring4
@Override
public Object resolve(Injectee injectee) {
AnnotatedElement parent = injectee.getParent();
String beanName = null;
if (parent != null) {
Qualifier an = parent.getAnnotation(Qualifier.class);
if (an != null) {
beanName = an.value();
}
}
boolean required = parent != null ? parent.getAnnotation(Autowired.class).required() : false;
return getBeanFromSpringContext(beanName, injectee, required);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Determine whether the given dependency declares an autowired annotation,
* checking its required flag.
* @see Autowired#required()
*/
@Override
public boolean isRequired(DependencyDescriptor descriptor) {
if (!super.isRequired(descriptor)) {
return false;
}
Autowired autowired = descriptor.getAnnotation(Autowired.class);
return (autowired == null || autowired.required());
}
代码示例来源:origin: com.haulmont.cuba/cuba-gui
required = element.getAnnotation(WindowParam.class).required();
} else if (element.isAnnotationPresent(Autowired.class)) {
required = element.getAnnotation(Autowired.class).required();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test
boolean required = (autowired == null || autowired.required());
代码示例来源:origin: apache/servicemix-bundles
boolean required = (autowired == null || autowired.required());
内容来源于网络,如有侵权,请联系作者删除!