I want to create a factory which will create a smack XMPPConnection. The factory should return the real XMPPConnection or a NullObject if the connection could not be made.
However smack’s XMPPConnection is a concrete class.
It does not implement any interfaces, so I can’t use java dynamic proxy API to proxy the sucker. I could extend the XMPPConnection but that’s not very elegant.
Are there any other options ? Note that the factory must never return a null !
You would have to create your own interface that basically duplicates the XMPPConnection and create an Adapter that implements that interface and wrapps the real XMPPConnection class. That way you could have a NullXMPPConnection as well.