Object bean = activationSpec.getComponent();
if (bean == null) {
throw new IllegalArgumentException("A Registration must have a component associated with it");
}
if (bean instanceof Component) {
Component component = (Component) bean;
if (component instanceof ComponentSupport) {
defaultComponentServiceAndEndpoint((ComponentSupport) component, activationSpec);
}
activateComponent(component, activationSpec);
return component;
} else if (bean instanceof ComponentLifeCycle) {
// lets support just plain lifecycle pojos
ComponentLifeCycle lifeCycle = (ComponentLifeCycle) bean;
if (bean instanceof PojoSupport) {
defaultComponentServiceAndEndpoint((PojoSupport) bean, activationSpec);
}
Component adaptor = createComponentAdaptor(lifeCycle, activationSpec);
activateComponent(adaptor, activationSpec);
return adaptor;
} else if (bean instanceof MessageExchangeListener) {
// lets support just plain listener pojos
MessageExchangeListener listener = (MessageExchangeListener) bean;
Component adaptor = createComponentAdaptor(listener, activationSpec);
activateComponent(adaptor, activationSpec);
return adaptor;
} else {
throw new IllegalArgumentException("Component name: " + id
+ " is bound to an object which is not a JBI component, it is of type: " + bean.getClass().getName());