Start migration to updated worker system

This commit is contained in:
2015-06-11 22:34:07 +01:00
parent 27868ce4dd
commit bee69c6ac0
21 changed files with 85 additions and 126 deletions

View File

@@ -18,7 +18,7 @@ package mimis.application.cmd.windows.gomplayer;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication; import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action; import mimis.value.Action;
import mimis.value.Amount; import mimis.value.Amount;
@@ -101,7 +101,7 @@ public class GomPlayerApplication extends WindowsApplication {
} }
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeSign; protected int volumeChangeSign;
public void start(int volumeChangeSign) throws ActivateException { public void start(int volumeChangeSign) throws ActivateException {
@@ -115,7 +115,7 @@ public class GomPlayerApplication extends WindowsApplication {
} }
}; };
protected class SeekWorker extends Worker { protected class SeekWorker extends ThreadWorker {
protected Amount amount; protected Amount amount;
protected int seekDirection; protected int seekDirection;

View File

@@ -17,7 +17,7 @@
package mimis.application.cmd.windows.photoviewer; package mimis.application.cmd.windows.photoviewer;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication; import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action; import mimis.value.Action;
import mimis.value.Key; import mimis.value.Key;
@@ -109,7 +109,7 @@ public class PhotoViewerApplication extends WindowsApplication {
} }
} }
protected class ZoomWorker extends Worker { protected class ZoomWorker extends ThreadWorker {
protected int zoomDirection; protected int zoomDirection;
public void start(int zoomDirection) { public void start(int zoomDirection) {

View File

@@ -17,7 +17,7 @@
package mimis.application.cmd.windows.winamp; package mimis.application.cmd.windows.winamp;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication; import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action; import mimis.value.Action;
import mimis.value.Command; import mimis.value.Command;
@@ -167,7 +167,7 @@ public class WinampApplication extends WindowsApplication {
return user(0, IPC_GETOUTPUTTIME) / 1000; return user(0, IPC_GETOUTPUTTIME) / 1000;
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeSign; protected int volumeChangeSign;
public void start(int volumeChangeSign) { public void start(int volumeChangeSign) {
@@ -181,7 +181,7 @@ public class WinampApplication extends WindowsApplication {
} }
}; };
protected class SeekWorker extends Worker { protected class SeekWorker extends ThreadWorker {
protected int seekDirection; protected int seekDirection;
public void start(int seekDirection) { public void start(int seekDirection) {

View File

@@ -16,7 +16,7 @@
*/ */
package mimis.application.cmd.windows.wmp; package mimis.application.cmd.windows.wmp;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication; import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action; import mimis.value.Action;
@@ -86,7 +86,7 @@ public class WMPApplication extends WindowsApplication {
} }
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeSign; protected int volumeChangeSign;
public void start(int volumeChangeSign) { public void start(int volumeChangeSign) {

View File

@@ -21,7 +21,7 @@ import mimis.application.Application;
import mimis.value.Action; import mimis.value.Action;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import com.dt.iTunesController.ITCOMDisabledReason; import com.dt.iTunesController.ITCOMDisabledReason;
import com.dt.iTunesController.ITTrack; import com.dt.iTunesController.ITTrack;
@@ -177,7 +177,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
public void onAboutToPromptUserToQuitEvent() {} public void onAboutToPromptUserToQuitEvent() {}
public void onSoundVolumeChangedEvent(int newVolume) {} public void onSoundVolumeChangedEvent(int newVolume) {}
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeRate; protected int volumeChangeRate;
public void start(int volumeChangeRate) { public void start(int volumeChangeRate) {

View File

@@ -18,7 +18,7 @@ package mimis.application.lirc.ipod;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.lirc.LircApplication; import mimis.application.lirc.LircApplication;
import mimis.device.lirc.remote.WC02IPOButton; import mimis.device.lirc.remote.WC02IPOButton;
import mimis.value.Action; import mimis.value.Action;
@@ -85,7 +85,7 @@ public class iPodApplication extends LircApplication {
} }
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeRate; protected int volumeChangeRate;
public void activate(int volumeChangeRate) throws ActivateException { public void activate(int volumeChangeRate) throws ActivateException {

View File

@@ -16,7 +16,7 @@
*/ */
package mimis.application.mpc; package mimis.application.mpc;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication; import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action; import mimis.value.Action;
@@ -88,7 +88,7 @@ public class MPCApplication extends WindowsApplication {
return TITLE; return TITLE;
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected int volumeChangeSign; protected int volumeChangeSign;
public void start(int volumeChangeSign) { public void start(int volumeChangeSign) {
@@ -102,7 +102,7 @@ public class MPCApplication extends WindowsApplication {
} }
}; };
protected class SeekWorker extends Worker { protected class SeekWorker extends ThreadWorker {
protected int seekDirection; protected int seekDirection;
public void start(int seekDirection) { public void start(int seekDirection) {

View File

@@ -25,7 +25,7 @@ import java.util.regex.Pattern;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.application.cmd.CMDApplication; import mimis.application.cmd.CMDApplication;
import mimis.util.Native; import mimis.util.Native;
import mimis.value.Action; import mimis.value.Action;
@@ -171,7 +171,7 @@ public class VLCApplication extends CMDApplication {
return TITLE; return TITLE;
} }
protected class VolumeWorker extends Worker { protected class VolumeWorker extends ThreadWorker {
protected String volumeChangeSign; protected String volumeChangeSign;
public void activate(String volumeChangeSign) throws ActivateException { public void activate(String volumeChangeSign) throws ActivateException {
@@ -186,7 +186,7 @@ public class VLCApplication extends CMDApplication {
} }
}; };
protected class SeekWorker extends Worker { protected class SeekWorker extends ThreadWorker {
protected Amount amount; protected Amount amount;
protected String seekDirection; protected String seekDirection;

View File

@@ -19,7 +19,7 @@ package mimis.device.javainput;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Queue; import java.util.Queue;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.exception.ButtonException; import mimis.exception.ButtonException;
import de.hardcode.jxinput.Button; import de.hardcode.jxinput.Button;
import de.hardcode.jxinput.Directional; import de.hardcode.jxinput.Directional;
@@ -33,7 +33,7 @@ import de.hardcode.jxinput.event.JXInputDirectionalEvent;
import de.hardcode.jxinput.event.JXInputDirectionalEventListener; import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
import de.hardcode.jxinput.event.JXInputEventManager; import de.hardcode.jxinput.event.JXInputEventManager;
public class JavaInputListener extends Worker implements Runnable, JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener { public class JavaInputListener extends ThreadWorker implements Runnable, JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
protected JavaInputDevice javaInputDevice; protected JavaInputDevice javaInputDevice;
protected JXInputDevice jxinputDevice; protected JXInputDevice jxinputDevice;
protected Queue<JXInputAxisEvent> axisEventQueue; protected Queue<JXInputAxisEvent> axisEventQueue;

View File

@@ -18,50 +18,43 @@ package mimis.device.lirc;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.InputMismatchException; import java.util.InputMismatchException;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Scanner; import java.util.Scanner;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.Worker;
import mimis.exception.button.UnknownButtonException; import mimis.exception.button.UnknownButtonException;
import mimis.util.Native; import mimis.util.Native;
import mimis.value.Registry; import mimis.value.Registry;
import base.exception.worker.ActivateException;
import base.server.socket.TcpClient;
public class LircService extends Worker { public class LircService extends TcpClient {
public static final String IP = "localhost"; public static final String IP = "atom";
public static final int PORT = 8765; public static final int PORT = 8765;
protected ArrayList<LircButtonListener> lircButtonListenerList; protected ArrayList<LircButtonListener> lircButtonListenerList;
protected String ip;
protected int port; // Pluggable reader and writer?
protected Socket socket; // Receive strings via callback?
protected InputStream inputStream;
protected OutputStream outputStream;
protected BufferedReader bufferedReader; protected BufferedReader bufferedReader;
protected PrintWriter printWriter; protected PrintWriter printWriter;
protected HashMap<String, LircButton[]> buttonMap; protected HashMap<String, LircButton[]> buttonMap;
protected String send; protected String send;
public LircService() { public static void main(String[] args) {
this(IP, PORT); LircService lircService = new LircService();
buttonMap = new HashMap<String, LircButton[]>(); lircService.start(false);
send = Native.getValue(Registry.CURRENT_USER, "Software\\LIRC", "password");
} }
public LircService(String ip, int port) { public LircService() {
this.ip = ip; super(IP, PORT);
this.port = port; buttonMap = new HashMap<String, LircButton[]>();
send = Native.getValue(Registry.CURRENT_USER, "Software\\LIRC", "password");
lircButtonListenerList = new ArrayList<LircButtonListener>(); lircButtonListenerList = new ArrayList<LircButtonListener>();
} }
@@ -77,44 +70,11 @@ public class LircService extends Worker {
lircButtonListenerList.remove(lircButtonListener); lircButtonListenerList.remove(lircButtonListener);
} }
public void activate() throws ActivateException { public void activate() throws ActivateException {
logger.trace("Activate LircService");
try {
socket = new Socket(ip, port);
socket.setSoTimeout(SLEEP);
inputStream = socket.getInputStream();
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
outputStream = socket.getOutputStream();
printWriter = new PrintWriter(outputStream);
} catch (UnknownHostException e) {
logger.error("", e);
throw new ActivateException();
} catch (IOException e) {
logger.error("", e);
throw new ActivateException();
}
super.activate(); super.activate();
} bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
printWriter = new PrintWriter(outputStream);
public synchronized boolean active() {
if (active && !socket.isConnected()) {
active = false;
}
return active;
}
public void deactivate() throws DeactivateException {
logger.trace("Deactivate LircService");
super.deactivate();
try {
inputStream.close();
outputStream.close();
socket.close();
} catch (IOException e) {
logger.error("", e);
}
} }
public void work() { public void work() {

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.Component; import mimis.Component;
import mimis.device.Device; import mimis.device.Device;
import mimis.input.Feedback; import mimis.input.Feedback;
@@ -83,7 +83,7 @@ public class NetworkDevice extends Component implements Device {
} }
} }
protected class Server extends Worker { protected class Server extends ThreadWorker {
protected ServerSocket serverSocket; protected ServerSocket serverSocket;
protected int port; protected int port;
@@ -138,7 +138,7 @@ public class NetworkDevice extends Component implements Device {
} }
} }
protected class Client extends Worker { protected class Client extends ThreadWorker {
protected Socket socket; protected Socket socket;
protected InputStream inputStream; protected InputStream inputStream;
protected OutputStream outputStream; protected OutputStream outputStream;

View File

@@ -40,7 +40,7 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
public class WiimoteDevice extends Component implements Device, GestureListener { public class WiimoteDevice extends Component implements Device, GestureListener {
protected static final String TITLE = "Wiimote"; protected static final String TITLE = "Wiimote";
@@ -243,7 +243,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
} }
} }
class LedWorker extends Worker { class LedWorker extends ThreadWorker {
protected ArrayCycle<Integer> ledCycle; protected ArrayCycle<Integer> ledCycle;
public LedWorker() { public LedWorker() {

View File

@@ -21,10 +21,10 @@ import java.util.Scanner;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.exception.device.DeviceNotFoundException; import mimis.exception.device.DeviceNotFoundException;
public class WiimoteDiscovery extends Worker { public class WiimoteDiscovery extends ThreadWorker {
protected static final String WIISCAN = "wiiscan"; protected static final String WIISCAN = "wiiscan";
protected static final int TIMEOUT = 1000; protected static final int TIMEOUT = 1000;
protected WiimoteDevice wiimoteDevice; protected WiimoteDevice wiimoteDevice;

View File

@@ -26,7 +26,7 @@ import java.util.ArrayList;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.Component; import mimis.Component;
import mimis.device.lirc.LircButton; import mimis.device.lirc.LircButton;
import mimis.device.lirc.remote.PhiliphsRCLE011Button; import mimis.device.lirc.remote.PhiliphsRCLE011Button;
@@ -151,7 +151,7 @@ public class MotionDevice extends Component {
} }
} }
class ReplayWorker extends Worker { class ReplayWorker extends ThreadWorker {
protected ObjectInputStream objectInputStream; protected ObjectInputStream objectInputStream;
protected int count, i, time; protected int count, i, time;

View File

@@ -16,7 +16,6 @@
*/ */
package mimis.input; package mimis.input;
public class Feedback implements Input { public class Feedback implements Input {
protected static final long serialVersionUID = 1L; protected static final long serialVersionUID = 1L;

View File

@@ -25,19 +25,19 @@ import javax.swing.JPanel;
import javax.swing.JToggleButton; import javax.swing.JToggleButton;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import base.worker.Worker; import base.worker.ThreadWorker;
public class ButtonManager extends Manager { public class ButtonManager extends Manager {
protected static final String TITLE = "Workers"; protected static final String TITLE = "Workers";
protected String title; protected String title;
protected Map<Worker, WorkerButton> buttonMap; protected Map<ThreadWorker, WorkerButton> buttonMap;
public ButtonManager(Worker... workerArray) { public ButtonManager(ThreadWorker... workerArray) {
this(TITLE, workerArray); this(TITLE, workerArray);
} }
public ButtonManager(String title, Worker... workerArray) { public ButtonManager(String title, ThreadWorker... workerArray) {
super(workerArray); super(workerArray);
this.title = title; this.title = title;
createButtons(); createButtons();
@@ -52,8 +52,8 @@ public class ButtonManager extends Manager {
} }
protected void createButtons() { protected void createButtons() {
buttonMap = new HashMap<Worker, WorkerButton>(); buttonMap = new HashMap<ThreadWorker, WorkerButton>();
for (Worker worker : workerList) { for (ThreadWorker worker : workerList) {
WorkerButton button = new WorkerButton(worker); WorkerButton button = new WorkerButton(worker);
buttonMap.put(worker, button); buttonMap.put(worker, button);
} }
@@ -85,7 +85,7 @@ public class ButtonManager extends Manager {
} }
protected void work() { protected void work() {
for (Worker worker : workerList) { for (ThreadWorker worker : workerList) {
buttonMap.get(worker).setPressed(worker.active()); buttonMap.get(worker).setPressed(worker.active());
} }
} }

View File

@@ -29,7 +29,7 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.Component; import mimis.Component;
import mimis.input.Task; import mimis.input.Task;
import mimis.router.Router; import mimis.router.Router;
@@ -41,13 +41,13 @@ import mimis.value.Target;
public class CurrentButtonManager extends ButtonManager implements ActionListener { public class CurrentButtonManager extends ButtonManager implements ActionListener {
protected Router router; protected Router router;
protected ArrayCycle<Component> componentCycle; protected ArrayCycle<Component> componentCycle;
protected Map<JRadioButton, Worker> radioButtonMap; protected Map<JRadioButton, ThreadWorker> radioButtonMap;
public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, Worker... workerArray) { public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, ThreadWorker... workerArray) {
super(title, workerArray); super(title, workerArray);
this.componentCycle = componentCycle; this.componentCycle = componentCycle;
this.router = router; this.router = router;
radioButtonMap = new HashMap<JRadioButton, Worker>(); radioButtonMap = new HashMap<JRadioButton, ThreadWorker>();
} }
public JPanel createPanel() { public JPanel createPanel() {
@@ -89,7 +89,7 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
JRadioButton radioButton = (JRadioButton) event.getSource(); JRadioButton radioButton = (JRadioButton) event.getSource();
if (radioButtonMap.containsKey(radioButton)) { if (radioButtonMap.containsKey(radioButton)) {
Worker worker = radioButtonMap.get(radioButton); ThreadWorker worker = radioButtonMap.get(radioButton);
if (componentCycle.contains(worker)) { if (componentCycle.contains(worker)) {
while (!componentCycle.current().equals(worker)) { while (!componentCycle.current().equals(worker)) {
componentCycle.next(); componentCycle.next();
@@ -100,9 +100,9 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
} }
public void currentChanged() { public void currentChanged() {
Worker worker = componentCycle.current(); ThreadWorker worker = componentCycle.current();
if (radioButtonMap.containsValue(worker)) { if (radioButtonMap.containsValue(worker)) {
for (Entry<JRadioButton, Worker> entry : radioButtonMap.entrySet()) { for (Entry<JRadioButton, ThreadWorker> entry : radioButtonMap.entrySet()) {
if (entry.getValue().equals(worker)) { if (entry.getValue().equals(worker)) {
JRadioButton radioButton = (JRadioButton) entry.getKey(); JRadioButton radioButton = (JRadioButton) entry.getKey();
radioButton.setSelected(true); radioButton.setSelected(true);

View File

@@ -20,37 +20,37 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.IntervalWorker; import base.worker.ThreadIntervalWorker;
import base.worker.Worker; import base.worker.ThreadWorker;
public class Manager extends IntervalWorker { public class Manager extends ThreadIntervalWorker {
protected static final int INTERVAL = 1000; protected static final int INTERVAL = 1000;
protected ArrayList<Worker> workerList; protected ArrayList<ThreadWorker> workerList;
public Manager(Worker... workerArray) { public Manager(ThreadWorker... workerArray) {
workerList = new ArrayList<Worker>(); workerList = new ArrayList<ThreadWorker>();
add(workerArray); add(workerArray);
} }
public void add(Worker... workerArray) { public void add(ThreadWorker... workerArray) {
workerList.addAll(Arrays.asList(workerArray)); workerList.addAll(Arrays.asList(workerArray));
} }
public void remove(Worker... workerArray) { public void remove(ThreadWorker... workerArray) {
workerList.removeAll(Arrays.asList(workerArray)); workerList.removeAll(Arrays.asList(workerArray));
} }
protected void deactivate() throws DeactivateException { protected void deactivate() throws DeactivateException {
super.deactivate(); super.deactivate();
for (Worker worker : workerList) { for (ThreadWorker worker : workerList) {
worker.stop(); worker.stop();
} }
} }
public void exit() { public void exit() {
super.exit(); super.exit();
for (Worker worker : workerList) { for (ThreadWorker worker : workerList) {
worker.exit(); worker.exit();
} }
} }
@@ -60,7 +60,7 @@ public class Manager extends IntervalWorker {
} }
protected void work() { protected void work() {
for (Worker worker : workerList) { for (ThreadWorker worker : workerList) {
worker.active(); worker.active();
} }
} }

View File

@@ -26,15 +26,15 @@ import mimis.Component;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import base.worker.Worker; import base.worker.ThreadWorker;
public class WorkerButton extends JToggleButton implements MouseListener { public class WorkerButton extends JToggleButton implements MouseListener {
protected static final long serialVersionUID = 1L; protected static final long serialVersionUID = 1L;
protected Logger logger = LoggerFactory.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
protected Worker worker; protected ThreadWorker worker;
public WorkerButton(Worker worker) { public WorkerButton(ThreadWorker worker) {
this.worker = worker; this.worker = worker;
setFocusable(false); setFocusable(false);
addMouseListener(this); addMouseListener(this);

View File

@@ -23,7 +23,7 @@ import java.net.Socket;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.worker.Worker; import base.worker.ThreadWorker;
import mimis.input.Feedback; import mimis.input.Feedback;
import mimis.input.Task; import mimis.input.Task;
@@ -60,7 +60,7 @@ public class GlobalRouter extends Router {
} }
} }
class Client extends Worker { class Client extends ThreadWorker {
protected Socket socket; protected Socket socket;
protected ObjectInputStream objectInputStream; protected ObjectInputStream objectInputStream;
protected ObjectOutputStream objectOutputStream; protected ObjectOutputStream objectOutputStream;

View File

@@ -16,11 +16,11 @@
*/ */
package mimis.util; package mimis.util;
import base.worker.Worker;
import mimis.util.multiplexer.SignalListener; import mimis.util.multiplexer.SignalListener;
import mimis.value.Signal; import mimis.value.Signal;
import base.work.Work;
public class Multiplexer<T> extends Worker { public class Multiplexer<T> extends Work {
public static final int TIMEOUT = 150; public static final int TIMEOUT = 150;
protected int threshold; protected int threshold;
@@ -37,12 +37,12 @@ public class Multiplexer<T> extends Worker {
} }
public synchronized void add(T object) { public synchronized void add(T object) {
if (this.type == null) { if (type == null) {
signalListener.add(Signal.BEGIN, object); signalListener.add(Signal.BEGIN, object);
this.type = object; type = object;
end = true; end = true;
start(); start();
} else if (this.type.equals(object)) { } else if (type.equals(object)) {
end = false; end = false;
notifyAll(); notifyAll();
} else { } else {
@@ -54,7 +54,7 @@ public class Multiplexer<T> extends Worker {
} }
} }
protected void work() { public void work() {
try { try {
synchronized (this) { synchronized (this) {
wait(TIMEOUT); wait(TIMEOUT);