Hello there,

I am currently implementing some code for talking to various devices through 
SSH and in order to set up a test framework, I have decided to use Mina SSHD in 
my testing framework for simulating the various devices.

I used the EchoShellFactory class in the test directory as a starting point, 
and rewrote the run() method in it which is working perfectly.

Now, I might have to emulate quite a few devices so copying the entire code in 
each instance would involve quite a lot of code duplication, which is naturally 
bad. I have therefore looked at ways to avoid this duplication and here is my 
problem.

I have tried to remove the run() method from the ShellFactory, make the class 
abstract and the reimplement this method in subclasses emulating each device. 
Additionally, I have tried giving the ShellFactory class a class implementing 
Runnable as an argument to its constructor and then use that for spawning the 
thread.

In both cases, the destroy method on the Command interface gets called before 
my run() method has finished doing its work resulting in an 
InterruptedIOException in my read() call. That never happens if I reimplement 
the entire class for each device.

I must admit I am far from an expert Java programmer, so if this is more a 
general Java question and not specific to Mina SSHD, please excuse me and I 
will take my question elsewhere, but I thought I would try here and see if 
anyone had a clue on to what is going on.

Thanks a lot for any help!

--
Venlig hilsen/Kind regards,

Kasper Laudrup
Developer
Code3 ApS

Reply via email to