Gwt-safe
or
Environment env = new Environment(home, null);
Note that many Environment objects may access a single environment.
To create an environment or customize attributes, the application should customize the configuration class. For example:
EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(true); envConfig.setAllowCreate(true); envConfig.setCacheSize(1000000);Environment newlyCreatedEnv = new Environment(home, envConfig);
Environment handles are free-threaded unless {@link com.sleepycat.db.EnvironmentConfig#setThreaded EnvironmentConfig.setThreaded} is called to disable this before the environment is opened.
An environment handle is an Environment instance. More than one Environment instance may be created for the same physical directory, which is the same as saying that more than one Environment handle may be open at one time for a given environment.
The Environment handle should not be closed while any other handle remains open that is using it as a reference (for example, {@link com.sleepycat.db.Database Database} or {@link com.sleepycat.db.Transaction Transaction}. Once {@link com.sleepycat.db.Environment#close Environment.close}is called, this object may not be accessed again, regardless of whether or not it throws an exception.
Environment env = new Environment(home, null);
Note that many Environment objects may access a single environment.
To create an environment or customize attributes, the application should customize the configuration class. For example:
EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(true); envConfig.setAllowCreate(true); envConfig.setCacheSize(1000000); Environment newlyCreatedEnv = new Environment(home, envConfig);
Note that environment configuration parameters can also be set through the <environment home>/je.properties file. This file takes precedence over any programmatically specified configuration parameters so that configuration changes can be made without recompiling. Environment configuration follows this order of precedence:
An environment handle is an Environment instance. More than one Environment instance may be created for the same physical directory, which is the same as saying that more than one Environment handle may be open at one time for a given environment.
The Environment handle should not be closed while any other handle remains open that is using it as a reference (for example, {@link com.sleepycat.je.Database Database} or {@link com.sleepycat.je.Transaction Transaction}. Once {@link com.sleepycat.je.Environment#close Environment.close} is called, this object may not be accessed again.Environment
object. The environment provides important services to the task. It keeps track of setting up the communication channels and provides access to input splits, memory manager, etc.
The following features are supported:
Data models that need to access the Environment object that represents the template processing on the current thread can use the {@link #getCurrentEnvironment()} method.
If you need to modify or read this object before or after the process call, use {@link Template#createProcessingEnvironment(Object rootMap,Writer out,ObjectWrapper wrapper)} @author Jonathan Revusky @author Attila Szegedi
This is often used to run a parallel server necessary during a build, such as an application server, a database reserved for the build, X server for performing UI tests, etc.
By having a plugin that does this, instead of asking each build script to do this, we can simplify the build script. {@link Environment} abstraction also givesyou guaranteed "tear down" phase, so that such resource won't keep running forever. @since 1.286 @see BuildWrapper @see NodeProperty @see RunListener#setUpEnvironment(AbstractBuild,Launcher,BuildListener)
Environment
object. The environment provides important services to the task. It keeps track of setting up the communication channels and provides access to input splits, memory manager, etc.
The Environment acts like a collection of stacks. Each stack contains environmental service providers of a given type.
The environment class mimics the environment variables available in any shell using a hash map of keys/values, the key being the variables names, excepted here they are called parameters.
In addition, this class provides facilities to:
As in any shell, most of the time, the environment is global and accessible from any part of the system. Here a singleton instance of this class is created and accessible from anywhere in the JVM using the {@link #getGlobalEnvironment()} method (indeed the singleton instance iscreated at its first access). However, it is still possible to create a private instance of this class for use in a specific part of a program.
To read a file of parameters, simply call the {@link #readParameterFile(String)} method. In the same way, to write a set ofparameters to a file, call the {@link #writeParameterFile(String)} method.The format of the parameter file is given in the description of these methods.
To read parameters from he command line, call the {@link #readCommandLine(String[])} or{@link #readCommandLine(String[],Collection)} methods. These methods expecta format for the command line that is described in there respective documentations.
It is also possible to setup automatically the fields of an arbitrary object, provided these fields have name that match parameters in this environment. To do this call the {@link #initializeFieldsOf(Object)} method passing theobject to initialise as argument. The object to setup must provide methods of the form "setThing(Type)" where "Thing" or "thing" is the name of the field to set and "Type" is one of "int", "long", "float", "double", "String" and "boolean". For the boolean type, the accepted values meaning true are "true", "on", "1", and "yes", all other value are considered as false.
TODO: how (or when) does the default configuration file is read? TODO: how to handle parameters that cannot be setup in the {@link #initializeFieldsOf(Object)}? @author Frédéric Guinand @author Yoann Pigné @author Antoine Dutot @version 1.0 (jdk 1.5)Objects have different lifecycles and different context's (aka scopes). An environment provides the structure to easily manage objects with different contexts.
Examples of contexts are:
An environment is typically installed like this
static EnvironmentFactory environmentFactory = new DefaultEnvironmentFactory(); ... Environment environment = environmentFactory.openEnvironment(); try { ... everything available in this block ... } finally { environment.close(); }
The first purpose of the environment is to separate the application from the environment. Standard Java and Enterprise Java are quite different and an environment abstraction like this allows for the development of applications that can run in both Standard and Enterprise environments. Also test environments are easier to tweak this way.
A second purpose of the environment is to enable specific to global searching of resources. E.g. you could search for an 'adminEmailAddress' in the contexts 'processDefinition-execution', 'processDefinition-definition' and 'application' in the given order. That way, a global adminEmailAddress can be specified in the application context and it can be refined in more specific contexts processDefinition-definition or processDefinition-execution.
To find an object in the environment, a searchOrder can be specified. A search order is an sequence that specifies the order in which the contexts should be searched.
The default search order is the inverse sequence of how the contexts are added to the environment. This is because in general, we can assume that the more recent a context was added, the more specific it is.
Three objects are used so frequently in an environment that they get special treatment:
For these special properties, setters are also available. That is to support programmatic injection into the environment. Alternatively, they can be configured in one of the contexts.
@see EnvironmentFactory @author Tom BaeyensObjects have different lifecycles and different context's (aka scopes). An environment provides the structure to easily manage objects with different contexts.
Examples of contexts are:
An environment is typically installed like this
static EnvironmentFactory environmentFactory = new DefaultEnvironmentFactory(); ... Environment environment = environmentFactory.openEnvironment(); try { ... everything available in this block ... } finally { environment.close(); }
The first purpose of the environment is to separate the application from the environment. Standard Java and Enterprise Java are quite different and an environment abstraction like this allows for the development of applications that can run in both Standard and Enterprise environments. Also test environments are easier to tweak this way.
A second purpose of the environment is to enable specific to global searching of resources. E.g. you could search for an 'adminEmailAddress' in the contexts 'execution', 'transaction' and 'process-engine' in the given order. That way, a global adminEmailAddress can be specified in the process-engine context and it can be refined in more specific contexts.
To find an object in the environment, a searchOrder can be specified. A search order is an sequence that specifies the order in which the contexts should be searched.
The default search order is the inverse sequence of how the contexts are added to the environment. This is because in general, we can assume that the more recent a context was added, the more specific it is.
Three objects are used so frequently in an environment that they get special treatment:
For these special properties, setters are also available. That is to support programmatic injection into the environment. Alternatively, they can be configured in one of the contexts.
@see EnvironmentFactory @author Tom BaeyensEnvironments can be thought of as consisting of two things:
When R looks up the vbalue for a symbol the frame is examined and if a matching symbol is found its value will be returned. If not, the enclosing environment is then accessed and the process repeated. Environments form a tree structure in which the enclosures play the role of parents. The tree of environments is rooted in an empty environment, available through emptyenv(), which has no parent. It is the direct parent of the environment of the base package (available through the baseenv() function). Formerly baseenv() had the special value {@code NULL}, but as from version 2.4.0, the use of {@code NULL} as an environment is defunct.
A profile is a named, logical group of bean definitions to be registered with the container only if the given profile is active. Beans may be assigned to a profile whether defined in XML or via annotations; see the spring-beans 3.1 schema or the {@link org.springframework.context.annotation.Profile @Profile} annotation forsyntax details. The role of the {@code Environment} object with relation to profiles isin determining which profiles (if any) are currently {@linkplain #getActiveProfiles active}, and which profiles (if any) should be {@linkplain #getDefaultProfiles activeby default}.
Properties play an important role in almost all applications, and may originate from a variety of sources: properties files, JVM system properties, system environment variables, JNDI, servlet context parameters, ad-hoc Properties objects, Maps, and so on. The role of the environment object with relation to properties is to provide the user with a convenient service interface for configuring property sources and resolving properties from them.
Beans managed within an {@code ApplicationContext} may register to be {@link org.springframework.context.EnvironmentAware EnvironmentAware} or {@code @Inject} the{@code Environment} in order to query profile state or resolve properties directly.
In most cases, however, application-level beans should not need to interact with the {@code Environment} directly but instead may have to have ${...}
propertyvalues replaced by a property placeholder configurer such as {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer PropertySourcesPlaceholderConfigurer}, which itself is {@code EnvironmentAware} andas of Spring 3.1 is registered by default when using {@code
Configuration of the environment object must be done through the {@code ConfigurableEnvironment} interface, returned from all{@code AbstractApplicationContext} subclass {@code getEnvironment()} methods. See{@link ConfigurableEnvironment} Javadoc for usage examples demonstrating manipulationof property sources prior to application context {@code refresh()}. @author Chris Beams @since 3.1 @see PropertyResolver @see EnvironmentCapable @see ConfigurableEnvironment @see AbstractEnvironment @see StandardEnvironment @see org.springframework.context.EnvironmentAware @see org.springframework.context.ConfigurableApplicationContext#getEnvironment @see org.springframework.context.ConfigurableApplicationContext#setEnvironment @see org.springframework.context.support.AbstractApplicationContext#createEnvironment
Environment also provides support for creating stacks of properties via {@link #push(Key,Object)} and {@link #pop(Key)}. @author daniel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|