All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.swarm.config.remoting.RemoteOutboundConnection Maven / Gradle / Ivy

package org.wildfly.swarm.config.remoting;

import org.wildfly.swarm.config.runtime.AttributeDocumentation;
import org.wildfly.swarm.config.runtime.ResourceDocumentation;
import org.wildfly.swarm.config.runtime.SingletonResource;
import org.wildfly.swarm.config.runtime.Address;
import org.wildfly.swarm.config.runtime.ResourceType;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.wildfly.swarm.config.runtime.Subresource;
import org.wildfly.swarm.config.remoting.PropertyConsumer;
import org.wildfly.swarm.config.remoting.PropertySupplier;
import org.wildfly.swarm.config.remoting.Property;
import org.wildfly.swarm.config.runtime.SubresourceInfo;
import org.wildfly.swarm.config.runtime.ModelNodeBinding;

/**
 * Remoting outbound connection.
 */
@Address("/subsystem=remoting/remote-outbound-connection=*")
@ResourceType("remote-outbound-connection")
public class RemoteOutboundConnection>
		implements
			org.wildfly.swarm.config.runtime.Keyed {

	private String key;
	private PropertyChangeSupport pcs;
	private RemoteOutboundConnectionResources subresources = new RemoteOutboundConnectionResources();
	@AttributeDocumentation("Reference to the authentication context instance containing the configuration for outbound connections.")
	private String authenticationContext;
	@AttributeDocumentation("Name of the outbound-socket-binding which will be used to determine the destination address and port for the connection.")
	private String outboundSocketBindingRef;
	@AttributeDocumentation("The protocol to use for the remote connection.")
	private String protocol;
	@AttributeDocumentation("Reference to the security realm to use to obtain the password and SSL configuration.")
	private String securityRealm;
	@AttributeDocumentation("The user name to use when authenticating against the remote server.")
	private String username;

	public RemoteOutboundConnection(java.lang.String key) {
		super();
		this.key = key;
	}

	public String getKey() {
		return this.key;
	}

	/**
	 * Adds a property change listener
	 */
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		if (null == this.pcs)
			this.pcs = new PropertyChangeSupport(this);
		this.pcs.addPropertyChangeListener(listener);
	}

	/**
	 * Removes a property change listener
	 */
	public void removePropertyChangeListener(
			java.beans.PropertyChangeListener listener) {
		if (this.pcs != null)
			this.pcs.removePropertyChangeListener(listener);
	}

	public RemoteOutboundConnectionResources subresources() {
		return this.subresources;
	}

	/**
	 * Add all Property objects to this subresource
	 * 
	 * @return this
	 * @param value
	 *            List of Property objects.
	 */
	@SuppressWarnings("unchecked")
	public T properties(java.util.List value) {
		this.subresources.properties = value;
		return (T) this;
	}

	/**
	 * Add the Property object to the list of subresources
	 * 
	 * @param value
	 *            The Property to add
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(Property value) {
		this.subresources.properties.add(value);
		return (T) this;
	}

	/**
	 * Create and configure a Property object to the list of subresources
	 * 
	 * @param key
	 *            The key for the Property resource
	 * @param config
	 *            The PropertyConsumer to use
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(java.lang.String childKey, PropertyConsumer consumer) {
		Property child = new Property<>(childKey);
		if (consumer != null) {
			consumer.accept(child);
		}
		property(child);
		return (T) this;
	}

	/**
	 * Create and configure a Property object to the list of subresources
	 * 
	 * @param key
	 *            The key for the Property resource
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(java.lang.String childKey) {
		property(childKey, null);
		return (T) this;
	}

	/**
	 * Install a supplied Property object to the list of subresources
	 */
	@SuppressWarnings("unchecked")
	public T property(PropertySupplier supplier) {
		property(supplier.get());
		return (T) this;
	}

	/**
	 * Child mutators for RemoteOutboundConnection
	 */
	public static class RemoteOutboundConnectionResources {
		/**
		 * Properties supported by the underlying provider. The property name is
		 * inferred from the last element of the properties address.
		 */
		@ResourceDocumentation("Properties supported by the underlying provider. The property name is inferred from the last element of the properties address.")
		@SubresourceInfo("property")
		private List properties = new java.util.ArrayList<>();

		/**
		 * Get the list of Property resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List properties() {
			return this.properties;
		}

		public Property property(java.lang.String key) {
			return this.properties.stream().filter(e -> e.getKey().equals(key))
					.findFirst().orElse(null);
		}
	}

	/**
	 * Reference to the authentication context instance containing the
	 * configuration for outbound connections.
	 */
	@ModelNodeBinding(detypedName = "authentication-context")
	public String authenticationContext() {
		return this.authenticationContext;
	}

	/**
	 * Reference to the authentication context instance containing the
	 * configuration for outbound connections.
	 */
	@SuppressWarnings("unchecked")
	public T authenticationContext(java.lang.String value) {
		Object oldValue = this.authenticationContext;
		this.authenticationContext = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("authenticationContext", oldValue,
					value);
		return (T) this;
	}

	/**
	 * Name of the outbound-socket-binding which will be used to determine the
	 * destination address and port for the connection.
	 */
	@ModelNodeBinding(detypedName = "outbound-socket-binding-ref")
	public String outboundSocketBindingRef() {
		return this.outboundSocketBindingRef;
	}

	/**
	 * Name of the outbound-socket-binding which will be used to determine the
	 * destination address and port for the connection.
	 */
	@SuppressWarnings("unchecked")
	public T outboundSocketBindingRef(java.lang.String value) {
		Object oldValue = this.outboundSocketBindingRef;
		this.outboundSocketBindingRef = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("outboundSocketBindingRef", oldValue,
					value);
		return (T) this;
	}

	/**
	 * The protocol to use for the remote connection.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@Deprecated
	@ModelNodeBinding(detypedName = "protocol")
	public String protocol() {
		return this.protocol;
	}

	/**
	 * The protocol to use for the remote connection.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@SuppressWarnings("unchecked")
	@Deprecated
	public T protocol(java.lang.String value) {
		Object oldValue = this.protocol;
		this.protocol = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("protocol", oldValue, value);
		return (T) this;
	}

	/**
	 * Reference to the security realm to use to obtain the password and SSL
	 * configuration.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@Deprecated
	@ModelNodeBinding(detypedName = "security-realm")
	public String securityRealm() {
		return this.securityRealm;
	}

	/**
	 * Reference to the security realm to use to obtain the password and SSL
	 * configuration.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@SuppressWarnings("unchecked")
	@Deprecated
	public T securityRealm(java.lang.String value) {
		Object oldValue = this.securityRealm;
		this.securityRealm = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("securityRealm", oldValue, value);
		return (T) this;
	}

	/**
	 * The user name to use when authenticating against the remote server.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@Deprecated
	@ModelNodeBinding(detypedName = "username")
	public String username() {
		return this.username;
	}

	/**
	 * The user name to use when authenticating against the remote server.
	 * 
	 * @deprecated Outbound security settings should be migrated to an
	 *             authentication-context definition.
	 */
	@SuppressWarnings("unchecked")
	@Deprecated
	public T username(java.lang.String value) {
		Object oldValue = this.username;
		this.username = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("username", oldValue, value);
		return (T) this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy