當前位置: 首頁>>代碼示例>>Java>>正文


Java InjectionPoint.getMember方法代碼示例

本文整理匯總了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);
}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:19,代碼來源:MockResourceInjectionServices.java

示例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;
}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:26,代碼來源:MockResourceInjectionServices.java

示例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];
    }
}
 
開發者ID:adminfaces,項目名稱:admin-persistence,代碼行數:18,代碼來源:CrudService.java

示例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;
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:19,代碼來源:PropertyFactory.java

示例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));
    }
}
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:14,代碼來源:ConfiguredType.java

示例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");
}
 
開發者ID:notsojug,項目名稱:jug-material,代碼行數:11,代碼來源:InjectionPointTest.java

示例7: ConfiguredField

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
ConfiguredField(InjectionPoint injectionPoint, String key){
    this.field = (Field)injectionPoint.getMember();
    this.key = key;
}
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:5,代碼來源:ConfiguredField.java

示例8: ConfiguredMethod

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
ConfiguredMethod(InjectionPoint injectionPoint, String key){
    this.method = (Method)injectionPoint.getMember();
    this.key = key;
}
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:5,代碼來源:ConfiguredMethod.java


注:本文中的javax.enterprise.inject.spi.InjectionPoint.getMember方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。