com.lambdaworks.redis.support.AbstractCdiBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lettuce Show documentation
Show all versions of lettuce Show documentation
Advanced and thread-safe Java Redis client for synchronous, asynchronous, and
reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs
and much more.
/*
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lambdaworks.redis.support;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import com.lambdaworks.redis.RedisURI;
import com.lambdaworks.redis.resource.ClientResources;
/**
* @author Mark Paluch
* @since 3.0
*/
abstract class AbstractCdiBean implements Bean {
protected final Bean redisURIBean;
protected final Bean clientResourcesBean;
protected final BeanManager beanManager;
protected final Set qualifiers;
protected final String name;
public AbstractCdiBean(Bean redisURIBean, Bean clientResourcesBean, BeanManager beanManager,
Set qualifiers, String name) {
this.redisURIBean = redisURIBean;
this.clientResourcesBean = clientResourcesBean;
this.beanManager = beanManager;
this.qualifiers = qualifiers;
this.name = name;
}
@Override
@SuppressWarnings("unchecked")
public Set getTypes() {
return Collections.singleton(getBeanClass());
}
@Override
public Set getQualifiers() {
return qualifiers;
}
@Override
public String getName() {
return name;
}
@Override
public Class getScope() {
return ApplicationScoped.class;
}
@Override
public Set> getStereotypes() {
Set> stereotypes = new HashSet<>();
for (Annotation annotation : getQualifiers()) {
Class annotationType = annotation.annotationType();
if (annotationType.isAnnotationPresent(Stereotype.class)) {
stereotypes.add(annotationType);
}
}
return stereotypes;
}
@Override
public boolean isAlternative() {
return false;
}
@Override
public boolean isNullable() {
return false;
}
@Override
public Set getInjectionPoints() {
return Collections.emptySet();
}
}