package com.gss.gmo.cao.integration.xmpp.component.inbound;

import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.xmpp.packet.Message;

import com.gss.gmo.cao.integration.xmpp.component.core.AbstractComponentManagerAwareEndpoint;
import com.gss.gmo.cao.integration.xmpp.component.core.ComponentManager;
import com.gss.gmo.cao.integration.xmpp.component.core.MessageListener;

/**
 * @author linus_chien
 *
 */
public class MessageListeningEndpoint extends AbstractComponentManagerAwareEndpoint {

	public MessageListeningEndpoint(ComponentManager componentManager) {
		super(componentManager);
	}

	@Override
	public String getComponentType() {
		return "xmpp-component:message-inbound-channel-adapter";
	}

	@Override
	protected void doStart() {
		this.componentManager.setMessageListener(new MessageListener() {
			@Override
			public void handleMessage(Message message) {
				AbstractIntegrationMessageBuilder<Message> messageBuilder = getMessageBuilderFactory().withPayload(message);
				sendMessage(messageBuilder.build());
			}
		});
	}

}

@@ -52,24 +52,81 @@
 inbound;%0D%0A%0D%0A
+import static org.springframework.util.Assert.isTrue;%0D%0A%0D%0A
 import org.s
@@ -863,16 +863,129 @@
 rt() %7B%0D%0A
+%09%09isTrue(this.initialized, this.getComponentName() + %22 %5B%22 + this.getComponentType() + %22%5D must be initialized%22);%0D%0A
 %09%09this.c

add precondition