in source/code/providers/support/appserver/appserverenumeration.cpp [452:565]
void AppServerEnumeration::Update(bool /*updateInstances*/)
{
SCX_LOGTRACE(m_log, L"AppServerEnumeration Update()");
vector<SCXCoreLib::SCXHandle<AppServerInstance> > ASInstances;
bool gotWeblogicProcesses = false;
vector<wstring> weblogicProcesses;
// Find all Java processes running
vector<SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> > procList = m_deps->Find(L"java");
for (vector<SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> >::iterator it = procList.begin(); it != procList.end(); it++)
{
vector<string> params;
if (m_deps->GetParameters((*it),params))
{
// Log "Found java process, Parameters: Size=x, Contents: y"
if (eTrace == m_log.GetSeverityThreshold())
{
std::wostringstream txt;
txt << L"AppServerEnumeration Update(): Found java process, Parameters: Size=" << params.size();
if (params.size() > 0)
{
txt << L", Contents:";
int count = 0;
for (vector<string>::iterator itp = params.begin(); itp != params.end(); ++itp)
{
txt << L" " << ++count << L":\"" << StrFromUTF8(*itp) << L"\"";
}
}
SCX_LOGTRACE(m_log, txt.str());
}
// Loop through each 'java' process and check for 'JBoss' argument on the commandline
if(CheckProcessCmdLineArgExists(params,"org.jboss.Main") ||
CheckProcessCmdLineArgExists(params,"org.jboss.as.standalone") ||
CheckProcessCmdLineArgExists(params,"org.jboss.as.server"))
{
CreateJBossInstance(&ASInstances, params);
}
// Loop through each 'java' process and check for Tomcat i.e. 'Catalina' argument on the commandline
if(CheckProcessCmdLineArgExists(params,"org.apache.catalina.startup.Bootstrap"))
{
CreateTomcatInstance(&ASInstances, params);
}
// Loop through each 'java' process and check for Weblogic i.e. 'weblogic.Server' argument on the commandline
if(CheckProcessCmdLineArgExists(params,"weblogic.Server"))
{
wstring wlHome = GetWeblogicHome(params);
if(!wlHome.empty())
{
weblogicProcesses.push_back(wlHome);
gotWeblogicProcesses = true;
}
}
// Loop through each 'java' process and check for WebSphere i.e.
// com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer argument on the commandline
if(CheckProcessCmdLineArgExists(params,"com.ibm.ws.bootstrap.WSLauncher") &&
CheckProcessCmdLineArgExists(params,WEBSPHERE_RUNTIME_CLASS))
{
CreateWebSphereInstance(&ASInstances, params);
}
}
}
// Get the list of Weblogic Instances and add them to the enumerator
if(gotWeblogicProcesses)
{
vector<SCXHandle<AppServerInstance> > newInst;
m_deps->GetWeblogicInstances(weblogicProcesses, newInst);
for (
vector<SCXCoreLib::SCXHandle<AppServerInstance> >::iterator it = newInst.begin();
it != newInst.end();
++it)
{
SCX_LOGTRACE(m_log, L"Adding a Weblogic instance");
ASInstances.push_back(*it);
}
}
//Get the current instances and place them in a vector
vector<SCXCoreLib::SCXHandle<AppServerInstance> > knownInstances;
for (EntityIterator iter = Begin(); iter != End(); ++iter)
{
knownInstances.push_back(*iter);
}
SCX_LOGTRACE(m_log, L"Merging previously known instances with current running processes");
SCX_LOGTRACE(m_log,
StrAppend(L"size of previously known instances: ",
knownInstances.size()));
SCX_LOGTRACE(m_log,
StrAppend(L"size of running processes : ", ASInstances.size()));
ManipulateAppServerInstances::UpdateInstancesWithRunningProcesses(knownInstances, ASInstances);
SCX_LOGTRACE(m_log,
StrAppend(L"size of merged list : ",
knownInstances.size()));
SCX_LOGTRACE(m_log, L"delete all instances");
RemoveInstances() ;
for (vector<SCXHandle<AppServerInstance> >::iterator it = knownInstances.begin();
it != knownInstances.end();
++it)
{
SCX_LOGTRACE(m_log, L"adding an instance from processes");
AddInstance(*it);
}
}