本文整理汇总了Java中org.apache.catalina.Server.findServices方法的典型用法代码示例。如果您正苦于以下问题:Java Server.findServices方法的具体用法?Java Server.findServices怎么用?Java Server.findServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Server
的用法示例。
在下文中一共展示了Server.findServices方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: createServerFromXML
import org.apache.catalina.Server; //导入方法依赖的package包/类
private StandardService createServerFromXML(URL xmlConfiguration) throws IOException {
OsgiCatalina catalina = new OsgiCatalina();
catalina.setAwait(false);
catalina.setUseShutdownHook(false);
catalina.setName("Catalina");
catalina.setParentClassLoader(Thread.currentThread().getContextClassLoader());
// copy the URL file to a local temporary file (since Catalina doesn't use URL unfortunately)
File configTempFile = File.createTempFile("dm.catalina", ".cfg.xml");
configTempFile.deleteOnExit();
// copy URL to temporary file
copyURLToFile(xmlConfiguration.openStream(), new FileOutputStream(configTempFile));
log.debug("Copied configuration " + xmlConfiguration + " to temporary file " + configTempFile);
catalina.setConfigFile(configTempFile.getAbsolutePath());
catalina.load();
Server server = catalina.getServer();
return (StandardService) server.findServices()[0];
}
示例3: registerListenersForServer
import org.apache.catalina.Server; //导入方法依赖的package包/类
private void registerListenersForServer(Server server) {
for (Service service : server.findServices()) {
Engine engine = (Engine) service.getContainer();
engine.addContainerListener(this);
registerListenersForEngine(engine);
}
}
示例4: createMBeans
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Create the MBeans for the specified Server and its nested components.
*
* @param server Server for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Server server) throws Exception {
// Create the MBean for the Server itself
if (log.isDebugEnabled())
log.debug("Creating MBean for Server " + server);
//MBeanUtils.createMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).addPropertyChangeListener(this);
}
// Create the MBeans for the global NamingResources (if any)
NamingResources resources = server.getGlobalNamingResources();
if (resources != null) {
createMBeans(resources);
}
// Create the MBeans for each child Service
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
// FIXME - Warp object hierarchy not currently supported
if (services[i].getContainer().getClass().getName().equals
("org.apache.catalina.connector.warp.WarpEngine")) {
if (log.isDebugEnabled()) {
log.debug("Skipping MBean for Service " + services[i]);
}
continue;
}
createMBeans(services[i]);
}
}
示例5: destroyMBeans
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Deregister the MBeans for the specified Server and its related
* components.
*
* @param server Server for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Server server) throws Exception {
// Destroy the MBeans for the global NamingResources (if any)
NamingResources resources = server.getGlobalNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// Destroy the MBeans for each child Service
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
// FIXME - Warp object hierarchy not currently supported
if (services[i].getContainer().getClass().getName().equals
("org.apache.catalina.connector.warp.WarpEngine")) {
if (log.isDebugEnabled()) {
log.debug("Skipping MBean for Service " + services[i]);
}
continue;
}
destroyMBeans(services[i]);
}
// Destroy the MBean for the Server itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Server " + server);
}
//MBeanUtils.destroyMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).removePropertyChangeListener(this);
}
}
示例6: stopServer
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Send commands to the front end server associated with the shutdown of the
* node.
*/
protected void stopServer(Server server, int pos) {
// JMX unregistration
if (oname==null) {
try {
Registry.getRegistry(null, null).unregisterComponent(oname);
} catch (Exception e) {
log.error(sm.getString("clusterListener.error.jmxUnregister"), e);
}
}
Service[] services = server.findServices();
for (int i = 0; i < services.length; i++) {
services[i].getContainer().removeContainerListener(this);
((Lifecycle) services[i].getContainer()).removeLifecycleListener(this);
removeAll((Engine) services[i].getContainer(), pos);
Container[] children = services[i].getContainer().findChildren();
for (int j = 0; j < children.length; j++) {
children[j].removeContainerListener(this);
Container[] children2 = children[j].findChildren();
for (int k = 0; k < children2.length; k++) {
((Lifecycle) children2[k]).removeLifecycleListener(this);
removeContext((Context) children2[k], pos);
}
}
}
}
示例7: createMBeans
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Create the MBeans for the specified Server and its nested components.
*
* @param server Server for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Server server) throws Exception {
// Create the MBean for the Server itself
if (debug >= 2)
log("Creating MBean for Server " + server);
MBeanUtils.createMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).addPropertyChangeListener(this);
}
// Create the MBeans for the global NamingResources (if any)
NamingResources resources = server.getGlobalNamingResources();
if (resources != null) {
createMBeans(resources);
}
// Create the MBeans for each child Service
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
// FIXME - Warp object hierarchy not currently supported
if (services[i].getContainer().getClass().getName().equals
("org.apache.catalina.connector.warp.WarpEngine")) {
if (debug >= 1) {
log("Skipping MBean for Service " + services[i]);
}
continue;
}
createMBeans(services[i]);
}
}
示例8: destroyMBeans
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Deregister the MBeans for the specified Server and its related
* components.
*
* @param server Server for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Server server) throws Exception {
// Destroy the MBeans for the global NamingResources (if any)
NamingResources resources = server.getGlobalNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// Destroy the MBeans for each child Service
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
// FIXME - Warp object hierarchy not currently supported
if (services[i].getContainer().getClass().getName().equals
("org.apache.catalina.connector.warp.WarpEngine")) {
if (debug >= 1) {
log("Skipping MBean for Service " + services[i]);
}
continue;
}
destroyMBeans(services[i]);
}
// Destroy the MBean for the Server itself
if (debug >= 2) {
log("Destroying MBean for Server " + server);
}
MBeanUtils.destroyMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).removePropertyChangeListener(this);
}
}
示例9: storeServer
import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
* Store the specified Server properties.
*
* @param writer PrintWriter to which we are storing
* @param indent Number of spaces to indent this element
* @param server Object to be stored
*
* @exception Exception if an exception occurs while storing
*/
private void storeServer(PrintWriter writer, int indent,
Server server) throws Exception {
// Store the beginning of this element
writer.println("<?xml version='1.0' encoding='utf-8'?>");
for (int i = 0; i < indent; i++) {
writer.print(' ');
}
writer.print("<Server");
storeAttributes(writer, server);
writer.println(">");
// Store nested <Listener> elements
if (server instanceof Lifecycle) {
LifecycleListener listeners[] =
((Lifecycle) server).findLifecycleListeners();
for (int i = 0; i < listeners.length; i++) {
storeListener(writer, indent + 2, listeners[i]);
}
}
// Store nested <GlobalNamingResources> element
NamingResources globalNamingResources =
server.getGlobalNamingResources();
if (globalNamingResources != null) {
for (int i = 0; i < indent + 2; i++) {
writer.print(' ');
}
writer.println("<GlobalNamingResources>");
storeNamingResources(writer, indent + 4, globalNamingResources);
for (int i = 0; i < indent + 2; i++) {
writer.print(' ');
}
writer.println("</GlobalNamingResources>");
}
// Store nested <Service> elements
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
storeService(writer, indent + 2, services[i]);
}
// Store the ending of this element
for (int i = 0; i < indent; i++) {
writer.print(' ');
}
writer.println("</Server>");
}
示例10: registerListenersForServer
import org.apache.catalina.Server; //导入方法依赖的package包/类
private void registerListenersForServer(Server server) {
for (Service service : server.findServices()) {
Engine engine = (Engine) service.getContainer();
engine.addContainerListener(this);
registerListenersForEngine(engine);
}
}
示例11: checkServer
import org.apache.catalina.Server; //导入方法依赖的package包/类
private boolean checkServer(final Server server) {
boolean succeeded = checkState(server);
for (Service service : server.findServices())
succeeded &= checkService(service);
return succeeded;
}
示例12: activateInternal
import org.apache.catalina.Server; //导入方法依赖的package包/类
private void activateInternal() throws Exception {
Server server = getServer();
org.apache.catalina.Service[] services = server.findServices();
for (org.apache.catalina.Service service : services) {
for (Connector connector : service.findConnectors()) {
if (connector.getScheme().equals("http")) {
httpConnectors.add(connector);
} else if (connector.getScheme().equals("https")) {
httpsConnectors.add(connector);
}
}
}
}
示例13: TomcatSecurityService
import org.apache.catalina.Server; //导入方法依赖的package包/类
public TomcatSecurityService() {
final Server server = TomcatHelper.getServer();
for (final Service service : server.findServices()) {
if (service.getContainer() instanceof Engine) {
final Engine engine = (Engine) service.getContainer();
if (engine.getRealm() != null) {
defaultRealm = engine.getRealm();
break;
}
}
}
}