felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Edelson <jus...@justinedelson.com>
Subject Re: how can I handle error condition during activate()?
Date Tue, 17 May 2011 00:13:23 GMT
Yes - you can throw an exception in the activate method if you don't
want the component to be activated. See section 112.5.8 of the
Compendium: "If the activate method throws
an exception, SCR must log an error message containing the exception with
the Log Service, if present, and the component configuration is not activated."

Justin

On Mon, May 16, 2011 at 12:47 PM, sam lee <skynare@gmail.com> wrote:
> Hey,
>
> I have:
>
>    @Activate
>    private void activate(Map<String, ?> config) {
>        cdnHost = OsgiUtil.toString(config.get(PROP_CDN_HOST), null);
>
>
>        if (cdnHost == null) {
>            // Do I throw an Exception here?
>            // I don't want this component to be Activated if cdnHost isn't
> set.
>        }
>
>    }
>
>
> Is exception a proper way?
> Or, is there a Service that I can @Reference, that has error flagging
> methods?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message