EMMA Coverage Report (generated Tue Apr 17 08:51:20 BST 2007)
[all classes][org.jtoolkit.essence.concurrency.impl]

COVERAGE SUMMARY FOR SOURCE FILE [SesThreadGroup.java]

nameclass, %method, %block, %line, %
SesThreadGroup.java100% (1/1)100% (3/3)66%  (23/35)80%  (8/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SesThreadGroup100% (1/1)100% (3/3)66%  (23/35)80%  (8/10)
getSes (): ScheduledExecutorService 100% (1/1)40%  (8/20)60%  (3/5)
SesThreadGroup (ThreadGroup, String): void 100% (1/1)100% (8/8)100% (3/3)
setSes (ScheduledExecutorService): void 100% (1/1)100% (7/7)100% (2/2)

1package org.jtoolkit.essence.concurrency.impl;
2 
3import org.jetbrains.annotations.Nullable;
4import org.jetbrains.annotations.NotNull;
5 
6import java.util.concurrent.ScheduledExecutorService;
7import java.lang.ref.Reference;
8import java.lang.ref.WeakReference;
9 
10/*
11   Copyright 2006 Peter Lawrey
12 
13   Licensed under the Apache License, Version 2.0 (the "License");
14   you may not use this file except in compliance with the License.
15   You may obtain a copy of the License at
16 
17       http://www.apache.org/licenses/LICENSE-2.0
18 
19   Unless required by applicable law or agreed to in writing, software
20   distributed under the License is distributed on an "AS IS" BASIS,
21   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22   See the License for the specific language governing permissions and
23   limitations under the License.
24*/
25 
26/**
27 * @author Peter Lawrey
28 */
29public class SesThreadGroup extends ThreadGroup {
30    // This has a static method as a getter.
31    @SuppressWarnings({"FieldHasSetterButNoGetter"})
32    private Reference<ScheduledExecutorService> ses = null;
33 
34    public SesThreadGroup(@NotNull ThreadGroup parent, @NotNull String name) {
35        super(parent, name);
36    }
37 
38    public void setSes(@NotNull ScheduledExecutorService executor) {
39        ses = new WeakReference<ScheduledExecutorService>(executor);
40    }
41 
42    @Nullable public static ScheduledExecutorService getSes() {
43        ThreadGroup tg = Thread.currentThread().getThreadGroup();
44        if (tg instanceof SesThreadGroup) {
45            Reference<ScheduledExecutorService> ref = ((SesThreadGroup) tg).ses;
46            return ref == null ? null : ref.get();
47        }
48        return null;
49    }
50 
51/*
52    public static ScheduledExecutorService getSesOrThrow() throws IllegalStateException {
53        ThreadGroup tg = Thread.currentThread().getThreadGroup();
54        if (tg instanceof SesThreadGroup) {
55            ScheduledExecutorService ses = ((SesThreadGroup) tg).ses;
56            if (ses == null) throw new IllegalStateException(Thread.currentThread() + ": SES not set for thread");
57            return ses;
58        }
59        throw new IllegalStateException(Thread.currentThread() + ": Not a member of an SesThreadGroup.");
60    }
61*/
62}
63 

[all classes][org.jtoolkit.essence.concurrency.impl]
EMMA 2.0.5312 (C) Vladimir Roubtsov