org.apache.catalina.Context.getInstanceManager()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中org.apache.catalina.Context.getInstanceManager()方法的一些代码示例,展示了Context.getInstanceManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getInstanceManager()方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:getInstanceManager

Context.getInstanceManager介绍

[英]Get the instance manager associated with this context.
[中]获取与此上下文关联的实例管理器。

代码示例

代码示例来源:origin: org.jboss.web/jbossweb

public <T extends AsyncListener> T createListener(Class<T> clazz)
    throws ServletException {
  T listenerInstance = null;
  try {
    listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
  } catch (Exception e) {
    throw new ServletException(MESSAGES.listenerCreationFailed(clazz.getName()), e);
  }
  asyncListenerInstances.add(listenerInstance);
  return listenerInstance;
}

代码示例来源:origin: jboss.web/jbossweb

public <T extends AsyncListener> T createListener(Class<T> clazz)
    throws ServletException {
  T listenerInstance = null;
  try {
    listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
  } catch (Exception e) {
    throw new ServletException(sm.getString("coyoteRequest.createListener", clazz.getName()), e);
  }
  return listenerInstance;
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@SuppressWarnings("unchecked")
@Override
public <T extends AsyncListener> T createListener(Class<T> clazz)
    throws ServletException {
  check();
  T listener = null;
  try {
     listener = (T) context.getInstanceManager().newInstance(
         clazz.getName(), clazz.getClassLoader());
  } catch (ReflectiveOperationException | NamingException e) {
    ServletException se = new ServletException(e);
    throw se;
  } catch (Exception e) {
    ExceptionUtils.handleThrowable(e.getCause());
    ServletException se = new ServletException(e);
    throw se;
  }
  return listener;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@SuppressWarnings("unchecked")
@Override
public <T extends AsyncListener> T createListener(Class<T> clazz)
    throws ServletException {
  check();
  T listener = null;
  try {
     listener = (T) context.getInstanceManager().newInstance(
         clazz.getName(), clazz.getClassLoader());
  } catch (ReflectiveOperationException | NamingException e) {
    ServletException se = new ServletException(e);
    throw se;
  } catch (Exception e) {
    ExceptionUtils.handleThrowable(e.getCause());
    ServletException se = new ServletException(e);
    throw se;
  }
  return listener;
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * {@inheritDoc}
 *
 * @since Servlet 3.1
 */
@SuppressWarnings("unchecked")
@Override
public <T extends HttpUpgradeHandler> T upgrade(
    Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException {
  T handler;
  try {
    handler = (T) context.getInstanceManager().newInstance(httpUpgradeHandlerClass);
  } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NamingException e) {
    throw new ServletException(e);
  }
  coyoteRequest.action(ActionCode.UPGRADE, handler);
  // Output required by RFC2616. Protocol specific headers should have
  // already been set.
  response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
  return handler;
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@SuppressWarnings("unchecked")
@Override
public <T extends HttpUpgradeHandler> T upgrade(
    Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException {
  T handler;
  InstanceManager instanceManager = null;
  try {
    // Do not go through the instance manager for internal Tomcat classes since they don't
    // need injection
    if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) {
      handler = httpUpgradeHandlerClass.getConstructor().newInstance();
    } else {
      instanceManager = getContext().getInstanceManager();
      handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass);
    }
  } catch (ReflectiveOperationException | NamingException | IllegalArgumentException |
      SecurityException e) {
    throw new ServletException(e);
  }
  UpgradeToken upgradeToken = new UpgradeToken(handler,
      getContext(), instanceManager);
  coyoteRequest.action(ActionCode.UPGRADE, upgradeToken);
  // Output required by RFC2616. Protocol specific headers should have
  // already been set.
  response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
  return handler;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@SuppressWarnings("unchecked")
@Override
public <T extends HttpUpgradeHandler> T upgrade(
    Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException {
  T handler;
  InstanceManager instanceManager = null;
  try {
    // Do not go through the instance manager for internal Tomcat classes since they don't
    // need injection
    if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) {
      handler = httpUpgradeHandlerClass.getConstructor().newInstance();
    } else {
      instanceManager = getContext().getInstanceManager();
      handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass);
    }
  } catch (ReflectiveOperationException | NamingException | IllegalArgumentException |
      SecurityException e) {
    throw new ServletException(e);
  }
  UpgradeToken upgradeToken = new UpgradeToken(handler,
      getContext(), instanceManager);
  coyoteRequest.action(ActionCode.UPGRADE, upgradeToken);
  // Output required by RFC2616. Protocol specific headers should have
  // already been set.
  response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
  return handler;
}

代码示例来源:origin: org.jboss.web/jbossweb

@SuppressWarnings("unchecked")
public <T extends HttpUpgradeHandler> T upgrade(Class<T> upgradeHandlerClass)
    throws IOException {
  T ugradeHandler = null;
  Throwable upgradeError = null;
  try {
    ugradeHandler = (T) context.getInstanceManager().newInstance(upgradeHandlerClass);
  } catch (Throwable t) {
    upgradeError = t;
  }
  if (ugradeHandler == null) {
    throw new IOException(MESSAGES.upgradeError(), upgradeError);
  }
  response.sendUpgrade();
  eventMode = true;
  this.upgradeHandler = ugradeHandler;
  asyncContext = new AsyncContextImpl();
  return ugradeHandler;
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Return the application Filter we are configured for.
 *
 * @exception ClassCastException if the specified class does not implement
 *  the <code>javax.servlet.Filter</code> interface
 * @exception ClassNotFoundException if the filter class cannot be found
 * @exception IllegalAccessException if the filter class cannot be
 *  publicly instantiated
 * @exception InstantiationException if an exception occurs while
 *  instantiating the filter object
 * @exception ServletException if thrown by the filter's init() method
 * @throws NamingException
 * @throws ReflectiveOperationException
 * @throws SecurityException
 * @throws IllegalArgumentException
 */
Filter getFilter() throws ClassCastException, ReflectiveOperationException, ServletException,
    NamingException, IllegalArgumentException, SecurityException {
  // Return the existing filter instance, if any
  if (this.filter != null)
    return this.filter;
  // Identify the class loader we will be using
  String filterClass = filterDef.getFilterClass();
  this.filter = (Filter) context.getInstanceManager().newInstance(filterClass);
  initFilter();
  return this.filter;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Return the application Filter we are configured for.
 *
 * @exception ClassCastException if the specified class does not implement
 *  the <code>javax.servlet.Filter</code> interface
 * @exception ClassNotFoundException if the filter class cannot be found
 * @exception IllegalAccessException if the filter class cannot be
 *  publicly instantiated
 * @exception InstantiationException if an exception occurs while
 *  instantiating the filter object
 * @exception ServletException if thrown by the filter's init() method
 * @throws NamingException
 * @throws ReflectiveOperationException
 * @throws SecurityException
 * @throws IllegalArgumentException
 */
Filter getFilter() throws ClassCastException, ReflectiveOperationException, ServletException,
    NamingException, IllegalArgumentException, SecurityException {
  // Return the existing filter instance, if any
  if (this.filter != null)
    return this.filter;
  // Identify the class loader we will be using
  String filterClass = filterDef.getFilterClass();
  this.filter = (Filter) context.getInstanceManager().newInstance(filterClass);
  initFilter();
  return this.filter;
}

代码示例来源:origin: org.jboss.web/jbossweb

this.filter = (Filter) context.getInstanceManager().newInstance(filterClass);
} else {
  this.filter = filterInstance;

代码示例来源:origin: org.jboss.web/jbossweb

for (AsyncListener listener : asyncListenerInstances) {
  try {
    context.getInstanceManager().destroyInstance(listener);
  } catch (Throwable t) {
    context.getLogger().error(MESSAGES.preDestroyException(), t);

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

} else {
  this.filter = filterDef.getFilter();
  context.getInstanceManager().newInstance(filter);
  initFilter();

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

} else {
  this.filter = filterDef.getFilter();
  context.getInstanceManager().newInstance(filter);
  initFilter();

代码示例来源:origin: jboss.web/jbossweb

this.filter = (Filter) context.getInstanceManager().newInstance(filterClass);
} else {
  this.filter = filterInstance;

代码示例来源:origin: org.jboss.web/jbossweb

((Context) getParent()).getInstanceManager().destroyInstance(instance);
    ((Context) getParent()).getInstanceManager().destroyInstance(s);

代码示例来源:origin: jboss.web/jbossweb

((Context) getParent()).getInstanceManager().destroyInstance(instance);
    ((Context) getParent()).getInstanceManager().destroyInstance(s);

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

((Context)getParent()).getInstanceManager().destroyInstance(instance);
} catch (Throwable t) {
  ExceptionUtils.handleThrowable(t);

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

context.getInstanceManager().destroyInstance(this.filter);
} catch (Exception e) {
  Throwable t = ExceptionUtils

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

context.getInstanceManager().destroyInstance(this.filter);
} catch (Exception e) {
  Throwable t = ExceptionUtils

相关文章

微信公众号

最新文章

更多

Context类方法