[ 
https://issues.apache.org/jira/browse/WW-4875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16217537#comment-16217537
 ] 

ASF GitHub Bot commented on WW-4875:
------------------------------------

aleksandr-m opened a new pull request #177: WW-4875 Add ability to use Java 
based configuration
URL: https://github.com/apache/struts/pull/177
 
 
   ## WIP - Don't merge this yet!
   
   ### Things to todo / improve
   
   - `Location` for java based configuration is currently `UNKNOWN`
   - `ConstantConfig` for plugins (convention, rest, spring, etc)
   - `unknownHandlerStack` configuration in current implementation is a list of 
strings
   
   ### Usage
   
   #### web.xml
   
   ```
   <filter>
       <filter-name>struts2</filter-name>
       
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
       <init-param>
        <param-name>javaConfigClasses</param-name>
        <param-value>com.example.AppConf</param-value>
       </init-param>
   </filter>
   ```
   
   
   #### com.example.AppConf
   
   ```
   public class AppConf implements StrutsJavaConfiguration {
       @Override
       public List<ConstantConfig> constants() {
           ConstantConfig c = new ConstantConfig();
           c.setDevMode(true);
           c.setObjectFactory(customObjectFactory());
           return Arrays.asList(c);
       }
   
       @Override
       public List<BeanConfig> beans() {
           List<BeanConfig> list = new ArrayList<>();
           list.add(new BeanConfig(SomeBean.class));
           list.add(customObjectFactory());
           return list;
       }
   
       @Override
       public List<String> unknownHandlerStack() {
           return null;
       }
   
       private BeanConfig customObjectFactory() {
           return new BeanConfig(CustomObjectFactory.class,
                                 "customObjectFactory", ObjectFactory.class);
       }
   }
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Java configuration
> ------------------
>
>                 Key: WW-4875
>                 URL: https://issues.apache.org/jira/browse/WW-4875
>             Project: Struts 2
>          Issue Type: Improvement
>    Affects Versions: 2.5.13
>            Reporter: Aleksandr Mashchenko
>            Assignee: Aleksandr Mashchenko
>             Fix For: 2.6
>
>
> Some people are allergic to XML and even with convention plugin currently 
> there is no way to define properties w/o struts.xml or properties file.
> It would be great to add the ability to configure app via java configuration.
> We can start with adding support for constant, bean and unknown-handler-stack 
> and see how it goes.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to