Project JXTA

net.jxta.impl.util
Class AdvCooker

java.lang.Object
  extended by net.jxta.impl.util.AdvCooker

public class AdvCooker
extends Object

Advertisements and ID's "cooked" according to recipes lifted from J-C and Frog. Static methods meant for convenience in developing experimental propagation modules (pipe or rendezvous services, rendezvous managers) but maybe generally useful.

Author:
vasha

Constructor Summary
AdvCooker()
           
 
Method Summary
static StructuredTextDocument buildCompat()
          Compat's (compatibility statements) serve to narrow the search for a ModuleImplAdvertisement.
static StructuredTextDocument buildCompat(String efmt, String bind)
          Use this form for customized compatibility statements.
static ModuleClassAdvertisement buildModuleClassAdvertisement(ModuleClassID mcid, String serviceName, String serviceDescription)
          The module class advertisement is to simply advertise the existence of a module.
static ModuleClassID buildModuleClassID(String uri)
          Reconstructs a ModuleClassID from its String representation as printed by the foregoing recipes.
static ModuleImplAdvertisement buildModuleImplAdvertisement(ModuleSpecID msid, String code, Element compat)
          A ModuleImplAdvertisement represents one of any number of published implementations of a given specification.
static ModuleImplAdvertisement buildModuleImplAdvertisement(ModuleSpecID msid, String code, Element compat, String description, String provider, String uri)
          Use this form to fully populate a ModuleImplAdvertisement.
static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid, String moduleSpecName, String moduleSpecDescription)
          The ModuleSpecAdvertisement has two purposes, to publish the uri of its formal specs for developers and to publish the means of remote access to the module's services if that is appropriate.
static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid, String moduleSpecName, String moduleSpecDescription, String creator, String version, String specURI)
          Use this form for production provided remote access is not required.
static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid, String moduleSpecName, String moduleSpecDescription, String creator, String version, String specURI, PipeAdvertisement pipeAdv, ModuleSpecID proxySpecID, ModuleSpecID authorizationSpecID, StructuredDocument param)
          Use this form for a fully populated advert.
static ModuleSpecID buildModuleSpecID(String uri)
          Reconstructs a ModuleSpecID from its String representation as printed by the foregoing recipes.
static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Hashtable newServices, Hashtable newApps)
           
static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Hashtable newServices, Hashtable newApps, Hashtable newProtos)
           
static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(StdPeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Hashtable newServices)
          Modifies a copy of the parent's implementation advertisement to reflect the addition or replacement of services.
static void printNewClassAndModuleID()
          Prints public static String declarations of new module class and spec ID's for hardcoding into a module, as per J-C's posted recipe.
static void printNewClassAndModuleID(ModuleClassID baseClassID)
          Use this form if your module is a custom implementation of a well-known module such as RendezvousServiceImpl.
static void typeCheckKeys(Hashtable moduleTable)
          Module table keys must be ModuleClassID's.
static void typeCheckValues(Hashtable moduleTable)
          Module table vaules must be ModuleImplAdvertisements here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvCooker

public AdvCooker()
Method Detail

printNewClassAndModuleID

public static void printNewClassAndModuleID()
Prints public static String declarations of new module class and spec ID's for hardcoding into a module, as per J-C's posted recipe. Use this form unless your module is a custom implementation of a standard module such as RendezvousServiceImpl.


printNewClassAndModuleID

public static void printNewClassAndModuleID(ModuleClassID baseClassID)
Use this form if your module is a custom implementation of a well-known module such as RendezvousServiceImpl. The class id's of well-known modules are static members of net.jxta.peergroup.PeerGroup, e.g., PeerGroup.rendezvousClassID.

Parameters:
baseClassID - --the class ID of the module to customized, e.g. that of RendezvousServiceImpl.

buildModuleClassID

public static ModuleClassID buildModuleClassID(String uri)
                                        throws URISyntaxException
Reconstructs a ModuleClassID from its String representation as printed by the foregoing recipes.

Parameters:
url - -- the module class id in String form, "urn:jxta:uuid-[the big hex string]"
Returns:
-- module class id reconstructed from String
Throws:
MalformedURLException - -- if url is messed up
UnknownServiceException - --if urn: isn't supported, meaning a jar is missing
URISyntaxException

buildModuleSpecID

public static ModuleSpecID buildModuleSpecID(String uri)
                                      throws URISyntaxException
Reconstructs a ModuleSpecID from its String representation as printed by the foregoing recipes.

Parameters:
url - -- the module spec id in String form, "urn:jxta:uuid-[the big hex string]"
Returns:
-- module spec id reconstructed from String
Throws:
MalformedURLException - -- if url is messed up
UnknownServiceException - --if urn: isn't supported, meaning a jar is missing
URISyntaxException

buildModuleClassAdvertisement

public static ModuleClassAdvertisement buildModuleClassAdvertisement(ModuleClassID mcid,
                                                                     String serviceName,
                                                                     String serviceDescription)
The module class advertisement is to simply advertise the existence of a module.

Parameters:
mcid - -- the module class id
serviceName - -- something like "JXTAMOD:JXTA-WIRE-MyNewThing"
serviceDescription - -- something like "JXTA-WIRE MyNewThing Module"
Returns:
an appropriate ModuleClassAdvertisement

buildModuleSpecAdvertisement

public static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid,
                                                                   String moduleSpecName,
                                                                   String moduleSpecDescription)
The ModuleSpecAdvertisement has two purposes, to publish the uri of its formal specs for developers and to publish the means of remote access to the module's services if that is appropriate. (See ModuleSpecAdvertisement ) Use this form for a minimal advertisement, suitable for development.

Parameters:
msid - -- the module spec id, "urn:jxta:uuid-[the big hex string]"
moduleSpecName - -- something like "JXTASPEC:JXTA-WIRE-MyNewThing-SPEC"
moduleSpecDescription - -- something like "JXTA-WIRE MyNewThing Specification"
Returns:
-- a boilerplate suitable for development.

buildModuleSpecAdvertisement

public static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid,
                                                                   String moduleSpecName,
                                                                   String moduleSpecDescription,
                                                                   String creator,
                                                                   String version,
                                                                   String specURI)
Use this form for production provided remote access is not required.

Parameters:
msid - -- the module spec id, "urn:jxta:uuid-[the big hex string]"
moduleSpecName - -- something like "JXTASPEC:JXTA-WIRE-MyNewThing-SPEC"
moduleSpecDescription - -- something like "JXTA-WIRE MyNewThing Specification"
creator - -- something like "jxta.org"
version - -- something like "Version 1.0"
specURI - -- where to locate the formal specs, e.g. "http://www.jxta.org/MyNewThing"
Returns:
-- a fully populated advert suitable if remote access is not required.

buildModuleSpecAdvertisement

public static ModuleSpecAdvertisement buildModuleSpecAdvertisement(ModuleSpecID msid,
                                                                   String moduleSpecName,
                                                                   String moduleSpecDescription,
                                                                   String creator,
                                                                   String version,
                                                                   String specURI,
                                                                   PipeAdvertisement pipeAdv,
                                                                   ModuleSpecID proxySpecID,
                                                                   ModuleSpecID authorizationSpecID,
                                                                   StructuredDocument param)
Use this form for a fully populated advert.

Parameters:
msid - -- the module spec id, "urn:jxta:uuid-[the big hex string]"
moduleSpecName - -- something like "JXTASPEC:JXTA-WIRE-MyNewThing-SPEC"
moduleSpecDescription - -- something like "JXTA-WIRE MyNewThing Specification"
creator - -- something like "jxta.org"
version - -- something like "Version 1.0"
specURI - -- where to locate the formal specs, e.g. "http://www.jxta.org/MyNewThing"
pipeAdv - -- to make the module useable remotely (see ModuleSpecAdvertisement)
proxySpecID - -- sometimes required for remote use (see ModuleSpecAdvertisement)
authorizationSpecID - -- sometimes required for remote use (see ModuleSpecAdvertisement)
param - -- anything else
Returns:
-- a fully populated advert specifying remote access to module services.

buildCompat

public static StructuredTextDocument buildCompat()
Compat's (compatibility statements) serve to narrow the search for a ModuleImplAdvertisement. Basically you want something compatible with your group's implementation. Use this form for compatibilty with the current StdPeerGroup.

Returns:
-- boilerplate compat for StdPeerGroup

buildCompat

public static StructuredTextDocument buildCompat(String efmt,
                                                 String bind)
Use this form for customized compatibility statements. Alternatively a group's compat is accessible via group.getCompat()

Parameters:
efmt - -- something like "JDK1.4"
bind - -- something like "V1.0 Ref Impl"
Returns:
-- custom compatibility tag

buildModuleImplAdvertisement

public static ModuleImplAdvertisement buildModuleImplAdvertisement(ModuleSpecID msid,
                                                                   String code,
                                                                   Element compat)
A ModuleImplAdvertisement represents one of any number of published implementations of a given specification. Use this form with for a development boilerplate. Use buildCompat() for a compat boilerplate. (See ModuleImplAdvertisement.)

Parameters:
msid - -- the module spec id
code - -- the module's fully qualified classname, "net.jxta.impl.wire.MyNewThing"
compat - -- a compatibility statement. Use buildCompat() for a boilerplate.
Returns:
-- a development boilerplate with custom compatibility.

buildModuleImplAdvertisement

public static ModuleImplAdvertisement buildModuleImplAdvertisement(ModuleSpecID msid,
                                                                   String code,
                                                                   Element compat,
                                                                   String description,
                                                                   String provider,
                                                                   String uri)
Use this form to fully populate a ModuleImplAdvertisement. A ModuleImplAdvertisement has an optional field, "param" which is neglected here. If needed it should be set with advert's setParam method. (See ModuleImplAdvertisement.)

Parameters:
msid - -- the module spec id
code - -- the module's fully qualified classname, "net.jxta.impl.wire.MyNewThing"
compat - -- a compatibility statement
description - -- something like "MyNewThing Module, J2SE Implementation"
provider - -- something like "jxta.org"
uri - -- currently ornamental, eventually where to find binaries.
Returns:
-- a custom advert, fully populated except for "param" field.

buildPeerGroupImplAdvertisement

public static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(StdPeerGroup parent,
                                                                      ModuleSpecID newGroupModuleSpecID,
                                                                      String newDescription,
                                                                      Hashtable newServices)
                                                               throws IllegalArgumentException,
                                                                      Exception
Modifies a copy of the parent's implementation advertisement to reflect the addition or replacement of services. The newServices Hashtable must have ModuleClassID keys and ModuleImplAdvertisement values. I've deferred adding applications or protocols for the moment --vasha@jxta.org Dec 3 2001.

Parameters:
parent - -- a running instance of the new group's parent
newGroupModuleSpecID - -- since new or replacement services are involved
newDescription - -- the new group's reason to be
newServices - -- advert's for the new services
Returns:
-- advert for the new peergroup which the StdPeerGroup module will implement.
Throws:
IllegalArgumentException - -- for a bad key or value type
Exception - --- if the parent can't produce a copy of its own impl advert

buildPeerGroupImplAdvertisement

public static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent,
                                                                      ModuleSpecID newGroupModuleSpecID,
                                                                      String newDescription,
                                                                      Hashtable newServices,
                                                                      Hashtable newApps)
                                                               throws IllegalArgumentException,
                                                                      Exception
Throws:
IllegalArgumentException
Exception

buildPeerGroupImplAdvertisement

public static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent,
                                                                      ModuleSpecID newGroupModuleSpecID,
                                                                      String newDescription,
                                                                      Hashtable newServices,
                                                                      Hashtable newApps,
                                                                      Hashtable newProtos)
                                                               throws IllegalArgumentException,
                                                                      Exception
Throws:
IllegalArgumentException
Exception

typeCheckValues

public static void typeCheckValues(Hashtable moduleTable)
                            throws IllegalArgumentException
Module table vaules must be ModuleImplAdvertisements here. Though StdPeerGroup allows for values of type ModuleSpecID, the context in which they seem to apply is not our context of adding or replacing modules, so I've prohibited them. --vasha@jxta.org dec 3 2001.

Parameters:
moduleTable - -- a Hashtable of services, applications or protocols.
Throws:
IllegalArgumentException - -- for an invalid key or value type

typeCheckKeys

public static void typeCheckKeys(Hashtable moduleTable)
                          throws IllegalArgumentException
Module table keys must be ModuleClassID's.

Parameters:
moduleTable - -- a Hashtable of services, applications or protocols.
Throws:
IllegalArgumentException - -- for an invalid key or value type

JXTA J2SE