use of org.apache.catalina.core.StandardService in project tomcat by apache.
the class MBeanFactory method removeContext.
/**
* Remove an existing Context.
*
* @param contextName MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeContext(String contextName) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(contextName);
String domain = oname.getDomain();
StandardService service = (StandardService) getService(oname);
Engine engine = service.getContainer();
String name = oname.getKeyProperty("name");
name = name.substring(2);
int i = name.indexOf('/');
String hostName = name.substring(0, i);
String path = name.substring(i);
ObjectName deployer = new ObjectName(domain + ":type=Deployer,host=" + hostName);
String pathStr = getPathStr(path);
if (mserver.isRegistered(deployer)) {
mserver.invoke(deployer, "addServiced", new Object[] { pathStr }, new String[] { "java.lang.String" });
mserver.invoke(deployer, "unmanageApp", new Object[] { pathStr }, new String[] { "java.lang.String" });
mserver.invoke(deployer, "removeServiced", new Object[] { pathStr }, new String[] { "java.lang.String" });
} else {
log.warn("Deployer not found for " + hostName);
Host host = (Host) engine.findChild(hostName);
Context context = (Context) host.findChild(pathStr);
// Remove this component from its parent component
host.removeChild(context);
if (context instanceof StandardContext)
try {
((StandardContext) context).destroy();
} catch (Exception e) {
log.warn("Error during context [" + context.getName() + "] destroy ", e);
}
}
}
use of org.apache.catalina.core.StandardService in project tomcat by apache.
the class TesterDigestAuthenticatorPerformance method setUp.
@Before
public void setUp() throws Exception {
ConcurrentMessageDigest.init("MD5");
// Configure the Realm
TesterMapRealm realm = new TesterMapRealm();
realm.addUser(USER, PWD);
realm.addUserRole(USER, ROLE);
// Add the Realm to the Context
Context context = new StandardContext();
context.setName(CONTEXT_PATH);
context.setRealm(realm);
Host host = new StandardHost();
context.setParent(host);
Engine engine = new StandardEngine();
host.setParent(engine);
Service service = new StandardService();
engine.setService(service);
// Configure the Login config
LoginConfig config = new LoginConfig();
config.setRealmName(REALM);
context.setLoginConfig(config);
// Make the Context and Realm visible to the Authenticator
authenticator.setContainer(context);
authenticator.setNonceCountWindowSize(8 * 1024);
authenticator.start();
}
Aggregations