本文整理汇总了Java中com.opensymphony.xwork2.inject.Container类的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Container类属于com.opensymphony.xwork2.inject包,在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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())));
}
示例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;
}
示例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));
}
}