if (serviceID == null || serviceUuid == null)
throw new AssertionError(
"serviceID and serviceUuid must be set");
// Default do nothing preparer
final ProxyPreparer defaultPreparer =
new net.jini.security.BasicProxyPreparer();
lookupLocatorPreparer =
(ProxyPreparer)Config.getNonNullEntry(config,
TxnManager.MAHALO, "lookupLocatorPreparer",
ProxyPreparer.class, defaultPreparer);
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "lookupLocatorPreparer: {0}",
lookupLocatorPreparer);
}
//TODO - defer creation of default LDM
dm = (DiscoveryManagement)
Config.getNonNullEntry(config, TxnManager.MAHALO,
"discoveryManager", DiscoveryManagement.class,
new LookupDiscoveryManager(
DiscoveryGroupManagement.NO_GROUPS, null, null, config));
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "discoveryManager: {0}", dm);
}
if (dm instanceof DiscoveryGroupManagement) {
// Verify proper initial state ---> NO_GROUPS
String[] groups =
((DiscoveryGroupManagement)dm).getGroups();
if( (groups == DiscoveryGroupManagement.ALL_GROUPS) ||
(groups.length != 0) )
{
throw new ConfigurationException(
"discoveryManager entry must be configured " +
"to initially discover/join NO_GROUPS");
}//endif
} else {
throw new ConfigurationException("Entry for component " +
TxnManager.MAHALO + ", name " +
"discoveryManager must implement " +
"net.jini.discovery.DiscoveryGroupManagement");
}
if (dm instanceof DiscoveryLocatorManagement) {
LookupLocator[] locs =
((DiscoveryLocatorManagement)dm).getLocators();
if( (locs != null) && (locs.length != 0) ) {
throw new ConfigurationException
("discoveryManager entry must be initially"
+ "configured with no locators");
}//endif
} else {
throw new ConfigurationException("Entry for component " +
TxnManager.MAHALO + ", name " +
"discoveryManager must implement " +
"net.jini.discovery.DiscoveryLocatorManagement");
}
// if this is the first incarnation, consult config for groups,
// locators and attributes.
if (initial) {
if(initlogger.isLoggable(Level.FINEST)) {
initlogger.log(Level.FINEST, "Obtaining initial values");
}
groups = (String[])
config.getEntry(TxnManager.MAHALO,
"initialLookupGroups", String[].class,
new String[] { "" }); //default to public group
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "Obtaining initial groups: {0}",
(groups==null?
Arrays.asList(new String[] {"<ALL_GROUPS>"}):
Arrays.asList(groups)));
}
locators = (LookupLocator[])
Config.getNonNullEntry(config, TxnManager.MAHALO,
"initialLookupLocators", LookupLocator[].class,
new LookupLocator[0]);
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "Obtaining initial locators: {0}",
Arrays.asList(locators));
}
final Entry[] cAttrs = (Entry[])
Config.getNonNullEntry(config, TxnManager.MAHALO,
"initialLookupAttributes", Entry[].class, new Entry[0]);
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "Obtaining initial attributes: {0}",
Arrays.asList(cAttrs));
}
if (cAttrs.length == 0) {
attributes = baseAttributes;
} else {
attributes = new Entry[cAttrs.length + baseAttributes.length];
System.arraycopy(baseAttributes, 0, attributes,
0, baseAttributes.length);
System.arraycopy(cAttrs, 0, attributes,
baseAttributes.length, cAttrs.length);
}
if(initlogger.isLoggable(Level.FINEST)) {
initlogger.log(Level.FINEST, "Combined attributes: {0}",
Arrays.asList(attributes));
}
} else {
/* recovery : if there are any locators get and
* use recoveredLookupLocatorPreparer
*/
if(initlogger.isLoggable(Level.FINEST)) {
initlogger.log(Level.FINEST, "Recovered locators: {0}",
Arrays.asList(locators));
}
if (locators.length > 0) {
final ProxyPreparer recoveredLookupLocatorPreparer =
(ProxyPreparer)Config.getNonNullEntry(config,
TxnManager.MAHALO,
"recoveredLookupLocatorPreparer", ProxyPreparer.class,
defaultPreparer);
if(initlogger.isLoggable(Level.CONFIG)) {
initlogger.log(Level.CONFIG, "recoveredLookupLocatorPreparer: {0}",
recoveredLookupLocatorPreparer);
}
final List prepared = new java.util.LinkedList();
for (int i=0; i<locators.length; i++) {
try {
prepared.add(recoveredLookupLocatorPreparer.
prepareProxy(locators[i]));
} catch (Throwable t) {
if(initlogger.isLoggable(Levels.HANDLED)) {
initlogger.log(Levels.HANDLED,
"Exception re-preparing LookupLocator: {0}. "