Hi,

On Tue, Aug 25, 2015 at 9:20 AM, Jörg Schaible <[email protected]
> wrote:

> Hi Martin,
>
> Martin Grigorov wrote:
>
> > Hi,
> >
> >
> > On Mon, Aug 24, 2015 at 4:06 PM, Jörg Schaible
> > <[email protected]
> >> wrote:
> >
> >> Hi,
> >>
> >> I am migrating an old Wicket application running in Apache Felix and I
> >> wonder how I should register my initializer. According the migration
> docs
> >> I should move and rename the "/wicket.properties" file to "META-
> >> INF/wicket/<package>.properties".
> >>
> >> However, in Felix I have an URL for this resource like
> >> "bundle://18.0:1/META-INF/wicket/". This is obviously not supported in
> >> Application.collectWicketProperties().
> >>
> >>
> > We can make this method protected or add another method where you could
> > plug custom logic.
> >
> >
> >> For now, I can return to the deprecated name and location, but I wonder
> >> what
> >> is the migration path when this support is dropped?
> >>
> >> Why do you iterate over all existing files anyway, when you stop the
> >> iteration at the first occurrence (at least for jar protocol)? The
> >> easiest solution would be to look again for a "known" resource, simply
> >> gain the name
> >> of the properties file from the current application instance:
> >> this.getClass().getPackage.getName() + ".properties"
> >>
> >
> > Because wicket.properties is something like a plugin system. It is not
> > properties of the Application, but properties which may define
> Application
> > extensions/mixins - o.a.w.IInitilizer.
>
> And in case of jar:// URL it stops at the first matching properties
> resource
> and ignores the rest. You cannot even control which one is taken.
>

Yes. We do not expect more than one /META-INF/wicket/.../xyz.properties in
a (single) jar

https://github.com/apache/wicket/blob/8d23f188e8509e4fae945bbfb9710c489c57423c/wicket-core/src/main/java/org/apache/wicket/Application.java#L517
the "break" here is only for the browsing in the jar entries, but there is
an outer "while" that iterates over all .jar files.


>
> > I.e. by using IInitialize any Wicket library could participate in the
> > application start/stop to setup/cleanup whatever it needs.
>
> Yes, but the current implementation is not compatible with all kind of
> classloaders. A Java ClassLoader does not offer a browse functionality, it
> can only search for stuff with known name. A browsing implementation is
> simply a hack. Wicket contains now code to support all kind of "unusual"
> protocols, e.g. a special one in a JBoss environment. How does the protocol
> looks like in WebLogic, WepSphere, ...? It fails badly at least in a Felix
> environment.
>

WebSphere is covered at
https://github.com/apache/wicket/blob/8d23f188e8509e4fae945bbfb9710c489c57423c/wicket-core/src/main/java/org/apache/wicket/Application.java#L501
- "wsjar".
AFAIR WebLogic uses normal protocol - "jar".
OSGi is designed to cause troubles :-)
But I already suggested to make the logic pluggable.


>
> I wonder why Wicket does not simply use the standard Java SPI mechanism?
> Everyone could announce his personal initializers just by adding the class
> names in a resource named
> "META-INF/services/org.apache.wicket.Initializer".
>

Because this breaks when people use jarjar/uberjar/shaded. And people do
use this a lot.
Using ServiceLoader is no different than what we have in Wicket 6.x -
ClassLoader#getResources("/wicket.properties").


>
> >> Then you can stop making assumptions about the URL. Unfortunately it is
> >> not possible to overwrite this behavior now because the interesting
> >> methods are either final or private.
> >>
> >
> > Patches/PullRequests are very welcome!
>
> As long as any 3rd party Wicket library relies on the fact that anything in
> META-INF/wicket is automatically found, it does not help to overload the
> functionality. Then I can also stick with the deprecated mechanism.
>

Instead of overload (I think you actually mean override) you could extend
the logic.
E.g. we can move the error logging at
https://github.com/apache/wicket/blob/8d23f188e8509e4fae945bbfb9710c489c57423c/wicket-core/src/main/java/org/apache/wicket/Application.java#L575

to a protected method. So Wicket will let the application to deal with
unknown schemes.


>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to