From 396e7432fa98eabab2ab211f22b25049115a26e3 Mon Sep 17 00:00:00 2001 From: Rogiel Date: Tue, 17 Jan 2012 20:48:14 -0200 Subject: [PATCH] Implements maven generated site --- pom.xml | 42 ++-- src/main/java/com/torrent4j/TestMain.java | 46 +++++ src/site/resources/CNAME | 1 + src/site/xdoc/index.xml | 238 ++++++++++++++++++++++ 4 files changed, 304 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/torrent4j/TestMain.java create mode 100644 src/site/resources/CNAME create mode 100644 src/site/xdoc/index.xml diff --git a/pom.xml b/pom.xml index b1955dd..17399e8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.rogiel + com.rogiel.torrent4j torrent4j 0.0.1-SNAPSHOT torrent4j @@ -12,26 +12,25 @@ Rogiel http://www.rogiel.com/ - http://www.rogiel.com/ + http://torrent4j.github.com/ scm:git:git@github.com:torrent4j/torrent4j.git - scm:git:github.com:torrent4j/torrent4j.git + scm:git:github.com/torrent4j/torrent4j.git + git@github.com:torrent4j/torrent4j.git https://github.com/torrent4j/torrent4j/downloads - torrent4j-repository - torrent4j-repository - scp://rogiels@rogiel.com/home/rogiels/maven.rogiel.com - default + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ false - - torrent4j-site - torrent4j-site - scp://rogiels@rogiel.com/home/rogiels/torrent4j.rogiel.com - + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + true + @@ -145,6 +144,7 @@ maven-site-plugin 3.0 + true UTF-8 @@ -155,16 +155,6 @@ UTF-8 - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.4 - - scm:git@github.com:torrent4j/torrent4j.git - scm:git://github.com/torrent4j/torrent4j.git - https://github.com/torrent4j/torrent4j/tree/master/ - - org.apache.maven.plugins maven-changelog-plugin @@ -203,7 +193,7 @@ - site + site-deploy site @@ -212,6 +202,12 @@ + + + + + + diff --git a/src/main/java/com/torrent4j/TestMain.java b/src/main/java/com/torrent4j/TestMain.java new file mode 100644 index 0000000..aed251c --- /dev/null +++ b/src/main/java/com/torrent4j/TestMain.java @@ -0,0 +1,46 @@ +package com.torrent4j; + +import java.io.IOException; +import java.net.Inet4Address; +import java.net.InetSocketAddress; +import java.nio.file.Paths; + +import com.torrent4j.model.Torrent; +import com.torrent4j.model.TorrentPeer; +import com.torrent4j.net.peerwire.PeerWireProtocol; +import com.torrent4j.storage.InMemoryTorrentStorage; + +public class TestMain { + /** + * @param args + * @throws IOException + * @throws InterruptedException + */ + public static void main(String[] args) throws IOException, InterruptedException { + final TorrentController controller = new TorrentController( + new PeerWireProtocol(), new InMemoryTorrentStorage()); + controller.start(1234); + + final Torrent torrent = Torrent.load(Paths.get("music.torrent")); + System.out.println("Torrent hash is " + torrent.getHash().getString()); + + // controller.checkExistingData(torrent); + + controller.registerTorrent(torrent); + final TorrentPeer peer = new TorrentPeer(torrent); + peer.setAddress(new InetSocketAddress(Inet4Address + .getByName("192.168.1.100"), 21958)); + torrent.getSwarm().addPeer(peer); + + while(true) { + Thread.sleep(1000); + System.out.println((peer.getTrafficControl().getCurrentDownloadSpeed() / 1024) + " kb/s"); + //peer.getTrafficControl().setDownloadSpeedLimit(32 * 1024); + torrent.getTrafficControl().setDownloadSpeedLimit(256 * 1024); + } + + // System.out.println(((StandardTorrentStrategy) + // torrent.getStrategy()).getPieceSelector() + // .selectPiece(peer)); + } +} diff --git a/src/site/resources/CNAME b/src/site/resources/CNAME new file mode 100644 index 0000000..f889b89 --- /dev/null +++ b/src/site/resources/CNAME @@ -0,0 +1 @@ +torrent4j.rogiel.com \ No newline at end of file diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml new file mode 100644 index 0000000..e72af5d --- /dev/null +++ b/src/site/xdoc/index.xml @@ -0,0 +1,238 @@ + + + + Home + Rogiel Sulzbach + + + + +
+

Torrent4J is a java library that provides easy downloading and + uploading of torrent files. It is possible to customize the storage + engine and the download algorithm. +

+
+ +
+

To get started, all you need to do is include the library as + dependency to your Maven project: +

+ + com.rogiel.torrent4j + torrent4j + library-version-here +]]> + You can find the latest version of the library at the top of + this page! + + +

Now that your dependency is included, you need to start the + torrent transfer: +

+ + + +

Seriously, that's it!

+
+ +
+

You're right, that does not explain much, so here is a detailed + explanation and some more advaced topics too! +

+ + +

The torrent controller is responsible for, as the name suggests, + controlling all torrent transfers. There can be several torrent + controllers serving several other torrents. They need, however, to + listen for peers at different ports. +

+
+ + +

+ While creating a new + TorrentController you can + choose which + TorrentProtocol + and which + TorrentStorage + you desire + to use. At + the moment, there is only a + single + TorrentProtocol + but + several + TorrentStorage + implementations. +

+

+ This guide will follow customization at a general point of view. + For more detailed information, the sources should be + consulted. +

+

+ You can easily and rapidly create a new + TorrentController + using the + default + no-arg + constructor, which will automatically use + PeerWireTorrentProtocol + and + NIOTorrentStorage + as default + protocol + and storage. The + NIOTorrentStorage + stores the torrent + files + directly + into the working + directory. +

+ +

If any of the default behavior + is not intented, + you can use other + constructors to customize it's + behavior, see as + follow: +

+ +

+ In this snippet, a new controller with + default + TorrentProtocol + and + InMemoryTorrentStorage + is created +

+

You can also create a controller customizing only the protocol or + the storage: +

+ + +
+ + +

+ Now that the + controller is instantiated, it + must be started in order + to + begin + download and serving other peer's + requests. Starting a + controller is + done using the + TorrentController.start(int) + method. + The single + argument in the + method defines the port in which + the + controller should + listen for + incoming connections. Example: +

+ + +

+ + This snippet starts the controller and listen for incoming + connections at + port + 4578 + . + +

+
+ + +

+ Once started the + TorrentController + , it's + time to load the + .torrent + meta + data file + into memory. Doing so, is + really easy with the static + Torrent.load() + methods. Those methods, + provide an utility to parse + and process + torrent files and appends an + default strategy to the + transfer. See + below how to load an torrent + from an remote URL: +

+ +

+ + This snipped will load the torrent from an URL and parse it + into an + Torrent + object + +

+ +

+ This snippet will load the torrent from an NIO.2 Path + +

+
+ + +

+ A single TorrentController can handle as many torrents as + the + hardware + can support. To do so, you need to attach the torrent to + the + controller. A single torrent can only be attached to a single + controller at a time (you can always load + another + instance of + Torrent + with the same file and start it with another controller!). + The + snippet below, registers the torrent into the controller, from + that + point onwards, the transfer is stared and everything is + managed + by + the library. + TorrentStrategy + implementations can customize the + transfer behavior as you desire, + if you want to implement your own + strategy, you need to inform the + desired strategy at torrent + loading + time. +

+ + +
+
+ +
+

+ Even more information can be found at our + wiki + , hosted on + github + . +

+
+ +
\ No newline at end of file