Hi,

This is by design (
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/Application.java#L944-L945
).
The application name is used for internal caches, keys, etc. and it must be
something stable and unique.
If it was allowed to change it at any time then many things may break.

I think the easiest thing to do is to export yet another JMX ObjectName
with the custom name. See
https://github.com/apache/wicket/blob/master/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java#L109


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jan 20, 2015 at 8:05 PM, Thorsten Schöning <tschoen...@am-soft.de>
wrote:

> Hi all,
>
> I have an application which gets deployed into different web app
> contexts of a Tomcat simply be naming the folder of the context
> differently. So "application" is hosted as "application1",
> "application2" etc. simply by copying the generic folder of
> "application" into a new target and do some minor configuration
> changes. The point is, that web.xml keeps the same for all
> installations within one Tomcat.
>
> Today I had a look at using JMX with Wicket and recognized, that the
> name of the application by default is set to the name the Wicket
> filter gets in web.xml. Because that's generic in my case I'm unable
> to distinguish what the JMX console shows me, it's always called the
> same and I can't see to which application it belongs.
>
> Two options now: Either one has to change web.xml for each folder or
> provide some logic to set the application name on runtime, e.g.
> depending on the folder name.
>
> I would prefer the latter and tested a bit around Application.setName,
> but this doesn't seem to work, because setName can only be called
> once and WicketFilter currently always calls it. So regardless if
> someone wants to call it earlier or afterwards, it will always result
> in an error.
>
> Is that expected behavior, should no application be able to provide
> another name at all? Or is there any other way to set the name on my
> own without WicketFilter trying to do the same?
>
> The relevant code in WicketFilter is the following:
>
> > public void init(final boolean isServlet, final FilterConfig
> filterConfig)
> [...]
> >                        // locate application instance unless it was
> already specified during construction
> >                        if (application == null)
> >                        {
> >                                applicationFactory =
> getApplicationFactory();
> >                                application =
> applicationFactory.createApplication(this);
> >                        }
> >
> >                        application.setName(filterConfig.getFilterName());
> >                        application.setWicketFilter(this);
>
> This looks to me as if setName is effectively useless for anyone
> except WicketFilter, because it's always called there.
>
> Thanks for your help!
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: thorsten.schoen...@am-soft.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to