private ObjectFactory getObjectFactory() { return ActionContext.getContext().getInstance(ObjectFactory.class); }
/** * This register dedicated BeanModel to support tiles tags. * It requires {@link org.apache.struts2.views.JspSupportServlet} to be registered in web.xml */ protected void registerTilesBeanModel(ActionContext ctx) { ServletContext servletContext = ServletActionContext.getServletContext(); Configuration configuration = ctx.getInstance(FreemarkerManager.class).getConfiguration(servletContext); StrutsBeanWrapper wrapper = (StrutsBeanWrapper) ctx.getInstance(FreemarkerManager.class).getWrapper(); LOG.trace("Adding support for Tiles tags, please remember to register {} in web.xml!", JspSupportServlet.class.getName()); BeanModel tilesBeanModel = new BeanModel(new TilesFMModelRepository(), wrapper); configuration.setSharedVariable("tiles", tilesBeanModel); }
@Override public Locale resolveLocale(Request request) { HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest(); ActionContext ctx = ServletActionContext.getActionContext(httpRequest); if (ctx == null) { LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName()); throw new ConfigurationException("There is no ActionContext for current request!"); } LocaleProviderFactory localeProviderFactory = ctx.getInstance(LocaleProviderFactory.class); return localeProviderFactory.createLocaleProvider().getLocale(); }
public DefaultClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols, Test<String> classNameFilter) { this.classLoaderInterface = classLoaderInterface; this.extractBaseInterfaces = extractBaseInterfaces; this.fileManager = ActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager();
public DefaultClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols, Test<String> classNameFilter) { this.classLoaderInterface = classLoaderInterface; this.extractBaseInterfaces = extractBaseInterfaces; this.fileManager = ActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager();
public ReloadingClassLoader(final ClassLoader pParent) { super(pParent); parent = pParent; URL parentRoot = pParent.getResource(""); FileManager fileManager = ActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager(); URL root = fileManager.normalizeToFileProtocol(parentRoot); root = ObjectUtils.defaultIfNull(root, parentRoot); try { if (root != null) { stores = new ResourceStore[]{new FileResourceStore(new File(root.toURI()))}; } else { throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false"); } } catch (URISyntaxException e) { throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e); } catch (RuntimeException e) { // see WW-3121 // TODO: Fix this for a reloading mechanism to be marked as stable if (root != null) LOG.error("Exception while trying to build the ResourceStore for URL [#0]", e, root.toString()); else LOG.error("Exception while trying to get root resource from class loader", e); LOG.error("Consider setting struts.convention.classes.reload=false"); throw e; } delegate = new ResourceStoreClassLoader(parent, stores); }
invocation.setContainer(container); ActionProxyFactory actionProxyFactory = context.getInstance(ActionProxyFactory.class); ActionProxy actionProxy = actionProxyFactory.createActionProxy(invocation, "java.lang", "java.lang.Object", null, false, false); invocation.init(actionProxy);
public static ValueStack createValuestack() { ValueStack result; ActionContext context = ActionContext.getContext(); if (context == null) { // no action context, create a value stack from scratch ConfigurationManager confManager = new ConfigurationManager("xwork"); Configuration conf = confManager.getConfiguration(); Container container = conf.getContainer(); ValueStackFactory stackFactory = container.getInstance(ValueStackFactory.class); result = stackFactory.createValueStack(); } else { // there is an action context, try to use his value stack result = context.getValueStack(); if (result == null) { // no value stack, create then a new one ValueStackFactory stackFactory = context.getInstance(ValueStackFactory.class); result = stackFactory.createValueStack(); } } return result; }