1 16 package org.apache.cocoon.environment.commandline; 17 18 import org.apache.cocoon.environment.Session; 19 20 import java.util.Enumeration ; 21 import java.util.Hashtable ; 22 23 30 public final class CommandLineSession 31 implements Session { 32 33 private long creationTime = System.currentTimeMillis(); 34 35 private Hashtable attributes = new Hashtable (); 36 37 public CommandLineSession() { 38 } 39 40 public long getCreationTime() { 41 return this.creationTime; 42 } 43 44 public String getId() { 45 return "1"; 46 } 47 48 public long getLastAccessedTime() { 49 return this.creationTime; 50 } 51 52 public void setMaxInactiveInterval(int interval) { 53 } 55 56 public int getMaxInactiveInterval() { 57 return -1; 58 } 59 60 public Object getAttribute(String name) { 61 return this.attributes.get(name); 62 } 63 64 public Enumeration getAttributeNames() { 65 return this.attributes.keys(); 66 } 67 68 public void setAttribute(String name, Object value) { 69 this.attributes.put(name, value); 70 } 71 72 public void removeAttribute(String name) { 73 this.attributes.remove(name); 74 } 75 76 public void invalidate() { 77 this.attributes.clear(); 78 invalidateSession(); 79 } 80 81 public boolean isNew() { 82 return false; 83 } 84 85 protected static CommandLineSession session; 86 87 90 public static Session getSession(boolean create) { 91 if (create && session == null) { 92 session = new CommandLineSession(); 93 } 94 return session; 95 } 96 97 100 public static void invalidateSession() { 101 session = null; 102 } 103 104 } 105 106 | Popular Tags |