private void configureMulticastSocket( ProtocolConfiguration protocol, org.jgroups.conf.ProtocolConfiguration config, String addressProperty, String portProperty, SocketBinding binding) { Map<String, String> properties = config.getProperties(); try { InetSocketAddress mcastSocketAddress = binding.getMulticastSocketAddress(); if (protocol.hasProperty(addressProperty)) { properties.put(addressProperty, mcastSocketAddress.getAddress().getHostAddress()); } if (protocol.hasProperty(portProperty)) { properties.put(portProperty, String.valueOf(mcastSocketAddress.getPort())); } } catch (IllegalStateException e) { ROOT_LOGGER.tracef( e, "Could not set %s.%s and %s.%s, %s socket binding does not specify a multicast socket", config.getProtocolName(), addressProperty, config.getProtocolName(), portProperty, binding.getName()); } }
Introspector(org.jgroups.conf.ProtocolConfiguration config) { String name = config.getProtocolName(); try { this.protocolClass = config.getClassLoader().loadClass(name).asSubclass(Protocol.class); PrivilegedAction<Void> action = new PrivilegedAction<Void>() { @Override public Void run() { Class<?> targetClass = Introspector.this.protocolClass; while (Protocol.class.isAssignableFrom(targetClass)) { for (Method method : targetClass.getDeclaredMethods()) { if (method.isAnnotationPresent(Property.class)) { String property = method.getAnnotation(Property.class).name(); if (!property.isEmpty()) { Introspector.this.properties.add(property); } } } for (Field field : targetClass.getDeclaredFields()) { if (field.isAnnotationPresent(Property.class)) { String property = field.getAnnotation(Property.class).name(); Introspector.this.properties.add( !property.isEmpty() ? property : field.getName()); } } targetClass = targetClass.getSuperclass(); } return null; } }; WildFlySecurityManager.doChecked(action); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
private static void setSocketBindingProperty( Introspector introspector, org.jgroups.conf.ProtocolConfiguration config, String name, String value) { try { Map<String, String> properties = config.getOriginalProperties(); if (properties.containsKey(name)) { ROOT_LOGGER.unableToOverrideSocketBindingValue( name, config.getProtocolName(), value, properties.get(name)); } setProperty(introspector, config, name, value); } catch (Exception e) { ROOT_LOGGER.unableToAccessProtocolPropertyValue(e, name, config.getProtocolName()); } }
/** * {@inheritDoc} * * @see org.jboss.msc.value.Value#getValue() */ @Override public ProtocolDefaults getValue() { ProtocolStackConfigurator configurator = load(ProtocolDefaultsBuilder.this.resource); for (org.jgroups.conf.ProtocolConfiguration config : configurator.getProtocolStack()) { this.map.put(config.getProtocolName(), Collections.unmodifiableMap(config.getProperties())); } return this; }
private static String replaceProperties( JGroupsProtocolCfg cfg, Map<String, String> newProps, ProtocolType type) { ProtocolConfiguration protocol = cfg.getProtocol(type); ProtocolConfiguration newProtocol = new ProtocolConfiguration(protocol.getProtocolName(), newProps); cfg.replaceProtocol(type, newProtocol); return cfg.toString(); }
static List<ProtocolConfiguration> copy(List<ProtocolConfiguration> protocols) { // Make a safe copy of the protocol stack to avoid concurrent modification issues List<ProtocolConfiguration> copy = new ArrayList<ProtocolConfiguration>(protocols.size()); for (ProtocolConfiguration p : protocols) copy.add( new ProtocolConfiguration(p.getProtocolName(), immutableMapCopy(p.getProperties()))); return copy; }
private static JGroupsProtocolCfg getJGroupsProtocolCfg(List<ProtocolConfiguration> baseStack) { JGroupsXmxlConfigurator configurator = new JGroupsXmxlConfigurator(baseStack); List<ProtocolConfiguration> protoStack = configurator.getProtocolStack(); Map<ProtocolType, ProtocolConfiguration> protoMap = new HashMap<ProtocolType, ProtocolConfiguration>(protoStack.size()); for (ProtocolConfiguration cfg : protoStack) protoMap.put(getProtocolType(cfg.getProtocolName()), cfg); return new JGroupsProtocolCfg(protoMap, configurator); }
private static void configureMulticastSocket( Introspector introspector, org.jgroups.conf.ProtocolConfiguration config, String addressProperty, String portProperty, SocketBinding binding) { try { InetSocketAddress mcastSocketAddress = binding.getMulticastSocketAddress(); setSocketBindingProperty( introspector, config, addressProperty, mcastSocketAddress.getAddress().getHostAddress()); setSocketBindingProperty( introspector, config, portProperty, String.valueOf(mcastSocketAddress.getPort())); } catch (IllegalStateException e) { ROOT_LOGGER.couldNotSetAddressAndPortNoMulticastSocket( e, config.getProtocolName(), addressProperty, config.getProtocolName(), portProperty, binding.getName()); } }