public void createRegistry(@Observes ArquillianDescriptor event) throws Exception
{
Collection<Protocol> protocols = serviceLoader.get().all(Protocol.class);
Protocol<?> defaultProtocol = null;
DefaultProtocolDef defaultProtcolDef = event.getDefaultProtocol();
if(defaultProtcolDef != null)
{
defaultProtocol = findMatch(new ProtocolDescription(defaultProtcolDef.getType()), protocols);
if(defaultProtocol == null)
{
// TODO: add printout of found protocols
throw new IllegalStateException("Defined default protocol " + defaultProtcolDef.getType() + " can not be found on classpath");
}
}
ProtocolRegistry registry = new ProtocolRegistry();
for(Protocol<?> protocol : protocols)
{
injector.get().inject(protocol); // TODO: should be moved to ServiceRegistry, during Service creation
if(defaultProtocol != null && protocol.equals(defaultProtocol))
{
registry.addProtocol(new ProtocolDefinition(protocol, defaultProtcolDef.getProperties(), true));
}
else
{
registry.addProtocol(new ProtocolDefinition(protocol));
}