You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2014/02/16 13:37:30 UTC

DevMode override

Hi,

Do you know how does it work? I need some usage example.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: DevMode override

Posted by Lukasz Lenart <lu...@apache.org>.
Ok, I wasn't too precise. In FilterDispatcher (deprecated) there is
option to have something like devModeOverride - but I cannot figure
out how can I use it :\

https://git-wip-us.apache.org/repos/asf?p=struts.git;a=blob;f=core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java;h=6f38026ef0d33b40233dab3ac59fe41b801d3cd5;hb=HEAD#l243

2014-02-17 8:50 GMT+01:00 Greg Huber <gr...@gmail.com>:
> The way I do mine is via web.xml:
>
> <!-- Switches dev mode via site.devMode property -->
>     <listener>
>
> <listener-class>ui.struts2.util.config.EnvironmentListener</listener-class>
>     </listener>
>
> public class EnvironmentListener implements ServletContextListener {
>
>     private static Log log = LogFactory.getLog(EnvironmentListener.class);
>
>     /**
>      * @see
> javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
>      */
>     public void contextInitialized(ServletContextEvent event) {
>
>         try {
>
>             Dispatcher
>                     .addDispatcherListener(new
> EnvironmentDispatcherListener());
>
>         } catch (Exception e) {
>             log.error("Error adding EnvironmentDispatcherListener", e);
>
>         }
>
>     }
>
>     /**
>      * @see
> javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
>      */
>     public void contextDestroyed(ServletContextEvent arg0) {
>         // do nothing
>     }
> }
>
> #######
>
> public class EnvironmentDispatcherListener implements DispatcherListener {
>
>     private static Log log = LogFactory
>             .getLog(EnvironmentDispatcherListener.class);
>
>     /**
>      * @see
> org.apache.struts2.dispatcher.DispatcherListener#dispatcherInitialized
>      *      (Dispatcher)
>      */
>     public void dispatcherInitialized(Dispatcher dispatcher) {
>
>         // Set system dev mode
>         Boolean debug = RuntimeConfig.getBooleanProperty("site.devMode");
>
>         // Note this only does the messages not
>         // struts.configuration.xml.reload=false or struts.i18n.reload=false
>         if (debug) {
>             dispatcher.setDevMode("true");
>             log.info("Devel environment: devMode is active");
>         } else {
>             dispatcher.setDevMode("false");
>             log.info("Devel environment: devMode is in-active");
>         }
>
>     }
>
>     /**
>      * @see
> org.apache.struts2.dispatcher.DispatcherListener#dispatcherDestroyed(Dispatcher)
>      */
>     public void dispatcherDestroyed(Dispatcher dispatcher) {
>         // do nothing
>     }
>
> }
>
> I could not find a way to do struts.configuration.xml.reload or
> struts.i18n.reload :
>
> struts.properties:
>
> # dev mode options.  See site.devMode mode via EnvironmentListener in
> web.xml
> #struts.devMode=false
> struts.configuration.xml.reload=true
> struts.i18n.reload=true
>
> Cheers Greg
>
>
> On 16 February 2014 12:37, Lukasz Lenart <lu...@apache.org> wrote:
>
>> Hi,
>>
>> Do you know how does it work? I need some usage example.
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: DevMode override

Posted by Greg Huber <gr...@gmail.com>.
The way I do mine is via web.xml:

<!-- Switches dev mode via site.devMode property -->
    <listener>

<listener-class>ui.struts2.util.config.EnvironmentListener</listener-class>
    </listener>

public class EnvironmentListener implements ServletContextListener {

    private static Log log = LogFactory.getLog(EnvironmentListener.class);

    /**
     * @see
javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent event) {

        try {

            Dispatcher
                    .addDispatcherListener(new
EnvironmentDispatcherListener());

        } catch (Exception e) {
            log.error("Error adding EnvironmentDispatcherListener", e);

        }

    }

    /**
     * @see
javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
        // do nothing
    }
}

#######

public class EnvironmentDispatcherListener implements DispatcherListener {

    private static Log log = LogFactory
            .getLog(EnvironmentDispatcherListener.class);

    /**
     * @see
org.apache.struts2.dispatcher.DispatcherListener#dispatcherInitialized
     *      (Dispatcher)
     */
    public void dispatcherInitialized(Dispatcher dispatcher) {

        // Set system dev mode
        Boolean debug = RuntimeConfig.getBooleanProperty("site.devMode");

        // Note this only does the messages not
        // struts.configuration.xml.reload=false or struts.i18n.reload=false
        if (debug) {
            dispatcher.setDevMode("true");
            log.info("Devel environment: devMode is active");
        } else {
            dispatcher.setDevMode("false");
            log.info("Devel environment: devMode is in-active");
        }

    }

    /**
     * @see
org.apache.struts2.dispatcher.DispatcherListener#dispatcherDestroyed(Dispatcher)
     */
    public void dispatcherDestroyed(Dispatcher dispatcher) {
        // do nothing
    }

}

I could not find a way to do struts.configuration.xml.reload or
struts.i18n.reload :

struts.properties:

# dev mode options.  See site.devMode mode via EnvironmentListener in
web.xml
#struts.devMode=false
struts.configuration.xml.reload=true
struts.i18n.reload=true

Cheers Greg


On 16 February 2014 12:37, Lukasz Lenart <lu...@apache.org> wrote:

> Hi,
>
> Do you know how does it work? I need some usage example.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>