Fix NPE for StreamWatchdog

The instance of StreamWatchdog should be discarded once calling
shutdown. If call twice, NPE is raised.

This patch prevents it.
Fix comments
Fix shutdown process

shutdownInProgress is flag. It is accessed from more than 2 threads.
When read this, it has possibility not to be able to get the latest
value which was written by other threads. This is caused by Java memory
model.

To avoid this, shutdownInProgress should be declared as volatile
variable. Then all threads can read/write value to it synchronously.

As a result, brute force related code and synchronized object can be
discarded.

For keeping secure, setter for this flag is changed to no parameters.
Remove connecting flag

Now "connecting" has been used to determine whether disconnect ssh
connection. But it is not needed by devising shutdown logic.
Refactor ssh connection loop
fix notification point for connection event

Now connection established and connection down are notified to handler at
the below timing.

* ssh connection established / down
* gerrit stream-events established / down

These established/down events are notified to handler without connecton
type. It should be separated.

But now handler is mainly for stream events, so ones for ssh connection
are not needed.

So this patch stops notification for ssh connection.

In the future, it is better to implement notification for ssh connection
as new interface if needed.
Add interface to check connection status
Merge pull request #66 from rinrinne/watchdog-npe

Fix NPE for StreamWatchdog
Merge pull request #67 from rinrinne/connection-changes

Fixes for GerritConnection
Revert "Merge pull request #67 from rinrinne/connection-changes"

This reverts commit 8b43697d4db690de45cf153a0ebf5ede4fab4bed, reversing
changes made to 028eb17efe1e456a2dd4316a4cb74385745ea302.
Fixing a test regression
Fix merge conflict.

Conflicts:
	gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/DuplicateGerritListenersHudsonTestCase.java

Change-Id: I44da83088dc1f5e8754c59c0633a6914676ac1a7