@Override public void afterReceive(boolean messageReceived, MessageSource<?> source) { if (this.logger.isTraceEnabled()) { this.logger.trace("Poll produced " + (messageReceived ? "a" : "no") + " message"); } this.factory.clearThreadKey(); if (!this.fair && !messageReceived) { configureSource(source); } }
@Override public Session<F> getSession() { return getSession(this.threadKey.get()); }
@Override public void beforeReceive(MessageSource<?> source) { if (this.fair || !this.initialized) { configureSource(source); this.initialized = true; } if (this.logger.isTraceEnabled()) { this.logger.trace("Next poll is for " + this.current); } this.factory.setThreadKey(this.current.getKey()); }
@Test public void testDelegates() { assertEquals(foo.mockSession, this.dsf.getSession("foo")); assertEquals(bar.mockSession, this.dsf.getSession("bar")); assertEquals(bar.mockSession, this.dsf.getSession("junk")); assertEquals(bar.mockSession, this.dsf.getSession()); this.dsf.setThreadKey("foo"); assertEquals(foo.mockSession, this.dsf.getSession("foo")); this.dsf.clearThreadKey(); TestSessionFactory factory = new TestSessionFactory(); this.sessionFactoryLocator.addSessionFactory("baz", factory); this.dsf.setThreadKey("baz"); assertEquals(factory.mockSession, this.dsf.getSession("baz")); this.dsf.clearThreadKey(); assertSame(factory, sessionFactoryLocator.removeSessionFactory("baz")); }
@Bean DelegatingSessionFactory<String> dsf() { SessionFactoryLocator<String> sff = sessionFactoryLocator(); return new DelegatingSessionFactory<>(sff); }
@Bean public DelegatingSessionFactory<FTPFile> sf() { return new DelegatingSessionFactory<>(factoryLocator()); }