本文整理汇总了Java中org.apache.catalina.core.StandardServer类的典型用法代码示例。如果您正苦于以下问题:Java StandardServer类的具体用法?Java StandardServer怎么用?Java StandardServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardServer类属于org.apache.catalina.core包,在下文中一共展示了StandardServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
/**
* Prepare for active use of the public methods of this Component.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents it from being started
*/
public synchronized void start() throws LifecycleException {
try {
StandardServer server = (StandardServer) ServerFactory.getServer();
Context context = server.getGlobalNamingContext();
database = (UserDatabase) context.lookup(resourceName);
} catch (Throwable e) {
e.printStackTrace();
log(sm.getString("userDatabaseRealm.lookup", resourceName), e);
database = null;
}
if (database == null) {
throw new LifecycleException
(sm.getString("userDatabaseRealm.noDatabase", resourceName));
}
// Perform normal superclass initialization
super.start();
}
示例2: createTomcat
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
private static Tomcat createTomcat(int port, String contextPath, String docBase) throws ServletException {
String tmpDir = System.getProperty("java.io.tmpdir");
Tomcat tomcat = new Tomcat();
tomcat.setBaseDir(tmpDir);
tomcat.getHost().setAppBase(tmpDir);
tomcat.getHost().setAutoDeploy(false);
tomcat.getEngine().setBackgroundProcessorDelay(-1);
tomcat.setConnector(newNioConnector());
tomcat.getConnector().setPort(port);
tomcat.getService().addConnector(tomcat.getConnector());
Context context = tomcat.addWebapp(contextPath, docBase);
StandardServer server = (StandardServer) tomcat.getServer();
server.addLifecycleListener(new AprLifecycleListener());
server.addLifecycleListener(new JreMemoryLeakPreventionListener());
return tomcat;
}
示例3: init
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
@BeforeClass
public void init() {
System.setProperty(Globals.CATALINA_BASE_PROP, Paths.get(TestConstants.TEST_RESOURCES_LOCATION).toString());
prepareCatalinaComponents();
// load the server level configurations
ServerConfigurationLoader loader = new ServerConfigurationLoader();
List<Lifecycle> components = new ArrayList<>();
components.add(new StandardServer());
components.add(engine);
components.stream()
.forEach(component -> loader.lifecycleEvent(
new LifecycleEvent(component, Lifecycle.BEFORE_START_EVENT, null)));
// load the context configurations
ContextConfigurationLoader contextLoader = new ContextConfigurationLoader();
contextLoader.lifecycleEvent(new LifecycleEvent(barContext, Lifecycle.BEFORE_START_EVENT, null));
contextLoader.lifecycleEvent(new LifecycleEvent(fooContext, Lifecycle.BEFORE_START_EVENT, null));
}
示例4: startTomcat
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
private void startTomcat() throws Exception {
tomcat = new Tomcat();
tomcat.setPort(8080);
File tomcatBaseDir = new File("target/tomcat");
tomcatBaseDir.mkdirs();
tomcat.setBaseDir(tomcatBaseDir.getAbsolutePath());
StandardServer server = (StandardServer) tomcat.getServer();
server.addLifecycleListener(new AprLifecycleListener());
String contextPath = "/logging-webapp";
File warFile = new File("target/wars/logging-webapp.war");
tomcat.addWebapp(contextPath, warFile.getAbsolutePath());
tomcat.start();
}
示例5: build
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
public Server build()
{
Server server = new StandardServer();
server.setPort(shutdownPort);
server.setShutdown(shutdownString);
if (enableJSP)
{
server.addLifecycleListener(new JasperListener());
}
for (ServiceConfiguration serviceConfiguration : getServices())
{
Service service = serviceConfiguration.build();
server.addService(service);
}
return server;
}
示例6: importOpenEJBResourcesInTomcat
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
public static void importOpenEJBResourcesInTomcat(final Collection<ResourceInfo> resources, final StandardServer server) {
final NamingResourcesImpl naming = server.getGlobalNamingResources();
for (final ResourceInfo info : resources) {
final String name = info.id;
// if invalid or existing or lazy just skip it cause doesnt work during startup
if (name == null || naming.findResource(name) != null || info.properties.containsKey("UseAppClassLoader")) {
continue;
}
final ContextResource resource = new ContextResource();
resource.setName(name);
resource.setProperty(Constants.FACTORY, ResourceFactory.class.getName());
resource.setProperty(NamingUtil.NAME, name);
resource.setType(info.className);
resource.setAuth("Container");
naming.addResource(resource);
}
}
示例7: start
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
public void start(final StandardServer server) {
if (SystemInstance.get().isDefaultProfile()) { // add user tomee is no user are specified
try {
final NamingResourcesImpl resources = server.getGlobalNamingResources();
final ContextResource userDataBaseResource = resources.findResource("UserDatabase");
final UserDatabase db = (UserDatabase) server.getGlobalNamingContext().lookup(userDataBaseResource.getName());
if (!db.getUsers().hasNext() && db instanceof MemoryUserDatabase) {
final MemoryUserDatabase mudb = (MemoryUserDatabase) db;
final boolean oldRo = mudb.getReadonly();
try {
((MemoryUserDatabase) db).setReadonly(false);
db.createRole("tomee-admin", "tomee admin role");
db.createUser("tomee", "tomee", "TomEE");
db.findUser("tomee").addRole(db.findRole("tomee-admin"));
} finally {
mudb.setReadonly(oldRo);
}
}
} catch (final Throwable t) {
// no-op
}
}
}
示例8: startTomcat
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
private void startTomcat() throws Exception {
tomcat = new Tomcat();
tomcat.setPort(8080);
File tomcatBaseDir = new File("target/tomcat");
tomcatBaseDir.mkdirs();
tomcat.setBaseDir(tomcatBaseDir.getAbsolutePath());
StandardServer server = (StandardServer) tomcat.getServer();
server.addLifecycleListener(new AprLifecycleListener());
String contextPath = "/logging-webapp";
File[] warFiles = new File("target").listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().endsWith(".war");
}
});
assertEquals("Not exactly one war file found", 1, warFiles.length);
tomcat.addWebapp(contextPath, warFiles[0].getAbsolutePath());
tomcat.start();
}
示例9: startTomcat
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
private void startTomcat() throws Exception {
String appBase = "target/wars/logging-webapp.war";
tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir(".");
tomcat.getHost().setAppBase(".");
String contextPath = "/logging-webapp";
StandardServer server = (StandardServer) tomcat.getServer();
server.addLifecycleListener(new AprLifecycleListener());
tomcat.addWebapp(contextPath, appBase);
tomcat.start();
}
示例10: deployBpmPlatform
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
protected void deployBpmPlatform(LifecycleEvent event) {
final StandardServer server = (StandardServer) event.getSource();
containerDelegate.getServiceContainer().createDeploymentOperation("deploy BPM platform")
.addAttachment(TomcatAttachments.SERVER, server)
.addStep(new TomcatParseBpmPlatformXmlStep())
.addStep(new DiscoverBpmPlatformPluginsStep())
.addStep(new StartManagedThreadPoolStep())
.addStep(new StartJobExecutorStep())
.addStep(new PlatformXmlStartProcessEnginesStep())
.execute();
LOG.camundaBpmPlatformSuccessfullyStarted(server.getServerInfo());
}
示例11: store
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
/**
* Write the configuration information for this entire <code>Server</code>
* out to the server.xml configuration file.
*
* @exception InstanceNotFoundException if the managed resource object
* cannot be found
* @exception MBeanException if the initializer of the object throws
* an exception, or persistence is not supported
* @exception RuntimeOperationsException if an exception is reported
* by the persistence mechanism
*/
public synchronized void store() throws InstanceNotFoundException,
MBeanException, RuntimeOperationsException {
Server server = ServerFactory.getServer();
if (server instanceof StandardServer) {
try {
((StandardServer) server).storeConfig();
} catch (Exception e) {
throw new MBeanException(e, "Error updating conf/server.xml");
}
}
}
示例12: createMBeans
import org.apache.catalina.core.StandardServer; //导入依赖的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]);
}
}
示例13: destroyMBeans
import org.apache.catalina.core.StandardServer; //导入依赖的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);
}
}
示例14: doPut
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
/**
* Process a PUT request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
public void doPut(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Verify that we were not accessed using the invoker servlet
if (request.getAttribute(Globals.INVOKED_ATTR) != null)
throw new UnavailableException
(sm.getString("managerServlet.cannotInvoke"));
// Identify the request parameters that we need
String command = request.getPathInfo();
if (command == null)
command = request.getServletPath();
String path = request.getParameter("path");
// Prepare our output writer to generate the response message
response.setContentType("text/plain");
Locale locale = Locale.getDefault();
response.setLocale(locale);
PrintWriter writer = response.getWriter();
// Process the requested command
if (command == null) {
writer.println(sm.getString("managerServlet.noCommand"));
} else if (command.equals("/deploy")) {
deploy(writer, path, request);
} else {
writer.println(sm.getString("managerServlet.unknownCommand",
command));
}
// Saving configuration
Server server = ServerFactory.getServer();
if ((server != null) && (server instanceof StandardServer)) {
try {
((StandardServer) server).store();
} catch (Exception e) {
writer.println(sm.getString("managerServlet.saveFail",
e.getMessage()));
}
}
// Finish up the response
writer.flush();
writer.close();
}
示例15: store
import org.apache.catalina.core.StandardServer; //导入依赖的package包/类
/**
* Write the configuration information for this entire <code>Server</code>
* out to the server.xml configuration file.
*
* @exception InstanceNotFoundException if the managed resource object
* cannot be found
* @exception MBeanException if the initializer of the object throws
* an exception, or persistence is not supported
* @exception RuntimeOperationsException if an exception is reported
* by the persistence mechanism
*/
public synchronized void store() throws InstanceNotFoundException,
MBeanException, RuntimeOperationsException {
Server server = ServerFactory.getServer();
if (server instanceof StandardServer) {
try {
((StandardServer) server).store();
} catch (Exception e) {
throw new MBeanException(e, "Error updating conf/server.xml");
}
}
}