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

org.wildfly.swarm.config.Undertow Maven / Gradle / Ivy

package org.wildfly.swarm.config;

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 org.wildfly.swarm.config.runtime.Implicit;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.wildfly.swarm.config.runtime.Subresource;
import org.wildfly.swarm.config.undertow.ApplicationSecurityDomainConsumer;
import org.wildfly.swarm.config.undertow.ApplicationSecurityDomainSupplier;
import org.wildfly.swarm.config.undertow.ApplicationSecurityDomain;
import org.wildfly.swarm.config.runtime.SubresourceInfo;
import org.wildfly.swarm.config.undertow.ServerConsumer;
import org.wildfly.swarm.config.undertow.ServerSupplier;
import org.wildfly.swarm.config.undertow.Server;
import org.wildfly.swarm.config.undertow.BufferCacheConsumer;
import org.wildfly.swarm.config.undertow.BufferCacheSupplier;
import org.wildfly.swarm.config.undertow.BufferCache;
import org.wildfly.swarm.config.undertow.ByteBufferPoolConsumer;
import org.wildfly.swarm.config.undertow.ByteBufferPoolSupplier;
import org.wildfly.swarm.config.undertow.ByteBufferPool;
import org.wildfly.swarm.config.undertow.ServletContainerConsumer;
import org.wildfly.swarm.config.undertow.ServletContainerSupplier;
import org.wildfly.swarm.config.undertow.ServletContainer;
import org.wildfly.swarm.config.undertow.HandlerConfiguration;
import org.wildfly.swarm.config.undertow.HandlerConfigurationConsumer;
import org.wildfly.swarm.config.undertow.HandlerConfigurationSupplier;
import org.wildfly.swarm.config.undertow.FilterConfiguration;
import org.wildfly.swarm.config.undertow.FilterConfigurationConsumer;
import org.wildfly.swarm.config.undertow.FilterConfigurationSupplier;
import org.wildfly.swarm.config.runtime.ModelNodeBinding;

/**
 * Undertow subsystem
 */
@Address("/subsystem=undertow")
@ResourceType("subsystem")
@Implicit
public class Undertow>
		implements
			org.wildfly.swarm.config.runtime.Keyed {

	private String key;
	private PropertyChangeSupport pcs;
	private UndertowResources subresources = new UndertowResources();
	@AttributeDocumentation("The default security domain used by web deployments")
	private String defaultSecurityDomain;
	@AttributeDocumentation("The default server to use for deployments")
	private String defaultServer;
	@AttributeDocumentation("The default servlet container to use for deployments")
	private String defaultServletContainer;
	@AttributeDocumentation("The default virtual host to use for deployments")
	private String defaultVirtualHost;
	@AttributeDocumentation("The cluster instance id")
	private String instanceId;
	@AttributeDocumentation("Configures if statistics are enabled. Changes take effect on the connector level statistics immediately, deployment level statistics will only be affected after the deployment is redeployed (or the container is reloaded).")
	private Boolean statisticsEnabled;

	public Undertow() {
		super();
		this.key = "undertow";
		this.pcs = new PropertyChangeSupport(this);
	}

	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 UndertowResources subresources() {
		return this.subresources;
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	/**
	 * Undertow handlers
	 */
	@SuppressWarnings("unchecked")
	public T handlerConfiguration(HandlerConfiguration value) {
		this.subresources.handlerConfiguration = value;
		return (T) this;
	}

	/**
	 * Undertow handlers
	 */
	@SuppressWarnings("unchecked")
	public T handlerConfiguration(HandlerConfigurationConsumer consumer) {
		HandlerConfiguration child = new HandlerConfiguration<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.handlerConfiguration = child;
		return (T) this;
	}

	/**
	 * Undertow handlers
	 */
	@SuppressWarnings("unchecked")
	public T handlerConfiguration() {
		HandlerConfiguration child = new HandlerConfiguration<>();
		this.subresources.handlerConfiguration = child;
		return (T) this;
	}

	/**
	 * Undertow handlers
	 */
	@SuppressWarnings("unchecked")
	public T handlerConfiguration(HandlerConfigurationSupplier supplier) {
		this.subresources.handlerConfiguration = supplier.get();
		return (T) this;
	}

	/**
	 * Undertow filters
	 */
	@SuppressWarnings("unchecked")
	public T filterConfiguration(FilterConfiguration value) {
		this.subresources.filterConfiguration = value;
		return (T) this;
	}

	/**
	 * Undertow filters
	 */
	@SuppressWarnings("unchecked")
	public T filterConfiguration(FilterConfigurationConsumer consumer) {
		FilterConfiguration child = new FilterConfiguration<>();
		if (consumer != null) {
			consumer.accept(child);
		}
		this.subresources.filterConfiguration = child;
		return (T) this;
	}

	/**
	 * Undertow filters
	 */
	@SuppressWarnings("unchecked")
	public T filterConfiguration() {
		FilterConfiguration child = new FilterConfiguration<>();
		this.subresources.filterConfiguration = child;
		return (T) this;
	}

	/**
	 * Undertow filters
	 */
	@SuppressWarnings("unchecked")
	public T filterConfiguration(FilterConfigurationSupplier supplier) {
		this.subresources.filterConfiguration = supplier.get();
		return (T) this;
	}

	/**
	 * Child mutators for Undertow
	 */
	public static class UndertowResources {
		/**
		 * A Mapping from a security domain references in a deployed
		 * application.
		 */
		@ResourceDocumentation("A Mapping from a security domain references in a deployed application.")
		@SubresourceInfo("applicationSecurityDomain")
		private List applicationSecurityDomains = new java.util.ArrayList<>();
		/**
		 * A server
		 */
		@ResourceDocumentation("A server")
		@SubresourceInfo("server")
		private List servers = new java.util.ArrayList<>();
		/**
		 * The buffer cache used to cache static content
		 */
		@ResourceDocumentation("The buffer cache used to cache static content")
		@SubresourceInfo("bufferCache")
		private List bufferCaches = new java.util.ArrayList<>();
		/**
		 * A byte buffer pool used for IO operations, this provides the same
		 * capabilities as the buffer pool from the IO subsystem, so they can be
		 * used interchangeably and must have a unique name. This buffer pool
		 * allows for more precise configuration of the total amount of retained
		 * memory than the IO subsystem.
		 */
		@ResourceDocumentation("A byte buffer pool used for IO operations, this provides the same capabilities as the buffer pool from the IO subsystem, so they can be used interchangeably and must have a unique name. This buffer pool allows for more precise configuration of the total amount of retained memory than the IO subsystem.")
		@SubresourceInfo("byteBufferPool")
		private List byteBufferPools = new java.util.ArrayList<>();
		/**
		 * A servlet container
		 */
		@ResourceDocumentation("A servlet container")
		@SubresourceInfo("servletContainer")
		private List servletContainers = new java.util.ArrayList<>();
		@SingletonResource
		@ResourceDocumentation("Undertow handlers")
		private HandlerConfiguration handlerConfiguration;
		@SingletonResource
		@ResourceDocumentation("Undertow filters")
		private FilterConfiguration filterConfiguration;

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

		public ApplicationSecurityDomain applicationSecurityDomain(
				java.lang.String key) {
			return this.applicationSecurityDomains.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Get the list of Server resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List servers() {
			return this.servers;
		}

		public Server server(java.lang.String key) {
			return this.servers.stream().filter(e -> e.getKey().equals(key))
					.findFirst().orElse(null);
		}
		/**
		 * Get the list of BufferCache resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List bufferCaches() {
			return this.bufferCaches;
		}

		public BufferCache bufferCache(java.lang.String key) {
			return this.bufferCaches.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Get the list of ByteBufferPool resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List byteBufferPools() {
			return this.byteBufferPools;
		}

		public ByteBufferPool byteBufferPool(java.lang.String key) {
			return this.byteBufferPools.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Get the list of ServletContainer resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List servletContainers() {
			return this.servletContainers;
		}

		public ServletContainer servletContainer(java.lang.String key) {
			return this.servletContainers.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Undertow handlers
		 */
		@Subresource
		public HandlerConfiguration handlerConfiguration() {
			return this.handlerConfiguration;
		}

		/**
		 * Undertow filters
		 */
		@Subresource
		public FilterConfiguration filterConfiguration() {
			return this.filterConfiguration;
		}
	}

	/**
	 * The default security domain used by web deployments
	 */
	@ModelNodeBinding(detypedName = "default-security-domain")
	public String defaultSecurityDomain() {
		return this.defaultSecurityDomain;
	}

	/**
	 * The default security domain used by web deployments
	 */
	@SuppressWarnings("unchecked")
	public T defaultSecurityDomain(java.lang.String value) {
		Object oldValue = this.defaultSecurityDomain;
		this.defaultSecurityDomain = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("defaultSecurityDomain", oldValue,
					value);
		return (T) this;
	}

	/**
	 * The default server to use for deployments
	 */
	@ModelNodeBinding(detypedName = "default-server")
	public String defaultServer() {
		return this.defaultServer;
	}

	/**
	 * The default server to use for deployments
	 */
	@SuppressWarnings("unchecked")
	public T defaultServer(java.lang.String value) {
		Object oldValue = this.defaultServer;
		this.defaultServer = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("defaultServer", oldValue, value);
		return (T) this;
	}

	/**
	 * The default servlet container to use for deployments
	 */
	@ModelNodeBinding(detypedName = "default-servlet-container")
	public String defaultServletContainer() {
		return this.defaultServletContainer;
	}

	/**
	 * The default servlet container to use for deployments
	 */
	@SuppressWarnings("unchecked")
	public T defaultServletContainer(java.lang.String value) {
		Object oldValue = this.defaultServletContainer;
		this.defaultServletContainer = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("defaultServletContainer", oldValue,
					value);
		return (T) this;
	}

	/**
	 * The default virtual host to use for deployments
	 */
	@ModelNodeBinding(detypedName = "default-virtual-host")
	public String defaultVirtualHost() {
		return this.defaultVirtualHost;
	}

	/**
	 * The default virtual host to use for deployments
	 */
	@SuppressWarnings("unchecked")
	public T defaultVirtualHost(java.lang.String value) {
		Object oldValue = this.defaultVirtualHost;
		this.defaultVirtualHost = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("defaultVirtualHost", oldValue, value);
		return (T) this;
	}

	/**
	 * The cluster instance id
	 */
	@ModelNodeBinding(detypedName = "instance-id")
	public String instanceId() {
		return this.instanceId;
	}

	/**
	 * The cluster instance id
	 */
	@SuppressWarnings("unchecked")
	public T instanceId(java.lang.String value) {
		Object oldValue = this.instanceId;
		this.instanceId = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("instanceId", oldValue, value);
		return (T) this;
	}

	/**
	 * Configures if statistics are enabled. Changes take effect on the
	 * connector level statistics immediately, deployment level statistics will
	 * only be affected after the deployment is redeployed (or the container is
	 * reloaded).
	 */
	@ModelNodeBinding(detypedName = "statistics-enabled")
	public Boolean statisticsEnabled() {
		return this.statisticsEnabled;
	}

	/**
	 * Configures if statistics are enabled. Changes take effect on the
	 * connector level statistics immediately, deployment level statistics will
	 * only be affected after the deployment is redeployed (or the container is
	 * reloaded).
	 */
	@SuppressWarnings("unchecked")
	public T statisticsEnabled(java.lang.Boolean value) {
		Object oldValue = this.statisticsEnabled;
		this.statisticsEnabled = value;
		if (this.pcs != null)
			this.pcs.firePropertyChange("statisticsEnabled", oldValue, value);
		return (T) this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy