boolean flag = false;
// Transfer argument properties into profile properties
ExtendedProperties profileProp = (ExtendedProperties)getProperties();
boolean isMain = true;
if (argProp.getProperty(Profile.MAIN) != null) {
isMain = fetchAndVerifyBoolean(Profile.MAIN);
}
else {
isMain = !fetchAndVerifyBoolean(CONTAINER_KEY);
}
if (isMain) {
profileProp.setProperty(Profile.MAIN, "true");
}
else {
profileProp.setProperty(Profile.MAIN, "false");
// Since the value is false, we cancel the default done in ProfileImpl's constructor
setSpecifiers(Profile.MTPS, new ArrayList(0)); // remove default MTP
}
String sm = argProp.getProperty(LOCAL_SERVICE_MANAGER);
if(sm != null) {
profileProp.setProperty(Profile.LOCAL_SERVICE_MANAGER, sm);
}
/* PER IL DF
value = argProp.getProperty(df.KBDF_MAX_RESULTS);
if (value != null) {
profileProp.setProperty(df.KBDF_MAX_RESULTS, value);
}
value = argProp.getProperty(df.DBDF_DRIVER);
if (value != null) {
profileProp.setProperty(df.DBDF_DRIVER, value);
}
value = argProp.getProperty(df.DBDF_URL);
if (value != null) {
profileProp.setProperty(df.DBDF_URL, value);
}*/
/*
value = argProp.getProperty(PASSWD_KEY);
if (value != null) {
//profileProp.setProperty(Profile.PASSWD_FILE, value);
}
*/
value = argProp.getProperty(IMTP);
if (value != null) {
profileProp.setProperty(Profile.IMTP, value);
}
String host = argProp.getProperty(MAIN_HOST);
if (host != null) {
profileProp.setProperty(Profile.MAIN_HOST, host);
} else {
host = profileProp.getProperty(Profile.MAIN_HOST);
if (host == null) {
host = getDefaultNetworkName();
profileProp.setProperty(Profile.MAIN_HOST, host);
}
}
String port = argProp.getProperty(MAIN_PORT);
if (port == null) {
// Default for a sole main container: use the local port, or
// the default port if also the local port is null.
if(isMasterMain()) {
port = argProp.getProperty(LOCAL_PORT);
}
if(port == null) {
// All other cases: use the default port.
port = Integer.toString(DEFAULT_PORT);
}
}
profileProp.setProperty(Profile.MAIN_PORT, port);
String localHost = argProp.getProperty(LOCAL_HOST);
if(localHost == null) {
// Default for a sole main container: use the MAIN_HOST property
if(isMasterMain()) {
localHost = host;
}
else {
// Default for a peripheral container or an added main container: use the local host
localHost = getDefaultNetworkName();
}
}
profileProp.setProperty(Profile.LOCAL_HOST, localHost);
String localPort = argProp.getProperty(LOCAL_PORT);
if(localPort == null) {
// Default for a sole main container: use the MAIN_PORT property
if(isMasterMain()) {
localPort = port;
}
else {
// Default for a peripheral container or an added main container: use the default port
localPort = Integer.toString(DEFAULT_PORT);
}
}
profileProp.setProperty(Profile.LOCAL_PORT, localPort);
value = argProp.getProperty(REMOTE_SERVICE_MANAGER_ADDRESSES);
if (value != null) {
try {
Vector v = Specifier.parseSpecifierList(value);
// Convert the Vector into a List
List l = new ArrayList(v.size());
Enumeration e = v.elements();
while (e.hasMoreElements()) {
l.add(e.nextElement());
}
setSpecifiers(Profile.REMOTE_SERVICE_MANAGER_ADDRESSES, l);
}
catch(Exception e) {
e.printStackTrace();
}
}
value = argProp.getProperty(NAME_KEY);
if (value != null) {
profileProp.setProperty(Profile.PLATFORM_ID, value);
}
value = argProp.getProperty(LOGIN_KEY);
if (value != null) {
profileProp.setProperty(Profile.USERAUTH_KEY, value);
}
value = argProp.getProperty(MTP_KEY);
if (value != null) {
setSpecifiers(Profile.MTPS, parseSpecifiers(value));
}
//NOMTP
flag = fetchAndVerifyBoolean(NOMTP_KEY);
if (flag) {
// Since the value was set to true, cancel the MTP settings
setSpecifiers(Profile.MTPS, new ArrayList(0));
}
value = argProp.getProperty(ACLCODEC_KEY);
if (value != null) {
setSpecifiers(Profile.ACLCODECS, parseSpecifiers(value));
}
// Get agent list (if any)
value = argProp.getProperty(AGENTS);
flag = fetchAndVerifyBoolean(GUI_KEY);
if (flag) {
// need to run RMA agent
if (value != null) {
value = "RMA:jade.tools.rma.rma " + value; // put before other agents
} else {
value = "RMA:jade.tools.rma.rma"; // only one
}
}
if (value != null) {
Vector agentVector = helper.T2(value, false);
List agents = new ArrayList();
for (Enumeration e = helper.getCommandLineAgentSpecifiers(agentVector);
e.hasMoreElements(); ) {
agents.add((Specifier) e.nextElement());
}
setSpecifiers(Profile.AGENTS, agents);
}
// Get service list (if any)
value = argProp.getProperty(SERVICES);
if(value == null) {
// Remove mobility service from the list if '-nomobility' was specified
flag = fetchAndVerifyBoolean(NOMOBILITY_KEY);
if (flag) {
value = DEFAULT_SERVICES_NOMOBILITY;
}
else {
value = DEFAULT_SERVICES;
}
}
setSpecifiers(Profile.SERVICES, parseSpecifiers(value));
// finally, copy into profileProp all the properties that
// were present in argProp AND were not already present in profileProp.
// The fact that we do not copy those properties that were already
// present in profileProp is a sanity check to avoid modification
// of properties that were set in the code above
for (Enumeration e=argProp.keys(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
if (getParameter(key,null) == null)
setParameter(key, argProp.get(key).toString());
}
// The following is for debugging only. Probably should not document the "dumpProfile" attribute.
// Note All the jade.util.leap.ArrayList structures will only print their type unless a
// toString() method were added to them.
if (argProp.getBooleanProperty("dumpProfile", false)) {
ArrayList aList = new ArrayList();
System.out.println("---------- Jade Boot profile property values ----------");
for (Enumeration e = profileProp.sortedKeys(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
Object o = profileProp.get(key);
if (o.getClass().isAssignableFrom(aList.getClass())) {
System.out.print(key + "=");
ArrayList al = (ArrayList)o;
Iterator itor = al.iterator();
if (!itor.hasNext()) {
System.out.println("<empty>");
} else {
StringBuffer sb = new StringBuffer();
while (itor.hasNext()) {
sb.append(itor.next());
if (itor.hasNext()) {
sb.append(" ");
}
}
System.out.println(sb.toString());
}
} else {
System.out.println(key + "=" + profileProp.getProperty(key));
}
}
System.out.println("-------------------------------------------------------");
}
}