nenok
Class Services

java.lang.Object
  extended by nenok.Services

public class Services
extends Object

This utility class deals with Nenok services. It provides static methods to start, localize & terminate Nenok Processors. Furthermore, localization of Registry services is an important task of this class, which is implemented as multicast localization. To assert best possible lookup times a static JINI LookupCache is used.

Version:
$LastChangedRevision: 550 $
$LastChangedDate: 2008-03-26 14:14:27 +0100 (Mi, 26 Mrz 2008) $
Author:
Marc Pouly

Constructor Summary
Services()
           
 
Method Summary
static boolean destroyAllProcessors()
          Destroy all processors that were started from this class.
static boolean destroyProcessor(Processor proc)
          Destroys a given processor.
static boolean destroyProcessor(Uuid pid)
          Destroys a given processor.
static Processor findProcessor(Uuid pid, String... urls)
          Finds the processor with the given ID via unicast or multicast.
static Registry findRegistry(String... urls)
          Finds an arbitrary registry service via unicast or multicast.
static Processor startProcessor(String... urls)
          Starts a new remote processor instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Services

public Services()
Method Detail

findRegistry

public static Registry findRegistry(String... urls)
                             throws MalformedURLException
Finds an arbitrary registry service via unicast or multicast.

Parameters:
urls - URL of the lookup service for unicast localization.
Returns:
A registry service or null, if localization failed.
Throws:
MalformedURLException - One of the argument URLs is not valid.

findProcessor

public static Processor findProcessor(Uuid pid,
                                      String... urls)
                               throws MalformedURLException
Finds the processor with the given ID via unicast or multicast.

Parameters:
pid - The processor identifier.
urls - URL of the lookup service for unicast localization.
Returns:
The referenced processor or null, if locatozation failed.
Throws:
MalformedURLException - One of the argument URLs is not valid.

startProcessor

public static Processor startProcessor(String... urls)
                                throws UnknownHostException,
                                       MalformedURLException
Starts a new remote processor instance.

Parameters:
urls - URL of the lookup service for unicast localization.
Returns:
The proxy of the created processor.
Throws:
UnknownHostException - Exception thrown when the machine's host name cannot be localized.
MalformedURLException - One of the argument URLs is not valid.

destroyProcessor

public static boolean destroyProcessor(Uuid pid)
Destroys a given processor. This method unexports the processor service and cancels all leases. The service disappears when the leases expire.

Parameters:
pid - The identifier of the processor to destroy.
Returns:
true, if the processor has been destroyed successfully.

destroyProcessor

public static boolean destroyProcessor(Processor proc)
Destroys a given processor. This method unexports the processor service and cancels all leases. The service disappears when the leases expire.

Parameters:
proc - The processor to destroy.
Returns:
true, if the processor has been destroyed successfully.

destroyAllProcessors

public static boolean destroyAllProcessors()
Destroy all processors that were started from this class.

Returns:
true, if all processors have been destroyed successfully.