本文整理汇总了Java中com.alibaba.dubbo.config.annotation.Reference类的典型用法代码示例。如果您正苦于以下问题:Java Reference类的具体用法?Java Reference怎么用?Java Reference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Reference类属于com.alibaba.dubbo.config.annotation包,在下文中一共展示了Reference类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveInterfaceName
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
private static String resolveInterfaceName(Reference reference, Class<?> beanClass)
throws IllegalStateException {
String interfaceName;
if (!"".equals(reference.interfaceName())) {
interfaceName = reference.interfaceName();
} else if (!void.class.equals(reference.interfaceClass())) {
interfaceName = reference.interfaceClass().getName();
} else if (beanClass.isInterface()) {
interfaceName = beanClass.getName();
} else {
throw new IllegalStateException(
"The @Reference undefined interfaceClass or interfaceName, and the property type "
+ beanClass.getName() + " is not a interface.");
}
return interfaceName;
}
示例2: configAndBuild
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceBean configAndBuild(Reference reference, Class<?> interfaceClass) throws Exception {
ReferenceBean referenceBean = new ReferenceBean(reference);
referenceBean.setApplication(findBean(reference.application(), ApplicationConfig.class));
referenceBean.setRegistries(findBean(reference.registry(), RegistryConfig.class));
referenceBean.setModule(findBean(reference.module(), ModuleConfig.class));
referenceBean.setApplicationContext(applicationContext);
referenceBean.setInterface(interfaceClass);
referenceBean.afterPropertiesSet();
return referenceBean;
}
示例3: inject
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
protected void inject(final MethodInvocation invocation, final Method method, final Class<?> returnType) throws Throwable {
final Reference reference = method.getAnnotation(Reference.class);
final ReferenceConfig<?> refer = new ReferenceConfig<>(reference);
refer.setCheck(reference.check());
refer.setInterface(returnType);
final Object newInstance = ReferenceConfigCache.getCache().get(refer);
setInstance(invocation.getThis(), method, returnType, newInstance);
}
示例4: injectMembers
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
public void injectMembers(final T instance) {
try {
final Reference reference = field.getAnnotation(Reference.class);
final ReferenceConfig<?> refer = new ReferenceConfig<>(reference);
refer.setCheck(reference.check());
refer.setInterface(field.getType());
final Object newInstance = ReferenceConfigCache.getCache().get(refer);
field.set(instance, newInstance);
} catch (final IllegalAccessException e) {
throw (Error) new IllegalAccessError(e.getMessage()).initCause(e);
}
}
示例5: findFieldReferenceMetadata
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
/**
* Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} fields
*
* @param beanClass The {@link Class} of Bean
* @return non-null {@link List}
*/
private List<InjectionMetadata.InjectedElement> findFieldReferenceMetadata(final Class<?> beanClass) {
final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
Reference reference = findReferenceAnnotation(field);
if (reference != null) {
if (Modifier.isStatic(field.getModifiers())) {
if (logger.isWarnEnabled()) {
logger.warn("@Reference annotation is not supported on static fields: " + field);
}
return;
}
elements.add(new ReferenceFieldElement(field, reference));
}
}
});
return elements;
}
示例6: findMethodReferenceMetadata
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
/**
* Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} methods
*
* @param beanClass The {@link Class} of Bean
* @return non-null {@link List}
*/
private List<InjectionMetadata.InjectedElement> findMethodReferenceMetadata(final Class<?> beanClass) {
final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
ReflectionUtils.doWithMethods(beanClass, new ReflectionUtils.MethodCallback() {
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
if (!BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod)) {
return;
}
Reference reference = findReferenceAnnotation(bridgedMethod);
if (reference != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
if (Modifier.isStatic(method.getModifiers())) {
if (logger.isWarnEnabled()) {
logger.warn("@Reference annotation is not supported on static methods: " + method);
}
return;
}
if (method.getParameterTypes().length == 0) {
if (logger.isWarnEnabled()) {
logger.warn("@Reference annotation should only be used on methods with parameters: " +
method);
}
}
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
elements.add(new ReferenceMethodElement(method, pd, reference));
}
}
});
return elements;
}
示例7: ReferenceBean
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceBean(Reference reference) {
super(reference);
}
示例8: ReferenceConfig
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceConfig(Reference reference) {
appendAnnotation(Reference.class, reference);
}
示例9: ReferenceInjectedElement
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
protected ReferenceInjectedElement(Member member, PropertyDescriptor pd, Reference reference) {
super(member, pd);
this.reference = reference;
}
示例10: configure
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
public void configure(final Binder binder) {
binder.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Reference.class), new DubboReferenceInterceptor());
}
示例11: getHelloWorldService
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Inject
@Reference(check = false, url = "dubbo://" + SERVER + "/org.nanoframework.extension.dubbo.service.HelloWorldService")
public HelloWorldService getHelloWorldService() {
return helloWorldService;
}
示例12:
import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Inject
@Reference(check = false, url = "dubbo://" + SERVER + "/org.nanoframework.extension.dubbo.service.HelloWorld2Service")
public HelloWorld2Service getHelloWorld2Service() {
return helloWorld2Service;
}