org.apache.struts2.dispatcher.Dispatcher类的使用及代码示例

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

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

Dispatcher介绍

暂无

代码示例

代码示例来源:origin: com.googlecode.struts2-conversation/struts2-junit4-plugin

protected Dispatcher initDispatcher(Map<String, String> params) {
  Dispatcher du = new Dispatcher(servletContext, params);
  du.init();
  Dispatcher.setInstance(du);
  ValueStack stack = ((ValueStackFactory) du.getContainer().getInstance(ValueStackFactory.class)).createValueStack();
  stack.getContext().put("com.opensymphony.xwork2.ActionContext.container", du.getContainer());
  ActionContext.setContext(new ActionContext(stack.getContext()));
  configurationManager = du.getConfigurationManager();
  configuration = configurationManager.getConfiguration();
  container = configuration.getContainer();
  return du;
}

代码示例来源:origin: com.googlecode.struts2-conversation/struts2-conversation-scope-plugin

protected static String getActionSuffix() {
  if (actionSuffix == null) {
    actionSuffix = Dispatcher
        .getInstance()
        .getContainer()
        .getInstance(String.class,
            ConventionConstants.ACTION_SUFFIX);
  }
  return actionSuffix;
}

代码示例来源:origin: com.atlassian/webwork-compat

request = dispatcher.wrapRequest(request);
} catch (IOException e) {
  String message = "Could not wrap servlet request with MultipartRequestWrapper!";
ActionMapping mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
if (mapping == null) {
  try {
  dispatcher.serviceAction(request, response, mapping);

代码示例来源:origin: org.apache.struts/struts2-spring-plugin

private void reload(File file) {
  if (classLoader != null) {
    LOG.debug("Change detected in file [{}], reloading class loader", file.getAbsolutePath());
    classLoader.reload();
    if (reloadConfig && Dispatcher.getInstance() != null) {
      LOG.debug("Change detected in file [{}], reloading configuration", file.getAbsolutePath());
      Dispatcher.getInstance().getConfigurationManager().reload();
    }
  }
}

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

protected void tearDown() throws Exception {
  super.tearDown();
  // maybe someone else already destroyed Dispatcher
  if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
    dispatcher.cleanup();
    dispatcher = null;
  }
  StrutsTestCaseHelper.tearDown();
}

代码示例来源:origin: org.entando.entando/entando-admin-console

@Override
public ActionMapping findActionMapping(HttpServletRequest request, HttpServletResponse response, boolean forceLookup) {
  ActionMapping mapping = (ActionMapping) request.getAttribute(STRUTS_ACTION_MAPPING_KEY);
  if (mapping == null || forceLookup) {
    try {
      Container container = this._dispatcher.getContainer();
      ActionMapper mapper = container.getInstance(ActionMapper.class);
      String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
      mapping = mapper.getMapping(request, this._dispatcher.getConfigurationManager());
      if (null != entandoActionName) {
        mapping.setName(entandoActionName);
      }
      if (mapping != null) {
        request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
      }
    } catch (Exception ex) {
      this._dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
    }
  }
  return mapping;
}

代码示例来源:origin: stackoverflow.com

public class ActionMenuBuilderListener implements ServletContextListener,DispatcherListener {

  @Override
  public void contextInitialized(ServletContextEvent sce) {
    Dispatcher.addDispatcherListener(this);
  }

  @Override
  public void dispatcherInitialized(Dispatcher du) {
    Map<String, Map<String, ActionConfig>> runtimeActionConfigs = du
      .getConfigurationManager().getConfiguration().getRuntimeConfiguration()
      .getActionConfigs();
  }
  // other methods
}

代码示例来源:origin: org.apache.struts/struts2-sitemesh-plugin

if (ctx == null) {
  ValueStack vs = Dispatcher.getInstance().getContainer().getInstance(ValueStackFactory.class).createValueStack();
  vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null));
  ctx = new ActionContext(vs.getContext());
  if (ctx.getActionInvocation() == null) {

代码示例来源:origin: com.googlecode.struts2-conversation/struts2-junit4-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 */
protected String executeAction(String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, servletContext, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK)
    throw new ServletException("Error code [" + response.getStatus() + "], Error: [" + response.getErrorMessage() + "]");
  return response.getContentAsString();
}

代码示例来源:origin: entando/entando-core

protected <T> T getContainerObject(Class<T> requiredType) {
  return this.dispatcher.getContainer().getInstance(requiredType);
}

代码示例来源:origin: entando/entando-core

@Override
public Dispatcher initDispatcher(HostConfig filterConfig) {
  Map<String, String> params = new HashMap<String, String>();
  for (Iterator<String> e = filterConfig.getInitParameterNames(); e.hasNext();) {
    String name = (String) e.next();
    String value = filterConfig.getInitParameter(name);
    params.put(name, value);
  }
  String struts2Config = filterConfig.getServletContext().getInitParameter(ApsAdminSystemConstants.STRUTS2_CONFIG_INIT_PARAM_NAME);
  if (null != struts2Config) {
    params.put("config", struts2Config);
  }
  Dispatcher dispatcher = new Dispatcher(filterConfig.getServletContext(), params);
  dispatcher.init();
  return dispatcher;
}

代码示例来源:origin: entando/entando-core

this.setInitParameters(props);
Map params = new HashMap(props);
this.dispatcher = new Dispatcher(servletContext, params);
this.dispatcher.init();
Dispatcher.setInstance(this.dispatcher);

代码示例来源:origin: org.entando.entando/entando-core-engine

@Override
public ActionMapping findActionMapping(HttpServletRequest request, HttpServletResponse response, boolean forceLookup) {
  ActionMapping mapping = (ActionMapping) request.getAttribute(STRUTS_ACTION_MAPPING_KEY);
  if (mapping == null || forceLookup) {
    try {
      Container container = this._dispatcher.getContainer();
      ActionMapper mapper = container.getInstance(ActionMapper.class);
      String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
      mapping = mapper.getMapping(request, this._dispatcher.getConfigurationManager());
      if (null != entandoActionName) {
        mapping.setName(entandoActionName);
      }
      if (mapping != null) {
        request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
      }
    } catch (Exception ex) {
      this._dispatcher.sendError(request, response, this._servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
    }
  }
  return mapping;
}

代码示例来源:origin: org.apache.struts/struts2-convention-plugin

public void dispatcherInitialized(Dispatcher du) {
  du.getConfigurationManager().addContainerProvider(this);
}

代码示例来源:origin: org.apache.struts/struts2-dwr-plugin

Map session = new SessionMap(req);
Map application = new ApplicationMap(servletContext);
Dispatcher du = Dispatcher.getInstance();
HashMap<String, Object> ctx = du.createContextMap(requestMap,
    requestParams.build(),
    session,
  ActionProxyFactory actionProxyFactory = du.getContainer().getInstance(ActionProxyFactory.class);
  ActionProxy proxy = actionProxyFactory.createActionProxy(namespace, actionName, null, ctx, true, true);
  proxy.execute();

代码示例来源:origin: org.apache.struts/struts2-struts1-plugin

Struts1Factory strutsFactory = new Struts1Factory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
ActionMapping mapping = strutsFactory.createActionMapping(actionConfig);
HttpServletRequest request = ServletActionContext.getRequest();

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 */
protected String executeAction(String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK) {
    throw new ServletException("Error code [" + response.getStatus() + "], Error: [" + response.getErrorMessage() + "]");
  }
  return response.getContentAsString();
}

代码示例来源:origin: org.apache.struts/struts2-sitemesh-plugin

throw new IllegalStateException("Unable to find the Dispatcher in the Servlet Context. Is '" + StrutsListener.class.getName() + "' missing in web.xml?");
freemarkerManager = dispatcher.getContainer().getInstance(FreemarkerManager.class);
config = createConfiguration();

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

@After
public void tearDown() throws Exception {
  super.tearDown();
  if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
    dispatcher.cleanup();
    dispatcher = null;
  }
  StrutsTestCaseHelper.tearDown();
}

代码示例来源:origin: org.entando.entando/entando-core-engine

@Override
public Dispatcher initDispatcher(HostConfig filterConfig) {
  Map<String, String> params = new HashMap<String, String>();
  for (Iterator<String> e = filterConfig.getInitParameterNames(); e.hasNext();) {
    String name = (String) e.next();
    String value = filterConfig.getInitParameter(name);
    params.put(name, value);
  }
  String struts2Config = filterConfig.getServletContext().getInitParameter(ApsAdminSystemConstants.STRUTS2_CONFIG_INIT_PARAM_NAME);
  if (null != struts2Config) {
    params.put("config", struts2Config);
  }
  Dispatcher dispatcher = new Dispatcher(filterConfig.getServletContext(), params);
  dispatcher.init();
  return dispatcher;
}

相关文章