@StickyRepository public class InMemoryScheduledRunnableRepository implements ScheduledRunnableRepository { private List<ScheduledRunnable> schedules = new LinkedList<ScheduledRunnable>(); @Override public void schedule(ScheduledRunnable runnable) { schedules.add(runnable); } @Override public Iterator<ScheduledRunnable> iterator() { return schedules.iterator(); } }
@StickyExtension public class ClasspathResourceProtocol implements ResourceProtocol {
@StickyFramework @StickyService public class ConfiguredBeanProcessor { @Inject private ConfigurationRepository configurationRepository; @Inject private ConfiguredMetadata annotations; public void process(Object instance) { configurationRepository.register(new ForMethodOnlyBeansDummyAttribute(instance)); if (instance instanceof ConfigurationTarget) process((ConfigurationTarget) instance, instance); else process(new SimpleNameConfigurationTarget(instance), instance); } public void process(ConfigurationTarget parent, Object target) { new Reflector() .forEachField(new ConfiguredFieldProcessor(configurationRepository, annotations, parent)) .process(target); } }
@StickyRepository public class StickyResourceProtocolRegistry implements ResourceProtocolRegistry { @Inject private Set<ResourceProtocol> protocols; @Override public ResourceProtocol find(String protocol) { if (protocol == null) throw new NullPointerException("Null protocols names makes not sense"); for (ResourceProtocol p : protocols) { if (p.canResolve(protocol)) return p; } throw new ResourceProtocolNotResolvableException(protocol, protocols); } }
@StickyExtension public class PropertiesResourceCodec implements ResourceCodec<Properties> {
@StickyRepository public class JaxbFactory {
@StickyExtension public class JaxbResourceCodec<T> implements ResourceCodec<T> {
@StickyRepository public class StickyResourceCodecRegistry implements ResourceCodecRegistry { private Logger log = LoggerFactory.getLogger(getClass()); @SuppressWarnings("rawtypes") @Inject private Set<ResourceCodec> codecs; @Override public <T> ResourceCodec<T> find(CoercionTarget target) { log.info("find a codec for {}", target); ResourceCodec<T> lookup = lookup(target); log.info("found {}", lookup); return lookup; } @SuppressWarnings("unchecked") private <T> ResourceCodec<T> lookup(CoercionTarget target) { for (ResourceCodec<?> r : codecs) { if (r.isApplicableTo(target)) return (ResourceCodec<T>) r; } throw new ResourceCodecNotFoundException(target, codecs); } }
@StickyExtension public class JaxbElementResourceCodec<T> implements ResourceCodec<T> {
@StickyRepository public class AnnoTest { @Test public void howToFindMetaAnnotation() { assertThat(StickyMapper.class.isAnnotationPresent(StickyComponent.class)).isTrue(); for (Annotation a : AnnoTest.class.getAnnotations()) { assertThat(a.annotationType().isAnnotationPresent(StickyComponent.class)).isTrue(); } } @Test public void howNotToFindMetaAnnotation() { for (Annotation a : AnnoTest.class.getAnnotations()) { assertThat(a.getClass().isAnnotationPresent(StickyComponent.class)).isFalse(); } } }
@StickyExtension public class StringResourceCodec implements ResourceCodec<String> {
@StickyFramework @StickyRepository public class Repository { }
@StickyRepository @StickyFramework public class WebServiceExposureRepository implements Iterable<WebServiceExposure> { private Logger log = LoggerFactory.getLogger(WebServiceExposureRepository.class); private List<WebServiceExposure> exposures = new ArrayList<WebServiceExposure>(); public void add(Object bean, Class<?> i) { log.info("found {}", bean); exposures.add(new WebServiceExposure(bean, i)); } @Override public Iterator<net.stickycode.component.cxf.WebServiceExposure> iterator() { return exposures.iterator(); } }
@StickyFramework @StickyRepository public class InlineConfigurationRepository implements ConfigurationRepository {