void startManager(Configuration config, LogOps log, Object service,
ServiceID serviceID, Entry[] baseAttributes)
throws IOException, ConfigurationException
{
// Default do nothing preparer
final ProxyPreparer defaultPreparer =
new net.jini.security.BasicProxyPreparer();
if (serviceID == null)
throw new NullPointerException("serviceID can't be null");
this.log = log;
lookupLocatorPreparer =
(ProxyPreparer)Config.getNonNullEntry(config,
OutriggerServerImpl.COMPONENT_NAME, "lookupLocatorPreparer",
ProxyPreparer.class, defaultPreparer);
dgm = (DiscoveryGroupManagement)
Config.getNonNullEntry(config,
OutriggerServerImpl.COMPONENT_NAME, "discoveryManager",
DiscoveryGroupManagement.class,
new LookupDiscoveryManager(
DiscoveryGroupManagement.NO_GROUPS, null, null,
config));
if (!(dgm instanceof DiscoveryManagement))
throw throwNewConfigurationException("Entry for component " +
OutriggerServerImpl.COMPONENT_NAME + ", name " +
"discoveryManager must implement " +
"net.jini.discovery.DiscoveryGroupManagement");
if (!(dgm instanceof DiscoveryLocatorManagement))
throw throwNewConfigurationException("Entry for component " +
OutriggerServerImpl.COMPONENT_NAME + ", name " +
"discoveryManager must implement " +
"net.jini.discovery.DiscoveryLocatorManagement");
final String[] toCheck = dgm.getGroups();
if (toCheck == null || toCheck.length != 0)
throw throwNewConfigurationException("Entry for component " +
OutriggerServerImpl.COMPONENT_NAME + ", name " +
"discoveryManager must be initially configured with no " +
"groups");
if (((DiscoveryLocatorManagement)dgm).getLocators().length != 0)
throw throwNewConfigurationException("Entry for component " +
OutriggerServerImpl.COMPONENT_NAME + ", name " +
"discoveryManager must be initially configured with no " +
"locators");
// if this is the first incarnation, consult config for groups,
// locators and attributes.
if (initial) {
groups = (String[])
config.getEntry(OutriggerServerImpl.COMPONENT_NAME,
"initialLookupGroups", String[].class,
new String[]{""});
locators = (LookupLocator[])
Config.getNonNullEntry(config,
OutriggerServerImpl.COMPONENT_NAME,
"initialLookupLocators", LookupLocator[].class,
new LookupLocator[0]);
final Entry[] cAttrs = (Entry[])
Config.getNonNullEntry(config,
OutriggerServerImpl.COMPONENT_NAME,
"initialLookupAttributes", Entry[].class, new Entry[0]);
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);
}
} else {
/* recovery : if there are any locators get and
* use recoveredLookupLocatorPreparer
*/
if (locators.length > 0) {
final ProxyPreparer recoveredLookupLocatorPreparer =
(ProxyPreparer)Config.getNonNullEntry(config,
OutriggerServerImpl.COMPONENT_NAME,
"recoveredLookupLocatorPreparer", ProxyPreparer.class,
defaultPreparer);
final List prepared = new java.util.LinkedList();
for (int i=0; i<locators.length; i++) {
final LookupLocator locator = locators[i];
try {
prepared.add(recoveredLookupLocatorPreparer.
prepareProxy(locator));
} catch (Throwable t) {
logger.log(Level.INFO,
"Encountered exception preparing lookup locator " +
"for " + locator + ", dropping locator", t);