public void initProtocolStack() throws Exception { List<Protocol> protocols = getProtocols(); Collections.reverse(protocols); for(Protocol prot: protocols) { if(prot.getProtocolStack() == null) prot.setProtocolStack(this); callAfterCreationHook(prot, prot.afterCreationHook()); prot.init(); } }
@Override public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException { PathAddress address = context.getCurrentAddress(); String channelName = address.getElement(address.size() - 3).getValue(); String forkName = address.getElement(address.size() - 2).getValue(); String protocolName = address.getElement(address.size() - 1).getValue(); ServiceRegistry registry = context.getServiceRegistry(true); JChannel channel = new PassiveServiceSupplier<JChannel>(registry, JGroupsRequirement.CHANNEL.getServiceName(context, channelName)).get(); if (channel != null) { FORK fork = (FORK) channel.getProtocolStack().findProtocol(FORK.class); if (fork != null) { ChannelFactory factory = new PassiveServiceSupplier<ChannelFactory>(registry, JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channelName)).get(); if (factory != null) { ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration(); ProtocolConfiguration<? extends TP> transport = configuration.getTransport(); if (transport.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = transport.createProtocol(configuration).getClass(); return channel.getProtocolStack().findProtocol(protocolClass); } for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) { if (protocol.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = protocol.createProtocol(configuration).getClass(); return fork.get(forkName).getProtocolStack().findProtocol(protocolClass); } } } } } return null; }
public void initProtocolStack() throws Exception { List<Protocol> protocols = getProtocols(); Collections.reverse(protocols); for(Protocol prot: protocols) { if(prot.getProtocolStack() == null) prot.setProtocolStack(this); callAfterCreationHook(prot, prot.afterCreationHook()); prot.init(); } }
@Override public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException { PathAddress address = context.getCurrentAddress(); String channelName = address.getElement(address.size() - 3).getValue(); String forkName = address.getElement(address.size() - 2).getValue(); String protocolName = address.getElement(address.size() - 1).getValue(); ServiceRegistry registry = context.getServiceRegistry(true); JChannel channel = new PassiveServiceSupplier<JChannel>(registry, JGroupsRequirement.CHANNEL.getServiceName(context, channelName)).get(); if (channel != null) { FORK fork = (FORK) channel.getProtocolStack().findProtocol(FORK.class); if (fork != null) { ChannelFactory factory = new PassiveServiceSupplier<ChannelFactory>(registry, JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channelName)).get(); if (factory != null) { ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration(); ProtocolConfiguration<? extends TP> transport = configuration.getTransport(); if (transport.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = transport.createProtocol(configuration).getClass(); return channel.getProtocolStack().findProtocol(protocolClass); } for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) { if (protocol.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = protocol.createProtocol(configuration).getClass(); return fork.get(forkName).getProtocolStack().findProtocol(protocolClass); } } } } } return null; }
@Override public Protocol findProtocol(ServiceRegistry registry, PathAddress address) throws ClassNotFoundException, ModuleLoadException { String channelName = address.getElement(address.size() - 3).getValue(); String forkName = address.getElement(address.size() - 2).getValue(); String protocolName = address.getElement(address.size() - 1).getValue(); ServiceController<?> controller = registry.getService(ChannelServiceName.CHANNEL.getServiceName(channelName)); if (controller != null) { JChannel channel = (JChannel) controller.getValue(); if (channel != null) { FORK fork = channel.getProtocolStack().findProtocol(FORK.class); if (fork != null) { controller = registry.getService(ProtocolStackServiceName.CHANNEL_FACTORY.getServiceName(channelName)); if (controller != null) { ChannelFactory factory = (ChannelFactory) controller.getValue(); if (factory != null) { ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration(); for (ProtocolConfiguration protocol : configuration.getProtocols()) { if (protocol.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = configuration.getModuleLoader().loadModule(protocol.getModule()).getClassLoader().loadClass(protocol.getProtocolClassName()).asSubclass(Protocol.class); return fork.get(forkName).getProtocolStack().findProtocol(protocolClass); } } } } } } } return null; }