public Class<T> getImplementationClass() { return bean.getImplementationClass(); }
@Override public Class<?> getScannableClass() { return entry.getImplementationClass(); }
public BeanEntryCommand(final BeanLocator beanLocator, final BeanEntry<?, Action> beanEntry) { super(beanEntry.getImplementationClass()); this.beanLocator = checkNotNull(beanLocator); this.beanEntry = checkNotNull(beanEntry); }
public Set<Class<?>> getEntryTypes() { if (entryTypes.size() < 1) { for (BeanEntry<ConfigurationEntry, Object> entry : entries) { Class<?> clazz = entry.getImplementationClass(); entryTypes.add(clazz); } } return ImmutableSet.copyOf(entryTypes); }
@Nullable @Override public Class<?> apply(final BeanEntry<Annotation, DirectComponent> input) { Class<DirectComponent> implementationClass = input.getImplementationClass(); log.debug("Registering Ext.Direct component '{}'", implementationClass); return implementationClass; } })
@Nullable @Override public Class<?> apply(final BeanEntry<Annotation, DirectComponent> input) { Class<DirectComponent> implementationClass = input.getImplementationClass(); log.debug("Registering Ext.Direct component '{}'", implementationClass); return implementationClass; } })
private void findResources() { log.debug("Finding resources"); for (BeanEntry<Annotation, Resource> entry : container.locate(Key.get(Resource.class))) { Class<?> type = entry.getImplementationClass(); Path path = type.getAnnotation(Path.class); if (path != null) { log.debug("Adding resource: {} -> {}", path.value(), type); classes.add(type); } } log.debug("Found {} resources", classes.size()); } }
private void checkDefaultBinding( final Class<?> api, final Class<?> imp ) { final Annotation defaultName = Names.named( "default" ); assertSame( imp, locator.locate( Key.get( api ) ).iterator().next().getImplementationClass() ); assertSame( imp, locator.locate( Key.get( api, Named.class ) ).iterator().next().getImplementationClass() ); assertSame( imp, locator.locate( Key.get( api, defaultName ) ).iterator().next().getImplementationClass() ); }
private void checkNamedBinding( final Class<?> api, final String name, final Class<?> imp ) { assertSame( imp, locator.locate( Key.get( api, Names.named( name ) ) ).iterator().next().getImplementationClass() ); }
private void checkLegacyBinding( final Class<?> api, final Class<?> imp ) { assertSame( imp, locator.locate( Key.get( api, Legacy.class ) ).iterator().next().getImplementationClass() ); }
private void findComponents() { log.debug("Finding components"); for (BeanEntry<Annotation, Component> entry : container.locate(Key.get(Component.class))) { log.trace("Found: {}", entry); Class<?> type = entry.getImplementationClass(); if (Resource.class.isAssignableFrom(type)) { // only add resources which are annotated with a path Path path = type.getAnnotation(Path.class); if (path != null) { log.debug("Adding resource: {} -> {}", path.value(), type); //noinspection unchecked resources.add((Class<Resource>) type); } } else { log.debug("Adding component: {}", type); components.add(type); } } classes.addAll(resources); classes.addAll(components); // TODO: Support singleton component discovery log.debug("Found {} components", classes.size()); } }
@Override public void add(final BeanEntry<Named, Action> beanEntry, final BundleContext bundleContext) throws Exception { Command command = beanEntry.getImplementationClass().getAnnotation(Command.class); if (command != null) { log.debug("Registering command: {}", beanEntry); sessionFactory.getRegistry().register(new BeanEntryCommand(beanLocator, beanEntry)); } else { log.warn("Missing @Command annotation on action: {}", beanEntry); } }
@Override public void remove(final BeanEntry<Named, Action> beanEntry, final BundleContext bundleContext) throws Exception { Command command = beanEntry.getImplementationClass().getAnnotation(Command.class); if (command != null) { log.debug("Unregistering command: {}", beanEntry); sessionFactory.getRegistry().unregister(new BeanEntryCommand(beanLocator, beanEntry)); } } }
@Override public void removeComponent(final BeanEntry<?, ?> entry) throws Exception { Class<?> type = entry.getImplementationClass(); if (isResource(type)) { getDispatcher().getRegistry().removeRegistrations(type); String path = resourcePath(type); log.debug("Removed resource: {} with path: {}", type.getName(), path); } else { ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory(); if (providerFactory instanceof SisuResteasyProviderFactory) { ((SisuResteasyProviderFactory) providerFactory).removeRegistrations(type); log.debug("Removed component: {}", type.getName()); } else { log.warn("Component removal not supported; Unable to remove component: {}", type.getName()); } } } }
@Override public void addComponent(final BeanEntry<?, ?> entry) throws Exception { Class<?> type = entry.getImplementationClass(); if (isResource(type)) { getDispatcher().getRegistry().addResourceFactory(new SisuResourceFactory(entry)); String path = resourcePath(type); if (path == null) { log.warn("Found resource implementation missing @Path: {}", type.getName()); } else { log.debug("Added resource: {} with path: {}", type.getName(), path); } } else { // TODO: Doesn't seem to be a late-biding/factory here so we create the object early getDispatcher().getProviderFactory().register(entry.getValue()); log.debug("Added component: {}", type.getName()); } }