users@hk2.java.net

Re: [Ask]about RunLevelControllerThread

From: John Wells <john.wells_at_oracle.com>
Date: Tue, 17 Dec 2013 11:19:51 -0500

I don't think that will work because inside the onProgress the
levelAchieved will always equal the current run level.

On 12/17/2013 8:26 AM, Tang Yong wrote:
> Thanks JWells's reply!
>
> Whether the following is also another way:
>
> @Inject
> private Provider<RunLevelController> controllerProvider;
>
> if (controllerProvider.get().getCurrentRunLevel() == levelAchieved) {
> ...
> }
>
> Thanks
> Tang
>
> John Wells wrote:
>> I guess I'd like to understand your use case, since I think you can
>> use the RunLevelListener to determine if the job is complete.
>>
>> Basically, if you were to do something like this:
>>
>> public void onProgress(ChangeableRunLevelFuture <https://hk2.java.net/2.2.0-b26/apidocs/org/glassfish/hk2/runlevel/ChangeableRunLevelFuture.html> currentJob,
>> int levelAchieved){
>> if (currentJob.getProposedLevel() == levelAchieved) {
>> // The job is finished
>> }
>> else {
>> // The job is not finished yet
>> }
>> }
>>
>> I think you would have what you wanted, right?
>>
>>
>> On 12/17/2013 4:46 AM, Tang Yong wrote:
>>> About the question, I also searched the source and [1],
>>>
>>> The best way should use RunLevelListener, however, RunLevelListener does
>>> not off an api for task completed.
>>>
>>> [1]:https://hk2.java.net/2.2.0-b26/runlevel.html
>>>
>>> Thanks
>>> Tang
>>>
>>> Tang Yong wrote:
>>>> Hi JWells, Mason,
>>>>
>>>> I have an urgent question about RunLevelControllerThread,
>>>>
>>>> While using the following way to move to the given run level,
>>>>
>>>> RunLevelController.proceedTo(runLevel)
>>>>
>>>> I want to know whether having any way to know when the
>>>> RunLevelControllerThread has been ended?
>>>>
>>>> Thanks
>>>> Tang
>>>>