1003398 IDEMPIERE-1469 idempiere monitor page don't display processes on starting
This commit is contained in:
parent
78eb8c02da
commit
07c83ff7fd
|
@ -22,6 +22,8 @@ Import-Package: javax.jms;version="1.1.0",
|
||||||
org.apache.ecs,
|
org.apache.ecs,
|
||||||
org.apache.ecs.xhtml,
|
org.apache.ecs.xhtml,
|
||||||
org.apache.poi.hssf.usermodel,
|
org.apache.poi.hssf.usermodel,
|
||||||
|
org.osgi.framework;version="1.6.0",
|
||||||
|
org.osgi.util.tracker;version="1.5.0",
|
||||||
org.restlet,
|
org.restlet,
|
||||||
org.restlet.data,
|
org.restlet.data,
|
||||||
org.restlet.ext.servlet,
|
org.restlet.ext.servlet,
|
||||||
|
@ -37,3 +39,4 @@ Export-Package: org.adempiere.server,
|
||||||
org.idempiere.server.factory
|
org.idempiere.server.factory
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Service-Component: OSGI-INF/acctprocessorfactory.xml, OSGI-INF/alertprocessorfactory.xml, OSGI-INF/ldapprocessorfactory.xml, OSGI-INF/requestprocessorfactory.xml, OSGI-INF/schedulerfactory.xml, OSGI-INF/workflowprocessorfactory.xml
|
Service-Component: OSGI-INF/acctprocessorfactory.xml, OSGI-INF/alertprocessorfactory.xml, OSGI-INF/ldapprocessorfactory.xml, OSGI-INF/requestprocessorfactory.xml, OSGI-INF/schedulerfactory.xml, OSGI-INF/workflowprocessorfactory.xml
|
||||||
|
Bundle-Activator: org.adempiere.server.AdempiereServerActivator
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2013 Trek Global *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.server;
|
||||||
|
|
||||||
|
import org.osgi.framework.BundleActivator;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AdempiereServerActivator implements BundleActivator {
|
||||||
|
|
||||||
|
private static BundleContext context = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public AdempiereServerActivator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void start(BundleContext context) throws Exception {
|
||||||
|
AdempiereServerActivator.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void stop(BundleContext context) throws Exception {
|
||||||
|
AdempiereServerActivator.context = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BundleContext
|
||||||
|
*/
|
||||||
|
public static BundleContext getBundleContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,19 +18,27 @@ package org.compiere.server;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.base.Service;
|
import org.adempiere.base.Service;
|
||||||
|
import org.adempiere.server.AdempiereServerActivator;
|
||||||
import org.adempiere.server.IServerFactory;
|
import org.adempiere.server.IServerFactory;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.model.AdempiereProcessor;
|
import org.compiere.model.AdempiereProcessor;
|
||||||
import org.compiere.model.MSession;
|
import org.compiere.model.MSession;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.osgi.framework.BundleEvent;
|
||||||
|
import org.osgi.framework.BundleListener;
|
||||||
|
import org.osgi.framework.ServiceReference;
|
||||||
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adempiere Server Manager
|
* Adempiere Server Manager
|
||||||
|
@ -38,8 +46,10 @@ import org.compiere.util.Env;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: AdempiereServerMgr.java,v 1.4 2006/10/09 00:23:26 jjanke Exp $
|
* @version $Id: AdempiereServerMgr.java,v 1.4 2006/10/09 00:23:26 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class AdempiereServerMgr
|
public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFactory<AdempiereServer, AdempiereProcessor>, IServerFactory<AdempiereServer, AdempiereProcessor>>, BundleListener
|
||||||
{
|
{
|
||||||
|
private static ServiceTracker<IServerFactory<AdempiereServer, AdempiereProcessor>, IServerFactory<AdempiereServer, AdempiereProcessor>> serviceTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Adempiere Server Manager
|
* Get Adempiere Server Manager
|
||||||
* @return mgr
|
* @return mgr
|
||||||
|
@ -48,10 +58,11 @@ public class AdempiereServerMgr
|
||||||
{
|
{
|
||||||
if (m_serverMgr == null)
|
if (m_serverMgr == null)
|
||||||
{
|
{
|
||||||
// for faster subsequent calls
|
|
||||||
m_serverMgr = new AdempiereServerMgr();
|
m_serverMgr = new AdempiereServerMgr();
|
||||||
m_serverMgr.startServers();
|
serviceTracker = new ServiceTracker<IServerFactory<AdempiereServer, AdempiereProcessor>, IServerFactory<AdempiereServer, AdempiereProcessor>>(AdempiereServerActivator.getBundleContext(),
|
||||||
m_serverMgr.log.info(m_serverMgr.toString());
|
IServerFactory.class.getName(), m_serverMgr);
|
||||||
|
serviceTracker.open();
|
||||||
|
AdempiereServerActivator.getBundleContext().addBundleListener(m_serverMgr);
|
||||||
}
|
}
|
||||||
return m_serverMgr;
|
return m_serverMgr;
|
||||||
} // get
|
} // get
|
||||||
|
@ -68,7 +79,8 @@ public class AdempiereServerMgr
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
startEnvironment();
|
startEnvironment();
|
||||||
// m_serverMgr.startServers();
|
m_servers=new ArrayList<ServerWrapper>();
|
||||||
|
processorClass = new HashSet<String>();
|
||||||
} // AdempiereServerMgr
|
} // AdempiereServerMgr
|
||||||
|
|
||||||
/** The Servers */
|
/** The Servers */
|
||||||
|
@ -78,6 +90,8 @@ public class AdempiereServerMgr
|
||||||
/** Start */
|
/** Start */
|
||||||
private Timestamp m_start = new Timestamp(System.currentTimeMillis());
|
private Timestamp m_start = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
private Set<String> processorClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Environment
|
* Start Environment
|
||||||
* @return true if started
|
* @return true if started
|
||||||
|
@ -100,36 +114,24 @@ public class AdempiereServerMgr
|
||||||
* Start Environment
|
* Start Environment
|
||||||
* @return true if started
|
* @return true if started
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public boolean startServers()
|
public synchronized boolean reload()
|
||||||
{
|
{
|
||||||
log.info("");
|
log.info("");
|
||||||
|
if (!stopAll())
|
||||||
|
return false;
|
||||||
|
|
||||||
int noServers = 0;
|
int noServers = 0;
|
||||||
m_servers=new ArrayList<ServerWrapper>();
|
m_servers=new ArrayList<ServerWrapper>();
|
||||||
|
processorClass = new HashSet<String>();
|
||||||
|
|
||||||
//osgi server
|
//osgi server
|
||||||
List<IServerFactory> serverFactoryList = Service.locator().list(IServerFactory.class).getServices();
|
List<IServerFactory> serverFactoryList = Service.locator().list(IServerFactory.class).getServices();
|
||||||
if (serverFactoryList != null && !serverFactoryList.isEmpty())
|
if (serverFactoryList != null && !serverFactoryList.isEmpty())
|
||||||
{
|
{
|
||||||
List<String> processed = new ArrayList<String>();
|
|
||||||
for(IServerFactory factory : serverFactoryList )
|
for(IServerFactory factory : serverFactoryList )
|
||||||
{
|
{
|
||||||
String name = factory.getProcessorClass().getName();
|
createServers(factory);
|
||||||
if (!processed.contains(name))
|
|
||||||
{
|
|
||||||
processed.add(name);
|
|
||||||
AdempiereServer[] servers = factory.create(m_ctx);
|
|
||||||
if (servers != null && servers.length > 0)
|
|
||||||
{
|
|
||||||
for (AdempiereServer server : servers)
|
|
||||||
{
|
|
||||||
AdempiereProcessor model = server.getModel();
|
|
||||||
if (AdempiereServer.isOKtoRunOnIP(model)) {
|
|
||||||
m_servers.add(new ServerWrapper(server));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +139,25 @@ public class AdempiereServerMgr
|
||||||
return startAll();
|
return startAll();
|
||||||
} // startEnvironment
|
} // startEnvironment
|
||||||
|
|
||||||
|
private void createServers(IServerFactory<AdempiereServer, AdempiereProcessor> factory) {
|
||||||
|
String name = factory.getProcessorClass().getName();
|
||||||
|
if (!processorClass.contains(name))
|
||||||
|
{
|
||||||
|
processorClass.add(name);
|
||||||
|
AdempiereServer[] servers = factory.create(m_ctx);
|
||||||
|
if (servers != null && servers.length > 0)
|
||||||
|
{
|
||||||
|
for (AdempiereServer server : servers)
|
||||||
|
{
|
||||||
|
AdempiereProcessor model = server.getModel();
|
||||||
|
if (AdempiereServer.isOKtoRunOnIP(model)) {
|
||||||
|
m_servers.add(new ServerWrapper(server));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Server Context
|
* Get Server Context
|
||||||
* @return ctx
|
* @return ctx
|
||||||
|
@ -150,7 +171,7 @@ public class AdempiereServerMgr
|
||||||
* Start all servers
|
* Start all servers
|
||||||
* @return true if started
|
* @return true if started
|
||||||
*/
|
*/
|
||||||
public boolean startAll()
|
public synchronized boolean startAll()
|
||||||
{
|
{
|
||||||
log.info ("");
|
log.info ("");
|
||||||
ServerWrapper[] servers = getInActive();
|
ServerWrapper[] servers = getInActive();
|
||||||
|
@ -159,7 +180,7 @@ public class AdempiereServerMgr
|
||||||
ServerWrapper server = servers[i];
|
ServerWrapper server = servers[i];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (server.scheduleFuture != null || !server.scheduleFuture.isDone())
|
if (server.scheduleFuture != null && !server.scheduleFuture.isDone())
|
||||||
continue;
|
continue;
|
||||||
// Do start
|
// Do start
|
||||||
// replace
|
// replace
|
||||||
|
@ -205,7 +226,7 @@ public class AdempiereServerMgr
|
||||||
* @param serverID server ID
|
* @param serverID server ID
|
||||||
* @return true if started
|
* @return true if started
|
||||||
*/
|
*/
|
||||||
public boolean start (String serverID)
|
public synchronized boolean start (String serverID)
|
||||||
{
|
{
|
||||||
ServerWrapper server = getServer(serverID);
|
ServerWrapper server = getServer(serverID);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
|
@ -231,7 +252,7 @@ public class AdempiereServerMgr
|
||||||
* Stop all Servers
|
* Stop all Servers
|
||||||
* @return true if stopped
|
* @return true if stopped
|
||||||
*/
|
*/
|
||||||
public boolean stopAll()
|
public synchronized boolean stopAll()
|
||||||
{
|
{
|
||||||
log.info ("");
|
log.info ("");
|
||||||
ServerWrapper[] servers = getActive();
|
ServerWrapper[] servers = getActive();
|
||||||
|
@ -311,7 +332,7 @@ public class AdempiereServerMgr
|
||||||
* @param serverID server ID
|
* @param serverID server ID
|
||||||
* @return true if interrupted
|
* @return true if interrupted
|
||||||
*/
|
*/
|
||||||
public boolean stop (String serverID)
|
public synchronized boolean stop (String serverID)
|
||||||
{
|
{
|
||||||
ServerWrapper server = getServer(serverID);
|
ServerWrapper server = getServer(serverID);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
|
@ -337,7 +358,7 @@ public class AdempiereServerMgr
|
||||||
/**
|
/**
|
||||||
* Destroy
|
* Destroy
|
||||||
*/
|
*/
|
||||||
public void destroy ()
|
public synchronized void destroy ()
|
||||||
{
|
{
|
||||||
log.info ("");
|
log.info ("");
|
||||||
stopAll();
|
stopAll();
|
||||||
|
@ -348,7 +369,7 @@ public class AdempiereServerMgr
|
||||||
* Get Active Servers
|
* Get Active Servers
|
||||||
* @return array of active servers
|
* @return array of active servers
|
||||||
*/
|
*/
|
||||||
protected ServerWrapper[] getActive()
|
protected synchronized ServerWrapper[] getActive()
|
||||||
{
|
{
|
||||||
ArrayList<ServerWrapper> list = new ArrayList<ServerWrapper>();
|
ArrayList<ServerWrapper> list = new ArrayList<ServerWrapper>();
|
||||||
for (int i = 0; i < m_servers.size(); i++)
|
for (int i = 0; i < m_servers.size(); i++)
|
||||||
|
@ -366,7 +387,7 @@ public class AdempiereServerMgr
|
||||||
* Get InActive Servers
|
* Get InActive Servers
|
||||||
* @return array of inactive servers
|
* @return array of inactive servers
|
||||||
*/
|
*/
|
||||||
protected ServerWrapper[] getInActive()
|
protected synchronized ServerWrapper[] getInActive()
|
||||||
{
|
{
|
||||||
ArrayList<ServerWrapper> list = new ArrayList<ServerWrapper>();
|
ArrayList<ServerWrapper> list = new ArrayList<ServerWrapper>();
|
||||||
for (int i = 0; i < m_servers.size(); i++)
|
for (int i = 0; i < m_servers.size(); i++)
|
||||||
|
@ -384,7 +405,7 @@ public class AdempiereServerMgr
|
||||||
* Get all Servers
|
* Get all Servers
|
||||||
* @return array of servers
|
* @return array of servers
|
||||||
*/
|
*/
|
||||||
public ServerWrapper[] getAll()
|
public synchronized ServerWrapper[] getAll()
|
||||||
{
|
{
|
||||||
ServerWrapper[] retValue = new ServerWrapper[m_servers.size()];
|
ServerWrapper[] retValue = new ServerWrapper[m_servers.size()];
|
||||||
m_servers.toArray (retValue);
|
m_servers.toArray (retValue);
|
||||||
|
@ -396,7 +417,7 @@ public class AdempiereServerMgr
|
||||||
* @param serverID server id
|
* @param serverID server id
|
||||||
* @return server or null
|
* @return server or null
|
||||||
*/
|
*/
|
||||||
public ServerWrapper getServer (String serverID)
|
public synchronized ServerWrapper getServer (String serverID)
|
||||||
{
|
{
|
||||||
if (serverID == null)
|
if (serverID == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -436,7 +457,7 @@ public class AdempiereServerMgr
|
||||||
* Get Number Servers
|
* Get Number Servers
|
||||||
* @return no of servers
|
* @return no of servers
|
||||||
*/
|
*/
|
||||||
public String getServerCount()
|
public synchronized String getServerCount()
|
||||||
{
|
{
|
||||||
int noRunning = 0;
|
int noRunning = 0;
|
||||||
int noStopped = 0;
|
int noStopped = 0;
|
||||||
|
@ -497,4 +518,36 @@ public class AdempiereServerMgr
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized IServerFactory<AdempiereServer, AdempiereProcessor> addingService(
|
||||||
|
ServiceReference<IServerFactory<AdempiereServer, AdempiereProcessor>> reference) {
|
||||||
|
IServerFactory<AdempiereServer, AdempiereProcessor> factory = AdempiereServerActivator.getBundleContext().getService(reference);
|
||||||
|
createServers(factory);
|
||||||
|
startAll();
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modifiedService(
|
||||||
|
ServiceReference<IServerFactory<AdempiereServer, AdempiereProcessor>> reference,
|
||||||
|
IServerFactory<AdempiereServer, AdempiereProcessor> service) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removedService(
|
||||||
|
ServiceReference<IServerFactory<AdempiereServer, AdempiereProcessor>> reference,
|
||||||
|
IServerFactory<AdempiereServer, AdempiereProcessor> service) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bundleChanged(BundleEvent event) {
|
||||||
|
if (event.getType() == BundleEvent.STOPPED) {
|
||||||
|
if (serviceTracker != null)
|
||||||
|
serviceTracker.close();
|
||||||
|
} else if (event.getType() == BundleEvent.STARTED) {
|
||||||
|
if (serviceTracker != null)
|
||||||
|
serviceTracker.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
} // AdempiereServerMgr
|
} // AdempiereServerMgr
|
||||||
|
|
|
@ -300,8 +300,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
{
|
{
|
||||||
if (reload)
|
if (reload)
|
||||||
{
|
{
|
||||||
m_serverMgr.stopAll();
|
ok=m_serverMgr.reload();
|
||||||
ok=m_serverMgr.startServers();
|
|
||||||
this.createSummaryPage(request, response,true);
|
this.createSummaryPage(request, response,true);
|
||||||
m_dirAccessList = getDirAcessList();
|
m_dirAccessList = getDirAcessList();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue