org.astrogrid.samp.bridge
Class Bridge

java.lang.Object
  extended by org.astrogrid.samp.bridge.Bridge

public class Bridge
extends Object

Runs a bridging service between two or more hubs. For each client on one hub, a proxy client appears on all other participating hubs. These proxies can be treated in exactly the same way as normal clients by other registered clients; any messages sent to/from them will be marshalled over the bridge in a transparent way. One application for this is to allow collaboration between users who each have their own hub running.

A notifyAll call is made on the Bridge object whenever the number of live hubs connected by the bridge changes.

Since:
15 Jul 2009
Author:
Mark Taylor

Constructor Summary
Bridge(ClientProfile[] profiles)
          Constructor.
 
Method Summary
 void exportUrls(int index, String host)
          Sets up a URL exporter for one of the hubs.
 HubConnector[] getBridgeClients()
          Returns the hub connectors representing the bridge client running on each linked hub.
 ClientProfile[] getProfiles()
          Returns the client profiles which define the hubs this bridge links.
static void main(String[] args)
          Main method.
static int runMain(String[] args)
          Does the work for the main method.
 boolean start()
          Starts this bridge running.
 void stop()
          Stops this bridge running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bridge

public Bridge(ClientProfile[] profiles)
       throws IOException
Constructor.

Parameters:
profiles - array of SAMP profile objects, one for each hub which is to participate in the bridge
Throws:
IOException
Method Detail

getProfiles

public ClientProfile[] getProfiles()
Returns the client profiles which define the hubs this bridge links.

Returns:
profile array, one for each connected hub

getBridgeClients

public HubConnector[] getBridgeClients()
Returns the hub connectors representing the bridge client running on each linked hub. Note this does not include any proxy clients, only the one-per-hub manager clients.

Returns:
array of bridge manager clients, one for each hub (in corresponding positions to the profiles)

exportUrls

public void exportUrls(int index,
                       String host)
Sets up a URL exporter for one of the hubs. This will attempt to edit transmitted data contents for use in remote contexts; the main job is to adjust loopback host references in URLs (127.0.0.1 or localhost) to become fully qualified domain names for non-local use. It's not an exact science, but a best effort is made.

Parameters:
index - index of the profile for which to export URLs
host - the name substitute for loopback host identifiers on the host on which that profile's hub is running

start

public boolean start()
Starts this bridge running.

Returns:
true iff all the participating hubs have been contacted successfully

stop

public void stop()
Stops this bridge running. All associated manager and proxy clients are unregistered.


main

public static void main(String[] args)
                 throws IOException
Main method. Runs a bridge.

Throws:
IOException

runMain

public static int runMain(String[] args)
                   throws IOException
Does the work for the main method. Use -help flag.

Throws:
IOException


Copyright © 2008-2011 AstroGrid. All Rights Reserved.