当前位置: 首页>>代码示例>>Java>>正文


Java ServiceBean类代码示例

本文整理汇总了Java中com.alibaba.dubbo.config.spring.ServiceBean的典型用法代码示例。如果您正苦于以下问题:Java ServiceBean类的具体用法?Java ServiceBean怎么用?Java ServiceBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceBean类属于com.alibaba.dubbo.config.spring包,在下文中一共展示了ServiceBean类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProxy

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public Object getProxy(String interfaceClass) {
    Set<Entry<Class<?>, Object>> entrySet = interfaceMapProxy.entrySet();
    for (Entry<Class<?>, Object> entry : entrySet) {
        if (entry.getKey().getName().equals(interfaceClass)) { return entry.getValue(); }
    }

    for (ServiceBean<?> service : services) {
        if (interfaceClass.equals(service.getInterfaceClass().getName())) {
            ReferenceConfig<Object> reference = new ReferenceConfig<Object>();
            reference.setApplication(service.getApplication());
            reference.setRegistry(service.getRegistry());
            reference.setRegistries(service.getRegistries());
            reference.setInterface(service.getInterfaceClass());
            reference.setVersion(service.getVersion());
            interfaceMapProxy.put(service.getInterfaceClass(), reference.get());
            return reference.get();
        }
    }
    return null;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:21,代码来源:ReferenceManager.java

示例2: init

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public void init() {
 //对标签中名字为application的进行解析,这里dubbo使用了统一的DubboBeanDefinitionParser进行解析。
    //DubboBeanDefinitionParser实现了BeanDefinitionParser接口,实现parse方法对标签进行解析。
    //将解析之后的标签变成Spring中的一个Bean对象。
    //application对应一个ApplicationConfig。
    //在执行完init方法之后,spring会得到所有的下面这个10个handler
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:DubboNamespaceHandler.java

示例3: getInstance

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public synchronized static ReferenceManager getInstance() {
    if (null != instance) return instance;
    instance = new ReferenceManager();
    Map<String, ServiceBean> beansOfType = ServiceBean.getSpringContext()
            .getBeansOfType(ServiceBean.class);
    services = beansOfType.values();
    for (ServiceBean<?> bean : services) {
        interfaceMapRef.put(bean.getInterfaceClass(), bean.getRef());
    }
    return instance;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:13,代码来源:ReferenceManager.java

示例4: init

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:DubboNamespaceHandler.java

示例5: init

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
    registerBeanDefinitionParser("mockSystemUrl", new DubboBeanDefinitionParser(MockSystemUrlConfig.class, true));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:14,代码来源:DubboNamespaceHandler.java

示例6: check

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Status check() {
    ApplicationContext context = ServiceBean.getSpringContext();
    if (context == null) {
        return new Status(Status.Level.UNKNOWN);
    }
    Map<String, DataSource> dataSources = context.getBeansOfType(DataSource.class, false, false);
    if (dataSources == null || dataSources.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Map.Entry<String, DataSource> entry : dataSources.entrySet()) {
        DataSource dataSource = entry.getValue();
        if (buf.length() > 0) {
            buf.append(", ");
        }
        buf.append(entry.getKey());
        try {
            try (Connection connection = dataSource.getConnection()) {
                DatabaseMetaData metaData = connection.getMetaData();
                try (ResultSet resultSet = metaData.getTypeInfo()) {
                    if (!resultSet.next()) {
                        level = Status.Level.ERROR;
                    }
                }
                buf.append(metaData.getURL());
                buf.append("(");
                buf.append(metaData.getDatabaseProductName());
                buf.append("-");
                buf.append(metaData.getDatabaseProductVersion());
                buf.append(")");
            }
        } catch (Throwable e) {
            logger.warn(e.getMessage(), e);
            return new Status(level, e.getMessage());
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:41,代码来源:DataSourceStatusChecker.java

示例7: init

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
        // 注意这里是<dubbo:annotation package="com.package.to.be.scanned" />的解析
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:yuexiahandao,项目名称:DubboCode,代码行数:14,代码来源:DubboNamespaceHandler.java

示例8: init

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
public void init() {
    registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:13,代码来源:DubboNamespaceHandler.java

示例9: getServices

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Collection<ServiceBean> getServices() {
    return services;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:5,代码来源:ReferenceManager.java

示例10: check

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Status check() {
    ApplicationContext context = ServiceBean.getSpringContext();
    if (context == null) {
        return new Status(Status.Level.UNKNOWN);
    }
    Map<String, DataSource> dataSources = context.getBeansOfType(DataSource.class, false, false);
    if (dataSources == null || dataSources.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Map.Entry<String, DataSource> entry : dataSources.entrySet()) {
        DataSource dataSource = entry.getValue();
        if (buf.length() > 0) {
            buf.append(", ");
        }
        buf.append(entry.getKey());
        try {
            Connection connection = dataSource.getConnection();
            try {
                DatabaseMetaData metaData = connection.getMetaData();
                ResultSet resultSet = metaData.getTypeInfo();
                try {
                    if (! resultSet.next()) {
                        level = Status.Level.ERROR;
                    }
                } finally {
                    resultSet.close();
                }
                buf.append(metaData.getURL());
                buf.append("(");
                buf.append(metaData.getDatabaseProductName());
                buf.append("-");
                buf.append(metaData.getDatabaseProductVersion());
                buf.append(")");
            } finally {
                connection.close();
            }
        } catch (Throwable e) {
            logger.warn(e.getMessage(), e);
            return new Status(level, e.getMessage());
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:47,代码来源:DataSourceStatusChecker.java

示例11: check

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Status check() {
    ApplicationContext context = ServiceBean.getSpringContext();
    if (context == null) {
        return new Status(Status.Level.UNKNOWN);
    }
    Map<String, DataSource> dataSources = context.getBeansOfType(DataSource.class, false, false);
    if (dataSources == null || dataSources.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Map.Entry<String, DataSource> entry : dataSources.entrySet()) {
        DataSource dataSource = entry.getValue();
        if (buf.length() > 0) {
            buf.append(", ");
        }
        buf.append(entry.getKey());
        try {
            Connection connection = dataSource.getConnection();
            try {
                DatabaseMetaData metaData = connection.getMetaData();
                ResultSet resultSet = metaData.getTypeInfo();
                try {
                    if (!resultSet.next()) {
                        level = Status.Level.ERROR;
                    }
                } finally {
                    resultSet.close();
                }
                buf.append(metaData.getURL());
                buf.append("(");
                buf.append(metaData.getDatabaseProductName());
                buf.append("-");
                buf.append(metaData.getDatabaseProductVersion());
                buf.append(")");
            } finally {
                connection.close();
            }
        } catch (Throwable e) {
            logger.warn(e.getMessage(), e);
            return new Status(level, e.getMessage());
        }
    }
    return new Status(level, buf.toString());
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:47,代码来源:DataSourceStatusChecker.java

示例12: buildServiceBeanDefinition

import com.alibaba.dubbo.config.spring.ServiceBean; //导入依赖的package包/类
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass,
                                                          String annotatedServiceBeanName) {

    BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class)
            .addConstructorArgValue(service)
            // References "ref" property to [email protected] Bean
            .addPropertyReference("ref", annotatedServiceBeanName)
            .addPropertyValue("interfaceClass", interfaceClass);

    /**
     * Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference
     */
    String providerConfigBeanName = service.provider();
    if (StringUtils.hasText(providerConfigBeanName)) {
        builder.addPropertyReference("provider", providerConfigBeanName);
    }

    /**
     * Add {@link com.alibaba.dubbo.config.MonitorConfig} Bean reference
     */
    String monitorConfigBeanName = service.monitor();
    if (StringUtils.hasText(monitorConfigBeanName)) {
        builder.addPropertyReference("monitor", monitorConfigBeanName);
    }

    /**
     * Add {@link com.alibaba.dubbo.config.ApplicationConfig} Bean reference
     */
    String applicationConfigBeanName = service.application();
    if (StringUtils.hasText(applicationConfigBeanName)) {
        builder.addPropertyReference("application", applicationConfigBeanName);
    }

    /**
     * Add {@link com.alibaba.dubbo.config.ModuleConfig} Bean reference
     */
    String moduleConfigBeanName = service.module();
    if (StringUtils.hasText(moduleConfigBeanName)) {
        builder.addPropertyReference("application", moduleConfigBeanName);
    }


    /**
     * Add {@link com.alibaba.dubbo.config.RegistryConfig} Bean reference
     */
    String[] registryConfigBeanNames = service.registry();

    List<RuntimeBeanReference> registryRuntimeBeanReferences = toRuntimeBeanReferences(registryConfigBeanNames);

    if (!registryRuntimeBeanReferences.isEmpty()) {
        builder.addPropertyValue("registries", registryRuntimeBeanReferences);
    }

    /**
     * Add {@link com.alibaba.dubbo.config.ProtocolConfig} Bean reference
     */
    String[] protocolConfigBeanNames = service.protocol();

    List<RuntimeBeanReference> protocolRuntimeBeanReferences = toRuntimeBeanReferences(protocolConfigBeanNames);

    if (!registryRuntimeBeanReferences.isEmpty()) {
        builder.addPropertyValue("protocols", protocolRuntimeBeanReferences);
    }

    return builder.getBeanDefinition();

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:68,代码来源:DubboComponentScanRegistrar.java


注:本文中的com.alibaba.dubbo.config.spring.ServiceBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。