Skip to content

Instantly share code, notes, and snippets.

@normanmaurer
Created March 10, 2014 10:13
Show Gist options
  • Select an option

  • Save normanmaurer/9462420 to your computer and use it in GitHub Desktop.

Select an option

Save normanmaurer/9462420 to your computer and use it in GitHub Desktop.
private static final Map<Class<?>, Boolean> SHARABLE_CACHE = PlatformDependent.newConcurrentHashMap();
// Not using volatile because it's used only for a sanity check.
boolean added;
/**
* Return {@code true} if the implementation is {@link Sharable} and so can be added
* to different {@link ChannelPipeline}s.
*/
public boolean isSharable() {
Class<?> clazz = getClass();
Boolean sharable = SHARABLE_CACHE.get(clazz);
if (sharable == null) {
sharable = clazz.isAnnotationPresent(Sharable.class);
SHARABLE_CACHE.put(clazz, sharable);
}
return sharable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment