KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > projector > SystemContext


1 package org.apache.slide.projector;
2
3 import java.io.IOException JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import org.apache.commons.httpclient.Credentials;
7 import org.apache.slide.projector.store.Cache;
8 import org.apache.slide.projector.store.ProcessStore;
9 import org.apache.slide.projector.store.RepositoryStore;
10
11 public class SystemContext extends AbstractContext {
12     protected final static String JavaDoc BOOKMARK = "_bookmark_";
13     protected Store stepStore;
14     
15     private Credentials credentials = Projector.getCredentials();
16     private Cache contextStore = new Cache();
17     private RepositoryStore repositoryStore = new RepositoryStore(this);
18     private ProcessStore transientProcessStore = new ProcessStore(Cache.getInstance());
19     private ProcessStore persistentProcessStore = new ProcessStore(repositoryStore);
20     private Cache inputParameterStore = new Cache();
21     
22     public Store getStore(int store) {
23         switch ( store ) {
24             case Store.CACHE : {
25                 return Cache.getInstance();
26             }
27             case Store.CONTEXT : {
28                 return contextStore;
29             }
30             case Store.REPOSITORY : {
31                 return repositoryStore;
32             }
33             case Store.TRANSIENT_PROCESS : {
34                 return transientProcessStore;
35             }
36             case Store.PERSISTENT_PROCESS : {
37                 return persistentProcessStore;
38             }
39             case Store.INPUT : {
40                 return inputParameterStore;
41             }
42             case Store.STEP : {
43                 return stepStore;
44             }
45         }
46         return null;
47     }
48
49     public void setCredentials(Credentials credentials) {
50         this.credentials = credentials;
51     }
52     
53     public Credentials getCredentials() {
54         return credentials;
55     }
56
57     public void setProcessId(String JavaDoc processId) {
58         transientProcessStore.setProcessId(processId);
59         persistentProcessStore.setProcessId(processId);
60     }
61     
62     public String JavaDoc getProcessId() {
63         return transientProcessStore.getProcessId();
64     }
65
66     public void setBookmark(URI processor) throws IOException JavaDoc {
67         transientProcessStore.put(BOOKMARK, processor);
68     }
69     
70     public URI getBookmark() throws IOException JavaDoc {
71         return (URI)transientProcessStore.get(BOOKMARK);
72     }
73
74     public void setStepStore(Store store) {
75         this.stepStore = store;
76     }
77
78     public void setInputParameters(Map JavaDoc parameters) {
79         inputParameterStore.setMap(parameters);
80     }
81 }
Popular Tags