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


Java InjectionPoint.getType方法代碼示例

本文整理匯總了Java中javax.enterprise.inject.spi.InjectionPoint.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java InjectionPoint.getType方法的具體用法?Java InjectionPoint.getType怎麽用?Java InjectionPoint.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.enterprise.inject.spi.InjectionPoint的用法示例。


在下文中一共展示了InjectionPoint.getType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerEjbInjectionPoint

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public ResourceReferenceFactory<Object> registerEjbInjectionPoint(
        final InjectionPoint injectionPoint
) {
    if (injectionPoint.getAnnotated().getAnnotation(EJB.class) == null) {
        throw new IllegalStateException("Unhandled injection point: " + injectionPoint);
    }
    final Type type = injectionPoint.getType();
    final ResourceReferenceFactory<Object> alternative = alternatives.alternativeFor(type);
    if (alternative != null) {
        return alternative;
    }
    final EjbDescriptor<Object> descriptor = (EjbDescriptor<Object>) lookup.lookup(type);
    if (descriptor == null) {
        throw new IllegalStateException("No EJB descriptor found for EJB injection point: " + injectionPoint);
    }
    return factory.createInstance(descriptor);
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:20,代碼來源:EjbInjectionServicesImpl.java

示例2: 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

示例3: validate

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
public void validate(@Observes AfterDeploymentValidation add, BeanManager bm) {
    List<String> deploymentProblems = new ArrayList<>();

    Config config = ConfigProvider.getConfig();
    for (InjectionPoint injectionPoint : injectionPoints) {
        Type type = injectionPoint.getType();
        ConfigProperty configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
        if (type instanceof Class) {
            String key = getConfigKey(injectionPoint, configProperty);

            if (!config.getOptionalValue(key, (Class)type).isPresent()) {
                String defaultValue = configProperty.defaultValue();
                if (defaultValue == null ||
                        defaultValue.equals(ConfigProperty.UNCONFIGURED_VALUE)) {
                    deploymentProblems.add("No Config Value exists for " + key);
                }
            }
        }
    }

    if (!deploymentProblems.isEmpty()) {
        add.addDeploymentProblem(new DeploymentException("Error while validating Configuration\n"
                + String.join("\n", deploymentProblems)));
    }

}
 
開發者ID:wildfly-extras,項目名稱:wildfly-microprofile-config,代碼行數:27,代碼來源:ConfigExtension.java

示例4: createBeanAdapter

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
/**
 * 
 * @param ip
 * @param beanManager
 * @return
 */
private <T> Bean<T> createBeanAdapter(InjectionPoint ip, BeanManager beanManager) {
	final Type type = ip.getType();
	final Class<T> rawType = ReflectionUtils.getRawType(type);
	final ContextualLifecycle<T> lifecycleAdapter = new BodyLifecycle<T>(ip, beanManager);
	final BeanBuilder<T> beanBuilder = new BeanBuilder<T>(beanManager)
			.readFromType(new AnnotatedTypeBuilder<T>().readFromType(rawType).create())
			.beanClass(Body.class) // see https://issues.jboss.org/browse/WELD-2165
			.name(ip.getMember().getName())
			.qualifiers(ip.getQualifiers())
			.beanLifecycle(lifecycleAdapter)
			.scope(Dependent.class)
			.passivationCapable(false)
			.alternative(false)
			.nullable(true)
			.id("BodyBean#" + type.toString())
			.addType(type); //java.lang.Object needs to be present (as type) in any case
	return beanBuilder.create();
}
 
開發者ID:dansiviter,項目名稱:cito,代碼行數:25,代碼來源:BodyProducerExtension.java

示例5: produceBooleanProperty

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Produces
@Dependent
@Property
public Boolean produceBooleanProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Boolean.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(boolean.class) ? Boolean.FALSE : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:18,代碼來源:PropertyProducerBean.java

示例6: produceIntegerProperty

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Produces
@Dependent
@Property
public Integer produceIntegerProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Integer.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(int.class) ? Integer.valueOf(0) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:18,代碼來源:PropertyProducerBean.java

示例7: produceLongProperty

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Produces
@Dependent
@Property
public Long produceLongProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Long.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(long.class) ? Long.valueOf(0L) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:18,代碼來源:PropertyProducerBean.java

示例8: produceFloatProperty

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Produces
@Dependent
@Property
public Float produceFloatProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Float.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(float.class) ? Float.valueOf(0f) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:18,代碼來源:PropertyProducerBean.java

示例9: produceDoubleProperty

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Produces
@Dependent
@Property
public Double produceDoubleProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Double.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(double.class) ? Double.valueOf(0d) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
開發者ID:xlate,項目名稱:property-inject,代碼行數:18,代碼來源:PropertyProducerBean.java

示例10: AsyncReferenceImpl

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Inject
public AsyncReferenceImpl(InjectionPoint injectionPoint, Vertx vertx, BeanManager beanManager, @Any WeldInstance<Object> instance) {
    this.isDone = new AtomicBoolean(false);
    this.future = new VertxCompletableFuture<>(vertx);
    this.instance = instance;

    ParameterizedType parameterizedType = (ParameterizedType) injectionPoint.getType();
    Type requiredType = parameterizedType.getActualTypeArguments()[0];
    Annotation[] qualifiers = injectionPoint.getQualifiers().toArray(new Annotation[] {});

    // First check if there is a relevant async producer method available
    WeldInstance<Object> completionStage = instance.select(new ParameterizedTypeImpl(CompletionStage.class, requiredType), qualifiers);

    if (completionStage.isAmbiguous()) {
        failure(new AmbiguousResolutionException(
                "Ambiguous async producer methods for type " + requiredType + " with qualifiers " + injectionPoint.getQualifiers()));
    } else if (!completionStage.isUnsatisfied()) {
        // Use the produced CompletionStage
        initWithCompletionStage(completionStage.getHandler());
    } else {
        // Use Vertx worker thread
        initWithWorker(requiredType, qualifiers, vertx, beanManager);
    }
}
 
開發者ID:weld,項目名稱:weld-vertx,代碼行數:25,代碼來源:AsyncReferenceImpl.java

示例11: processClaimValueInjections

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
    log.debugf("pipRaw: %s", pip.getInjectionPoint());
    InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
        Class rawClass = (Class) ip.getType();
        if (Modifier.isFinal(rawClass.getModifiers())) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            rawTypes.add(ip.getType());
            rawTypeQualifiers.add(claim);
            log.debugf("+++ Added Claim raw type: %s", ip.getType());
            Class declaringClass = ip.getMember().getDeclaringClass();
            Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
            Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
            if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
                String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
                pip.addDefinitionError(new DeploymentException(err));
            }

        }
    }
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:22,代碼來源:MPJWTExtension.java

示例12: validate

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
public void validate(@Observes AfterDeploymentValidation add) {
    List<String> deploymentProblems = new ArrayList<>();

    config = ConfigProvider.getConfig();

    for (InjectionPoint injectionPoint : injectionPoints) {
        Type type = injectionPoint.getType();
        ConfigProperty configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
        if (type instanceof Class) {
            // a direct injection of a ConfigProperty
            // that means a Converter must exist.
            String key = ConfigInjectionBean.getConfigKey(injectionPoint, configProperty);
            if (!config.getOptionalValue(key, (Class) type).isPresent()) {
                deploymentProblems.add("No Config Value exists for " + key);
            }
        }
    }

    if (!deploymentProblems.isEmpty()) {
        add.addDeploymentProblem(new DeploymentException("Error while validating Configuration\n"
                                                         + String.join("\n", deploymentProblems)));
    }

}
 
開發者ID:struberg,項目名稱:javaConfig,代碼行數:25,代碼來源:ConfigExtension.java

示例13: resolve

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Override
public Object resolve(final InjectionPoint injectionPoint) {
    if (RestServer.class != injectionPoint.getType()) {
        return null;
    }
    final RestServerImpl server = new RestServerImpl(
            annotationScanner,
            dependencyInjection,
            dependencyInjection.getInstancesOf(StaticResourceResolver.class, releaser)
    );
    servers.add(server);
    return server;
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:14,代碼來源:RestServerResourceProvider.java

示例14: resolve

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Override
public Object resolve(final InjectionPoint injectionPoint) {
    if (null == injectionPoint.getAnnotated().getAnnotation(Resource.class)) {
        return null;
    }
    if (ConnectionFactory.class != injectionPoint.getType()) {
        return null;
    }
    return new TestEEfiConnectionFactory(testQueue::addMessage);
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:11,代碼來源:ConnectionFactoryResourceProvider.java

示例15: resolve

import javax.enterprise.inject.spi.InjectionPoint; //導入方法依賴的package包/類
@Override
public Object resolve(final InjectionPoint injectionPoint) {
    final Resource annotation = injectionPoint.getAnnotated().getAnnotation(Resource.class);
    if (null == annotation) {
        return null;
    }
    if (Queue.class != injectionPoint.getType()) {
        return null;
    }
    return new TestEEfiQueue(annotation.mappedName());
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:12,代碼來源:QueueResourceProvider.java


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