{
result = true;
String[] channels = configure.value();
for (String channel : channels)
{
final Initializer init = new Initializer()
{
public void configureChannel(ConfigurableServerChannel channel)
{
boolean flip = false;
try
{
if (logger.isDebugEnabled())
logger.debug("Configure channel {} with method {} on bean {}", channel, method, bean);
if (!method.isAccessible())
{
flip = true;
method.setAccessible(true);
}
method.invoke(bean, channel);
}
catch (Exception x)
{
throw new RuntimeException(x);
}
finally
{
if (flip)
method.setAccessible(false);
}
}
};
MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channel, init);
if (initializedChannel.isMarked())
{
if (logger.isDebugEnabled())
logger.debug("Channel {} already initialized. Not called method {} on bean {}", channel, method, bean);
}
else
{
if (configure.configureIfExists())
{
if (logger.isDebugEnabled())
logger.debug("Configure channel {} with method {} on bean {}", channel, method, bean);
init.configureChannel(initializedChannel.getReference());
}
else if (configure.errorIfExists())
{
throw new IllegalStateException("Channel already configured: " + channel);
}