Class AdvCooker
package: src.net.jxta.impl.util
public class AdvCooker
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
Method Summary
public static StructuredTextDocument
   Compat's (compatibility statements) serve to narrow the search for a ModuleImplAdvertisement.
 
public static StructuredTextDocument
buildCompat(String efmt, String bind)
   Use this form for customized compatibility statements.
 
public static ModuleClassAdvertisement
buildModuleClassAdvertisement(ModuleClassID mcid, String serviceName, String serviceDescription)
   The module class advertisement is to simply advertise the existence of a module.
 
public static ModuleClassID
buildModuleClassID(String uri)
   Reconstructs a ModuleClassID from its String representation as printed by the foregoing recipes.
 
public static ModuleImplAdvertisement
buildModuleImplAdvertisement(ModuleSpecID msid, String code, Element compat)
   A ModuleImplAdvertisement represents one of any number of published implementations of a given specification.
 
public static ModuleImplAdvertisement
buildModuleImplAdvertisement(ModuleSpecID msid, String code, Element compat, String description, String provider, String uri)
   Use this form to fully populate a ModuleImplAdvertisement.
 
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.
 
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.
 
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.
 
public static ModuleSpecID
buildModuleSpecID(String uri)
   Reconstructs a ModuleSpecID from its String representation as printed by the foregoing recipes.
 
public 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.
 
public static ModuleImplAdvertisement
buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Hashtable newServices, Hashtable newApps)
public static ModuleImplAdvertisement
buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Hashtable newServices, Hashtable newApps, Hashtable newProtos)
private static Hashtable
mergeTables(Hashtable oldServices, Hashtable newServices)
   Merge two hashtables of servcices, overwriting old with new if they have the same base class id.
 
public static void
   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.
 
public static void
printNewClassAndModuleID(ModuleClassID baseClassID)
   Use this form if your module is a custom implementation of a well-known module such as RendezvousServiceImpl.
 
public static void
typeCheckKeys(Hashtable moduleTable)
   Module table keys must be ModuleClassID's.
 
public static void
typeCheckValues(Hashtable moduleTable)
   Module table vaules must be ModuleImplAdvertisements here.
 
Method Detail
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.
Return:
-- 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"
Return:
-- custom compatibility tag

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"
Return:
an appropriate ModuleClassAdvertisement

buildModuleClassID
public static ModuleClassID buildModuleClassID(String uri)
Reconstructs a ModuleClassID from its String representation as printed by the foregoing recipes.
Throws:
java.net.URISyntaxException
Parameters:
url -- the module class id in String form, "urn:jxta:uuid-[the big hex string]"
throws:
MalformedURLException -- if url is messed up
UnknownServiceException --if urn: isn't supported, meaning a jar is missing
Return:
-- module class id reconstructed from String

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.
Return:
-- 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.
Return:
-- a custom advert, fully populated except for "param" field.

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
Return:
-- a fully populated advert specifying remote access to module services.

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"
Return:
-- 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"
Return:
-- a fully populated advert suitable if remote access is not required.

buildModuleSpecID
public static ModuleSpecID buildModuleSpecID(String uri)
Reconstructs a ModuleSpecID from its String representation as printed by the foregoing recipes.
Throws:
java.net.URISyntaxException
Parameters:
url -- the module spec id in String form, "urn:jxta:uuid-[the big hex string]"
throws:
MalformedURLException -- if url is messed up
UnknownServiceException --if urn: isn't supported, meaning a jar is missing
Return:
-- module spec id reconstructed from String

buildPeerGroupImplAdvertisement
public 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. 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.
Throws:
IllegalArgumentException
Exception
Return:
-- advert for the new peergroup which the StdPeerGroup module will implement.
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
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

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

mergeTables
private static Hashtable mergeTables(Hashtable oldServices, Hashtable newServices)
Merge two hashtables of servcices, overwriting old with new if they have the same base class id.
oldServices:
--service table of a parent group
newServices:
--services to be added or substituted
Return:
--merged table

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.

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.

typeCheckKeys
public static void typeCheckKeys(Hashtable moduleTable)
Module table keys must be ModuleClassID's.
Throws:
IllegalArgumentException
Parameters:
moduleTable -- a Hashtable of services, applications or protocols.
throws:
IllegalArgumentException -- for an invalid key or value type

typeCheckValues
public static void typeCheckValues(Hashtable moduleTable)
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.
Throws:
IllegalArgumentException
Parameters:
moduleTable -- a Hashtable of services, applications or protocols.
throws:
IllegalArgumentException -- for an invalid key or value type