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)
{
if(defaultProtocol != null && protocol.equals(defaultProtocol))
{
registry.addProtocol(new ProtocolDefinition(protocol, defaultProtcolDef.getProperties(), true));
}
else
{
registry.addProtocol(new ProtocolDefinition(protocol));
}