p2ps.imp.pipe
Class PipeServiceImp

java.lang.Object
  extended byp2ps.imp.pipe.PipeServiceImp
All Implemented Interfaces:
PipeService

public class PipeServiceImp
extends java.lang.Object
implements PipeService

The service for creating input pipes and connecting output pipes.

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
PipeServiceImp(Peer peer)
           
 
Method Summary
 void addPipeConnectionListener(PipeConnectionListener listener)
          Adds a pipe connection listener to the pipe service
 Endpoint connectOutputEndpoint(java.net.URI uri)
          Connects and intializes an output endpoint to the specified URI.
 Endpoint connectOutputEndpoint(java.net.URI uri, boolean init, SecurityContext context)
          Connects an output endpoint to the specified URI
 void connectOutputPipe(PipeAdvertisement pipead)
          Attempts to connect an output pipe to the pipe specified in the advert.
 void connectOutputPipe(java.net.URI uri)
          Connects an output pipe to the specified URI
 Endpoint createInputEndpoint(java.net.URI uri)
          Creates an input endpoint for the specified URI
 Endpoint createInputEndpoint(java.net.URI uri, boolean init)
          Creates an input endpoint for the specified URI
 Endpoint[] createInputEndpoints(PipeAdvertisement pipead, boolean init)
           
 InputPipe createInputPipe(PipeAdvertisement pipead)
          Creates an input pipe using the specified advert
 InputPipe createInputPipe(PipeAdvertisement pipead, Endpoint[] endpoints)
          Creates an input pipe using the specified advert with the specified set of endpoints.
 InputPipe createInputPipe(java.net.URI uri)
          Creates an input pipe for the specified URI
 EndpointResolver[] getEndpointResolvers()
           
 java.lang.String[] getEndpointSchemes(boolean input)
           
 EndpointResolver[] getPipeResolvers(java.lang.String scheme, boolean input)
           
 java.lang.String[] getPipeSchemes(boolean input)
           
 void init()
          Initialises the pipe service
 boolean isEndpointScheme(java.lang.String scheme, boolean input)
           
 boolean isPipeSchemes(java.lang.String scheme, boolean input)
           
 void register(EndpointResolver resolver)
          Register a pipe resolver to create pipes for a particular protocol
 void removePipeConnectionListener(PipeConnectionListener listener)
          Removes a pipe connection listener from the pipe service
 void unregister(EndpointResolver resolver)
          Unregister the pipe resolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipeServiceImp

public PipeServiceImp(Peer peer)
Method Detail

init

public void init()
          throws InitializationException,
                 java.io.IOException
Initialises the pipe service

Specified by:
init in interface PipeService
Throws:
InitializationException
java.io.IOException

addPipeConnectionListener

public void addPipeConnectionListener(PipeConnectionListener listener)
Adds a pipe connection listener to the pipe service

Specified by:
addPipeConnectionListener in interface PipeService

removePipeConnectionListener

public void removePipeConnectionListener(PipeConnectionListener listener)
Removes a pipe connection listener from the pipe service

Specified by:
removePipeConnectionListener in interface PipeService

register

public void register(EndpointResolver resolver)
Register a pipe resolver to create pipes for a particular protocol

Specified by:
register in interface PipeService

unregister

public void unregister(EndpointResolver resolver)
Unregister the pipe resolver

Specified by:
unregister in interface PipeService

getEndpointSchemes

public java.lang.String[] getEndpointSchemes(boolean input)
Specified by:
getEndpointSchemes in interface PipeService
Parameters:
input - true if input schemes, false if output schemes
Returns:
the currently enabled endpoint schemes

isEndpointScheme

public boolean isEndpointScheme(java.lang.String scheme,
                                boolean input)
Specified by:
isEndpointScheme in interface PipeService
Parameters:
scheme - the scheme name
input - true if input scheme, false if output scheme
Returns:
true if the scheme is an enabled endpoint scheme

getPipeSchemes

public java.lang.String[] getPipeSchemes(boolean input)
Specified by:
getPipeSchemes in interface PipeService
Parameters:
input - true if input schemes, false if output schemes
Returns:
the currently enabled pipe schemes

isPipeSchemes

public boolean isPipeSchemes(java.lang.String scheme,
                             boolean input)
Specified by:
isPipeSchemes in interface PipeService
Parameters:
scheme - the scheme name
input - true if input scheme, false if output scheme
Returns:
true if the scheme is an enabled pipe scheme

getEndpointResolvers

public EndpointResolver[] getEndpointResolvers()
Specified by:
getEndpointResolvers in interface PipeService
Returns:
the registered pipe resolvers for this peer

getPipeResolvers

public EndpointResolver[] getPipeResolvers(java.lang.String scheme,
                                           boolean input)
Specified by:
getPipeResolvers in interface PipeService
Returns:
the registered pipe resolvers for thie specified pipe scheme

createInputEndpoint

public Endpoint createInputEndpoint(java.net.URI uri)
                             throws java.io.IOException
Creates an input endpoint for the specified URI

Specified by:
createInputEndpoint in interface PipeService
Throws:
java.io.IOException

createInputEndpoint

public Endpoint createInputEndpoint(java.net.URI uri,
                                    boolean init)
                             throws java.io.IOException
Creates an input endpoint for the specified URI

Specified by:
createInputEndpoint in interface PipeService
Parameters:
uri - the uri to connect to
init - true if the endpoint should be initialized
Throws:
java.io.IOException

createInputEndpoints

public Endpoint[] createInputEndpoints(PipeAdvertisement pipead,
                                       boolean init)
                                throws UnknownSchemeException,
                                       java.io.IOException
Specified by:
createInputEndpoints in interface PipeService
Returns:
an array of input endpoints for a pipe advertisement, optionally initializing.
Throws:
UnknownSchemeException
java.io.IOException

createInputPipe

public InputPipe createInputPipe(java.net.URI uri)
                          throws UnknownSchemeException,
                                 java.io.IOException
Creates an input pipe for the specified URI

Specified by:
createInputPipe in interface PipeService
Throws:
UnknownSchemeException
java.io.IOException

createInputPipe

public InputPipe createInputPipe(PipeAdvertisement pipead)
                          throws UnknownSchemeException,
                                 java.io.IOException
Creates an input pipe using the specified advert

Specified by:
createInputPipe in interface PipeService
Throws:
UnknownSchemeException
java.io.IOException

createInputPipe

public InputPipe createInputPipe(PipeAdvertisement pipead,
                                 Endpoint[] endpoints)
                          throws java.io.IOException
Creates an input pipe using the specified advert with the specified set of endpoints.

Specified by:
createInputPipe in interface PipeService
Throws:
java.io.IOException

connectOutputEndpoint

public Endpoint connectOutputEndpoint(java.net.URI uri)
                               throws UnknownSchemeException,
                                      java.io.IOException
Connects and intializes an output endpoint to the specified URI.

Specified by:
connectOutputEndpoint in interface PipeService
Throws:
UnknownSchemeException
java.io.IOException

connectOutputEndpoint

public Endpoint connectOutputEndpoint(java.net.URI uri,
                                      boolean init,
                                      SecurityContext context)
                               throws UnknownSchemeException,
                                      java.io.IOException
Connects an output endpoint to the specified URI

Specified by:
connectOutputEndpoint in interface PipeService
Parameters:
uri - the uri to connect to
init - true if the endpoint should be initialized
context -
Throws:
UnknownSchemeException
java.io.IOException

connectOutputPipe

public void connectOutputPipe(java.net.URI uri)
                       throws UnknownSchemeException,
                              java.io.IOException
Connects an output pipe to the specified URI

Specified by:
connectOutputPipe in interface PipeService
Throws:
UnknownSchemeException
java.io.IOException

connectOutputPipe

public void connectOutputPipe(PipeAdvertisement pipead)
                       throws UnknownSchemeException,
                              java.io.IOException
Attempts to connect an output pipe to the pipe specified in the advert. PipeConnectionListeners are notified when connection is achieved/fails.

Specified by:
connectOutputPipe in interface PipeService
Throws:
UnknownSchemeException
java.io.IOException