Hi,

On 12.01.11 09:35, "Bengt Rodehav" <[email protected]> wrote:

>Clement,
>
>I managed to get this to work using the following pattern:
>
>*...@component(...)*
>
>*public class MyComponent {*
>
>*  private boolean mIsValid = false;*
>
>*
>> *
>
>*  @Validate*
>
>*  public void starting() throws Exception {*
>
>*    init();*
>
>*    mIsValid = true;*
>
>*  }*
>
>*
>> *
>
>*  @Invalidate*
>
>*  public void stopping() {*
>
>*    mIsValid = false;*
>
>*    terminate();*
>
>*  }*
>
>*
>> *
>
>*  @Updated*
>
>*  public void updated() throws Exception {*
>
>*    // Do nothing if we are not valid yet*
>
>*    if (mIsValid) {*
>
>*      restart();*
>
>*    }*
>
>*  }*
>
>*
>> *
>
>*  @Property(name = "myProp", mandatory = false, value = "default value")*
>
>*  private String mMyProp;*
>
>*
>> *
>
>*  private String mRegisteredMyProp;*
>
>*
>> *
>
>*  private void init() throws Exception {*
>
>*    // Perform my initialisation*
>
>*    ...*
>
>*    mRegisteredMyProp = mMyProp;*
>
>*  }*
>
>*
>> *
>
>*  private void terminate() {*
>
>*    // Perform my cleanup*
>
>*    ...*
>
>*    mRegisteredMyProp = null;*
>
>*  }*
>
>*
>> *
>
>*  private void restart() throws Exception {*
>
>*    // Has the configuration changed?*
>
>*    if (!mMyProp.equals(mRegisteredMyProp) {*
>
>*      terminate();*
>
>*      init();*
>
>*    }*
>
>*  }*
>
>*}*
>
>
>Thus I didn't need a life cycle controller after all. The implementation
>of
> FELIX-2773 could probably do something similar.


Yes something like that. During reconfiguration I can just set the state
to invalid and immediately to valid.

>I think that if iPOJO were
>to support inheritance, then the need to include functionality such as
>FELIX-2773 would be void since it would then be an easy task to put it in
>a
>super class. Forgive me for asking again but would is the status of
>supporting inheritance in iPOJO?

I've finally more or less designed and planned for iPOJO 2.0 (2011).

Regards,

Clement

>
>/Bengt
>
>
>2011/1/11 Clement Escoffier <[email protected]>
>
>>
>>
>> On 11.01.11 10:16, "Bengt Rodehav" <[email protected]> wrote:
>>
>> >I created the following JIRA ticket:
>> >
>> >https://issues.apache.org/jira/browse/FELIX-2773
>>
>> Thanks,
>>
>> >
>> ><https://issues.apache.org/jira/browse/FELIX-2773>I'll try
>>experimenting
>> >with the life cycle controller and see if I can use that as a
>>workaround.
>> >
>> >Are you thinking something like this:
>> >
>> >- Create an attribute that acts as life cycle controller. Initial value
>> >would be true.
>> >- When I detect that a critical property (one that requires restart) is
>> >updated, I set the life cycle controller to false. I guess I would do
>>this
>> >in an @Updated method.
>> >
>> >When do I set the life cycle controller to true again?
>>
>>
>> Probably at the end of the @Updated if everything is fine.
>>
>> Regards,
>>
>> Clement
>>
>> >
>> >/Bengt
>> >
>> >2011/1/11 Clement Escoffier <[email protected]>
>> >
>> >> Hi,
>> >>
>> >> On 10.01.11 14:59, "Bengt Rodehav" <[email protected]> wrote:
>> >>
>> >> >I use iPOJO and configuration admin. When certain configuration
>> >>properties
>> >> >change, I want to "restart" my iPOJO instance. I e I want the
>>instance
>> >>to
>> >> >become invalid and then valid again. Currently I do some
>> >>initialisation on
>> >> >the method marked as @Validate and some cleanup in the method marked
>> >> >as @Invalidate.
>> >> >
>> >> >It's very tricky to get this to work. When I start my application it
>> >>seems
>> >> >like both the @Validate and the @Updated methods are called which
>> >>causes
>> >> >problems. What is the recommended way to accomplish this?
>> >> >
>> >> >Ideally I would like to mark my iPOJO properties as requiring the
>> >>instance
>> >> >to "restart", e g
>> >> >
>> >> >*  @Property(name = "rootUrl", restart = "true")*
>> >> >
>> >> >*  private String mRootUrl;*
>> >>
>> >> Unfortunately this is not supported. It can be an interesting
>>feature to
>> >> allow an instance to be invalidated/validated during the
>> >>reconfiguration.
>> >> Could you open a jira issue  ?
>> >>
>> >> In the meantime, you could try to use the lifecycle controller to
>>force
>> >> the invalidation / revalidation.
>> >>
>> >> Regards,
>> >>
>> >> Clement
>> >>
>> >> >
>> >> >
>> >> >/Bengt
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to