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 XMLDocument buildCompat()
          Compat's (compatibility statements) serve to narrow the search for a ModuleImplAdvertisement.
static XMLDocument 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 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 ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Map newServices, Map newApps)
           
static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(PeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Map newServices, Map newApps, Map newProtos)
           
static ModuleImplAdvertisement buildPeerGroupImplAdvertisement(StdPeerGroup parent, ModuleSpecID newGroupModuleSpecID, String newDescription, Map newServices)
          Modifies a copy of the parent's implementation advertisement to reflect the addition or replacement of services.
static void typeCheckKeys(Map moduleTable)
          Module table keys must be ModuleClassID's.
static void typeCheckValues(Map 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

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 2.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 XMLDocument 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 XMLDocument 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,
                                                                      Map newServices)
                                                               throws 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,
                                                                      Map newServices,
                                                                      Map newApps)
                                                               throws Exception
Throws:
Exception

buildPeerGroupImplAdvertisement

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

typeCheckValues

public static void typeCheckValues(Map 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.

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

typeCheckKeys

public static void typeCheckKeys(Map moduleTable)
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

JXSE