用于扩展 SIDDHI 的 JAR
JAR for extends SIDDHI
我想要扩展 siddhi,mi java 代码是:
package org.wso2.siddhi.extension.fraude;
import org.wso2.siddhi.core.config.ExecutionPlanContext;
import org.wso2.siddhi.core.executor.ExpressionExecutor;
import org.wso2.siddhi.core.executor.function.FunctionExecutor;
import org.wso2.siddhi.query.api.definition.Attribute;
import org.wso2.siddhi.query.api.definition.Attribute.Type;
import javax.json.Json;
import javax.json.JsonReader;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import java.io.StringReader;
public class Swordphish extends FunctionExecutor {
ExpressionExecutor[] url;
public static void main (String[] arg1){
System.out.println("Programa test phishing");
}
@Override
protected void init(ExpressionExecutor[] url, ExecutionPlanContext arg1) {
// TODO Auto-generated method stub
this.url = url;
}
@Override
public Type getReturnType() {
// TODO Auto-generated method stub
return Attribute.Type.FLOAT;
}
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
@Override
public Object[] currentState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void restoreState(Object[] arg0) {
// TODO Auto-generated method stub
}
@Override
protected Object execute(Object[] arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
protected Object execute(Object arg0) {
// TODO Auto-generated method stub
float res = 0;
String e = null;
try {
Client client = ClientBuilder.newClient();
e = client.target("http://52.37.125.225:3000/phishing").queryParam("url", url).request(MediaType.TEXT_HTML)
.get(String.class);
try (JsonReader jr = Json.createReader(new StringReader(e))) {
String valor = jr.readObject().getString("result");
try {
res = Float.parseFloat(valor);
} catch (Exception ex1) {
res = 0;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return new Float(res);
}
}
siddhiext:
#
# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you 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.
#
swordurl=org.wso2.siddhi.extension.fraude.Swordphish
我生成了我的 JAR,你的位置是 C:\wso2\wso2das-3.0.1\repository\components\lib
我可以使用来自 siddhi 的 "swordurl":
from DSBStream
select fraude:swordurl('www.babas.com') as porcsword
insert into testswordphish;
但是我 运行 我的执行计划,我得到下一个错误:
java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
当我对 Siddhi 使用外部依赖项时,总是会发生此错误。 为什么?
在这种情况下,我使用下一个外部依赖项:
import javax.json.Json;
import javax.json.JsonReader;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import java.io.StringReader;
您必须将所有依赖项 JAR 添加到 <DAS_HOME>\repository\components\lib
目录。我看到你正在使用 JAX-RS 库,你也必须添加那个 JAR。
我将外部 jar 复制到:
<DAS_HOME>\repository\components\lib
<DAS_HOME>\repository\components\plugins
我也创建了包含外部 jar 的 jar。我正在使用选项 "Runnable JAR File".
我的问题仍然存在。
我真的无法使用外部库对 Siddhi 进行扩展,也不明白为什么。
我的MANIFEST.MF是下一个:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ siddhi-query-api_3.0.4.jar javax.json-1.0.4.jar ja
vax.json-api-1.0.jar jaxrs-api-3.0.2.Final.jar resteasy-client-3.0.2.
Final.jar resteasy-jaxrs-3.0.2.Final.jar siddhi-core_3.0.4.jar
Class-Path: .
Rsrc-Main-Class: org.wso2.siddhi.extension.fraude.Swordphish
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
我想要扩展 siddhi,mi java 代码是:
package org.wso2.siddhi.extension.fraude;
import org.wso2.siddhi.core.config.ExecutionPlanContext;
import org.wso2.siddhi.core.executor.ExpressionExecutor;
import org.wso2.siddhi.core.executor.function.FunctionExecutor;
import org.wso2.siddhi.query.api.definition.Attribute;
import org.wso2.siddhi.query.api.definition.Attribute.Type;
import javax.json.Json;
import javax.json.JsonReader;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import java.io.StringReader;
public class Swordphish extends FunctionExecutor {
ExpressionExecutor[] url;
public static void main (String[] arg1){
System.out.println("Programa test phishing");
}
@Override
protected void init(ExpressionExecutor[] url, ExecutionPlanContext arg1) {
// TODO Auto-generated method stub
this.url = url;
}
@Override
public Type getReturnType() {
// TODO Auto-generated method stub
return Attribute.Type.FLOAT;
}
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
@Override
public Object[] currentState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void restoreState(Object[] arg0) {
// TODO Auto-generated method stub
}
@Override
protected Object execute(Object[] arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
protected Object execute(Object arg0) {
// TODO Auto-generated method stub
float res = 0;
String e = null;
try {
Client client = ClientBuilder.newClient();
e = client.target("http://52.37.125.225:3000/phishing").queryParam("url", url).request(MediaType.TEXT_HTML)
.get(String.class);
try (JsonReader jr = Json.createReader(new StringReader(e))) {
String valor = jr.readObject().getString("result");
try {
res = Float.parseFloat(valor);
} catch (Exception ex1) {
res = 0;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return new Float(res);
}
}
siddhiext:
#
# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you 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.
#
swordurl=org.wso2.siddhi.extension.fraude.Swordphish
我生成了我的 JAR,你的位置是 C:\wso2\wso2das-3.0.1\repository\components\lib
我可以使用来自 siddhi 的 "swordurl":
from DSBStream
select fraude:swordurl('www.babas.com') as porcsword
insert into testswordphish;
但是我 运行 我的执行计划,我得到下一个错误:
java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
当我对 Siddhi 使用外部依赖项时,总是会发生此错误。 为什么?
在这种情况下,我使用下一个外部依赖项:
import javax.json.Json;
import javax.json.JsonReader;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import java.io.StringReader;
您必须将所有依赖项 JAR 添加到 <DAS_HOME>\repository\components\lib
目录。我看到你正在使用 JAX-RS 库,你也必须添加那个 JAR。
我将外部 jar 复制到:
<DAS_HOME>\repository\components\lib
<DAS_HOME>\repository\components\plugins
我也创建了包含外部 jar 的 jar。我正在使用选项 "Runnable JAR File".
我的问题仍然存在。
我真的无法使用外部库对 Siddhi 进行扩展,也不明白为什么。
我的MANIFEST.MF是下一个:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ siddhi-query-api_3.0.4.jar javax.json-1.0.4.jar ja
vax.json-api-1.0.jar jaxrs-api-3.0.2.Final.jar resteasy-client-3.0.2.
Final.jar resteasy-jaxrs-3.0.2.Final.jar siddhi-core_3.0.4.jar
Class-Path: .
Rsrc-Main-Class: org.wso2.siddhi.extension.fraude.Swordphish
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader