如何在 wso2cep 4.0.0 中添加自定义输入事件接收器?
How can I add custom input event receiver in wso2cep 4.0.0?
我正在尝试根据 wso2cep 4.0.0 文档和来自 cep/repository/components/plugins.(https://docs.wso2.com/display/CEP400/Building+Custom+Event+Receivers).[=14 的 filetail 输入事件接收器的反编译版本创建自定义输入事件接收器=]
到目前为止,我已经成功地添加了反编译版本中的所有 classes,并以此为基础构建了一个项目。在我将其复制到 cep_home/repository/components/dropins 后,我尝试启动 CEP 服务器,然后我遇到了这个:
[2015-12-04 14:00:31,483] ERROR {org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS} - Cannot create the MultipleFile input event adapter service!
java.util.MissingResourceException: Can't find bundle for base name org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:795)
at org.wso2.carbon.event.input.adapter.multiplefiletail.MultipleFileTailEventAdapterFactory.<init>(MultipleFileTailEventAdapterFactory.java:20)
at org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS.activate(MultipleFileTailEventAdapterServiceDS.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:517)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)}
错误出现在行:private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapter;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory;
import org.wso2.carbon.event.input.adapter.core.Property;
public class MultipleFileTailEventAdapterFactory
extends InputEventAdapterFactory
{
private static final Log log = LogFactory.getLog(MultipleFileTailEventAdapterFactory.class);
private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());
public String getType()
{
return "multiplefile-tail";
}
public List<String> getSupportedMessageFormats()
{
List<String> supportInputMessageTypes = new ArrayList();
supportInputMessageTypes.add("text");
return supportInputMessageTypes;
}
public List<Property> getPropertyList()
{
List<Property> propertyList = new ArrayList();
log.info("Method call:MultipleFileEventReceiver::getInputMessageProperties()");
Property filePath = new Property("filepath");
filePath.setDisplayName(this.resourceBundle.getString("filepath"));
filePath.setRequired(true);
filePath.setHint(this.resourceBundle.getString("filepathHint"));
propertyList.add(filePath);
Property filePattern = new Property("filepattern");
filePattern.setDisplayName(this.resourceBundle.getString("filepattern"));
filePattern.setRequired(true);
filePattern.setHint(this.resourceBundle.getString("filepatternHint"));
propertyList.add(filePattern);
Property procFolder = new Property("procfolder");
procFolder.setDisplayName(this.resourceBundle.getString("procfolder"));
procFolder.setRequired(true);
procFolder.setHint(this.resourceBundle.getString("procfolderHint"));
propertyList.add(procFolder);
Property streamDefinitionProperty = new Property("separator");
streamDefinitionProperty.setDisplayName("separator");
streamDefinitionProperty.setRequired(true);
streamDefinitionProperty.setHint(this.resourceBundle.getString("separatorHint"));
propertyList.add(streamDefinitionProperty);
Property numberFields = new Property("numberFields");
numberFields.setDisplayName(this.resourceBundle.getString("numberFields"));
numberFields.setRequired(true);
numberFields.setHint(this.resourceBundle.getString("numberFieldsHint"));
propertyList.add(numberFields);
return propertyList;
}
public String getUsageTips()
{
return this.resourceBundle.getString("file.usage.tips");
}
public InputEventAdapter createEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, Map<String, String> globalProperties)
{
return new MultipleFileTailEventAdapter(eventAdapterConfiguration, globalProperties);
}
我不明白为什么在原始编译的适配器中 class 是相同的并且可以工作,而在我的情况下却不能。
有人能帮帮我吗??非常感谢!
(如果您需要有关此问题的任何其他信息,请在评论中告诉我,谢谢)
经过更多研究并感谢 Dilini(谢谢!)我设法发现错误出现是因为我错误地配置了 Resources 文件夹,它是
src/main/resources/org/wso2/event/adapter/multiplefiletail/i18n/Resources
而不是
src/main/resources/org/wso2/carbon/event/input/adapter/multiplefiletail/i18n/Resources
就像在 MultipleFileTailEventAdapterFactory class 中配置的一样,出现错误的地方。希望对您有所帮助!
我正在尝试根据 wso2cep 4.0.0 文档和来自 cep/repository/components/plugins.(https://docs.wso2.com/display/CEP400/Building+Custom+Event+Receivers).[=14 的 filetail 输入事件接收器的反编译版本创建自定义输入事件接收器=]
到目前为止,我已经成功地添加了反编译版本中的所有 classes,并以此为基础构建了一个项目。在我将其复制到 cep_home/repository/components/dropins 后,我尝试启动 CEP 服务器,然后我遇到了这个:
[2015-12-04 14:00:31,483] ERROR {org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS} - Cannot create the MultipleFile input event adapter service!
java.util.MissingResourceException: Can't find bundle for base name org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:795)
at org.wso2.carbon.event.input.adapter.multiplefiletail.MultipleFileTailEventAdapterFactory.<init>(MultipleFileTailEventAdapterFactory.java:20)
at org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS.activate(MultipleFileTailEventAdapterServiceDS.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:517)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)}
错误出现在行:private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapter;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory;
import org.wso2.carbon.event.input.adapter.core.Property;
public class MultipleFileTailEventAdapterFactory
extends InputEventAdapterFactory
{
private static final Log log = LogFactory.getLog(MultipleFileTailEventAdapterFactory.class);
private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());
public String getType()
{
return "multiplefile-tail";
}
public List<String> getSupportedMessageFormats()
{
List<String> supportInputMessageTypes = new ArrayList();
supportInputMessageTypes.add("text");
return supportInputMessageTypes;
}
public List<Property> getPropertyList()
{
List<Property> propertyList = new ArrayList();
log.info("Method call:MultipleFileEventReceiver::getInputMessageProperties()");
Property filePath = new Property("filepath");
filePath.setDisplayName(this.resourceBundle.getString("filepath"));
filePath.setRequired(true);
filePath.setHint(this.resourceBundle.getString("filepathHint"));
propertyList.add(filePath);
Property filePattern = new Property("filepattern");
filePattern.setDisplayName(this.resourceBundle.getString("filepattern"));
filePattern.setRequired(true);
filePattern.setHint(this.resourceBundle.getString("filepatternHint"));
propertyList.add(filePattern);
Property procFolder = new Property("procfolder");
procFolder.setDisplayName(this.resourceBundle.getString("procfolder"));
procFolder.setRequired(true);
procFolder.setHint(this.resourceBundle.getString("procfolderHint"));
propertyList.add(procFolder);
Property streamDefinitionProperty = new Property("separator");
streamDefinitionProperty.setDisplayName("separator");
streamDefinitionProperty.setRequired(true);
streamDefinitionProperty.setHint(this.resourceBundle.getString("separatorHint"));
propertyList.add(streamDefinitionProperty);
Property numberFields = new Property("numberFields");
numberFields.setDisplayName(this.resourceBundle.getString("numberFields"));
numberFields.setRequired(true);
numberFields.setHint(this.resourceBundle.getString("numberFieldsHint"));
propertyList.add(numberFields);
return propertyList;
}
public String getUsageTips()
{
return this.resourceBundle.getString("file.usage.tips");
}
public InputEventAdapter createEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, Map<String, String> globalProperties)
{
return new MultipleFileTailEventAdapter(eventAdapterConfiguration, globalProperties);
}
我不明白为什么在原始编译的适配器中 class 是相同的并且可以工作,而在我的情况下却不能。
有人能帮帮我吗??非常感谢!
(如果您需要有关此问题的任何其他信息,请在评论中告诉我,谢谢)
经过更多研究并感谢 Dilini(谢谢!)我设法发现错误出现是因为我错误地配置了 Resources 文件夹,它是
src/main/resources/org/wso2/event/adapter/multiplefiletail/i18n/Resources
而不是
src/main/resources/org/wso2/carbon/event/input/adapter/multiplefiletail/i18n/Resources
就像在 MultipleFileTailEventAdapterFactory class 中配置的一样,出现错误的地方。希望对您有所帮助!