Component API or convention?
tcunning Oct 28, 2010 12:41 PMIs there going to be any formal API around the components we provide? I know "component" is sort of a vague idea purposefully, but it seems like there should be some convention here in at least the components we write so that components do things similarly :
Component Consumers :
How does a Component register a service? Does it register a service itself automatically? Do we pass a service name into the component so it can register a service? Or does the component provide the user with a ExchangeHandler so that the user can register a service based on that component?
QName myService = new QName("myService"); Component component = new Component() ComponentConfig config = new ComponentConfig(domainName); component.init(config); // component.registerService(myService);
or
QName myService = new QName("myService"); Component component = new Component() _domain.registerService(myService, component.getConsumerHandler));
Provider Components :
If the component is a provider, do we pass it an ExchangeHandler or ExchangeHandlerChain to deal with? Or should we be able to add handlers to a chain, get the component's provider service, and then add our Handler to the component service's handler chain?
// note : I made PrintlnBaseHandler up, assume it just prints the content of the message ExchangeHandler consumer = new PrintlnBaseHandler(); Component component = new Component(); ComponentConfig config = new ComponentConfig(); config.setABunchofStuff(abunchOfStuff); config.setExchangeHandler(consumer); component.deploy(config); component.start();
or
// note : I made PrintlnBaseHandler up, assume it just prints the content of the message ExchangeHandler consumer = new PrintlnBaseHandler(); Component component = new Component(); ComponentConfig config = new ComponentConfig(); config.setABunchofStuff(abunchOfStuff); component.deploy(config); ServiceRegistration sr = component.getProviderService(); sr.getHandlers().addHandler(consumer); // I believe this currently will fail component.start();