xp-forge/easc — pull request #1 by pdietz (2013-02-21 12:04:22+00:00)
Title: Fix lost lookup references

#### Problem
Lookups are _only_ stored as WeakReference within the ServerContext. This means, that as soon as the GC runs they get collected.
Further calls of the same client, that rely on a still existent lookup will fail with an IOException with the message being either
```
Object referenced by 33120418 has been destroyed
```
or
```
Cannot find object referenced by 33120418 in server context net.xp_framework.easc.server.InvocationServerContext@8b5441b)
```
The message depends on the current status of the ReferenceCleaner, which removes keys pointing to null values (collected WeakReferences).

#### Fix
The fix introduces a strong reference to those lookups beside the weak one in the ServerContext.
The strong references are stored within the scope of the method handling one client connection.
Thus those strong references will be removed once the connection is closed/terminated.
This will ensure that the references to the lookups will at least live as long as the current connection lives.
If there are no more strong references to a lookup in any client connection, the GC will collect the WeakReferences.

#### Annotations
The implementation is not as good as it could be, since it introduces deeper knowledge about available delegates to the handle()-method it should not have.
A better approach would be to introduce a HandlerContext, only valid within one handler, that get's passed over to the Delegates, so the LookupDelegate could handle the caching/referencing (strong/weak) all by itself.
However the current implementation is simple/quite centralized and does not introduce lots of changes in lots of places, thus possible erroneous impacts should be small.