333679 Refactored jetty-jmx. Improved deployer mbeans
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2630 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
881e599860
commit
6f0b83a272
|
@ -107,21 +107,18 @@ public class LikeJettyXml
|
|||
server.addBean(deployer);
|
||||
|
||||
ContextProvider context_provider = new ContextProvider();
|
||||
context_provider.setMonitoredDir(jetty_home + "/contexts");
|
||||
context_provider.setMonitoredDirName(jetty_home + "/contexts");
|
||||
context_provider.setScanInterval(2);
|
||||
server.addBean(context_provider);
|
||||
deployer.addAppProvider(context_provider);
|
||||
|
||||
/*
|
||||
WebAppProvider webapp_provider = new WebAppProvider();
|
||||
webapp_provider.setMonitoredDir(jetty_home + "/webapps");
|
||||
webapp_provider.setMonitoredDirName(jetty_home + "/webapps");
|
||||
webapp_provider.setParentLoaderPriority(false);
|
||||
webapp_provider.setExtractWars(true);
|
||||
webapp_provider.setScanInterval(2);
|
||||
webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml");
|
||||
webapp_provider.setContextXmlDir(jetty_home + "/contexts");
|
||||
deployer.addAppProvider(webapp_provider);
|
||||
*/
|
||||
|
||||
HashLoginService login = new HashLoginService();
|
||||
login.setName("Test Realm");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<!-- =============================================================== -->
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<Ref id="DeploymentManager">
|
||||
<Call name="addAppProvider">
|
||||
<Call id="webappprovider" name="addAppProvider">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
|
||||
<Set name="monitoredDir"><Property name="jetty.home" default="." />/webapps</Set>
|
||||
|
|
|
@ -159,8 +159,11 @@ public class DeploymentManager extends AggregateLifeCycle
|
|||
if (isRunning())
|
||||
throw new IllegalStateException();
|
||||
|
||||
_providers.add(provider);
|
||||
addBean(provider);
|
||||
List<AppProvider> old = new ArrayList<AppProvider>(_providers);
|
||||
if (_providers.add(provider) && getServer()!=null)
|
||||
getServer().getContainer().update(this, null, provider, "provider");
|
||||
|
||||
addBean(provider);
|
||||
}
|
||||
|
||||
public void setLifeCycleBindings(Collection<AppLifeCycle.Binding> bindings)
|
||||
|
@ -395,7 +398,11 @@ public class DeploymentManager extends AggregateLifeCycle
|
|||
public void removeAppProvider(AppProvider provider)
|
||||
{
|
||||
if(_providers.remove(provider))
|
||||
{
|
||||
removeBean(provider);
|
||||
if (getServer()!=null)
|
||||
getServer().getContainer().update(this, provider,null, "provider");
|
||||
}
|
||||
try
|
||||
{
|
||||
provider.stop();
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package org.eclipse.jetty.deploy.jmx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.deploy.App;
|
||||
import org.eclipse.jetty.deploy.AppProvider;
|
||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
||||
public class DeploymentManagerMBean extends ObjectMBean
|
||||
{
|
||||
|
@ -13,6 +20,24 @@ public class DeploymentManagerMBean extends ObjectMBean
|
|||
_manager=(DeploymentManager)managedObject;
|
||||
}
|
||||
|
||||
public Collection<String> getApps()
|
||||
{
|
||||
List<String> apps=new ArrayList<String>();
|
||||
for (App app: _manager.getApps())
|
||||
apps.add(app.getOriginId());
|
||||
return apps;
|
||||
}
|
||||
|
||||
|
||||
public Collection<ContextHandler> getContexts() throws Exception
|
||||
{
|
||||
List<ContextHandler> apps=new ArrayList<ContextHandler>();
|
||||
for (App app: _manager.getApps())
|
||||
apps.add(app.getContextHandler());
|
||||
return apps;
|
||||
}
|
||||
|
||||
public Collection<AppProvider> getAppProviders()
|
||||
{
|
||||
return _manager.getAppProviders();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
DeploymentManager: Deployment Manager
|
||||
apps:MBean:Deployed Apps
|
||||
contexts:MMBean:Deployed Contexts
|
||||
appProviders:MMBean:Application Providers
|
|
@ -0,0 +1 @@
|
|||
ContextProvider: Context AppProvider for Deployment manager
|
|
@ -0,0 +1,4 @@
|
|||
ScanningAppProvider: Scanning AppProvider for Deployment manager
|
||||
monitoredDirName: The directory to monitor for new Apps
|
||||
scanInterval: The scan interval in seconds
|
||||
recursive: Look in subdirectories
|
|
@ -0,0 +1,7 @@
|
|||
WebAppProvider: Web application AppProvider for Deployment manager
|
||||
extractWars: Extract WAR files to temporary directory
|
||||
parentLoaderPriority: ClassLoaders give priority to classes from parent loader
|
||||
defaultsDescriptor: The default descriptor applied before any web.xml
|
||||
contextXmlDir: The directory of context.xml files
|
||||
configurationClasses: The configuration classes to apply
|
||||
tempDir: The temporary directory to use
|
|
@ -18,6 +18,7 @@ import java.lang.reflect.Constructor;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -319,6 +320,15 @@ public class ObjectMBean implements DynamicMBean
|
|||
on[i]=_mbeanContainer.findMBean(Array.get(r, i));
|
||||
r=on;
|
||||
}
|
||||
else if (r instanceof Collection<?>)
|
||||
{
|
||||
Collection<Object> c = (Collection<Object>)r;
|
||||
ObjectName[] on = new ObjectName[c.size()];
|
||||
int i=0;
|
||||
for (Object obj :c)
|
||||
on[i++]=_mbeanContainer.findMBean(obj);
|
||||
r=on;
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectName mbean = _mbeanContainer.findMBean(r);
|
||||
|
|
Loading…
Reference in New Issue