GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members  

GATContext.java

Go to the documentation of this file.
00001 package org.gridlab.gat;
00002 
00003 import java.util.Enumeration;
00004 import java.util.List;
00005 import java.util.Vector;
00006 
00007 import org.gridlab.gat.security.SecurityContext;
00008 
00009 /**
00010  * An instance of this class is the primary GAT state object.
00011  */
00012 public class GATContext implements Cloneable {
00013 
00014     /**
00015      * This member variable holds the preferences for this GATContext
00016      */
00017     private Preferences preferences = null;
00018 
00019     /**
00020      * This member variable holds the SecurityContext's for this GATcontext
00021      */
00022     private Vector securityContexts = null;
00023 
00024     /**
00025      * This no arguments constructor creates an instance of a GATContext.
00026      */
00027     public GATContext() {
00028         super();
00029 
00030         securityContexts = new Vector();
00031     }
00032 
00033     /**
00034      * Adds the passed SecurityContext.
00035      * 
00036      * @param securityContext
00037      *            A SecurityContext.
00038      */
00039     public void addSecurityContext(SecurityContext securityContext) {
00040         securityContexts.add(securityContext);
00041     }
00042 
00043     /**
00044      * Removes the passed SecurityContext.
00045      * 
00046      * @param securityContext
00047      *            A SecurityContext.
00048      */
00049     public void removeSecurityContext(SecurityContext securityContext) {
00050         securityContexts.remove(securityContext);
00051     }
00052 
00053     /**
00054      * Gets the list of SecurityContexts associated with this GATContext.
00055      * 
00056      * @return java.util.List of SecurityContexts.
00057      */
00058     public List getSecurityContexts() {
00059         return securityContexts;
00060     }
00061 
00062     /**
00063      * Gets a list of SecurityContexts of the specified type associated with
00064      * this GATContext.
00065      * 
00066      * @param type
00067      *            A SecurityContext type, a java.lang.String
00068      * @return java.util.List of SecurityContexts.
00069      */
00070     public List getSecurityContextsByType(String type) {
00071         SecurityContext nextSecurityContext;
00072         Vector typedSecurityContexts = new Vector();
00073 
00074         Enumeration enumeration = securityContexts.elements();
00075         while (enumeration.hasMoreElements()) {
00076             nextSecurityContext = (SecurityContext) enumeration.nextElement();
00077 
00078             if (type.equals(nextSecurityContext.getType())) {
00079                 typedSecurityContexts.add(nextSecurityContext);
00080             }
00081         }
00082 
00083         return typedSecurityContexts;
00084     }
00085 
00086     /**
00087      * Adds a Preferences object to the GATContext which will be used to choose
00088      * between adaptors if the constructor of an object is not called with a
00089      * Preferences object. Only one such object may be associated with the
00090      * GATContext at any one time.
00091      * 
00092      * @param preferences
00093      *            A Preferences object.
00094      */
00095     public void addPreferences(Preferences preferences) {
00096         this.preferences = preferences;
00097     }
00098 
00099     /**
00100      * Removes the Preferences object associated with the GATContext.
00101      */
00102     public void removePreferences() {
00103         preferences = null;
00104     }
00105 
00106     /**
00107      * Returns the Preferences object associated with the GATContext.
00108      */
00109     public Preferences getPreferences() {
00110         return preferences;
00111     }
00112 
00113     /**
00114      * Returns a clone of this context.
00115      */
00116     public Object clone() {
00117         return null;
00118     }
00119 }