Skip to content

Commit

Permalink
Added component to download web page; plus test network
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaulm committed Jun 3, 2021
1 parent 1829ce5 commit 5641d5e
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ apply plugin: 'java-library'

}

version = '4.1.11'
version = '4.1.12'

group = 'com.jpaulmorrison'

Expand Down Expand Up @@ -135,7 +135,7 @@ description = "Create default maven directory structure"

groupId = 'com.jpaulmorrison'
artifactId = 'javafbp'
version = '4.1.11'
version = project.version

from components.java

Expand Down
Binary file modified build/distributions/javafbp-4.1.11.tar
Binary file not shown.
Binary file modified build/distributions/javafbp-4.1.11.zip
Binary file not shown.
Binary file added build/distributions/javafbp-4.1.12.tar
Binary file not shown.
Binary file added build/distributions/javafbp-4.1.12.zip
Binary file not shown.
Binary file modified build/libs/javafbp-4.1.11-sources.jar
Binary file not shown.
Binary file modified build/libs/javafbp-4.1.11.jar
Binary file not shown.
Binary file added build/libs/javafbp-4.1.12-javadoc.jar
Binary file not shown.
Binary file added build/libs/javafbp-4.1.12-sources.jar
Binary file not shown.
Binary file added build/libs/javafbp-4.1.12.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion build/scripts/javafbp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ case "`uname`" in
;;
esac

CLASSPATH=$APP_HOME/lib/javafbp-4.1.11.jar
CLASSPATH=$APP_HOME/lib/javafbp-4.1.12.jar


# Determine the Java command to use to start the JVM.
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/javafbp.bat
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\lib\javafbp-4.1.11.jar
set CLASSPATH=%APP_HOME%\lib\javafbp-4.1.12.jar


@rem Execute javafbp
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.jpaulmorrison</groupId>
<artifactId>javafbp</artifactId>
<version>4.1.11</version>
<version>4.1.12</version>
<inceptionYear>2016</inceptionYear>
<licenses>
<license>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.jpaulmorrison.fbp.core.components.httpurl;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import com.jpaulmorrison.fbp.core.engine.Component;
import com.jpaulmorrison.fbp.core.engine.InPort;
import com.jpaulmorrison.fbp.core.engine.InputPort;
import com.jpaulmorrison.fbp.core.engine.OutPort;
import com.jpaulmorrison.fbp.core.engine.OutputPort;
import com.jpaulmorrison.fbp.core.engine.Packet;

//https://www.codejava.net/java-se/networking/use-httpurlconnection-to-download-file-from-an-http-url

@InPort(value = "SOURCE", description = "HTMLName")
@OutPort(value = "OUT", description = "HTML")

public class LoadURL extends Component {

private InputPort inPort;
private OutputPort outPort;

protected void execute() throws Exception {

Packet<?> pp = inPort.receive();

String fileURL = (String) pp.getContent();
drop(pp);
inPort.close();


// https://stackoverflow.com/questions/2793168/reading-httpurlconnection-inputstream-manual-buffer-or-bufferedinputstream

URL url = new URL(fileURL);

//HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();

InputStream in = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder result = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null) {
result.append(line);
}
outPort.send(create(result.toString()));
reader.close();
}

@Override
protected void openPorts() {
inPort = openInput("SOURCE");
outPort = openOutput("OUT");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public final class VersionAndTimestamp {
*
*/

private static String version = "JavaFBP - version 4.1.11";
private static String version = "JavaFBP - version 4.1.12";

private static String date = "Oct. 31, 2020";
private static String date = "June 3, 2021";

static String getVersion() {
return version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ public class Copy1 extends Network {
protected void define() {
// component("MONITOR", Monitor.class);

connect(component("Generate", GenerateTestData.class), port("OUT"), component("SlowPass", SlowPass.class), port("IN"));
connect(component("SlowPass"), port("OUT"), component("Write", WriteToConsole.class), port("IN"));
connect(component("Generate", GenerateTestData.class), port("OUT"), //component("SlowPass", SlowPass.class), port("IN"));
//connect(component("SlowPass"), port("OUT"),
component("Write", WriteToConsole.class), port("IN"));

initialize("100", component("Generate"), port("COUNT"));

}

public static void main(final String[] argv) throws Exception {
for (int i = 0; i < 50; i++)
//for (int i = 0; i < 50; i++)
new Copy1().go();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* JavaFBP - A Java Implementation of Flow-Based Programming (FBP)
* Copyright (C) 2009, 2016 J. Paul Morrison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see the GNU Library General Public License v3
* at https://www.gnu.org/licenses/lgpl-3.0.en.html for more details.
*/

package com.jpaulmorrison.fbp.resourcekit.examples.networks;




import com.jpaulmorrison.fbp.core.components.httpurl.LoadURL;
import com.jpaulmorrison.fbp.core.components.misc.WriteToConsole;
import com.jpaulmorrison.fbp.core.engine.Network;

/**
* Read from URL; write to the console
*
*/


public class ReadHTML extends Network {

@Override
protected void define() {
connect(component("Load URL", LoadURL.class), port("OUT"), component("Write", WriteToConsole.class), port("IN"), 1);
initialize("https://github.com/jpaulm/javafbp/blob/master/README.md", component("Load URL"), port("SOURCE"));

}

public static void main(final String[] argv) throws Exception {
new ReadHTML().go();
}
}

0 comments on commit 5641d5e

Please sign in to comment.