org.apache.struts2.dispatcher.Dispatcher.getContainer()方法的使用及代码示例

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

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

Dispatcher.getContainer介绍

暂无

代码示例

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

/**
 * Injects dependencies on an Object using Struts internal IoC container
 */
protected void injectStrutsDependencies(Object object) {
  Dispatcher.getInstance().getContainer().inject(object);
}

代码示例来源: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: entando/entando-core

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

代码示例来源: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.onebusaway/onebusaway-presentation

public static String resource(String resourcePath) {

  Dispatcher instance = Dispatcher.getInstance();
  if (instance == null)
   return null;

  Container container = instance.getContainer();
  ResourceUrlFunction function = new ResourceUrlFunction();
  container.inject(function);

  return function.getExternalUrlForResource(resourcePath);
 }
}

代码示例来源:origin: OneBusAway/onebusaway-application-modules

public static String resource(String resourcePath) {

  Dispatcher instance = Dispatcher.getInstance();
  if (instance == null)
   return null;

  Container container = instance.getContainer();
  ResourceUrlFunction function = new ResourceUrlFunction();
  container.inject(function);

  return function.getExternalUrlForResource(resourcePath);
 }
}

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

public static ConversationConfigurationProvider getConfigurationProvider() {
  if (configurationProvider == null) {
    configurationProvider = Dispatcher
        .getInstance()
        .getContainer()
        .getInstance(ScopeContainerProvider.class).getScopeContainer().getComponent(ConversationConfigurationProvider.class);
  }
  return configurationProvider;
}

代码示例来源:origin: OneBusAway/onebusaway-application-modules

public static String url(String value) {
  Dispatcher instance = Dispatcher.getInstance();
  if( instance == null)
   return null;
  Container container = instance.getContainer();
  UrlFunction function = new UrlFunction();
  container.inject(function);
  return function.getUrl(value);
 }
}

代码示例来源:origin: OneBusAway/onebusaway-application-modules

public static String configValue(String key) {
 Dispatcher instance = Dispatcher.getInstance();
 if (instance == null) 
  return null;
 
 Container container = instance.getContainer();
 ConfigurationValueFunction cv = new ConfigurationValueFunction();
 container.inject(cv);
 
 return cv.lookup(key);
}

代码示例来源:origin: org.onebusaway/onebusaway-presentation

public static String url(String value) {
  Dispatcher instance = Dispatcher.getInstance();
  if( instance == null)
   return null;
  Container container = instance.getContainer();
  UrlFunction function = new UrlFunction();
  container.inject(function);
  return function.getUrl(value);
 }
}

代码示例来源: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: entando/entando-core

@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: 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: 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: org.onebusaway/onebusaway-wiki-integration-xwiki-struts-macros

public List<Block> execute(T parameters, String content,
  MacroTransformationContext context) throws MacroExecutionException {
 ActionContext actionContext = ActionContext.getContext();
 ValueStack stack = actionContext.getValueStack();
 V component = getBean(stack);
 Container container = Dispatcher.getInstance().getContainer();
 container.inject(component);
 populateParams(component, parameters);
 if (content == null)
  content = "";
 if (parameters.isWiki() && content.trim().length() > 0)
  content = renderWikiSyntax(content, context);
 StringWriter writer = new StringWriter();
 boolean evaluateBody = component.start(writer);
 if (!evaluateBody)
  content = "";
 component.end(writer, content);
 List<Block> wordBlockAsList = Arrays.<Block> asList(new RawBlock(
   writer.toString(), XHTML_SYNTAX));
 // Handle both inline mode and standalone mode.
 if (context.isInline()) {
  return wordBlockAsList;
 } else {
  // Wrap the result in a Paragraph Block since a WordBlock is an inline
  // element and it needs to be
  // inside a standalone block.
  return Arrays.<Block> asList(new ParagraphBlock(wordBlockAsList));
 }
}

代码示例来源: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?");
velocityManager = dispatcher.getContainer().getInstance(VelocityManager.class);
velocityManager.init(config.getServletContext());

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

/**
 * Created action class based on namespace and name
 *
 * @param namespace The namespace
 * @param name The name of the action
 * @throws java.lang.Exception In case of error
 */
protected void initAction(String namespace, String name) throws Exception {
  // create a proxy class which is just a wrapper around the action call.
  // The proxy is created by checking the namespace and name against the
  // struts.xml configuration
  ActionProxyFactory proxyFactory = (ActionProxyFactory) this.dispatcher.getContainer().getInstance(ActionProxyFactory.class);
  this.proxy = proxyFactory.createActionProxy(namespace, name, null, null, true, false);
  // set to true if you want to process Freemarker or JSP results
  this.proxy.setExecuteResult(false);
  // by default, don't pass in any request parameters
  // set the actions context to the one which the proxy is using
  this.proxy.getInvocation().getInvocationContext().setSession(new HashMap<>());
  ServletActionContext.setContext(this.proxy.getInvocation().getInvocationContext());
  ServletActionContext.setRequest(this.request);
  ServletActionContext.setResponse(response);
  ServletActionContext.setServletContext(servletContext);
  this.action = (ActionSupport) this.proxy.getAction();
  //reset previsious params
  List<String> paramNames = new ArrayList<String>(this.request.getParameterMap().keySet());
  for (int i = 0; i < paramNames.size(); i++) {
    String paramName = (String) paramNames.get(i);
    this.removeParameter(paramName);
  }
}

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

ActionProxyFactory actionProxyFactory = du.getContainer().getInstance(ActionProxyFactory.class);
ActionProxy proxy = actionProxyFactory.createActionProxy(namespace, actionName, null, ctx, true, true);
proxy.execute();

代码示例来源: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());

相关文章