You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by sam lee <sk...@gmail.com> on 2011/05/16 21:47:30 UTC

how can I handle error condition during activate()?

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?

Re: how can I handle error condition during activate()?

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

Am Montag, den 23.05.2011, 15:49 +0100 schrieb Donald Whytock: 
> Yes, Dual Screen.  Felix for GameBoy, with new stylus interface for gogo.

Nice one ;-) 
> 
> On Mon, May 23, 2011 at 9:24 AM, sam lee <sk...@gmail.com> wrote:
> > What's DS?  Dual Screen? Declarative Service? Dynamic Service?

In the context of OSGi it is:

   DS == Declarative Services

Its that kind of well-known acronyms we like to throw around
ourselves ;-)

Regards
Felix

> >
> >
> > On Mon, May 23, 2011 at 8:44 AM, Peter Kriens <pe...@aqute.biz>wrote:
> >
> >> It is the beauty of DS: Just throw the exception and it ends up in the log!
> >>
> >> Kind regards,
> >>
> >>        Peter Kriens
> >>
> >> On 16 mei 2011, at 21:47, sam lee 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
> >>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 



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


Re: how can I handle error condition during activate()?

Posted by Donald Whytock <dw...@gmail.com>.
Yes, Dual Screen.  Felix for GameBoy, with new stylus interface for gogo.

On Mon, May 23, 2011 at 9:24 AM, sam lee <sk...@gmail.com> wrote:
> What's DS?  Dual Screen? Declarative Service? Dynamic Service?
>
>
> On Mon, May 23, 2011 at 8:44 AM, Peter Kriens <pe...@aqute.biz>wrote:
>
>> It is the beauty of DS: Just throw the exception and it ends up in the log!
>>
>> Kind regards,
>>
>>        Peter Kriens
>>
>> On 16 mei 2011, at 21:47, sam lee 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
>>
>>
>

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


Re: how can I handle error condition during activate()?

Posted by sam lee <sk...@gmail.com>.
What's DS?  Dual Screen? Declarative Service? Dynamic Service?


On Mon, May 23, 2011 at 8:44 AM, Peter Kriens <pe...@aqute.biz>wrote:

> It is the beauty of DS: Just throw the exception and it ends up in the log!
>
> Kind regards,
>
>        Peter Kriens
>
> On 16 mei 2011, at 21:47, sam lee 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
>
>

Re: how can I handle error condition during activate()?

Posted by Peter Kriens <pe...@aqute.biz>.
It is the beauty of DS: Just throw the exception and it ends up in the log!

Kind regards,

	Peter Kriens

On 16 mei 2011, at 21:47, sam lee 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


Re: how can I handle error condition during activate()?

Posted by Justin Edelson <ju...@justinedelson.com>.
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 <sk...@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