diff options
author | rsuen | 2007-03-05 02:23:17 +0000 |
---|---|---|
committer | rsuen | 2007-03-05 02:23:17 +0000 |
commit | ccac19fe5715ed3719cce5a88b8b728330cecb21 (patch) | |
tree | 2f0046c742bff3259220cf4ae5ff0b9c893943d2 /providers/bundles/org.eclipse.ecf.provider.bittorrent/src | |
parent | 8ecdb938cfcb663c5ce846edc75461450aad5707 (diff) | |
download | org.eclipse.ecf-ccac19fe5715ed3719cce5a88b8b728330cecb21.tar.gz org.eclipse.ecf-ccac19fe5715ed3719cce5a88b8b728330cecb21.tar.xz org.eclipse.ecf-ccac19fe5715ed3719cce5a88b8b728330cecb21.zip |
Leverage the stream handling functionality that has been introduced in the filetransfer API.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.bittorrent/src')
2 files changed, 64 insertions, 0 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentConnection.java b/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentConnection.java new file mode 100644 index 000000000..10a84232a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentConnection.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2007 Remy Suen, Composent Inc., and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remy Suen <remy.suen@gmail.com> - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.internal.provider.bittorrent; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +import org.eclipse.bittorrent.Torrent; +import org.eclipse.bittorrent.TorrentFactory; +import org.eclipse.bittorrent.TorrentFile; + +final class BitTorrentConnection extends URLConnection { + + private Torrent torrent; + + BitTorrentConnection(URL url) { + super(url); + } + + public void connect() throws IOException { + if (torrent == null) { + torrent = TorrentFactory.createTorrent(new TorrentFile(new File(url + .getFile()))); + torrent.start(); + } + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentURLStreamHandlerService.java b/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentURLStreamHandlerService.java new file mode 100644 index 000000000..b823804e9 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.bittorrent/src/org/eclipse/ecf/internal/provider/bittorrent/BitTorrentURLStreamHandlerService.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2007 Remy Suen, Composent Inc., and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remy Suen <remy.suen@gmail.com> - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.internal.provider.bittorrent; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +import org.osgi.service.url.AbstractURLStreamHandlerService; + +public final class BitTorrentURLStreamHandlerService extends + AbstractURLStreamHandlerService { + + public URLConnection openConnection(URL u) throws IOException { + return new BitTorrentConnection(u); + } + +} |