Thanks JB,  would it work with file:// <file:///?> protocol, or only mvn? 
Also, what start level do you recommend?

Best regards,
Alex soto




> On Apr 15, 2020, at 1:55 PM, Jean-Baptiste Onofre <[email protected]> wrote:
> 
> Hi Alex,
> 
> Yes, SystemService is exactly provided for that (it’s used by the 
> halt/shutdown Karaf command).
> 
> Another option (it’s basically what the SystemService is doing) is to do: 
> bundleContext.stop(0);
> 
> Bundle 0 is the system bundle (the framework basically).
> 
> SystemService is a better option IMHO.
> 
> If you want to be even faster, you can also have this bundle in 
> etc/startup.properties (it’s before the feature service to boot features).
> 
> Regards
> JB
> 
>> Le 15 avr. 2020 à 17:25, Alex Soto <[email protected] 
>> <mailto:[email protected]>> a écrit :
>> 
>> Hello,
>> 
>> What would be the best way to shutdown Karaf as soon as possible from a 
>> Declarative Component that needs to run at startup. 
>> This component will check some authorization API and decide if the user is 
>> authorized to run the app.  So, I thought to have a component  with 
>> @Component(immediate = true) and: 
>> 
>>      @Reference
>>      private SystemService systemService;
>> 
>>      @Activate
>>      void init() {
>>              if (!authorized()) {
>>                      systemService.halt();
>>              }
>>      }
>> 
>> 
>> Is this a good approach?
>> Should I add the bundle containing this component as a boot feature? 
>> Any other advise?
>> 
>> 
>> Best regards,
>> Alex soto
>> 
>> 
>> 
>> 
> 

Reply via email to