HHH-7030 - EventListenerRegistry interface generic declaration is not extensible to subclasses

This commit is contained in:
Steve Ebersole 2012-02-08 07:36:21 -06:00
parent 4595df2395
commit 79774a0453
2 changed files with 7 additions and 7 deletions

View File

@ -115,12 +115,12 @@ public class EventListenerRegistryImpl implements EventListenerRegistry {
} }
@Override @Override
public <T> void setListeners(EventType<T> type, Class<T>... listenerClasses) { public <T> void setListeners(EventType<T> type, Class<? extends T>... listenerClasses) {
setListeners( type, resolveListenerInstances( type, listenerClasses ) ); setListeners( type, resolveListenerInstances( type, listenerClasses ) );
} }
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})
private <T> T[] resolveListenerInstances(EventType<T> type, Class<T>... listenerClasses) { private <T> T[] resolveListenerInstances(EventType<T> type, Class<? extends T>... listenerClasses) {
T[] listeners = (T[]) Array.newInstance( type.baseListenerInterface(), listenerClasses.length ); T[] listeners = (T[]) Array.newInstance( type.baseListenerInterface(), listenerClasses.length );
for ( int i = 0; i < listenerClasses.length; i++ ) { for ( int i = 0; i < listenerClasses.length; i++ ) {
listeners[i] = resolveListenerInstance( listenerClasses[i] ); listeners[i] = resolveListenerInstance( listenerClasses[i] );
@ -162,7 +162,7 @@ public class EventListenerRegistryImpl implements EventListenerRegistry {
} }
@Override @Override
public <T> void appendListeners(EventType<T> type, Class<T>... listenerClasses) { public <T> void appendListeners(EventType<T> type, Class<? extends T>... listenerClasses) {
appendListeners( type, resolveListenerInstances( type, listenerClasses ) ); appendListeners( type, resolveListenerInstances( type, listenerClasses ) );
} }
@ -172,7 +172,7 @@ public class EventListenerRegistryImpl implements EventListenerRegistry {
} }
@Override @Override
public <T> void prependListeners(EventType<T> type, Class<T>... listenerClasses) { public <T> void prependListeners(EventType<T> type, Class<? extends T>... listenerClasses) {
prependListeners( type, resolveListenerInstances( type, listenerClasses ) ); prependListeners( type, resolveListenerInstances( type, listenerClasses ) );
} }

View File

@ -39,12 +39,12 @@ public interface EventListenerRegistry extends Service, Serializable {
public void addDuplicationStrategy(DuplicationStrategy strategy); public void addDuplicationStrategy(DuplicationStrategy strategy);
public <T> void setListeners(EventType<T> type, Class<T>... listeners); public <T> void setListeners(EventType<T> type, Class<? extends T>... listeners);
public <T> void setListeners(EventType<T> type, T... listeners); public <T> void setListeners(EventType<T> type, T... listeners);
public <T> void appendListeners(EventType<T> type, Class<T>... listeners); public <T> void appendListeners(EventType<T> type, Class<? extends T>... listeners);
public <T> void appendListeners(EventType<T> type, T... listeners); public <T> void appendListeners(EventType<T> type, T... listeners);
public <T> void prependListeners(EventType<T> type, Class<T>... listeners); public <T> void prependListeners(EventType<T> type, Class<? extends T>... listeners);
public <T> void prependListeners(EventType<T> type, T... listeners); public <T> void prependListeners(EventType<T> type, T... listeners);
} }