Package org.apache.guacamole.environment
Class LocalEnvironment
java.lang.Object
org.apache.guacamole.environment.LocalEnvironment
- All Implemented Interfaces:
Environment
The environment of the locally-running Guacamole instance, describing
available protocols, configuration parameters, and the GUACAMOLE_HOME
directory. Sources of configuration properties like guacamole.properties and
environment variables will be automatically added by the Guacamole web
application and may also be added by extensions using
addGuacamoleProperties(org.apache.guacamole.properties.GuacamoleProperties)
.-
Field Summary
Fields inherited from interface org.apache.guacamole.environment.Environment
CASE_SENSITIVITY, GUACD_HOSTNAME, GUACD_PORT, GUACD_SSL
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Extensions leveraging LocalEnvironment should instead use LocalEnvironment.getInstance() to obtain a singleton instance of the environment. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGuacamoleProperties
(GuacamoleProperties properties) Adds another possible source of Guacamole configuration properties to this Environment.Returns the connection information which should be used, by default, to connect to guacd when establishing a remote desktop connection.Returns the Guacamole home directory as determined when this Environment object was created.static LocalEnvironment
Returns a singleton instance of LocalEnvironment which may be shared by the Guacamole web application and all extensions.<Type> Type
getProperty
(GuacamoleProperty<Type> property) Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any.<Type> Type
getProperty
(GuacamoleProperty<Type> property, Type defaultValue) Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any.<Type> Collection
<Type> getPropertyCollection
(GuacamoleProperty<Type> property) Given a GuacamoleProperty, parses and returns a sorted Collection of the value set for that property in guacamole.properties, if any.<Type> Collection
<Type> getPropertyCollection
(GuacamoleProperty<Type> property, Collection<Type> defaultValue) Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any.<Type> Collection
<Type> getPropertyCollection
(GuacamoleProperty<Type> property, Type defaultValue) Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any.getProtocol
(String name) Returns the protocol having the given name.Returns a map of all available protocols, where each key is the name of that protocol as would be passed to guacd during connection.<Type> Type
getRequiredProperty
(GuacamoleProperty<Type> property) Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties.<Type> Collection
<Type> getRequiredPropertyCollection
(GuacamoleProperty<Type> property) Given a GuacamoleProperty, parses and returns a sorted Collection of values for that property in guacamole.properties.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.guacamole.environment.Environment
getCaseSensitivity
-
Constructor Details
-
LocalEnvironment
Deprecated.Extensions leveraging LocalEnvironment should instead use LocalEnvironment.getInstance() to obtain a singleton instance of the environment.Creates a new LocalEnvironment, initializing that environment based on the contents of GUACAMOLE_HOME. Sources of configuration properties like guacamole.properties and environment variables will be automatically added by the Guacamole web application and/or any installed extensions.
-
-
Method Details
-
getInstance
Returns a singleton instance of LocalEnvironment which may be shared by the Guacamole web application and all extensions.- Returns:
- A singleton instance of this class.
-
getGuacamoleHome
Description copied from interface:Environment
Returns the Guacamole home directory as determined when this Environment object was created. The Guacamole home directory is found by checking, in order: the guacamole.home system property, the GUACAMOLE_HOME environment variable, and finally the .guacamole directory in the home directory of the user running the servlet container.- Specified by:
getGuacamoleHome
in interfaceEnvironment
- Returns:
- The File representing the Guacamole home directory, which may or may not exist, and may turn out to not be a directory.
-
getProperty
public <Type> Type getProperty(GuacamoleProperty<Type> property) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any.- Specified by:
getProperty
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.- Returns:
- The parsed value of the property as read from guacamole.properties.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties.
-
getProperty
public <Type> Type getProperty(GuacamoleProperty<Type> property, Type defaultValue) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any. If no value is found, the provided default value is returned.- Specified by:
getProperty
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.defaultValue
- The value to return if no value was given in guacamole.properties.- Returns:
- The parsed value of the property as read from guacamole.properties, or the provided default value if no value was found.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties.
-
getPropertyCollection
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns a sorted Collection of the value set for that property in guacamole.properties, if any. The implementation of parsing and returning a collection of multiple values is up to the individual property implementations, and not all implementations will support reading and returning multiple values.- Specified by:
getPropertyCollection
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.- Returns:
- A sorted collection of the the parsed values of the property as read from guacamole.properties.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties.
-
getPropertyCollection
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property, Type defaultValue) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any. If no value is found, a Collection is returned with the provided default value. The implementation of parsing and returning a collection of multiple values is up to the individual property implementations, and not all implementations will support reading and returning multiple values.- Specified by:
getPropertyCollection
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.defaultValue
- The single value to return in the Collection if no value was given in guacamole.properties.- Returns:
- A sorted collection of the the parsed values of the property as read from guacamole.properties, or a Collection with the single default value provided.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties.
-
getPropertyCollection
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property, Collection<Type> defaultValue) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties, if any. If no value is found, the provided Collection of default values is returned. The implementation of parsing and returning a collection of multiple values is up to the individual property implementations, and not all implementations will support reading and returning multiple values.- Specified by:
getPropertyCollection
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.defaultValue
- The Collection of values to return in the Collection if no value was given in guacamole.properties.- Returns:
- A sorted collection of the the parsed values of the property as read from guacamole.properties, or a Collection with the single default value provided.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties.
-
getRequiredProperty
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns the value set for that property in guacamole.properties. An exception is thrown if the value is not provided.- Specified by:
getRequiredProperty
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.- Returns:
- The parsed value of the property as read from guacamole.properties.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties, or if the property is not specified.
-
getRequiredPropertyCollection
public <Type> Collection<Type> getRequiredPropertyCollection(GuacamoleProperty<Type> property) throws org.apache.guacamole.GuacamoleException Description copied from interface:Environment
Given a GuacamoleProperty, parses and returns a sorted Collection of values for that property in guacamole.properties. An exception is thrown if the value is not provided. The implementation of parsing and returning a collection of multiple values is up to the individual property implementations, and not all implementations will support reading and returning multiple values.- Specified by:
getRequiredPropertyCollection
in interfaceEnvironment
- Type Parameters:
Type
- The type that the given property is parsed into.- Parameters:
property
- The property to read from guacamole.properties.- Returns:
- A sorted Collection of the property as read from guacamole.properties.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while parsing the value for the given property in guacamole.properties, or if the property is not specified.
-
getProtocols
Description copied from interface:Environment
Returns a map of all available protocols, where each key is the name of that protocol as would be passed to guacd during connection.- Specified by:
getProtocols
in interfaceEnvironment
- Returns:
- A map of all available protocols.
-
getProtocol
Description copied from interface:Environment
Returns the protocol having the given name. The name must be the protocol name as would be passed to guacd during connection.- Specified by:
getProtocol
in interfaceEnvironment
- Parameters:
name
- The name of the protocol.- Returns:
- The protocol having the given name, or null if no such protocol is registered.
-
getDefaultGuacamoleProxyConfiguration
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration() throws org.apache.guacamole.GuacamoleExceptionDescription copied from interface:Environment
Returns the connection information which should be used, by default, to connect to guacd when establishing a remote desktop connection.- Specified by:
getDefaultGuacamoleProxyConfiguration
in interfaceEnvironment
- Returns:
- The connection information which should be used, by default, to connect to guacd.
- Throws:
org.apache.guacamole.GuacamoleException
- If the connection information for guacd cannot be retrieved.
-
addGuacamoleProperties
Description copied from interface:Environment
Adds another possible source of Guacamole configuration properties to this Environment. Properties not already defined by other sources of Guacamole configuration properties will alternatively be read from the givenGuacamoleProperties
.- Specified by:
addGuacamoleProperties
in interfaceEnvironment
- Parameters:
properties
- The GuacamoleProperties to add to this Environment.
-