本文整理匯總了Java中javax.enterprise.inject.spi.InjectionPoint.getMember方法的典型用法代碼示例。如果您正苦於以下問題:Java InjectionPoint.getMember方法的具體用法?Java InjectionPoint.getMember怎麽用?Java InjectionPoint.getMember使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.enterprise.inject.spi.InjectionPoint
的用法示例。
在下文中一共展示了InjectionPoint.getMember方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveResource
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Override
public Object resolveResource(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotation(injectionPoint);
if (resource == null) {
throw new IllegalArgumentException("No @Resource annotation found on " + injectionPoint);
}
if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1) {
throw new IllegalArgumentException(
"Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
}
String name;
if (!resource.lookup().equals("")) {
name = resource.lookup();
} else {
name = getResourceName(injectionPoint);
}
return resources.get(name);
}
示例2: getResourceName
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
private String getResourceName(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotation(injectionPoint);
String mappedName = resource.mappedName();
if (!mappedName.equals("")) {
return mappedName;
}
String name = resource.name();
if (!name.equals("")) {
return RESOURCE_LOOKUP_PREFIX + "/" + name;
}
String propertyName;
if (injectionPoint.getMember() instanceof Field) {
propertyName = injectionPoint.getMember().getName();
} else if (injectionPoint.getMember() instanceof Method) {
propertyName = getPropertyName((Method) injectionPoint.getMember());
if (propertyName == null) {
throw new IllegalArgumentException("Injection point represents a method which doesn't follow "
+ "JavaBean conventions (unable to determine property name) " + injectionPoint);
}
} else {
throw new AssertionError("Unable to inject into " + injectionPoint);
}
String className = injectionPoint.getMember().getDeclaringClass().getName();
return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
}
示例3: CrudService
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Inject
protected void CrudService(InjectionPoint ip) {
if (ip != null && ip.getType() != null && ip.getMember() != null) {
try {
//Used for generic service injection, e.g: @Inject @Service CrudService<Entity,Key>
resolveEntity(ip);
} catch (Exception e) {
LOG.warning(String.format("Could not resolve entity type and entity key via injection point [%s]. Now trying to resolve via generic superclass of [%s].", ip.getMember().getName(), getClass().getName()));
}
}
if (entityClass == null) {
//Used on service inheritance, e.g: MyService extends CrudService<Entity, Key>
entityClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
entityKey = (Class<PK>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[1];
}
}
示例4: getPropertyName
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
String getPropertyName(final InjectionPoint point, final String propertyName) {
if (!propertyName.isEmpty()) {
return propertyName;
}
Member member = point.getMember();
final String name;
if (member instanceof Executable) {
Annotated annotated = point.getAnnotated();
int p = ((AnnotatedParameter<?>) annotated).getPosition();
name = member.getName() + ".arg" + p;
} else {
name = member.getName();
}
return name;
}
示例5: addConfiguredMember
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
/**
* Used to build up during injection point processing.
* @param injectionPoint the CDI injection point, not null.
* @param key the possible config key, not null.
*/
void addConfiguredMember(InjectionPoint injectionPoint, String key) {
Member member = injectionPoint.getMember();
if(member instanceof Field){
this.fields.add(new ConfiguredField(injectionPoint, key));
} else if(member instanceof Method){
this.methods.add(new ConfiguredMethod(injectionPoint, key));
}
}
示例6: producerShouldHaveBeenCalledByThisTestClass
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Test
public void producerShouldHaveBeenCalledByThisTestClass() throws Exception {
InjectionPoint injectionPoint = generator.getLatest();
Member injectDestination= injectionPoint.getMember();
// you can get the class of the object that is requesting injection.
assertThat(injectDestination.getDeclaringClass()).isSameAs(this.getClass());
// the name of the field/parameter in which to inject
assertThat(injectDestination.getName()).isEqualTo("addUser");
}
示例7: ConfiguredField
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
ConfiguredField(InjectionPoint injectionPoint, String key){
this.field = (Field)injectionPoint.getMember();
this.key = key;
}
示例8: ConfiguredMethod
import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
ConfiguredMethod(InjectionPoint injectionPoint, String key){
this.method = (Method)injectionPoint.getMember();
this.key = key;
}