{
Map<String, ServiceInfo> result = new HashMap<String, ServiceInfo>();
Map<Integer, Integer> processes = WindowsXPProcess.getProcessMaps(0)[0];
for (Integer pid : processes.keySet())
{
Process p = _processes.get(pid);
if (p == null)
{
p = WindowsXPProcess.getProcess(pid);
if (p == null)
continue;
_processes.put(pid, p);
}
String cmd = p.getCommand();
if (cmd != null && cmd.contains("wrapper.jar\" -c"))
{
JCLParser jp = JCLParser.parse(cmd);
ServiceInfoImpl service = new ServiceInfoImpl();
service.setCommand(cmd);
String confFile = jp.getArgs().get(1);
if (confFile == null)
continue;
File f = new File(confFile);
if (!f.exists())
f = new File(p.getWorkingDir(), confFile);
service.setDisplayName(f.getAbsolutePath());
service.setName(jp.getArgs().get(1));
service.setPid(pid);
service.setWrapperAppPid(getAppPid(pid));
service.setAccount(p.getUser());
result.put(service.getName(), service);
}
Set<Integer> newPids = new HashSet<Integer>(processes.keySet());
Set<Integer> toRemove = new HashSet<Integer>(_processes.keySet());
toRemove.removeAll(newPids);