本文整理汇总了Java中org.apache.tomcat.InstanceManager类的典型用法代码示例。如果您正苦于以下问题:Java InstanceManager类的具体用法?Java InstanceManager怎么用?Java InstanceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstanceManager类属于org.apache.tomcat包,在下文中一共展示了InstanceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
@Override
public void initialize() throws Exception {
if (context == null) {
throw new IllegalStateException();
}
/*
* Configure the application to support the compilation of JSP files.
* We need a new class loader and some stuff so that Jetty can call the
* onStartup() methods as required.
*/
setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
addBean(new ServletContainerInitializersStarter(this), true);
//setClassLoader(new URLClassLoader(new URL[0], context.getClassLoader()));
if (!standalone) {
CoreService rootService = context.getRootService();
WebService webService = WebService.create(getServletContext(), rootService);
webService.start();
setAttribute(WebService.ROOT_WEB_SERVICE_ATTRIBUTE, webService);
}
}
示例2: configureWebAppContext
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
/**
* Setups the web application context.
*
* @throws IOException
* @throws Exception
*/
protected void configureWebAppContext(final WebContextWithExtraConfigurations context) throws Exception {
context.setAttribute("javax.servlet.context.tempdir", getScratchDir());
// Set the ContainerIncludeJarPattern so that jetty examines these
// container-path jars for tlds, web-fragments etc.
// If you omit the jar that contains the jstl .tlds, the jsp engine will
// scan for them instead.
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
// context.setClassLoader(getUrlClassLoader());
context.addServlet(jspServletHolder(), "*.jsp");
context.replaceConfiguration(WebInfConfiguration.class, WebInfConfigurationHomeUnpacked.class);
}
示例3: createDeployedApplicationInstance
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private WebAppContext createDeployedApplicationInstance(File workDirectory,
String deployedApplicationPath) {
WebAppContext deployedApplication = new WebAppContext();
deployedApplication.setContextPath(this.getContextPath());
deployedApplication.setWar(deployedApplicationPath);
deployedApplication.setAttribute("javax.servlet.context.tempdir",
workDirectory.getAbsolutePath());
deployedApplication
.setAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
deployedApplication.setAttribute(
"org.eclipse.jetty.containerInitializers", jspInitializers());
deployedApplication.setAttribute(InstanceManager.class.getName(),
new SimpleInstanceManager());
deployedApplication.addBean(new ServletContainerInitializersStarter(
deployedApplication), true);
// webapp.setClassLoader(new URLClassLoader(new
// URL[0],App.class.getClassLoader()));
deployedApplication.addServlet(jspServletHolder(), "*.jsp");
return deployedApplication;
}
示例4: createCrossDomainHandler
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
/**
* Creates a Jetty context handler that can be used to expose the cross-domain functionality as implemented by
* {@link FlashCrossDomainServlet}.
*
* Note that an invocation of this method will not register the handler (and thus make the related functionality
* available to the end user). Instead, the created handler is returned by this method, and will need to be
* registered with the embedded Jetty webserver by the caller.
*
* @return A Jetty context handler (never null).
*/
protected Handler createCrossDomainHandler()
{
final ServletContextHandler context = new ServletContextHandler( null, "/crossdomain.xml", ServletContextHandler.SESSIONS );
// Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add( new ContainerInitializer( new JasperInitializer(), null ) );
context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers );
context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );
// Generic configuration of the context.
context.setAllowNullPathInfo( true );
// Add the functionality-providers.
context.addServlet( new ServletHolder( new FlashCrossDomainServlet() ), "" );
return context;
}
示例5: initializePlugin
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
@Override
public void initializePlugin( PluginManager manager, File pluginDirectory )
{
for ( final String publicResource : publicResources )
{
AuthCheckFilter.addExclude( publicResource );
}
// Add the Webchat sources to the same context as the one that's providing the BOSH interface.
context = new WebAppContext( null, pluginDirectory.getPath() + File.separator + "classes/", "/inverse" );
context.setClassLoader( this.getClass().getClassLoader() );
// Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add( new ContainerInitializer( new JettyJasperInitializer(), null ) );
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager());
HttpBindManager.getInstance().addJettyHandler( context );
}
示例6: initializePlugin
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
@Override
public void initializePlugin( PluginManager manager, File pluginDirectory )
{
for ( final String publicResource : publicResources )
{
AuthCheckFilter.addExclude( publicResource );
}
// Add the Webchat sources to the same context as the one that's providing the BOSH interface.
context = new WebAppContext( null, pluginDirectory.getPath() + File.separator + "classes", "/candy" );
context.setClassLoader( this.getClass().getClassLoader() );
// Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add( new ContainerInitializer( new JettyJasperInitializer(), null ) );
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager());
HttpBindManager.getInstance().addJettyHandler( context );
}
示例7: main
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(8080);
server.setConnectors(new Connector[]{connector});
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$");
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
// Prevent loading of logging classes
context.getSystemClasspathPattern().add("org.apache.log4j.");
context.getSystemClasspathPattern().add("org.slf4j.");
context.getSystemClasspathPattern().add("org.apache.commons.logging.");
ProtectionDomain protectionDomain = EmbeddedJettyServer.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
context.setWar(location.toExternalForm());
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例8: getInstanceManager
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private InstanceManager getInstanceManager() {
if (instanceManager == null) {
if (context instanceof StandardContext) {
instanceManager = ((StandardContext)context).getInstanceManager();
} else {
instanceManager = new DefaultInstanceManager(null,
new HashMap<String, Map<String, String>>(),
context,
getClass().getClassLoader());
}
}
return instanceManager;
}
示例9: getInstanceManager
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private InstanceManager getInstanceManager() {
if (instanceManager == null) {
if (context instanceof StandardContext) {
instanceManager = ((StandardContext)context).getInstanceManager();
} else {
instanceManager = new DefaultInstanceManager(null,
new HashMap<String, Map<String, String>>(),
context,
getClass().getClassLoader());
}
}
return instanceManager;
}
示例10: fireEndpointOnClose
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private void fireEndpointOnClose(CloseReason closeReason) {
// Fire the onClose event
Throwable throwable = null;
InstanceManager instanceManager = webSocketContainer.getInstanceManager();
Thread t = Thread.currentThread();
ClassLoader cl = t.getContextClassLoader();
t.setContextClassLoader(applicationClassLoader);
try {
localEndpoint.onClose(this, closeReason);
} catch (Throwable t1) {
ExceptionUtils.handleThrowable(t1);
throwable = t1;
} finally {
if (instanceManager != null) {
try {
instanceManager.destroyInstance(localEndpoint);
} catch (Throwable t2) {
ExceptionUtils.handleThrowable(t2);
if (throwable == null) {
throwable = t2;
}
}
}
t.setContextClassLoader(cl);
}
if (throwable != null) {
fireEndpointOnError(throwable);
}
}
示例11: getInstanceManager
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
public static InstanceManager getInstanceManager(ServletConfig config) {
InstanceManager instanceManager =
(InstanceManager) config.getServletContext().getAttribute(InstanceManager.class.getName());
if (instanceManager == null) {
throw new IllegalStateException("No org.apache.tomcat.InstanceManager set in ServletContext");
}
return instanceManager;
}
示例12: createWebApp
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
/**
* Creates a web-app deployment for a war file gives as path
* @param webappWar
* path to the war file
* @return
* a webApplication context that can be deployed on the jetty server.
*/
private static WebAppContext createWebApp(final Path webappWar) throws IOException {
// Path tempWar = Files.createTempFile("bdj-", webappWar.getFileName().toString());
// LOG.info("Creating temporary copy of war " + tempWar);
// Files.copy(webappWar, tempWar, StandardCopyOption.REPLACE_EXISTING);
// LOG.info("Deploying web app from " + tempWar);
final WebAppContext webapp = new WebAppContext();
webapp.setSystemClasses(new String[] {
Configuration.class.getName(), ConfigChangeListener.class.getName()
});
webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
/*
* Configure the application to support the compilation of JSP files.
* We need a new class loader and some stuff so that Jetty can call the
* onStartup() methods as required.
*/
webapp.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
webapp.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
webapp.addBean(new ServletContainerInitializersStarter(webapp), true);
webapp.setContextPath("/");
webapp.setWar(webappWar.toString());
return webapp;
}
示例13: backgroundProcess
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
@Override
public void backgroundProcess() {
InstanceManager instanceManager = getInstanceManager();
if (instanceManager instanceof DefaultInstanceManager) {
try {
((DefaultInstanceManager) instanceManager).backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("standardContext.backgroundProcess.instanceManager", resources), e);
}
}
super.backgroundProcess();
}
示例14: getInstanceManager
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private InstanceManager getInstanceManager() {
if (instanceManager == null) {
if (context instanceof StandardContext) {
instanceManager = ((StandardContext) context).getInstanceManager();
} else {
instanceManager = new DefaultInstanceManager(null, new HashMap<String, Map<String, String>>(), context,
getClass().getClassLoader());
}
}
return instanceManager;
}
示例15: fireEndpointOnClose
import org.apache.tomcat.InstanceManager; //导入依赖的package包/类
private void fireEndpointOnClose(CloseReason closeReason) {
// Fire the onClose event
Throwable throwable = null;
InstanceManager instanceManager = webSocketContainer.getInstanceManager();
Thread t = Thread.currentThread();
ClassLoader cl = t.getContextClassLoader();
t.setContextClassLoader(applicationClassLoader);
try {
localEndpoint.onClose(this, closeReason);
} catch (Throwable t1) {
ExceptionUtils.handleThrowable(t1);
throwable = t1;
} finally {
if (instanceManager != null) {
try {
instanceManager.destroyInstance(localEndpoint);
} catch (Throwable t2) {
ExceptionUtils.handleThrowable(t2);
if (throwable == null) {
throwable = t2;
}
}
}
t.setContextClassLoader(cl);
}
if (throwable != null) {
fireEndpointOnError(throwable);
}
}