]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/test/ExampleObject.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / test / ExampleObject.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 /*
13  *
14  * @author Toni Kalajainen
15  */
16 package org.simantics.utils.threads.test;
17
18 import java.lang.reflect.Method;
19
20 import org.simantics.utils.threads.IThreadWorkQueue;
21 import org.simantics.utils.threads.SyncListenerList;
22
23
24 public class ExampleObject {
25
26         SyncListenerList<ExampleListener> listeners = new SyncListenerList<ExampleListener>(ExampleListener.class);
27         
28         public void addListener(IThreadWorkQueue thread, ExampleListener l)
29         {
30                 listeners.add(thread, l);               
31         }
32         
33         public void removeListener(IThreadWorkQueue thread, ExampleListener l)
34         {
35                 listeners.remove(thread, l);
36         }
37         
38         static final Method onMessage = SyncListenerList.getMethod(ExampleListener.class, "onMessage");
39         public void fireMessage(String message)
40         {
41                 listeners.fireEventSync(onMessage, this, message);
42         }
43         
44 }