本文整理汇总了Java中org.apache.catalina.Server类的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Server类属于org.apache.catalina包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStandardService
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Create a new StandardService.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this StandardService
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardService(String parent, String name, String domain)
throws Exception {
// Create a new StandardService instance
StandardService service = new StandardService();
service.setName(name);
// Add the new instance to its parent component
Server server = ServerFactory.getServer();
server.addService(service);
// Return the corresponding MBean name
return (service.getObjectName().toString());
}
示例2: getTomcat7Port
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Gets my listen port in Tomcat 7. Returns zero if not possible
*/
public static int getTomcat7Port() {
try {
MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName name = new ObjectName("Catalina", "type", "Server");
Server server = (Server) mBeanServer.getAttribute(name, "managedResource");
Service[] services = server.findServices();
for (Service service : services) {
for (Connector connector : service.findConnectors()) {
ProtocolHandler protocolHandler = connector.getProtocolHandler();
if (protocolHandler instanceof Http11Protocol) {
return connector.getPort();
}
}
}
return 0;
} catch(Exception ex) {
ex.printStackTrace(System.err);
return 0;
}
}
示例3: destroy
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Process a "destroy" event for this Context.
*/
protected synchronized void destroy() {
// Called from StandardContext.destroy()
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.destroy"));
// Skip clearing the work directory if Tomcat is being shutdown
Server s = getServer();
if (s != null && !s.getState().isAvailable()) {
return;
}
// Changed to getWorkPath per Bugzilla 35819.
if (context instanceof StandardContext) {
String workDir = ((StandardContext) context).getWorkPath();
if (workDir != null) {
ExpandWar.delete(new File(workDir));
}
}
}
示例4: getServer
import org.apache.catalina.Server; //导入依赖的package包/类
private Server getServer() {
Container c = context;
while (c != null && !(c instanceof Engine)) {
c = c.getParent();
}
if (c == null) {
return null;
}
Service s = ((Engine)c).getService();
if (s == null) {
return null;
}
return s.getServer();
}
示例5: createStandardServiceEngine
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Creates a new StandardService and StandardEngine.
*
* @param domain Domain name for the container instance
* @param defaultHost Name of the default host to be used in the Engine
* @param baseDir Base directory value for Engine
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardServiceEngine(String domain,
String defaultHost, String baseDir) throws Exception{
if (!(container instanceof Server)) {
throw new Exception("Container not Server");
}
StandardEngine engine = new StandardEngine();
engine.setDomain(domain);
engine.setName(domain);
engine.setDefaultHost(defaultHost);
engine.setBaseDir(baseDir);
Service service = new StandardService();
service.setContainer(engine);
service.setName(domain);
((Server) container).addService(service);
return engine.getObjectName().toString();
}
示例6: getServer
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Return the Server object that is the ultimate parent for the container
* with which this Realm is associated. If the server cannot be found (eg
* because the container hierarchy is not complete), <code>null</code> is
* returned.
*/
protected Server getServer() {
Container c = container;
if (c instanceof Context) {
c = c.getParent();
}
if (c instanceof Host) {
c = c.getParent();
}
if (c instanceof Engine) {
Service s = ((Engine)c).getService();
if (s != null) {
return s.getServer();
}
}
return null;
}
示例7: createMBean
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Server</code> object.
*
* @param server The Server to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Server server)
throws Exception {
String mname = createManagedName(server);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(server);
ObjectName oname = createObjectName(domain, server);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例8: destroyMBean
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Server</code> object.
*
* @param server The Server to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
static void destroyMBean(Server server)
throws Exception {
String mname = createManagedName(server);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, server);
if( mserver.isRegistered(oname) )
mserver.unregisterMBean(oname);
}
示例9: getServer
import org.apache.catalina.Server; //导入依赖的package包/类
@Override
public Server getServer() {
if (server != null) {
return server;
}
ExtendedCatalina extendedCatalina = new ExtendedCatalina();
Digester digester = extendedCatalina.createStartDigester();
digester.push(extendedCatalina);
try {
server = ((ExtendedCatalina) digester
.parse(new File(System.getProperty("catalina.base") + RELATIVE_SERVERXML_PATH))).getServer();
this.initBaseDir();
} catch (Exception e) {
log.error("Error while parsing server.xml", e);
server = null;
} finally {
return server;
}
}
示例10: createStandardEngine
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Create a new StandardEngine.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this Engine
* @param defaultHost Default hostname of this Engine
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardEngine(String parent, String name,
String defaultHost)
throws Exception {
// Create a new StandardEngine instance
StandardEngine engine = new StandardEngine();
engine.setName(name);
engine.setDefaultHost(defaultHost);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Server server = ServerFactory.getServer();
Service service = server.findService(pname.getKeyProperty("name"));
service.setContainer(engine);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("StandardEngine");
ObjectName oname =
MBeanUtils.createObjectName(managed.getDomain(), engine);
return (oname.toString());
}
示例11: createStandardService
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Create a new StandardService.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this StandardService
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardService(String parent, String name)
throws Exception {
// Create a new StandardService instance
StandardService service = new StandardService();
service.setName(name);
// Add the new instance to its parent component
Server server = ServerFactory.getServer();
server.addService(service);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("StandardService");
ObjectName oname =
MBeanUtils.createObjectName(managed.getDomain(), service);
return (oname.toString());
}
示例12: removeContext
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Remove an existing Context.
*
* @param name MBean Name of the comonent to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeContext(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
String serviceName = oname.getKeyProperty("service");
String hostName = oname.getKeyProperty("host");
String contextName = getPathStr(oname.getKeyProperty("path"));
Server server = ServerFactory.getServer();
Service service = server.findService(serviceName);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(hostName);
Context context = (Context) host.findChild(contextName);
// Remove this component from its parent component
host.removeChild(context);
}
示例13: removeHost
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Remove an existing Host.
*
* @param name MBean Name of the comonent to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeHost(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
String serviceName = oname.getKeyProperty("service");
String hostName = oname.getKeyProperty("host");
Server server = ServerFactory.getServer();
Service service = server.findService(serviceName);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(hostName);
// Remove this component from its parent component
engine.removeChild(host);
}
示例14: createMBean
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Server</code> object.
*
* @param server The Server to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
public static ModelMBean createMBean(Server server)
throws Exception {
String mname = createManagedName(server);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ModelMBean mbean = managed.createMBean(server);
ObjectName oname = createObjectName(domain, server);
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例15: destroyMBean
import org.apache.catalina.Server; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Server</code> object.
*
* @param server The Server to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
public static void destroyMBean(Server server)
throws Exception {
String mname = createManagedName(server);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, server);
mserver.unregisterMBean(oname);
}