本文整理汇总了Java中org.glassfish.hk2.api.ActiveDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ActiveDescriptor类的具体用法?Java ActiveDescriptor怎么用?Java ActiveDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActiveDescriptor类属于org.glassfish.hk2.api包,在下文中一共展示了ActiveDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: activate
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
protected void activate(ActiveDescriptor<?> handle, Object service, Method method, CachedGauge annotation) {
if (method.getParameterCount() != 0) {
log.error("@CachedGauge placed on method {} which must have zero parameters, but has {}", method, method.getParameterCount());
return;
}
com.codahale.metrics.CachedGauge<?> gauge = new com.codahale.metrics.CachedGauge<Object>(annotation.timeout(),
annotation.timeoutUnit()
) {
@Override
protected Object loadValue() {
try {
return method.invoke(service);
} catch (Exception e) {
throw new RuntimeException("Failed to read gauge value from " + method, e instanceof InvocationTargetException ? (
(InvocationTargetException) e
).getTargetException() : e);
}
}
};
String name = metricNameService.getFormattedMetricName(method, com.codahale.metrics.CachedGauge.class);
log.debug("Activating cached gauge {} monitoring {}", name, method);
metricRegistry.register(name, gauge);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:25,代码来源:CachedGaugeAnnotationActivator.java
示例2: activate
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
protected void activate(ActiveDescriptor<?> handle, Object service, Method method, Gauge annotation) {
if (method.getParameterCount() != 0) {
log.error("@Gauge placed on method {} which must have zero parameters, but has {}", method, method.getParameterCount());
return;
}
com.codahale.metrics.Gauge<?> gauge = () -> {
try {
return method.invoke(service);
} catch (Exception e) {
throw new RuntimeException("Failed to read gauge value from " + method, e instanceof InvocationTargetException ? (
(InvocationTargetException) e
).getTargetException() : e);
}
};
String name = metricNameService.getFormattedMetricName(method, com.codahale.metrics.Gauge.class);
log.debug("Activating gauge {} monitoring {}", name, method);
metricRegistry.register(name, gauge);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:20,代码来源:GaugeAnnotationActivator.java
示例3: resolve
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public Object resolve(Injectee injectee, ServiceHandle<?> root) {
ActiveDescriptor<?> descriptor = locator.getInjecteeDescriptor(injectee);
if (descriptor == null) {
// Is it OK to return null?
if (isNullable(injectee)) {
return null;
}
throw new MultiException(new UnsatisfiedDependencyException(injectee));
}
return locator.getService(descriptor, root, injectee);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:17,代码来源:GuiceThreeThirtyResolver.java
示例4: newActiveDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
/**
* @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator)
* @see #newGuiceInjectionResolverDescriptor(ServiceLocator, ActiveDescriptor)
*/
private static <T extends Annotation> ActiveDescriptor<InjectionResolver<T>> newActiveDescriptor(ServiceLocator locator,
InjectionResolver<T> resolver, Set<Annotation> qualifiers, String name, Class<? extends T> clazz) {
Set<Type> contracts = Collections.<Type>singleton(
new ParameterizedTypeImpl(InjectionResolver.class, clazz));
ActiveDescriptor<InjectionResolver<T>> descriptor =
new ConstantActiveDescriptor<InjectionResolver<T>>(
resolver, contracts, Singleton.class,
name, qualifiers, DescriptorVisibility.NORMAL,
0, (Boolean)null, (Boolean)null, (String)null,
locator.getLocatorId(), (Map<String, List<String>>)null);
return descriptor;
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:20,代码来源:BindingUtils.java
示例5: init
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
/**
* Scan the requested packages on the classpath for HK2 'Service' and 'Contract' annotated classes.
* Load the metadata for those classes into the HK2 Service Locator.
*
* This implementation should support all Annotations that are supported by HK2 - however - if you are using
* HK2 older than 2.3.0 - note that it is impacted by this bug: https://java.net/jira/browse/HK2-187
*
* For an implementation that is not impacted by that bug, see {@link HK2RuntimeInitializerCustom}
*
* @see org.glassfish.hk2.api.ServiceLocatorFactory#create(String)
* @see ServiceLocatorUtilities#createAndPopulateServiceLocator(String)
*
* @param serviceLocatorName - The name of the ServiceLocator to find (or create if it doesn't yet exist)
* @param readInhabitantFiles - Read and process inhabitant files before doing the classpath scan. Annotated items
* found during the scan will override items found in the inhabitant files, if they collide.
* @param packageNames -- The set of package names to scan recursively - for example - new String[]{"org.foo", "com.bar"}
* If not provided, the entire classpath is scanned
* @return - The created ServiceLocator (but in practice, you can lookup this ServiceLocator by doing:
* <pre>
* {@code
* ServiceLocatorFactory.getInstance().create("SomeName");
* }
* </pre>
* @throws IOException
* @throws ClassNotFoundException
*/
public static ServiceLocator init(String serviceLocatorName, boolean readInhabitantFiles, String ... packageNames) throws IOException, ClassNotFoundException
{
AnnotatedClasses ac = new AnnotatedClasses();
@SuppressWarnings("unchecked")
AnnotationDetector cf = new AnnotationDetector(new AnnotationReporter(ac, new Class[]{Service.class}));
if (packageNames == null || packageNames.length == 0)
{
cf.detect();
}
else
{
cf.detect(packageNames);
}
ServiceLocator locator = null;
if (readInhabitantFiles)
{
locator = ServiceLocatorUtilities.createAndPopulateServiceLocator(serviceLocatorName);
}
else
{
ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance();
locator = factory.create(serviceLocatorName);
}
for (ActiveDescriptor<?> ad : ServiceLocatorUtilities.addClasses(locator, ac.getAnnotatedClasses()))
{
log.debug("Added " + ad.toString());
}
return locator;
}
开发者ID:darmbrust,项目名称:HK2Utilities,代码行数:61,代码来源:HK2RuntimeInitializer.java
示例6: listInjected
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
private void listInjected(ServiceLocator locator) {
LOGGER.trace("registered injectables [{}]:", locator.getName());
for (ActiveDescriptor<?> descriptor : locator.getDescriptors(d -> true)) {
LOGGER.trace("registered c:{} s:{} r:{} d:{}", descriptor.getImplementation(), descriptor.getScope(), descriptor.isReified(), descriptor);
}
}
开发者ID:redbooth,项目名称:baseline,代码行数:8,代码来源:Service.java
示例7: newThreeThirtyInjectionResolverDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
/**
* Creates and returns a {@link InjectionResolver} for {@link javax.inject.Inject}.
*
* @see javax.inject.Inject
* @see InjectionResolver
*/
public static ActiveDescriptor<InjectionResolver<javax.inject.Inject>> newThreeThirtyInjectionResolverDescriptor(ServiceLocator locator) {
GuiceThreeThirtyResolver resolver
= new GuiceThreeThirtyResolver(locator);
Set<Annotation> qualifiers = Collections.<Annotation>singleton(
new NamedImpl(SYSTEM_RESOLVER_NAME));
return newActiveDescriptor(locator, resolver, qualifiers, SYSTEM_RESOLVER_NAME, javax.inject.Inject.class);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:16,代码来源:BindingUtils.java
示例8: newGuiceInjectionResolverDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
/**
* Creates and returns a {@link InjectionResolver} for {@link com.google.inject.Inject}
*
* @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator)
* @see com.google.inject.Inject
* @see InjectionResolver
*/
public static ActiveDescriptor<InjectionResolver<com.google.inject.Inject>> newGuiceInjectionResolverDescriptor(ServiceLocator locator,
ActiveDescriptor<? extends InjectionResolver<?>> threeThirtyResolver) {
GuiceInjectionResolver resolver = new GuiceInjectionResolver(threeThirtyResolver);
Set<Annotation> qualifiers = Collections.emptySet();
return newActiveDescriptor(locator, resolver, qualifiers, GUICE_RESOLVER_NAME, com.google.inject.Inject.class);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:16,代码来源:BindingUtils.java
示例9: getInterceptors
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
protected <T extends Executable, I extends Interceptor, F> List<I> getInterceptors(
T interceptee,
IterableProvider<? extends F> factoryProviders,
Class<F> interceptorType,
InterceptorFactory<F, T, Annotation, I> interceptorProvider
) {
List<I> interceptors = Lists.newArrayList();
factoryProviders.handleIterator().forEach(handle -> {
// Make sure descriptor is fully reified
ActiveDescriptor<?> descriptor = handle.getActiveDescriptor();
if (!descriptor.isReified()) {
descriptor = locator.reifyDescriptor(descriptor);
}
// Check the type of annotation supported by the factory
for (Type contract : descriptor.getContractTypes()) {
if (ReflectionHelper.getRawClass(contract) == interceptorType) {
Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) ReflectionHelper.getRawClass(
ReflectionHelper.getFirstTypeArgument(contract));
// Might be Object.class if getRawClass found an unbound type variable or wildcard
if (!Annotation.class.isAssignableFrom(annotationClass)) {
log.warn("Unable to determine annotation binder from contract type {}", annotationClass);
return;
}
Annotation ann = interceptee.getAnnotation(annotationClass);
if (ann == null) {
ann = interceptee.getDeclaringClass().getAnnotation(annotationClass);
}
if (ann != null) {
// Create the factory and produce an interceptor
F factory = handle.getService();
I interceptor = interceptorProvider.apply(factory, interceptee, ann);
if (interceptor != null) {
interceptors.add(interceptor);
}
}
return;
}
}
});
return interceptors;
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:42,代码来源:AnnotationInterceptionService.java
示例10: activate
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
protected void activate(ActiveDescriptor<?> descriptor, Object service, ManagedObject annotation) {
container.beanAdded(null, service);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:5,代码来源:MBeanActivator.java
示例11: deactivate
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
protected void deactivate(ActiveDescriptor<?> descriptor, Object service, ManagedObject annotation) {
container.beanRemoved(null, service);
}
开发者ID:baharclerode,项目名称:dropwizard-hk2,代码行数:5,代码来源:MBeanActivator.java
示例12: getDescriptors
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public List<ActiveDescriptor<?>> getDescriptors(Filter filter) {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:OAuthServiceLocatorShim.java
示例13: getBestDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public ActiveDescriptor<?> getBestDescriptor(Filter filter) {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:OAuthServiceLocatorShim.java
示例14: reifyDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor, Injectee injectee) throws MultiException {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:OAuthServiceLocatorShim.java
示例15: getInjecteeDescriptor
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public ActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee) throws MultiException {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:OAuthServiceLocatorShim.java
示例16: getServiceHandle
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee) throws MultiException {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:OAuthServiceLocatorShim.java
示例17: getService
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public <T> T getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root) throws MultiException {
throw new UnsupportedOperationException("Will not be supported!");
}
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:6,代码来源:OAuthServiceLocatorShim.java
示例18: GuiceInjectionResolver
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
public GuiceInjectionResolver(ActiveDescriptor<? extends InjectionResolver<?>> descriptor) {
this.descriptor = descriptor;
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:4,代码来源:GuiceInjectionResolver.java
示例19: findOrCreate
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public <U> U findOrCreate(ActiveDescriptor<U> descriptor, ServiceHandle<?> root) {
return descriptor.create(root);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:5,代码来源:GuiceScopeContext.java
示例20: containsKey
import org.glassfish.hk2.api.ActiveDescriptor; //导入依赖的package包/类
@Override
public boolean containsKey(ActiveDescriptor<?> descriptor) {
return false;
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:5,代码来源:GuiceScopeContext.java
注:本文中的org.glassfish.hk2.api.ActiveDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论