001 /*
002 * JBoss, Home of Professional Open Source.
003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
004 * as indicated by the @author tags. See the copyright.txt file in the
005 * distribution for a full listing of individual contributors.
006 *
007 * This is free software; you can redistribute it and/or modify it
008 * under the terms of the GNU Lesser General Public License as
009 * published by the Free Software Foundation; either version 2.1 of
010 * the License, or (at your option) any later version.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022 package org.jboss.dna.graph;
023
024 import java.security.AccessControlContext;
025 import javax.security.auth.Subject;
026 import javax.security.auth.login.LoginContext;
027 import org.jboss.dna.common.component.ClassLoaderFactory;
028 import org.jboss.dna.common.util.Logger;
029 import org.jboss.dna.graph.properties.NamespaceRegistry;
030 import org.jboss.dna.graph.properties.Property;
031 import org.jboss.dna.graph.properties.PropertyFactory;
032 import org.jboss.dna.graph.properties.ValueFactories;
033
034 /**
035 * An ExecutionContext is a representation of the environment or context in which a component or operation is operating. Some
036 * components require this context to be passed into individual methods, allowing the context to vary with each method invocation.
037 * Other components require the context to be provided before it's used, and will use that context for all its operations (until
038 * it is given a different one).
039 *
040 * @author Randall Hauch
041 * @author John Verhaeg
042 * @see ExecutionContextFactory
043 */
044 public interface ExecutionContext extends ClassLoaderFactory {
045
046 /**
047 * @return the access control context; may be <code>null</code>
048 */
049 AccessControlContext getAccessControlContext();
050
051 /**
052 * Return a logger associated with this context. This logger records only those activities within the context and provide a
053 * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log
054 * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}.
055 *
056 * @param clazz the class that is doing the logging
057 * @return the logger, named after <code>clazz</code>; never null
058 * @see #getLogger(String)
059 */
060 Logger getLogger( Class<?> clazz );
061
062 /**
063 * Return a logger associated with this context. This logger records only those activities within the context and provide a
064 * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log
065 * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}.
066 *
067 * @param name the name for the logger
068 * @return the logger, named after <code>clazz</code>; never null
069 * @see #getLogger(Class)
070 */
071 Logger getLogger( String name );
072
073 /**
074 * @return the login context; may be <code>null</code>
075 */
076 LoginContext getLoginContext();
077
078 /**
079 * Get the namespace registry for this context.
080 *
081 * @return the namespace registry; never <code>null</code>
082 */
083 NamespaceRegistry getNamespaceRegistry();
084
085 /**
086 * Get the factory for creating {@link Property} objects.
087 *
088 * @return the property factory; never <code>null</code>
089 */
090 PropertyFactory getPropertyFactory();
091
092 /**
093 * Get the JAAS subject for which this context was created.
094 *
095 * @return the subject; never <code>null</code>
096 */
097 Subject getSubject();
098
099 /**
100 * Get the factories that should be used to create values for {@link Property properties}.
101 *
102 * @return the property value factory; never null
103 */
104 ValueFactories getValueFactories();
105 }