Java 类org.springframework.beans.factory.NamedBean 实例源码

项目:spring4-understanding    文件:ExposeBeanNameAdvisorsTests.java   
@Test
public void testWithIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();

    assertTrue("Introduction was made", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();

    NamedBean nb = (NamedBean) proxy;
    assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
项目:jetstream    文件:DataFlows.java   
public void popuateGraph(String beanName,
        DefaultListableBeanFactory beanFactory, DirectedGraph<String> dg) {
    Object object = beanFactory.getBean(beanName);
    if (object instanceof EventSource) {
        Collection<EventSink> eventSinks = ((EventSource) object)
                .getEventSinks();
        for (EventSink eventSink : eventSinks) {
            if (eventSink != null) {
                boolean isNodeNotExistsed = dg.addNode(eventSink
                        .getBeanName());
                dg.addEdge(beanName, eventSink.getBeanName());
                if (isNodeNotExistsed) {
                    popuateGraph(eventSink.getBeanName(), beanFactory, dg);
                }
            }
        }
    } else if (object instanceof NamedBean) {
        dg.addNode(beanName);
    } else {
        throw new RuntimeException("should not happen!!");
    }
}
项目:jetstream    文件:AbstractEventSource.java   
/**
 * 
 * @param pauseEvent
 */
public void processPauseEvent(PauseEvent pauseEvent) {
    Object eventSource = pauseEvent.getSource();
    NamedBean bean = (NamedBean) eventSource;
    Collection<EventSink> eventSinks = getEventSinks();
    if (eventSinks != null) {
        for (EventSink eventSink : eventSinks) {
            if (bean.getBeanName()
                    .equalsIgnoreCase(eventSink.getBeanName())) {
                removeEventSink(eventSink);
                m_pausedEventSink.add(eventSink);
            }
        }
        if (isEventFromTheSink(getPausedEventSink(), bean.getBeanName())
                && m_pauseIfAnyEventSinkPauses && !m_isSourcePaused.get()) {
            m_isSourcePaused.set(true);
            pause();
        } else if (isEventFromTheSink(getPausedEventSink(),
                bean.getBeanName())
                && getEventSinks().size() == 0 && !m_isSourcePaused.get()) {
            m_isSourcePaused.set(true);
            pause();
        }
    }
}
项目:class-guard    文件:ExposeBeanNameAdvisorsTests.java   
@Test
public void testWithIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();

    assertTrue("Introduction was made", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();

    NamedBean nb = (NamedBean) proxy;
    assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
项目:spring4-understanding    文件:ExposeBeanNameAdvisorsTests.java   
@Test
public void testNoIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();

    assertFalse("No introduction", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();
}
项目:jetstream    文件:AbstractEventSource.java   
/**
 * 
 * @param resumeEvent
 */
public void processResumeEvent(ResumeEvent resumeEvent) {
    Object eventSource = resumeEvent.getSource();
    NamedBean bean = (NamedBean) eventSource;
    List<EventSink> eventSinks = new ArrayList<EventSink>();
    eventSinks
            .addAll(Collections.unmodifiableCollection(m_pausedEventSink));
    if (eventSinks != null) {
        for (EventSink eventSink : eventSinks) {
            if (bean.getBeanName()
                    .equalsIgnoreCase(eventSink.getBeanName())) {
                addEventSink(eventSink);
                m_pausedEventSink.remove(eventSink);
            }
        }
        if (isEventFromTheSink(eventSinks, bean.getBeanName())
                && m_pauseIfAnyEventSinkPauses
                && getPausedEventSink().size() == 0
                && m_isSourcePaused.get()) {
            m_isSourcePaused.set(false);
            resume();
        } else if (isEventFromTheSink(eventSinks, bean.getBeanName())
                && !m_pauseIfAnyEventSinkPauses
                && getEventSinks().size() > 0 && m_isSourcePaused.get()) {
            m_isSourcePaused.set(false);
            resume();
        }
    }
}
项目:class-guard    文件:ExposeBeanNameAdvisorsTests.java   
@Test
public void testNoIntroduction() {
    String beanName = "foo";
    TestBean target = new RequiresBeanNameBoundTestBean(beanName);
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
    ITestBean proxy = (ITestBean) pf.getProxy();

    assertFalse("No introduction", proxy instanceof NamedBean);
    // Requires binding
    proxy.getAge();
}
项目:jetstream    文件:EPLBeanRecoveryEvent.java   
public boolean isChangedBean(NamedBean bean) {
    return bean != null && getBeanName().equals(bean.getBeanName());
}
项目:jetstream    文件:EPLBeanSuccessEvent.java   
public boolean isChangedBean(NamedBean bean) {
    return bean != null && getBeanName().equals(bean.getBeanName());
}
项目:jetstream    文件:ContextBeanChangedEvent.java   
public boolean isChangedBean(NamedBean bean) {
  return bean != null && getBeanName().equals(bean.getBeanName());
}
项目:jetstream    文件:JetstreamEvent.java   
/**
 * Any caller is required to pass a source Identifier which will be part of the log message. The 
 * implementation of this method must add the event ID to the log message along with the passed source Identifier
 * 
 * @param source
 * @return
 */
public void log(NamedBean source) {
    LOGGER.debug( "eventSource=" + source.getBeanName() + "&eventId = " + getEventId());
}