You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2015/08/05 15:52:39 UTC

Startup handling: StartupModeProvider?

Hi,

Looking at https://cwiki.apache.org/confluence/display/SLING/Startup+Handling
I'm wondering if we shouldn't just (or initially) simplify some of the
APIs that currently couple modules to the launchpad in terms of
startup.

Looking at bundles/extensions/settings for example it seems like it's
only interested in the StartupMode, and I suspect other modules are in
the same case. The dynamics like "is startup finished" don't make
sense anyway with other launchers like Karaf IIUC.

Currently the only way to get that mode is via

public interface StartupHandler {
    StartupMode getMode();
    boolean isFinished();
    void waitWithStartup(final boolean flag);
}

which mixes several concerns. How about creating a StartupModeProvider
service API:

public interface StartupModeProvider {
    StartupMode getMode();
}

and have StartupHandler inherit from this?

This would reduce the coupling area between the startup stuff and
client modules, and we can then isolate the StartupModeProvider
implementation in its own bundle which handles just this concern and
is independent of the startup mechanism.

WDYT?

-Bertrand

Re: Startup handling: StartupModeProvider?

Posted by Carsten Ziegeler <cz...@apache.org>.
Am 05.08.15 um 08:52 schrieb Bertrand Delacretaz:
> Hi,
> 
> Looking at https://cwiki.apache.org/confluence/display/SLING/Startup+Handling
> I'm wondering if we shouldn't just (or initially) simplify some of the
> APIs that currently couple modules to the launchpad in terms of
> startup.
> 
> Looking at bundles/extensions/settings for example it seems like it's
> only interested in the StartupMode, and I suspect other modules are in
> the same case. The dynamics like "is startup finished" don't make
> sense anyway with other launchers like Karaf IIUC.
> 
> Currently the only way to get that mode is via
> 
> public interface StartupHandler {
>     StartupMode getMode();
>     boolean isFinished();
>     void waitWithStartup(final boolean flag);
> }
> 
> which mixes several concerns. How about creating a StartupModeProvider
> service API:
> 
> public interface StartupModeProvider {
>     StartupMode getMode();
> }
> 
> and have StartupHandler inherit from this?
> 
> This would reduce the coupling area between the startup stuff and
> client modules, and we can then isolate the StartupModeProvider
> implementation in its own bundle which handles just this concern and
> is independent of the startup mechanism.
> 
We should put the interface in a separate api package. Otherwise a
bundle implementing this service should also implement the other
services in that package and we end up with the same situation. if a
bundle is only implemnting a single service in an api package it's kind
of breaking the api contract.

Carsten
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Startup handling: StartupModeProvider?

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Wednesday 05 August 2015 17:24:07 Bertrand Delacretaz wrote:
> On Wed, Aug 5, 2015 at 5:17 PM, Carsten Ziegeler <cz...@apache.org> 
wrote:
> > ...how is the startup mode detected when running in Karaf?..
> 
> As far as I can tell from [1] it's not currently detected, only configured.

Right, it's configured. Though there are some hooks in Karaf (e.g. 
FeatureMBean) which may allow proper detection.

O.

> -Bertrand
> 
> [1]
> https://svn.apache.org/repos/asf/sling/trunk/contrib/launchpad/karaf/org.ap
> ache.sling.launchpad.karaf/src/main/java/org/apache/sling/launchpad/karaf/Ka
> rafStartupHandler.java



Re: Startup handling: StartupModeProvider?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Aug 5, 2015 at 5:17 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> ...how is the startup mode detected when running in Karaf?..

As far as I can tell from [1] it's not currently detected, only configured.

-Bertrand

[1] https://svn.apache.org/repos/asf/sling/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf/src/main/java/org/apache/sling/launchpad/karaf/KarafStartupHandler.java

Re: Startup handling: StartupModeProvider?

Posted by Carsten Ziegeler <cz...@apache.org>.
Before we think about a new api, what about thinking how this is handled
in other scenarios? So, e.g. how is the startup mode detected when
running in Karaf? Or somewhere else?

Carsten


-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Startup handling: StartupModeProvider?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Thu, Aug 6, 2015 at 12:30 PM, Oliver Lietz <ap...@oliverlietz.de> wrote:
> ...I wonder if we should break up Sling Settings into API and implementations and
> provide dedicated Sling Settings services for each launcher/platform...

That might work but a number of components use the StartupMode as
well, so I still think that service should be provided by a bundle
that's distinct from the launchpad.

-Bertrand

Re: Startup handling: StartupModeProvider?

Posted by Carsten Ziegeler <cz...@apache.org>.
Am 06.08.15 um 05:30 schrieb Oliver Lietz:



> 
> I wonder if we should break up Sling Settings into API and implementations and 
> provide dedicated Sling Settings services for each launcher/platform. Or make 
> StartupHandler optional.

+1, I think we should make it optional. In the case of the launchpad we
know that the handler is registered on framework init, and it's safe to
assume that the service will not be registered at a later point.

Carsten


-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: Startup handling: StartupModeProvider?

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Wednesday 05 August 2015 15:52:39 Bertrand Delacretaz wrote:
> Hi,

hi,

> Looking at
> https://cwiki.apache.org/confluence/display/SLING/Startup+Handling I'm
> wondering if we shouldn't just (or initially) simplify some of the APIs
> that currently couple modules to the launchpad in terms of
> startup.
> 
> Looking at bundles/extensions/settings for example it seems like it's
> only interested in the StartupMode, and I suspect other modules are in
> the same case. The dynamics like "is startup finished" don't make
> sense anyway with other launchers like Karaf IIUC.
> 
> Currently the only way to get that mode is via
> 
> public interface StartupHandler {
>     StartupMode getMode();
>     boolean isFinished();
>     void waitWithStartup(final boolean flag);
> }
> 
> which mixes several concerns. How about creating a StartupModeProvider
> service API:
> 
> public interface StartupModeProvider {
>     StartupMode getMode();
> }
> 
> and have StartupHandler inherit from this?
> 
> This would reduce the coupling area between the startup stuff and
> client modules, and we can then isolate the StartupModeProvider
> implementation in its own bundle which handles just this concern and
> is independent of the startup mechanism.
> 
> WDYT?

looking closer at StartupMode again it looks like they are only used for 
sling.run.mode.install.options (which I've never used AFAIR).
And they do not seem useful on Karaf with Features either.

I wonder if we should break up Sling Settings into API and implementations and 
provide dedicated Sling Settings services for each launcher/platform. Or make 
StartupHandler optional.

Dedicated services would also allow setting run modes in other ways than by 
framework property (I'm aware of dangers).

Regards,
O.

> -Bertrand