首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过blueprint xml设置引用

通过blueprint xml设置引用
EN

Stack Overflow用户
提问于 2017-09-19 00:59:45
回答 1查看 435关注 0票数 0

我试图将一个接口的引用作为一个类中的属性传递(继承另一个类),我得到一个错误。我在一个不继承任何东西的类中尝试了同样的方法,它工作得很好。我不知道我是不是错过了什么。任何帮助都是非常感谢的。谢谢:)

类:

代码语言:javascript
复制
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.ScheduledPollConsumer;

import com.walmart.utils.storeConfig.api.IStoreConfigService;


public class WalPipeConsumer extends ScheduledPollConsumer
{
    final static private String CLASS_NAME = WalPipeConsumer.class.getName();

    final static private Logger logger = Logger.getLogger(CLASS_NAME);

    protected Hashtable pipeBuffers;

    private Vector msgs = new Vector();

    private int arrrayLength = 0, headerLength = 0;

    private final Endpoint endpoint;

    private final String pipe;

    private IStoreConfigService storeConfigService;

public WalPipeConsumer(Endpoint endpoint, Processor processor, String pipe)
        throws Exception
{
    super(endpoint, processor);
    logger.finest("inside the wal pipe consumer constructor");
    this.pipe = pipe;
    this.endpoint = endpoint;
    this.countryCode = countryCode;
    logger.finest("before starting the thread");
    new Thread(new WalPipeInputRunner(), "WalCamel Pipe Consumer[" + pipe
            + "]").start();
    logger.finest("after starting the thread");
}

// There are some more functions 
/**
 * @param storeConfigServicethe storeConfigService to set
 */
public void setStoreConfigService(IStoreConfigService storeConfigService) {
    this.storeConfigService = storeConfigService;
}

Blueprint.xml:

代码语言:javascript
复制
<reference id="storeConfigService"
    interface="com.walmart.utils.storeConfig.api.IStoreConfigService" />

<bean id="storeConfigAdapter" class="com.tgcs.walpipe.endpoint.StoreConfigAdapter" init-method="init">
    <property name="storeConfigService" ref="storeConfigService" />
</bean>

<bean id="WalPipeConsumer" class="com.tgcs.walpipe.endpoint.WalPipeConsumer">
    <property name="storeConfigService" ref="storeConfigService" /> 
</bean>

错误:

代码语言:javascript
复制
[2017.09.15-10:34:00.788] [SEVERE] 
[org.apache.aries.blueprint.container.BlueprintContainerImpl] 
[org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun] - Unable 
to start blueprint container for bundle com.tgcs.walpipe.endpoint
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to 
find a matching constructor on class 
com.tgcs.walpipe.endpoint.WalPipeConsumer for arguments [] when 
instanciating bean WalPipeConsumer 
EN

回答 1

Stack Overflow用户

发布于 2017-09-19 02:40:54

Blueprint尝试创建WalPipeConsumer的实例。您正在使用属性来设置storeConfigService。因此blueprint将首先调用空构造函数来实例化该类,然后调用设置器来设置storeConfigService。

因为该类没有空的构造器,所以这将失败。

要解决这个问题,要么需要一个空的构造函数,要么使用元素来设置现有构造函数的所有参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46284624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档