ich erweitern wollen siddhi, mi Java-Code ist:JAR für sich SIDDHI
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);
}
}
die 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
ich meine JAR erzeugt, und Ihre Position ist C: \ WSO2 \ wso2das- 3.0.1 \ Repository \ components \ lib
I "swordurl" von siddhi verwenden können:
from DSBStream
select fraude:swordurl('www.babas.com') as porcsword
insert into testswordphish;
Aber ich betreibe meine executionplan, und ich bekomme den nächsten Fehler:
java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
dieser Fehler immer passiert, wenn ich externe Abhängigkeiten zu Siddhi verwenden. WARUM?
in diesem Fall verwende ich die nächsten externen Abhängigkeiten:
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;
fügen Sie bitte Ihre pom-Datei –
Ich bin für dieses Projekt nicht Maven verwenden. Sie brauchen ?, Ist es obligatorisch? –