• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Container类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.opensymphony.xwork2.inject.Container的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Container类属于com.opensymphony.xwork2.inject包,在下文中一共展示了Container类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: render

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
    // get the bean
    ValueStack stack = (ValueStack) ctx.get("stack");
    HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
    HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
    Component bean = getBean(stack, req, res);
    Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
    container.inject(bean);
    // get the parameters
    Map params = createPropertyMap(ctx, node);
    bean.copyParams(params);
    //bean.addAllParameters(params);
    bean.start(writer);

    if (getType() == BLOCK) {
        Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1);
        body.render(ctx, writer);
    }

    bean.end(writer, "");
    return true;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:23,代码来源:AbstractDirective.java


示例2: getStandardContext

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public static Map getStandardContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
    HashMap map = new HashMap();
    map.put(REQUEST, req);
    map.put(REQUEST2, req);
    map.put(RESPONSE, res);
    map.put(RESPONSE2, res);
    map.put(SESSION, req.getSession(false));
    map.put(BASE, req.getContextPath());
    map.put(STACK, stack);
    map.put(OGNL, ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(OgnlTool.class));
    map.put(STRUTS, new StrutsUtil(stack, req, res));

    ActionInvocation invocation = (ActionInvocation) stack.getContext().get(ActionContext.ACTION_INVOCATION);
    if (invocation != null) {
        map.put(ACTION, invocation.getAction());
    }
    return map;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:ContextUtil.java


示例3: getContainer

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
/**
 * Expose the dependency injection container.
 * @return Our dependency injection container
 */

// 源码解析: 获取容器
public Container getContainer() {
    // 源码解析: 先尝试从ThreadLocal中获取容器
    if (ContainerHolder.get() != null) {
        return ContainerHolder.get();
    }

    // 源码解析: 容器未创建, 创建一个新的容器

    ConfigurationManager mgr = getConfigurationManager();
    if (mgr == null) {
        throw new IllegalStateException("The configuration manager shouldn't be null");
    } else {
        // 源码解析: 加载配置
        Configuration config = mgr.getConfiguration();
        if (config == null) {
            throw new IllegalStateException("Unable to load configuration");
        } else {
            Container container = config.getContainer();
            ContainerHolder.store(container);
            return container;
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:30,代码来源:Dispatcher.java


示例4: initDispatcher

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public static Dispatcher initDispatcher(ServletContext ctx, Map<String,String> params) {
    if (params == null) {
        params = new HashMap<>();
    }
    Dispatcher du = new DispatcherWrapper(ctx, params);
    du.init();
    Dispatcher.setInstance(du);

    // Reset the value stack
    Container container = du.getContainer();
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));
    
    return du;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:17,代码来源:StrutsTestCaseHelper.java


示例5: setUp

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public static ConfigurationManager setUp() throws Exception {
    ConfigurationManager configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    Configuration config = configurationManager.getConfiguration();
    Container container = config.getContainer();
    
    // Reset the value stack
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));

    // clear out localization
    LocalizedTextUtil.reset();
    

    //ObjectFactory.setObjectFactory(container.getInstance(ObjectFactory.class));
    return configurationManager;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:XWorkTestCaseHelper.java


示例6: translateVariables

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
/**
 * Converted object from variable translation.
 *
 * @param openChars open character array
 * @param expression expression string
 * @param stack value stack
 * @param asType as class type
 * @param evaluator value evaluator
 * @param maxLoopCount max loop count
 * @return Converted object from variable translation.
 */
public static Object translateVariables(char[] openChars, String expression, final ValueStack stack, final Class asType, final ParsedValueEvaluator evaluator, int maxLoopCount) {

    ParsedValueEvaluator ognlEval = new ParsedValueEvaluator() {
        public Object evaluate(String parsedValue) {
            Object o = stack.findValue(parsedValue, asType);
            if (evaluator != null && o != null) {
                o = evaluator.evaluate(o.toString());
            }
            return o;
        }
    };

    TextParser parser = ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(TextParser.class);

    return parser.evaluate(openChars, expression, ognlEval, maxLoopCount);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:28,代码来源:TextParseUtil.java


示例7: initMockRequest

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
/**
 * Initialize the mock request.
 */
@Before
public void initMockRequest() {
    ConfigurationManager configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    Configuration config = configurationManager.getConfiguration();
    Container container = config.getContainer();

    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));

    assertNotNull(ActionContext.getContext());

    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setSession(new MockHttpSession());
    request.setRemoteUser(TEST_USER);
    ServletActionContext.setServletContext(new MockServletContext());
    ServletActionContext.setRequest(request);
    ServletActionContext.setResponse(response);

}
 
开发者ID:NCIP,项目名称:labviewer,代码行数:26,代码来源:AbstractActionTest.java


示例8: setUp

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    authentication = new AcegiAuthenticationStub();
    authentication.setUsername("user");
    ConfigurationManager configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    Configuration config = configurationManager.getConfiguration();
    Container container = config.getContainer();

    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));

    SecurityContextHolder.getContext().setAuthentication(authentication);
    ActionContext.getContext().setSession(new HashMap<String, Object>());

    SessionHelper.getInstance().setStudyManager(true);

    setUpWebContextBuilder();
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:21,代码来源:AbstractSessionBasedTest.java


示例9: doStartTag

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public int doStartTag() throws JspException {
    ValueStack stack = getStack();
    component = getBean(stack, (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
    Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
    container.inject(component);
    
    populateParams();
    boolean evalBody = component.start(pageContext.getOut());

    if (evalBody) {
        return component.usesBody() ? EVAL_BODY_BUFFERED : EVAL_BODY_INCLUDE;
    } else {
        return SKIP_BODY;
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:16,代码来源:ComponentTagSupport.java


示例10: setContainer

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Inject
public void setContainer(Container container) {
    Map<String, TagLibraryModelProvider> map = new HashMap<>();
    Set<String> prefixes = container.getInstanceNames(TagLibraryModelProvider.class);
    for (String prefix : prefixes) {
        map.put(prefix, container.getInstance(TagLibraryModelProvider.class, prefix));
    }
    this.tagLibraries = Collections.unmodifiableMap(map);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:FreemarkerManager.java


示例11: getWriter

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public Writer getWriter(Writer writer, Map params)
    throws TemplateModelException, IOException {
    Component bean = getBean();
    Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
    container.inject(bean);

    Map unwrappedParameters = unwrapParameters(params);
    bean.copyParams(unwrappedParameters);

    return new CallbackWriter(bean, writer);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:12,代码来源:TagModel.java


示例12: setContainer

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Inject
public void setContainer(Container container) {
    List<TagLibraryDirectiveProvider> list = new ArrayList<>();
    Set<String> prefixes = container.getInstanceNames(TagLibraryDirectiveProvider.class);
    for (String prefix : prefixes) {
        list.add(container.getInstance(TagLibraryDirectiveProvider.class, prefix));
    }
    this.tagLibraries = Collections.unmodifiableList(list);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:VelocityManager.java


示例13: isUseAltSyntax

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
/**
 * Return true if either Configuration's altSyntax is on or the stack context's useAltSyntax is on
 * @param context stack's context
 * @return boolean
 */
public static boolean isUseAltSyntax(Map context) {
    // We didn't make altSyntax static cause, if so, struts.configuration.xml.reload will not work
    // plus the Configuration implementation should cache the properties, which the framework's
    // configuration implementation does
    return "true".equals(((Container)context.get(ActionContext.CONTAINER)).getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)) ||(
            (context.containsKey("useAltSyntax") &&
                    context.get("useAltSyntax") != null &&
                    "true".equals(context.get("useAltSyntax").toString())));
}
 
开发者ID:txazo,项目名称:struts2,代码行数:15,代码来源:ContextUtil.java


示例14: init_PreloadConfiguration

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
private Container init_PreloadConfiguration() {
    // 源码解析: 获取容器
    Container container = getContainer();

    // 源码解析: 是否reload资源文件
    boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
    LocalizedTextUtil.setReloadBundles(reloadi18n);

    // 源码解析: 是否开发模式
    boolean devMode = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_DEVMODE));
    LocalizedTextUtil.setDevMode(devMode);

    return container;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:15,代码来源:Dispatcher.java


示例15: init_CheckWebLogicWorkaround

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
private void init_CheckWebLogicWorkaround(Container container) {
    // test whether param-access workaround needs to be enabled
    if (servletContext != null && StringUtils.contains(servletContext.getServerInfo(), "WebLogic")) {
        LOG.info("WebLogic server detected. Enabling Struts parameter access work-around.");
        paramsWorkaroundEnabled = true;
    } else {
        paramsWorkaroundEnabled = "true".equals(container.getInstance(String.class,
                StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND));
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:11,代码来源:Dispatcher.java


示例16: CompositeActionMapper

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Inject
public CompositeActionMapper(Container container,
                             @Inject(value = StrutsConstants.STRUTS_MAPPER_COMPOSITE) String list) {
    String[] arr = StringUtils.split(StringUtils.trimToEmpty(list), ",");
    for (String name : arr) {
        Object obj = container.getInstance(ActionMapper.class, name);
        if (obj != null) {
            actionMappers.add((ActionMapper) obj);
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:12,代码来源:CompositeActionMapper.java


示例17: StrutsUtil

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public StrutsUtil(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
    this.stack = stack;
    this.request = request;
    this.response = response;
    this.ognl = ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(OgnlTool.class);
    this.urlHelper = ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(UrlHelper.class);
    this.objectFactory = ((Container)stack.getContext().get(ActionContext.CONTAINER)).getInstance(ObjectFactory.class);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:9,代码来源:StrutsUtil.java


示例18: setContainer

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Inject
public void setContainer(Container container) {
    this.container = container;
    Map<String, EngineFactory> map = new HashMap<>();
    Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
    for (String prefix : prefixes) {
        map.put(prefix, new LazyEngineFactory(prefix));
    }
    this.templateEngines = Collections.unmodifiableMap(map);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:11,代码来源:TemplateEngineManager.java


示例19: setContainer

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
@Inject
public void setContainer(Container container) {
    this.container = container;
    try {
        build();
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:DefaultUnknownHandlerManager.java


示例20: loadConfigurationProviders

import com.opensymphony.xwork2.inject.Container; //导入依赖的package包/类
public static ConfigurationManager loadConfigurationProviders(ConfigurationManager configurationManager,
        ConfigurationProvider... providers) {
    try {
        tearDown(configurationManager);
    } catch (Exception e) {
        throw new RuntimeException("Cannot clean old configuration", e);
    }
    configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new ContainerProvider() {
        public void destroy() {}
        public void init(Configuration configuration) throws ConfigurationException {}
        public boolean needsReload() { return false; }

        public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
            builder.setAllowDuplicates(true);
        }
        
    });
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    for (ConfigurationProvider prov : providers) {
        if (prov instanceof XmlConfigurationProvider) {
            ((XmlConfigurationProvider)prov).setThrowExceptionOnDuplicateBeans(false);
        }
        configurationManager.addContainerProvider(prov);
    }
    Container container = configurationManager.getConfiguration().getContainer();
    
    // Reset the value stack
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));
    
    return configurationManager;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:35,代码来源:XWorkTestCaseHelper.java



注:本文中的com.opensymphony.xwork2.inject.Container类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AsyncSubject类代码示例发布时间:2022-05-22
下一篇:
Java ProjectWizardStepFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap