M
marvind
Hello,
I have to implement two sets of connection pools - one for JDBC
connections and the other for connections to HP service desk.
I guess I could use an abstract factory but I found out that I have to
duplicate a lot of code, mainly:
1. Making a lot of classes singletons
2. Write essentially the same connection pool class that contains the
hashtable
I tried using generics for both 1 (SingletonHolder) and 2 but I ran
into the following problems in both cases:
Due to Java's implementation of generics, I cannot declare a static
field with unknown type or in static methods.
So, my question is code duplication unavoidable (note all methods are
static and the application is multithreaded, so you may have to lock on
the class in some cases) or is there an elegant solution that I am
missing?
Thanks,
mar
I have to implement two sets of connection pools - one for JDBC
connections and the other for connections to HP service desk.
I guess I could use an abstract factory but I found out that I have to
duplicate a lot of code, mainly:
1. Making a lot of classes singletons
2. Write essentially the same connection pool class that contains the
hashtable
I tried using generics for both 1 (SingletonHolder) and 2 but I ran
into the following problems in both cases:
Due to Java's implementation of generics, I cannot declare a static
field with unknown type or in static methods.
So, my question is code duplication unavoidable (note all methods are
static and the application is multithreaded, so you may have to lock on
the class in some cases) or is there an elegant solution that I am
missing?
Thanks,
mar