本文整理汇总了Java中org.apache.catalina.core.StandardService类的典型用法代码示例。如果您正苦于以下问题:Java StandardService类的具体用法?Java StandardService怎么用?Java StandardService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardService类属于org.apache.catalina.core包,在下文中一共展示了StandardService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStandardService
import org.apache.catalina.core.StandardService; //导入依赖的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: createStandardServiceEngine
import org.apache.catalina.core.StandardService; //导入依赖的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();
}
示例3: createMBeans
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
/**
* Create the MBeans for the specified Service and its nested components.
*
* @param service Service for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Service service) throws Exception {
// Create the MBean for the Service itself
if (log.isDebugEnabled())
log.debug("Creating MBean for Service " + service);
//MBeanUtils.createMBean(service);
if (service instanceof StandardService) {
((StandardService) service).addPropertyChangeListener(this);
}
// Create the MBeans for the corresponding Connectors
Connector connectors[] = service.findConnectors();
for (int j = 0; j < connectors.length; j++) {
createMBeans(connectors[j]);
}
// Create the MBean for the associated Engine and friends
Engine engine = (Engine) service.getContainer();
if (engine != null) {
createMBeans(engine);
}
}
示例4: destroyMBeans
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
/**
* Deregister the MBeans for the specified Service and its nested
* components.
*
* @param service Service for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Service service) throws Exception {
// Deregister the MBeans for the associated Engine
Engine engine = (Engine) service.getContainer();
if (engine != null) {
//destroyMBeans(engine);
}
// // Deregister the MBeans for the corresponding Connectors
// Connector connectors[] = service.findConnectors();
// for (int j = 0; j < connectors.length; j++) {
// destroyMBeans(connectors[j], service);
// }
// Deregister the MBean for the Service itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Service " + service);
}
//MBeanUtils.destroyMBean(service);
if (service instanceof StandardService) {
((StandardService) service).removePropertyChangeListener(this);
}
}
示例5: createMBeans
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
/**
* Create the MBeans for the specified Service and its nested components.
*
* @param service Service for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Service service) throws Exception {
// Create the MBean for the Service itself
if (debug >= 2)
log("Creating MBean for Service " + service);
MBeanUtils.createMBean(service);
if (service instanceof StandardService) {
((StandardService) service).addPropertyChangeListener(this);
}
// Create the MBeans for the corresponding Connectors
Connector connectors[] = service.findConnectors();
for (int j = 0; j < connectors.length; j++) {
createMBeans(connectors[j]);
}
// Create the MBean for the associated Engine and friends
Engine engine = (Engine) service.getContainer();
if (engine != null) {
createMBeans(engine);
}
}
示例6: destroyMBeans
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
/**
* Deregister the MBeans for the specified Service and its nested
* components.
*
* @param service Service for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Service service) throws Exception {
// Deregister the MBeans for the associated Engine
Engine engine = (Engine) service.getContainer();
if (engine != null) {
destroyMBeans(engine);
}
// Deregister the MBeans for the corresponding Connectors
Connector connectors[] = service.findConnectors();
for (int j = 0; j < connectors.length; j++) {
destroyMBeans(connectors[j], service);
}
// Deregister the MBean for the Service itself
if (debug >= 2) {
log("Destroying MBean for Service " + service);
}
MBeanUtils.destroyMBean(service);
if (service instanceof StandardService) {
((StandardService) service).removePropertyChangeListener(this);
}
}
示例7: createStandardService
import org.apache.catalina.core.StandardService; //导入依赖的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());
}
示例8: createStandardServiceEngine
import org.apache.catalina.core.StandardService; //导入依赖的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);
// engine.setService(service);
return engine.getObjectName().toString();
}
示例9: getPort
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
public static int getPort(Host h) {
int port = -1;
StandardHost host = (StandardHost) h;
CatalinaUtil.host = (StandardHost) h;
StandardEngine se = (StandardEngine) host.getParent();
StandardService ss = (StandardService) se.getService();
Connector[] cs = ss.findConnectors();
for (Connector c : cs) {
if (c.getProtocolHandlerClassName().contains("Http11Protocol"))
port = c.getPort();
}
return port;
}
示例10: testConstructionOfApplicationServerURL
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
@Test(description = "Tests the construction of Application Server URL for a sample request")
public void testConstructionOfApplicationServerURL() {
Request request = new Request();
Connector connector = new Connector();
connector.setProtocol(TestConstants.SSL_PROTOCOL);
connector.setPort(TestConstants.SSL_PORT);
connector.setScheme(TestConstants.SSL_PROTOCOL);
Engine engine = new StandardEngine();
Service service = new StandardService();
engine.setService(service);
engine.getService().addConnector(connector);
Host host = new StandardHost();
host.setName(TestConstants.DEFAULT_TOMCAT_HOST);
request.getMappingData().host = host;
host.setParent(engine);
Optional<String> actual = SSOUtils.constructApplicationServerURL(request);
if (actual.isPresent()) {
Assert.assertEquals(actual.get(), TestConstants.DEFAULT_APPLICATION_SERVER_URL);
} else {
Assert.fail();
}
}
示例11: testConstructionOfApplicationServerURLWithNoConnector
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
@Test(description = "Tests the construction of Application Server URL for no SSL/TLS Connector")
public void testConstructionOfApplicationServerURLWithNoConnector() {
Request request = new Request();
Engine engine = new StandardEngine();
Service service = new StandardService();
engine.setService(service);
Host host = new StandardHost();
host.setName(TestConstants.DEFAULT_TOMCAT_HOST);
request.getMappingData().host = host;
host.setParent(engine);
Optional<String> actual = SSOUtils.constructApplicationServerURL(request);
Assert.assertTrue(!actual.isPresent());
}
示例12: prepareCatalinaComponents
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
private void prepareCatalinaComponents() {
engine = new StandardEngine();
host = new StandardHost();
fooContext = new StandardContext();
barContext = new StandardContext();
Connector connector = new Connector();
connector.setProtocol(TestConstants.SSL_PROTOCOL);
connector.setPort(TestConstants.SSL_PORT);
connector.setScheme(TestConstants.SSL_PROTOCOL);
Service service = new StandardService();
engine.setService(service);
engine.getService().addConnector(connector);
host.setAppBase(TestConstants.WEB_APP_BASE);
host.setName(TestConstants.DEFAULT_TOMCAT_HOST);
host.setParent(engine);
fooContext.setParent(host);
fooContext.setDocBase(TestConstants.FOO_CONTEXT);
barContext.setParent(host);
barContext.setDocBase(TestConstants.BAR_CONTEXT);
}
示例13: createCatalinaServer
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
private StandardService createCatalinaServer(Bundle bundle) throws Exception {
// first try to use the XML file
URL xmlConfiguration = bundle.getResource(XML_CONF_LOCATION);
if (xmlConfiguration != null) {
log.info("Using custom XML configuration " + xmlConfiguration);
}
else {
xmlConfiguration = bundle.getResource(DEFAULT_XML_CONF_LOCATION);
if (xmlConfiguration == null)
log.error("No XML configuration found; bailing out...");
else
log.info("Using default XML configuration " + xmlConfiguration);
}
return createServerFromXML(xmlConfiguration);
}
示例14: createServerFromXML
import org.apache.catalina.core.StandardService; //导入依赖的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];
}
示例15: publishServerAsAService
import org.apache.catalina.core.StandardService; //导入依赖的package包/类
private ServiceRegistration publishServerAsAService(StandardService server) {
Properties props = new Properties();
// put some extra properties to easily identify the service
props.put(Constants.SERVICE_VENDOR, "Spring Dynamic Modules");
props.put(Constants.SERVICE_DESCRIPTION, ServerInfo.getServerInfo());
props.put(Constants.BUNDLE_VERSION, ServerInfo.getServerNumber());
props.put(Constants.BUNDLE_NAME, bundleContext.getBundle().getSymbolicName());
// spring-dm specific property
props.put("org.springframework.osgi.bean.name", "tomcat-server");
// publish just the interfaces and the major classes (server/handlerWrapper)
String[] classes = new String[] { StandardService.class.getName(), Service.class.getName(),
MBeanRegistration.class.getName(), Lifecycle.class.getName() };
return bundleContext.registerService(classes, server, props);
}