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

COVERAGE SUMMARY FOR SOURCE FILE [ThreadedCallbackImpl.java]

nameclass, %method, %block, %line, %
ThreadedCallbackImpl.java100% (3/3)100% (8/8)81%  (79/98)83%  (15/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ThreadedCallbackImpl100% (1/1)100% (4/4)76%  (44/58)89%  (8/9)
onException (Throwable): void 100% (1/1)50%  (14/28)75%  (3/4)
ThreadedCallbackImpl (Callback): void 100% (1/1)100% (4/4)100% (2/2)
onCallback (Object): void 100% (1/1)100% (10/10)100% (2/2)
toString (): String 100% (1/1)100% (16/16)100% (1/1)
     
class ThreadedCallbackImpl$1100% (1/1)100% (2/2)78%  (18/23)67%  (4/6)
call (): Void 100% (1/1)64%  (9/14)60%  (3/5)
ThreadedCallbackImpl$1 (ThreadedCallbackImpl, Object): void 100% (1/1)100% (9/9)100% (1/1)
     
class ThreadedCallbackImpl$2100% (1/1)100% (2/2)100% (17/17)100% (3/3)
ThreadedCallbackImpl$2 (ThreadedCallbackImpl, Throwable): void 100% (1/1)100% (9/9)100% (1/1)
run (): void 100% (1/1)100% (8/8)100% (2/2)

1package org.jtoolkit.essence.concurrency.impl;
2 
3import org.jetbrains.annotations.NotNull;
4import org.jetbrains.annotations.Nullable;
5import org.jtoolkit.essence.concurrency.Callback;
6import org.jtoolkit.essence.concurrency.CallbackEx;
7import org.jtoolkit.essence.app.Main;
8 
9import java.util.concurrent.Callable;
10 
11/*
12   Copyright 2006 Peter Lawrey
13 
14   Licensed under the Apache License, Version 2.0 (the "License");
15   you may not use this file except in compliance with the License.
16   You may obtain a copy of the License at
17 
18       http://www.apache.org/licenses/LICENSE-2.0
19 
20   Unless required by applicable law or agreed to in writing, software
21   distributed under the License is distributed on an "AS IS" BASIS,
22   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23   See the License for the specific language governing permissions and
24   limitations under the License.
25*/
26 
27/**
28 * @author Peter Lawrey
29 */
30 
31public class ThreadedCallbackImpl<T> extends ThreadedCallback<T> {
32    public ThreadedCallbackImpl(Callback<T> callback) {
33        super(callback);
34    }
35 
36    public void onCallback(@NotNull final T value) throws IllegalStateException {
37        getExecutorOrFail().submit(new Callable<Void>() {
38            @Nullable public Void call() {
39                try {
40                    callback.onCallback(value);
41                } catch (Exception e) {
42                    handleException(e);
43                }
44                return null;
45            }
46        });
47    }
48 
49    public void onException(@NotNull final Throwable t) throws IllegalStateException {
50        if (callback instanceof CallbackEx)
51            getExecutorOrFail().execute(new Runnable() {
52                public void run() {
53                    ((CallbackEx) callback).onException(t);
54                }
55            });
56        else
57            LOG.warn(Thread.currentThread().getName() + ": " + Main.UNHANDLED_EXCEPTION, t);
58    }
59 
60    public String toString() {
61        return "TCI exec " + executor.get() + " callback " + callback;
62    }
63}

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