/** * Removes the specified {@link SystemProperty} named property from the {@link SystemProperties}, returning a new * {@link SystemProperties} without the said {@link SystemProperty}. * * @param propertyName the {@link SystemProperty} to remove * * @return the a new {@link SystemProperties} instance, excluding the specified {@link SystemProperty} */ public SystemProperties remove(String propertyName) { if (propertyName == null || propertyName.isEmpty() ||!contains(propertyName)) { return this; } else { SystemProperties systemProperties = new SystemProperties(this); systemProperties.properties.remove(propertyName); return systemProperties; } }
@Override public SystemProperties with(SystemProperty property) { return add(property); }
@Override public SystemProperties compose(SystemProperties other) { // create a new SystemProperties based on this SystemProperties, including all of the other SystemProperties return this.addAll(other); }
@Override public void onLaunching(Platform platform, MetaClass metaClass, OptionsByType optionsByType) { SystemProperties systemProperties = optionsByType.get(SystemProperties.class); if (systemProperties != null) { systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JAVA_NET_PREFER_IPV4_STACK, preferred)); optionsByType.add(systemProperties); } }
systemProperties = optionsByType.get(SystemProperties.class).resolve(platform, optionsByType);
/** * Obtain a {@link SystemProperties} instance that is a copy of the specified * {@link SystemProperties} with all of the properties contained within this * {@link Ports} altered to be the value of the mapped ports. * * @param properties the {@link SystemProperties} to copy * * @return a {@link SystemProperties} with the mapped port values */ public SystemProperties asMappedProperties(SystemProperties properties) { SystemProperties copy = new SystemProperties(properties); Map<String, Object> mappedProperties = new HashMap<>(); for (SystemProperty property : properties) { String name = property.getName(); if (ports.containsKey(name)) { Port port = ports.get(name); mappedProperties.put(name, port.getMappedPort()); } } return copy.addAll(mappedProperties); }
/** * Adds all of the specified properties represented as a {@link Map} of name-value pairs * as individual {@link SystemProperty}s, returning a new {@link SystemProperties}. * * @param properties the {@link Map} of properties * * @return a new {@link SystemProperties} */ public SystemProperties addAll(Map<String, Object> properties) { SystemProperties systemProperties = new SystemProperties(this); for (String name : properties.keySet()) { systemProperties.properties.put(name, SystemProperty.of(name, properties.get(name))); } return systemProperties; }
@Override public SystemProperties without(SystemProperty property) { return remove(property.getName()); }
systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE)); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JavaApplication.JAVA_RMI_SERVER_HOSTNAME, hostName.get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JavaApplication.JAVA_RMI_SERVER_HOSTNAME, platform.getAddress().getHostAddress())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of("java.rmi.server.useCodebaseOnly", "true")); systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_PORT, port.get().get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_PORT, LocalPlatform.get().getAvailablePorts())); systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_AUTHENTICATE, authenticate.get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_SSL, ssl.get()));
Properties systemProperties = launchOptions.get(SystemProperties.class).resolve(platform, launchOptions);
/** * Obtain a {@link SystemProperties} instance that is a copy of the specified * {@link SystemProperties} with all of the properties contained within this * {@link Ports} altered to be the value of the mapped ports. * * @param properties the {@link SystemProperties} to copy * * @return a {@link SystemProperties} with the mapped port values */ public SystemProperties asMappedProperties(SystemProperties properties) { SystemProperties copy = new SystemProperties(properties); Map<String, Object> mappedProperties = new HashMap<>(); for (SystemProperty property : properties) { String name = property.getName(); if (ports.containsKey(name)) { Port port = ports.get(name); mappedProperties.put(name, port.getMappedPort()); } } return copy.addAll(mappedProperties); }
/** * Adds all of the {@link SystemProperties} to this {@link SystemProperties} * returning a new {@link SystemProperties}. * * @param properties the {@link SystemProperties} * * @return a new {@link SystemProperties} */ public SystemProperties addAll(SystemProperties properties) { SystemProperties systemProperties = new SystemProperties(this); for (SystemProperty property : properties) { systemProperties.properties.put(property.getName(), property); } return systemProperties; }
@Override public SystemProperties without(SystemProperty property) { return remove(property.getName()); }
@Override public void onLaunching(Platform platform, MetaClass metaClass, OptionsByType optionsByType) { SystemProperties systemProperties = optionsByType.get(SystemProperties.class); if (systemProperties != null) { systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JAVA_NET_PREFER_IPV4_STACK, preferred)); optionsByType.add(systemProperties); } }
Properties systemProperties = launchOptions.get(SystemProperties.class).resolve(platform, launchOptions);
/** * Removes the specified {@link SystemProperty} named property from the {@link SystemProperties}, returning a new * {@link SystemProperties} without the said {@link SystemProperty}. * * @param propertyName the {@link SystemProperty} to remove * * @return the a new {@link SystemProperties} instance, excluding the specified {@link SystemProperty} */ public SystemProperties remove(String propertyName) { if (propertyName == null || propertyName.isEmpty() ||!contains(propertyName)) { return this; } else { SystemProperties systemProperties = new SystemProperties(this); systemProperties.properties.remove(propertyName); return systemProperties; } }
@Override public SystemProperties with(SystemProperty property) { return add(property); }
/** * Adds all of the specified properties represented as a {@link Map} of name-value pairs * as individual {@link SystemProperty}s, returning a new {@link SystemProperties}. * * @param properties the {@link Map} of properties * * @return a new {@link SystemProperties} */ public SystemProperties addAll(Map<String, Object> properties) { SystemProperties systemProperties = new SystemProperties(this); for (String name : properties.keySet()) { systemProperties.properties.put(name, SystemProperty.of(name, properties.get(name))); } return systemProperties; }
@Override public SystemProperties compose(SystemProperties other) { // create a new SystemProperties based on this SystemProperties, including all of the other SystemProperties return this.addAll(other); }
systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE)); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JavaApplication.JAVA_RMI_SERVER_HOSTNAME, hostName.get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JavaApplication.JAVA_RMI_SERVER_HOSTNAME, platform.getAddress().getHostAddress())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of("java.rmi.server.useCodebaseOnly", "true")); systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_PORT, port.get().get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_PORT, LocalPlatform.get().getAvailablePorts())); systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_AUTHENTICATE, authenticate.get())); systemProperties = systemProperties.addIfAbsent(SystemProperty.of(JmxFeature.SUN_MANAGEMENT_JMXREMOTE_SSL, ssl.get()));