public T getValue() { return bean.getValue(); }
public String getKey() { return bean.getKey().value(); }
public Class<T> getImplementationClass() { return bean.getImplementationClass(); }
public static double priorityOf(final BeanEntry<Annotation, ?> beanEntry) { try { Double priority = priorityOf(beanEntry.getKey()); if (priority == null) { priority = priorityOf(beanEntry.getImplementationClass()); if (priority == null) { priority = priorityOf(beanEntry.getValue()); if (priority == null) { return DEFAULT_PRIORITY; } } } return priority.doubleValue(); } catch (Throwable e) { return DEFAULT_PRIORITY; } }
String hint = entry.getKey().value(); String description = entry.getDescription();
public String getDescription() { return bean.getDescription(); }
public static boolean isOptional(final BeanEntry<Annotation,?> beanEntry) { try { Boolean isOptional = isOptional(beanEntry.getKey()); if (isOptional == null) { isOptional = isOptional(beanEntry.getImplementationClass()); if (isOptional == null) { isOptional = isOptional(beanEntry.getValue()); if (isOptional == null) { return false; } } } return isOptional.booleanValue(); } catch (Throwable e) { return false; } }
public static double priorityOf(final BeanEntry<Annotation, ?> beanEntry) { try { Double priority = priorityOf(beanEntry.getKey()); if (priority == null) { priority = priorityOf(beanEntry.getImplementationClass()); if (priority == null) { priority = priorityOf(beanEntry.getValue()); if (priority == null) { return DEFAULT_PRIORITY; } } } return priority.doubleValue(); } catch (Throwable e) { return DEFAULT_PRIORITY; } }
public SmoothieComponent(final BeanEntry<Annotation,T> bean) { super(null); this.bean = bean; this.value = bean.getValue(); this.priority = priorityOf(bean); }
public Iterator<PlexusBean<T>> iterator() { final List<PlexusBean<T>> plexusBeans = new ArrayList<PlexusBean<T>>( missingPlexusBeans ); final int size = plexusBeans.size(); final Iterator<BeanEntry<Named, T>> itr = beans.iterator(); for ( int numFound = 0; numFound < size && itr.hasNext(); ) { final BeanEntry<Named, T> candidate = itr.next(); final String hint = candidate.getKey().value(); for ( int i = 0; i < size; i++ ) { final PlexusBean<T> element = plexusBeans.get( i ); if ( element instanceof MissingPlexusBean<?> && hint.equals( element.getKey() ) ) { plexusBeans.set( i, new LazyPlexusBean<T>( candidate ) ); numFound++; } } } return plexusBeans.iterator(); } }
public Class<?> getType() { return getBean().getImplementationClass(); }
public static boolean isOptional(final BeanEntry<Annotation,?> beanEntry) { try { Boolean isOptional = isOptional(beanEntry.getKey()); if (isOptional == null) { isOptional = isOptional(beanEntry.getImplementationClass()); if (isOptional == null) { isOptional = isOptional(beanEntry.getValue()); if (isOptional == null) { return false; } } } return isOptional.booleanValue(); } catch (Throwable e) { return false; } }
public SmoothieComponent(final BeanEntry<Annotation,T> bean) { super(null); this.bean = bean; this.value = bean.getValue(); this.priority = priorityOf(bean); }
public Class<?> getType() { return getBean().getImplementationClass(); }
@SuppressWarnings({"unchecked"}) private CommandAction createAction(final String className) throws ClassNotFoundException { assert className != null; Class<?> type = loadClass(className); Iterator<BeanEntry<Annotation, ?>> iter = container.locate(Key.get((Class)type)).iterator(); if (iter.hasNext()) { return (CommandAction) iter.next().getValue(); } // This should really never happen throw new RuntimeException("Unable to load command action implementation: " + type); } }
public <T> T get(final Key<T> key) { Iterator<BeanEntry<Annotation,T>> iter = locate(key).iterator(); assert iter != null; if (iter.hasNext()) { BeanEntry<Annotation,T> bean = iter.next(); log.debug("Found: {}", bean); T value = bean.getValue(); // If more than one component is found, complain softly if (log.isDebugEnabled()) { if (iter.hasNext()) { log.debug("More than one instance bound for key: {}", key); while (iter.hasNext()) { log.debug(" {}", iter.next()); } } } return value; } throw new RuntimeException("No object bound for key: " + key); } }
public <T> T get(final Key<T> key) { Iterator<BeanEntry<Annotation,T>> iter = locate(key).iterator(); assert iter != null; if (iter.hasNext()) { BeanEntry<Annotation,T> bean = iter.next(); log.debug("Found: {}", bean); T value = bean.getValue(); // If more than one component is found, complain softly if (log.isDebugEnabled()) { if (iter.hasNext()) { log.debug("More than one instance bound for key: {}", key); while (iter.hasNext()) { log.debug(" {}", iter.next()); } } } return value; } throw new RuntimeException("No object bound for key: " + key); } }
private EventSpy loadDelegate() { checkState(locator != null); // Setup the Injector to load spy impls from URL[] scanPath = { getClass().getProtectionDomain().getCodeSource().getLocation(), }; URLClassSpace space = new URLClassSpace(getClass().getClassLoader(), scanPath); Injector injector = Guice.createInjector(new WireModule(new SpaceModule(space), this)); // Log what spies we know about if (log.isDebugEnabled()) { log.debug("Known spies:"); for (BeanEntry<Annotation, EventSpy> spy : locator.locate(Key.get(EventSpy.class))) { log.debug(" {}", spy); } } // Load the delegate, default to RemotingEventSpy String name = getProperty(DELEGATE_PROPERTY, RemotingEventSpy.class.getName()); log.debug("Loading delegate named: {}", name); Iterator<BeanEntry<Annotation, EventSpy>> itr = locator.locate(Key.get(EventSpy.class, Names.named(name))).iterator(); if (itr.hasNext()) { return itr.next().getValue(); } throw new RuntimeException("No such delegate: "+name); }
private EventSpy loadDelegate() { checkState(locator != null); // Setup the Injector to load spy impls from URL[] scanPath = { getClass().getProtectionDomain().getCodeSource().getLocation(), }; URLClassSpace space = new URLClassSpace(getClass().getClassLoader(), scanPath); Injector injector = Guice.createInjector(new WireModule(new SpaceModule(space), this)); // Log what spies we know about if (log.isDebugEnabled()) { log.debug("Known spies:"); for (BeanEntry<Annotation, EventSpy> spy : locator.locate(Key.get(EventSpy.class))) { log.debug(" {}", spy); } } // Load the delegate, default to RemotingEventSpy String name = getProperty(DELEGATE_PROPERTY, RemotingEventSpy.class.getName()); log.debug("Loading delegate named: {}", name); Iterator<BeanEntry<Annotation, EventSpy>> itr = locator.locate(Key.get(EventSpy.class, Names.named(name))).iterator(); if (itr.hasNext()) { return itr.next().getValue(); } throw new RuntimeException("No such delegate: "+name); }