Hi all,
I have a question on how to solve a situation were I have classes that
uses generics, and they are part of an infrastructure.
The usage differentiated only by the <T> generics.
Example:
I have BlockingQueueWrapper: public interface BlockingQueueWrapper<T>
{...}
and an impl:
public class BlockingQueueWrapperImpl<T> implements
BlockingQueueWrapper<T> {
@Inject
@Singleton
public BlockingQueueWrapperImpl(@Named("QUEUE_POLL_TIMEOUT") long
pollTimeoutMilliseconds, @Named("QUEUE_CAPACITY") int queueCapacity)
{...}
}
and I am using several queues in the application (each with different
generic type T (and actually I need to give them different capacity).
Non Guice example: BlockingQueueWrapper<ChunkItem> usersQueue = new
BlockingQueueWrapperImpl<ChunkItem>(...);
the only way I found in Guice was to create a concrete class for each
queue, and then call it.
I used AnnotedWith to inject to the dependent classes the queues, but
I could not avoid creating a special queue that inherits the Impl.
Example:
public class QueueChunkItems extends BlockingQueueWrapper<ChunkItem> {
@Inject
@Singleton
public QueueChunkItems(@Named("QUEUE_POLL_TIMEOUT") long
pollTimeoutMilliseconds, @Named("chunkItemsQueueCapacity") int
queueCapacity) {
super(pollTimeoutMilliseconds, queueCapacity);
}
}
and:
bind(new TypeLiteral<HermesBlockingQueue<ChunkItem>>() {
}).annotatedWith((Names.named("QueueChunks"))).to(QueueChunkItems.class).asEagerSingleton();
the thing I find irritating is that we have several classes of that
behavior (not only the queues).
So in order to convince my teammates, how can I respond to their
argument : "because of Guice we need more dummy, empty classes. Where
is the benefit?"
thanks
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.