org.springframework.context.ApplicationEvent.getSource()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(27)

本文整理了Java中org.springframework.context.ApplicationEvent.getSource()方法的一些代码示例,展示了ApplicationEvent.getSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationEvent.getSource()方法的具体详情如下:
包路径:org.springframework.context.ApplicationEvent
类名称:ApplicationEvent
方法名:getSource

ApplicationEvent.getSource介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

/**
   * Get {@link ServiceBean} instance
   *
   * @return non-null
   */
  public ServiceBean getServiceBean() {
    return (ServiceBean) super.getSource();
  }
}

代码示例来源:origin: apache/incubator-dubbo

/**
   * Get {@link ServiceBean} instance
   *
   * @return non-null
   */
  public ServiceBean getServiceBean() {
    return (ServiceBean) super.getSource();
  }
}

代码示例来源:origin: spring-projects/spring-security

/**
   * Getters for the <code>Authentication</code> request that caused the event. Also
   * available from <code>super.getSource()</code>.
   *
   * @return the authentication request
   */
  public Authentication getAuthentication() {
    return (Authentication) super.getSource();
  }
}

代码示例来源:origin: org.springframework.security/spring-security-core

/**
   * Getters for the <code>Authentication</code> request that caused the event. Also
   * available from <code>super.getSource()</code>.
   *
   * @return the authentication request
   */
  public Authentication getAuthentication() {
    return (Authentication) super.getSource();
  }
}

代码示例来源:origin: org.springframework.boot/spring-boot

/**
 * Access the source of the event (an {@link WebServer}).
 * @return the embedded web server
 */
@Override
public WebServer getSource() {
  return (WebServer) super.getSource();
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@SuppressWarnings({ "unchecked" })
@Override
public T getSource() {
  return (T) super.getSource();
}

代码示例来源:origin: spring-projects/spring-data-redis

public byte[] getSource() {
  return (byte[]) super.getSource();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (event.getSource() == this.source) {
    onApplicationEventInternal(event);
  }
}

代码示例来源:origin: org.springframework/spring-context

@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (event.getSource() == this.source) {
    onApplicationEventInternal(event);
  }
}

代码示例来源:origin: spring-projects/spring-security

public void onApplicationEvent(ApplicationEvent event) {
  if (event == null) {
    return;
  }
  for (SmartApplicationListener listener : listeners) {
    Object source = event.getSource();
    if (source != null && listener.supportsEventType(event.getClass())
        && listener.supportsSourceType(source.getClass())) {
      listener.onApplicationEvent(event);
    }
  }
}

代码示例来源:origin: org.springframework.security/spring-security-core

public void onApplicationEvent(ApplicationEvent event) {
  if (event == null) {
    return;
  }
  for (SmartApplicationListener listener : listeners) {
    Object source = event.getSource();
    if (source != null && listener.supportsEventType(event.getClass())
        && listener.supportsSourceType(source.getClass())) {
      listener.onApplicationEvent(event);
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

ApplicationEvent event, ResolvableType eventType) {
Object source = event.getSource();
Class<?> sourceType = (source != null ? source.getClass() : null);
ListenerCacheKey cacheKey = new ListenerCacheKey(eventType, sourceType);

代码示例来源:origin: org.springframework/spring-context

ApplicationEvent event, ResolvableType eventType) {
Object source = event.getSource();
Class<?> sourceType = (source != null ? source.getClass() : null);
ListenerCacheKey cacheKey = new ListenerCacheKey(eventType, sourceType);

代码示例来源:origin: spring-projects/spring-security

@Test
public void processEventSuccess() {
  when(delegate.supportsEventType(event.getClass())).thenReturn(true);
  when(delegate.supportsSourceType(event.getSource().getClass())).thenReturn(true);
  listener.onApplicationEvent(event);
  verify(delegate).onApplicationEvent(event);
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@SuppressWarnings({ "unchecked" })
@Override
public T getSource() {
  return (T) super.getSource();
}

代码示例来源:origin: org.apache.camel/camel-spring

@Override
public EventEndpoint getSource() {
  return (EventEndpoint) super.getSource();
}

代码示例来源:origin: spring-projects/spring-integration

@Override
  public void onApplicationEvent(ApplicationEvent event) {
    MessageHistory history = MessageHistory.read((Message<?>) event.getSource());
    Properties adapterHistory = history.get(1);
    assertEquals("myAdapter", adapterHistory.get("name"));
    assertEquals("outbound-channel-adapter", adapterHistory.get("type"));
  }
};

代码示例来源:origin: spring-projects/spring-integration

@Test //INT-2275
public void testInsideChain() {
  this.receivedEvent = false;
  ApplicationListener<?> listener = event -> {
    Object source = event.getSource();
    if (source instanceof Message) {
      String payload = (String) ((Message<?>) source).getPayload();
      if (payload.equals("foobar")) {
        receivedEvent = true;
      }
    }
  };
  this.context.addApplicationListener(listener);
  DirectChannel channel = context.getBean("inputChain", DirectChannel.class);
  channel.send(new GenericMessage<String>("foo"));
  Assert.assertTrue(this.receivedEvent);
}

代码示例来源:origin: spring-projects/spring-integration

@Test
public void withAdvice() {
  this.receivedEvent = false;
  ApplicationListener<?> listener = event -> {
    Object source = event.getSource();
    if (source instanceof Message) {
      String payload = (String) ((Message<?>) source).getPayload();
      if (payload.equals("hello")) {
        receivedEvent = true;
      }
    }
  };
  context.addApplicationListener(listener);
  DirectChannel channel = context.getBean("inputAdvice", DirectChannel.class);
  channel.send(new GenericMessage<String>("hello"));
  Assert.assertTrue(this.receivedEvent);
  Assert.assertEquals(1, adviceCalled);
}

代码示例来源:origin: spring-projects/spring-integration

@Test
public void anyApplicationEventSentByDefault() {
  QueueChannel channel = new QueueChannel();
  ApplicationEventListeningMessageProducer adapter = new ApplicationEventListeningMessageProducer();
  adapter.setOutputChannel(channel);
  adapter.start();
  Message<?> message1 = channel.receive(0);
  assertNull(message1);
  assertTrue(adapter.supportsEventType(ResolvableType.forClass(TestApplicationEvent1.class)));
  adapter.onApplicationEvent(new TestApplicationEvent1());
  assertTrue(adapter.supportsEventType(ResolvableType.forClass(TestApplicationEvent2.class)));
  adapter.onApplicationEvent(new TestApplicationEvent2());
  Message<?> message2 = channel.receive(20);
  assertNotNull(message2);
  assertEquals("event1", ((ApplicationEvent) message2.getPayload()).getSource());
  Message<?> message3 = channel.receive(20);
  assertNotNull(message3);
  assertEquals("event2", ((ApplicationEvent) message3.getPayload()).getSource());
}

相关文章

最新文章

更多