Redberry context. This class collects Redberry session defaults and context-sensitive under the hood information. It has a single unique thread-local instance during each Redberry session. Hence, all variables keeping by the context (like e.g. namespace) have unique instances during session and cannot be changed externally. In order to create a new session of Redberry with a particular context, an instance of this class should be set as a current context via {@link ContextManager#setCurrentContext(Context)}.
@author Dmitry Bolotin @author Stanislav Poslavsky @see NameManager @see IndexConverterManager @see ParseManager @see OutputFormat @see ContextManager @see ContextSettings @since 1.0Then environment that services these requires is known as the Context. There should be a single instance of the implementation of this interface and it should be registered with {@link com.adito.boot.ContextHolder#setContext(Context)}.
The instance of the context may then be accessed in the web application and boot classes using {@link com.adito.boot.ContextHolder#getContext()}.
The context responsibilities include :-
TODO: This needs some cleanup. Perhaps we should split up into a FileContext and a ProjectContext.
NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.This class is in charge of discovering and storing several configuration points, such as the configured {@link AssetCache} implementation or theactive {@link AssetProcessor}s.
There should be only one instance of this class per JVM. @author Thibault Duchateau @since 0.10.0
Also the interface used for event publishing. Wraps the event publishing functionality of the established context.
This interface provides API's to encapsulate environment specific objects so that the FileStreamer class is not specific to a specific environment (like a Servlet environment).
In the compiler, we simply use Phase.instance(context) to get the reference to the phase. But in extensions of the compiler, we must register extensions of the phases to replace the base phase, and this must be done before any reference to the phase is accessed using Phase.instance(). An extended phase might be declared thus:
{@code}public class NewPhase extends Phase protected NewPhase(Context context) { super(context); } public static void preRegister(final Context context) { context.put(phaseKey, new Context.Factory() { public Phase make() { return new NewPhase(context); } }); } } }
And is registered early in the extended compiler like this
NewPhase.preRegister(context);
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Every context has a well-defined lifecycle. It means that in some time, context is active and some other time context may be passive. Moreover, each context is created and destroyed by the container according to the timing requirements. For example, request context is started by every http request and destroyed at the end of the http response. According to the current thread, active context is called an thread current context.
Context is responsible for creating and destroying the {@link Contextual} instances of thewebbeans components.
Every context has a well-defined lifecycle. It means that in some time, context is active and some other time context may be passive. Moreover, each context is created and destroyed by the container according to the timing requirements. For example, request context is started by every http request and destroyed at the end of the http response. According to the current thread, active context is called an thread current context.
Context is responsible for creating and destroying the {@link Contextual} instances of thewebbeans components.
@version $Rev: 815435 $ $Date: 2009-09-15 14:18:44 -0400 (Tue, 15 Sep 2009) $Context
interface describes a naming context comprising a collection of bindings (see javax.naming.Binding
) and methods for manipulating them. This interface is extended by interfaces javax.naming.directory.DirContext
and javax.naming.event.EventContext
. The class javax.naming.InitialContext
implements the Context
interface. Any of the methods may throw a NamingException
or one of its subclasses. The specifications for those exceptions explain the circumstances in which they may be thrown.
Name parameters to context methods are each relative to the context. Name parameters cannot be null. The empty name, whether of type Name
or String
, is the name of the initial context. Names may be composed of multiple components; for example, in the filesystem name "usr/include/stdio.h", each of the components "usr", "include", "stdio.h" is an atomic component, but only "stdio.h" is the terminal atomic component. The example name may be used in context operations providing the intervening parent contexts for "usr" and "include" already exist. Finally, if the current context has name "usr/include", then the example name could be the result of composeName("stdio.h","usr/include")
.
Depending on whether a naming system supports federation, that is, names that may include components from different naming systems, name parameters to context methods may be considered differently as described below.
In systems supporting federation, String name parameters are treated as composite names. When Name
parameters are not instances of CompositeName
, they are deemed to be compound names (CompoundName
instances or subclasses of them). Also, when using list()
or listBindings()
to obtain a NamingEnumeration
, all names in the enumeration are string representations of composite names.
Where systems do not support federation, a service provider may treat name parameters to context methods and names found using NamingEnumeration
may either as composite names or as compound names. See service provider documentation for details.
Any Name
parameter specified to a context method is owned by the caller and will remain unchanged, but applications should avoid modifying these Name
objects while the operation has not completed. Any Name
object returned by a context operation becomes owned by the caller.
JNDI applications can provide preferences and configuration information, such as security details for authentication to a service, using JNDI environment properties. JNDI environment properties nearly all begin with "java.naming." except for provider-specific properties (explained below). All specified JNDI environment properties together comprise the context environment and methods are available for examining and manipulating that environment. The environment of a context may not necessarily contain all possible JNDI properties; for example, one or more may remain unspecified.
The set of standard JNDI environment properties is:
Property name Value type Notes ------------- ---------- ----- java.naming.applet F java.naming.authoritative F java.naming.batchsize F java.naming.dns.url F java.naming.factory.control C see LdapContext java.naming.factory.initial F java.naming.factory.object C java.naming.factory.state C java.naming.factory.url.pkgs C java.naming.language F java.naming.provider.url F java.naming.referral F java.naming.security.authentication F java.naming.security.credentials F java.naming.security.principal F java.naming.security.protocol F
For each property above marked with "C" for "concatenate", when encountered while searching sources of environment properties, values are combined into a single list separated by colons and becomes the resulting value of that property.
For each property above marked with "F" for "first occurrence", when encountered while searching sources of environment properties, the first value encountered is the resulting value of that property. In the latter case, and with additional JNDI environment properties explained further below, the type and syntax of acceptable property values should be described in the corresponding documentation for the property. In particular, a property may accept a value consisting of several pieces of relevant information, but the search order and precedence for environment properties ensures that the entire value of the first occurrence of a given property is deemed the value to be used.
Additional JNDI environment properties may be defined according to the needs of the particular service and/or service providers and a few guidelines should be followed when choosing appropriate names for them. Such additional properties comprise service-specific, feature-specific, or provider-specific properties.
Service-specific JNDI properties may be used by all service providers that offer implementations for a given service and would include the service type in the property name prefix. For example, JNDI service providers for Java RMI should name their service-specific JNDI properties using prefix "java.naming.rmi.", or LDAP service providers should use prefix "java.naming.ldap.".
Feature-specific JNDI properties may be used by all service providers offering implementations using a particular flavour of a feature and would include the feature name and the particular flavour name in the property name prefix. A common example is SASL used by several service providers for security; appropriate SASL feature-specific properties would use prefix "java.naming.security.sasl.".
Provider-specific JNDI properties are used by only a single provider though a provider may offer more than one service provider implementation. The provider should ensure uniqueness of their provider properties, for example, an LDAP service provider from mycom might use a service provider package name such as "com.mycom.jndi.ldap." as their provider-specific prefix.
JNDI environment properties can be specified in a Hashtable
and passed as the environment parameter when creating an initial context.
Two other important sources of JNDI environment properties are resource files provided by applications and applet parameters (each is considered as an application resource file) and by service provider implementations (provider resource files) in the format of Java properties files - see java.util.Properties
class for details.
At runtime, the application classpath and, where appropriate, the applet codebase attribute is used to locate the classes to run; when creating the first initial context, the JNDI also searches the same path for all files (application resource files) called "jndi.properties"; it is the classpath associated with the context ClassLoader
(for example, the return value from Thread.getContextClassLoader()
or from ClassLoader.getSystemClassLoader()
) which is searched to get the resource files. Further, a path comprising the value of the "java.home" system property followed by "lib/jndi.properties" is checked for a readable file; if one exists, then that file is used as another application resource file. All application resource files found in the application classpath are examined, but JNDI properties set in a file found early will override the same properties also set in a file found later in the classpath.
Provider resource files are located according to the package prefix for the service provider's initial context factory and context implementation class in which dot separator characters are converted into slash path separator characters to construct a filepath appended with "jndiprovider.properties". Consider the example where you have a service provider which supplies a context org.apache.harmony.jndi.example.exampleCtx
. In this case the package prefix is org.apache.harmony.jndi.example
. Substituting slash chars for dots & appending "jndiprovider.properties" gives you org/apache/harmony/jndi/example/jndiprovider.properties
.
An important part of service provider implementation is to specify certain standard JNDI properties that are using to locate any of the various factory classes needed for the implementation; these are:
java.naming.factory.control java.naming.factory.object java.naming.factory.state java.naming.factory.url.pkgs - package prefixes used for URL contexts
When searching for the above 4 properties only provider resource files should be examined. Although other properties may be specified in them for use by the service provider implementation, the JNDI ignores properties from these files other than those related to factories.
It should be noted that a provider resource file's properties differ from those in application resource files in that their values are not incorporated into the environment. Instead, they are read when the following methods are invoked with Context
and Hashtable
parameters:
ControlFactory.getControlInstance - uses java.naming.factory.control DirectoryManager.getObjectInstance - uses java.naming.factory.object DirectoryManager.getStateToBind - uses java.naming.factory.state NamingManager.getObjectInstance - uses java.naming.factory.object NamingManager.getStateToBind - uses java.naming.factory.state
These methods use their Hashtable
parameter to get the environment properties. Then they use the class loader of the Context
parameter to look for the provider resource file. If the file is found, then the value of the required property is appended to the value of the required property in the environment. Note that it is appended for use by this method but the environment itself is unaffected.
The jndiprovider.properties
files may specify additional properties, but documentation for the service provider should clearly describe which properties are valid in this file and under what circumstances.
To summarize the search order and precedence for JNDI environment properties, the earliest having highest precedence:
1. environment parameter used to initialize an initial context, 2. applet parameters, (only used if that environment param does not exist) 3. system properties, (only used if that environment and applet parameter do not exist) 4. application resource files.
It should be noted that in the case of applet parameters and system properties only a subset of the properties are read. These are the following 7:
java.naming.dns.url java.naming.factory.control java.naming.factory.initial java.naming.factory.object java.naming.factory.state java.naming.factory.url.pkgs java.naming.provider.url
For a JNDI property found in more than one of those sources, if it is one of the JNDI factory list properties then values are joined into a colon-separated list, otherwise the first instance of a property defines the value to be used.
The above search order and precedence applies when creating contexts for any class implementing the Context
interface.
Although a subcontext inherits the environment of its parent context, subsequent changes to either's environment has no direct effect on the other. However, applications should avoid dependency on when JNDI properties are used or verified as this depends on the service provider implementation. As the environment of a context can be examined by any object that has a reference to the context, care should be taken to assess the risk to any security details stored in the environment.
Multithreaded access to a single Context
instance is only safe when client code uses appropriate synchronization and locking.
When a NamingEnumeration
is returned by a Context
method, the operation should not be considered complete, for concurrency purposes, if the NamingEnumeration is still being used or if any referrals are still being followed resulting from that operation.
In the regular case, you will use an already created instance of this class.
@version $Id: Context.java 4785 2009-12-21 20:10:28Z mosipov $$Id: Context.java 217 2011-01-11 22:54:43Z georgosn $
@author $LastChangedBy: georgosn $ @version $LastChangedRevision: 217 $Different forms of script execution are supported. Scripts may be evaluated from the source directly, or first compiled and then later executed. Interactive execution is also supported.
Some aspects of script execution, such as type conversions and object creation, may be accessed directly through methods of Context. @see Scriptable @author Norris Boyd @author Brendan Eich
The context is the interface through which the component and its container communicate.
Note: In the text below there are several requirements that a component may set up for a container. It is understood that a container does not have to satisfy those requirements in order to be Avalon-compliant. If a component says "I require X to run" a container may reply with "I don't have any X, so I'm not running you". The requirements here are the maximum that a component may ask for, not the minimum a container must deliver. However, a container should document what it is and isn't capable of delivering.
Each Container-Component relationship involves defining a contract between the two entities. A Context contract is defined by (1) an optional target class, and (2) a set of context entries.
The optional target class is an interface, called T
below. It is required that the component should be able to perform the following operation:
public void contextualize( Context context ) throws ContextException { T tContext = (T) context; }
The container may choose any method to supply the component with a context instance cast-able to T
.
There is no requirement for T
to extend the Context
interface.
Warning: A component that specifies this requirement will not be as portable as one that doesn't. Few containers support it. It is therefore discouraged for components to require a castable context.
The second part of the context contract defines the set of entries the component can access via the Context.get()
method, where an entry consists of the key passed to get()
and the expected return type (the class or interface). Optionally, an alias for the key name can be specified. The contract associated with a particular entry is defined in the container documentation.
The class/interface T
above may also have associated meta-info that specifies entries, in which case these entries must be supplied by the container in addition to any entries the component itself requires.
See: Context Meta-Info Specification
Standard Avalon context entries, their keys, types and and associated semantics are defined under the framework standard attributes table.
See: Avalon Standard Context Entries Specification
When a component specifies:
<entry key="avalon:work" type="java.io.File"/>
It should be able to do:
File workDirectory = (File) context.get( "avalon:work" );
in order to obtain the value.
When a component specifies:
<entry alias="work" key="avalon:work" type="java.io.File"/>
It should be able to do:
File workDirectory = (File) context.get( "work" );
The parent Container attached to a Context is generally a Host, but may be some other implementation, or may be omitted if it is not necessary.
The child containers attached to a Context are generally implementations of Wrapper (representing individual servlet definitions).
@author Craig R. McClanahan @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $
Context
describes the context used to evaluate bean expressions. This is mostly a bean together with a number of context variables. Context variables are named objects. In other words, a context variable associates an object with a string.
Logging during expression evaluation is done through the logging instance held by this class. The object initiating the evaluation should control this logging and so passing a Log
instance is enforced by the constructors.
Context
is a natural place to include shared evaluation code. One of the problems that you get with object graphs is that they can be cyclic. Xml cannot (directly) include cycles. Therefore betwixt
needs to find and deal properly with cycles. The algorithm used is to check the parentage of a new child. If the child is a parent then that operation fails.
A {@link Context} represents the state information that isaccessed and manipulated by the execution of a {@link Command} or a{@link Chain}. Specialized implementations of {@link Context} willtypically add JavaBeans properties that contain typesafe accessors to information that is relevant to a particular use case for this context, and/or add operations that affect the state information that is saved in the context.
Implementations of {@link Context} must also implement all of therequired and optional contracts of the java.util.Map
interface.
It is strongly recommended, but not required, that JavaBeans properties added to a particular {@link Context} implementation exhibitAttribute-Property Transparency. In other words, a value stored via a call to setFoo(value)
should be visible by calling get("foo")
, and a value stored via a call to put("foo", value)
should be visible by calling getFoo()
. If your {@link Context}implementation class exhibits this featue, it becomes easier to reuse the implementation in multiple environments, without the need to cast to a particular implementation class in order to access the property getter and setter methods.
To protect applications from evolution of this interface, specialized implementations of {@link Context} should generally be created by extendingthe provided base class ( {@link org.apache.commons.chain.impl.ContextBase}) rather than directly implementing this interface.
Applications should NOT assume that {@link Context} implementations, or the values stored in itsattributes, may be accessed from multiple threads simultaneously unless this is explicitly documented for a particular implementation.
@author Craig R. McClanahan @version $Revision: 1.6 $ $Date: 2004/02/25 00:01:07 $A basic context implementation is provided as an abstract class; this implementation satisfies the interface and should in general be used as the supertype of all context types. Otherwise, context classes must satisfy the semantics of the interface through their own distinct implementations.
Contexts assist in cleanup when errors are caught in the outer block.
Use of context cleanup is preferred over using try/catch blocks throughout the code.
Use of context pushing and popping is preferred over using many instance or local variables, even when try/catch is present. when the instance or local variables would be holding resources.
Usually Context's have a reference based equality, ie. they do not provide an implementation of equals(). Contexts may implement a value based equality but this usually means there is only one instance of the Context on the stack, This is because the popContext(Context) will remove the most recently pushed Context that matches via the equals method, not by a reference check. Implementing equals is useful for Contexts used in notifyAllThreads() that is not aimed at a single thread.
While this class is primarily used for (un)marshalling processes, it may also be opportunistically used for other processes like {@link org.apache.sis.metadata.AbstractMetadata#equals(Object)}. The class name is only " {@code Context}" for that reason.
@author Martin Desruisseaux (Geomatys) @since 0.3 (derived from geotk-3.07) @version 0.3 @moduleThe parent Container attached to a Context is generally a Host, but may be some other implementation, or may be omitted if it is not necessary.
The child containers attached to a Context are generally implementations of Wrapper (representing individual servlet definitions).
@author Craig R. McClanahan @version $Revision: 1.5 $ $Date: 2000/02/13 01:43:43 $
Context
may be a composite, managing child contexts or it may be an atomic, i.e. leaf, context.
@version $Rev: 408581 $ $Date: 2006-05-21 23:34:24 -0700 (Sun, 21 May 2006) $
A common base interface for items that may enclose a local type. This is used to construct inner class names.
org.deuce.transaction.tl2.*
and org.deuce.transaction.lsa*
@author Yoav Cohen, yoav.cohen@cs.tau.ac.il
Typical use of the context object will involve constructing one, and setting the current user if one is authenticated. Several operations may be performed using the context object. If all goes well, complete
is called to commit the changes and free up any resources used by the context. If anything has gone wrong, abort
is called to roll back any changes and free up the resources.
The context object is also used as a cache for CM API objects. @version $Revision: 3985 $
A context is an answer to the question "when". Other services can listen for the activation and deactivation of contexts, and change their own state in response to these changes. For example, Eclipse's key binding service listens to context activation and deactivation to determine which key bindings should be active.
An instance of this interface can be obtained from an instance of ContextManager
for any identifier, whether or not an context with that identifier is defined in the extension registry.
The handle-based nature of this API allows it to work well with runtime plugin activation and deactivation. If a context is defined, that means that its corresponding plug-in is active. If the plug-in is then deactivated, the context will still exist but it will be undefined. An attempts to use an undefined context will result in a NotDefinedException
being thrown.
This class is not intended to be extended by clients.
@since 3.1 @see ContextManagerCopyright (C) 2013 Carlos Eduardo Leite de Andrade
This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see www.gnu.org/licenses/
For more information, contact: www.japura.org
@author Carlos Eduardo Leite de Andrade
NOTE: This class is not typically used directly, but is exposed for writers of implementation-specific XPath packages.
The Context
bundles utilities together for evaluation of the expression. It wraps the provided objects for ease-of-passage through the expression AST.
Its main purpose is to support the concept of scopes so that {@link Statement}s can be validated prior to compilation.
@author Christian Sadilek
new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);This class should have been called ServletContext, but this would have cause confusion with {@link ServletContext}.
Different forms of script execution are supported. Scripts may be evaluated from the source directly, or first compiled and then later executed. Interactive execution is also supported.
Some aspects of script execution, such as type conversions and object creation, may be accessed directly through methods of Context. @see Scriptable @author Norris Boyd @author Brendan Eich
This is basic context implementation used by Red5.
Standard implementation of {@link IContext}.
This {@link IContext} implementation uses a {@link ContextExecutionInfo} object as its{@link IContextExecutionInfo} implementation.
If Thymeleaf is used for the creation of an HTML/XHTML interface in a web application, an implementation of the {@link IWebContext} interface should beused instead.
@author Daniel Fernández @since 1.0Context ctx = new Context(""); ctx.addHandler("/site/*", new FileServiceRequestHandler(basePath, true)); ctx.addHandler("/rpc/*", new MyBusinessHandler()); ctx.addHandler(new MappingAnnotatedHandler()); Server server = new HttpServer(8080, ctx); server.start();@author grro@xlightweb.org
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|