Clement,

Now I've tested trunk again and I can't seem to get it to work. When the
exception is thrown in the start() method, the instance disappears from the
iPOJO tab in Webconsole. I assume it is because it is STOPPED.

When I change my configuration (so that it's correct) I'm hoping the
instance will start again but nothing happens.

Does your test case involve the configuration admin? Remember that my
controller property is connected to the configuration admin. This makes it
possible for me to enable/disable my service with a configuration property.
Could this lead to timing issues? Will the instance receive configuration
changes while it is stopped?

BTW the Svn revision of iPOJO that I've tested is 1033833.

/Bengt

2010/11/12 Bengt Rodehav <[email protected]>

> Clement,
>
> I've tested the workaround again to get a feel for what is happening.
>
> I use the same code I wrote in my previous post. When forcing an exception
> in the start() method, the following situation occurs: When looking at the
> iPOJO instance via the Webconsole, it is still marked as valid but the
> architecture says the valid property is false.
>
> Looking at the configuration tab in the Webconsole, it seems the valid
> property (according to configuration admin) is still true. It seems like I
> cannot change the valid property (mValid field) directly like I do. Do I
> have to use configuration admin?
>
> /Bengt
>
> 2010/11/12 Clement Escoffier <[email protected]>
>
> Hi,
>>
>>
>> On 11.11.10 09:51, "Bengt Rodehav" <[email protected]> wrote:
>>
>> >Clement,
>> >
>> >Unfortunately it's still not working for me. I firs tried the workaround
>> >which basically goes as follows:
>> >
>> >  @Controller
>> >  @Property(name = "enable", mandatory = true)
>> >  private boolean mValid;
>> >  .
>> >  .
>> >  .
>> >  try {
>> >      // start the route
>> >    } catch (Exception e) {
>> >      mValid = false;
>> >    }
>> >
>> >If an exception is thrown, then the instance is made invalid. However, I
>> >cannot get it valid again even if I fix the underlying configuration
>> >problems and enable it again.
>> >
>> >I get the same result when using the trunk version of iPOJO.
>>
>> Hum, that's not normal. Check that another exception is not thrown (the
>> log should contain it).
>>
>> >
>> >Have you tested that it's possible to validate a stopped instance this
>> >way?
>> >I'm not sure if I'm doing anything wrong here...
>>
>> Yes, I've implemented a test case, and the instance is restarted.
>>
>> >
>> >I use the following annotations on my class:
>> >
>> >@Component(name = "myName", propagation = true, immediate = true)
>> >@Provides(specifications = myInterface.class, strategy = "SERVICE")
>>
>> I will test with this configuration.
>>
>> >
>> >I usually use the Felix Webconsole with the iPOJO plugin to inspect my
>> >iPOJO
>> >instances. Currently when instances are stopped, they are not shown in
>> the
>> >Webconsole at all while if they are invalidated they are shown with the
>> >state "invalid" and also information about why the instance is not valid.
>>
>> A stopped instance is really stopped. The Architecture service is no more
>> exposed as no data can be collected (all handlers will say : STOPPED).
>>
>> >
>> >It would be very useful if even stopped instances were shown in the
>> >Webconsole and perhaps with some information about why the instance is
>> >stopped (e g the exception thrown during initialization).
>>
>> I've received a similar request, and I'm looking for the best way to
>> implement this. Right now, the log contain the error.
>>
>> Clement
>>
>> >
>> >/Bengt
>> >
>> >
>> >
>> >2010/11/11 Bengt Rodehav <[email protected]>
>> >
>> >> Wow, your're fast...
>> >>
>> >> I'll try both the workaround and the fix since I'll probably need to
>> use
>> >> the workaround until the next iPOJO release.
>> >>
>> >> /Bengt
>> >>
>> >> 2010/11/10 Clement Escoffier <[email protected]>
>> >>
>> >>>
>> >>>
>> >>> On 10.11.10 20:45, "Bengt Rodehav" <[email protected]> wrote:
>> >>>
>> >>> >Thanks a lot Clement. I'll try your workaround while wating for a fix
>> >>>on
>> >>> >trunk.
>> >>>
>> >>> Already Fixed in trunk :-)
>> >>>
>> >>> Clement
>> >>>
>> >>> >
>> >>> >/Bengt
>> >>> >
>> >>> >2010/11/10 Clement Escoffier <[email protected]>
>> >>> >
>> >>> >> Hi,
>> >>> >>
>> >>> >> So, I've checked. So, what I explained works correctly. So if the
>> >>> >>instance
>> >>> >> is INVALID and we reconfigure the instance, the instance state is
>> >>> >> recomputed. However... In your case you're not INVALID but STOPPED.
>> >>> >> Indeed, when the constructor or a @Validate callback throw an
>> >>> exception,
>> >>> >> the instance is shutdown.
>> >>> >>
>> >>> >> Unfortunately, when a stopped instance is reconfigured, the state
>> is
>> >>> not
>> >>> >> recomputed. That's definitely a bug (and a pretty nice catch !).
>> The
>> >>> >> instance should be restarted with the new configuration. This issue
>> >>> will
>> >>> >> be fixed pretty soon in the trunk.
>> >>> >>
>> >>> >> What you can do for now is to use a lifecycle controller
>> >>>(@Controller),
>> >>> >> catch the Exception and set the controller to false. Then the
>> >>>instance
>> >>> >>is
>> >>> >> invalid not stopped.
>> >>> >>
>> >>> >> Regards,
>> >>> >>
>> >>> >> Clement
>> >>> >>
>> >>> >>
>> >>> >> On 10.11.10 18:00, "Bengt Rodehav" <[email protected]> wrote:
>> >>> >>
>> >>> >> >Thanks Clement.
>> >>> >> >
>> >>> >> >I forgot to write that I use iPOJO 1.6.6.
>> >>> >> >
>> >>> >> >/Bengt
>> >>> >> >
>> >>> >> >2010/11/10 Clement Escoffier <[email protected]>
>> >>> >> >
>> >>> >> >> Hi,
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> On 10.11.10 17:04, "Bengt Rodehav" <[email protected]> wrote:
>> >>> >> >>
>> >>> >> >> >I create iPOJO instances from factory configurations using
>> >>> >> >>Configuration
>> >>> >> >> >Admin and File Install. When the iPOJO instance becomes valid I
>> >>>do
>> >>> >>my
>> >>> >> >> >initialisation (which normally starts a Camel route) and when
>> >>>the
>> >>> >>iPOJO
>> >>> >> >> >instance becomes invalid I terminate my processing (which means
>> >>> >>that I
>> >>> >> >> >normally stop a Camel route).
>> >>> >> >> >
>> >>> >> >> >  @Validate
>> >>> >> >> >  public void start() {
>> >>> >> >> >    // Start the route
>> >>> >> >> >  }
>> >>> >> >> >
>> >>> >> >> >  @Invalidate
>> >>> >> >> >  public void stop() {
>> >>> >> >> >    // Stop the route
>> >>> >> >> >  }
>> >>> >> >> >
>> >>> >> >> >To make it possible to control my iPOJO instances I use a
>> >>> controller
>> >>> >> >> >property as follows:
>> >>> >> >> >
>> >>> >> >> >  @Controller
>> >>> >> >> >  @Property(name = "enable", mandatory = true)
>> >>> >> >> >  private boolean mValid;
>> >>> >> >> >
>> >>> >> >> >This allows me to enable/disable my service via configuration.
>> >>> >> >>However, I
>> >>> >> >> >have noticed that if an exception is thrown in the start()
>> >>>method
>> >>> >> >>above,
>> >>> >> >> >then the iPOJO becomes invalid and there is no way for me to
>> >>>make
>> >>> it
>> >>> >> >>valid
>> >>> >> >> >by changing any configuration property. It seems like I have to
>> >>> >>delete
>> >>> >> >>the
>> >>> >> >> >configuration and create a new one. Have I understood this
>> >>> >>correctly?
>> >>> >> >>
>> >>> >> >> Modifying the configuration should trigger a reconfiguration of
>> >>>the
>> >>> >> >> instance. It should then recompute the state (in theory it
>> should
>> >>> >>work).
>> >>> >> >> Deleting the configuration disposes the instance and recreates a
>> >>>new
>> >>> >> >>one.
>> >>> >> >>
>> >>> >> >> >
>> >>> >> >> >I would like a convenient way to either make my iPOJO instance
>> >>> valid
>> >>> >> >>again
>> >>> >> >> >or a way to dispose of the old instance and create a new one.
>> >>>How
>> >>> >>can I
>> >>> >> >> >accomplish this? It would be convenient if I could flag my
>> iPOJO
>> >>> >>class
>> >>> >> >> >with
>> >>> >> >> >an annotation like "deleteOnException" or something like that.
>> >>> >> >>
>> >>> >> >> Modifying the configuration should do the work. I will check
>> >>>that.
>> >>> >> >>
>> >>> >> >> 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]
>> >>>
>> >>>
>> >>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

Reply via email to