1 4 package com.nightlabs.ipanema.base; 5 6 import java.rmi.RemoteException ; 7 import java.security.Principal ; 8 import java.util.ArrayList ; 9 import java.util.Collection ; 10 import java.util.Hashtable ; 11 12 import javax.ejb.EJBException ; 13 import javax.ejb.SessionContext ; 14 import javax.jdo.PersistenceManager; 15 import javax.jdo.PersistenceManagerFactory; 16 import javax.naming.InitialContext ; 17 18 import com.nightlabs.ModuleException; 19 import com.nightlabs.ipanema.servermanager.IpanemaServerManager; 20 import com.nightlabs.ipanema.servermanager.IpanemaServerManagerFactory; 21 22 31 public class BaseSessionBeanImpl 32 { 33 protected SessionContext sessionContext; 34 35 public void setSessionContext(SessionContext sessionContext) 36 throws EJBException , RemoteException 37 { 38 this.sessionContext = sessionContext; 39 } 40 public void unsetSessionContext() 41 { 42 this.sessionContext = null; 43 } 44 45 51 public IpanemaPrincipal getPrincipal() 52 { 53 Principal pr = sessionContext.getCallerPrincipal(); 54 return (IpanemaPrincipal)pr; 59 } 60 61 69 protected Lookup getLookup() 70 { 71 return getPrincipal().getLookup(); 72 } 73 74 protected PersistenceManagerFactory getPersistenceManagerFactory() 75 throws ModuleException 76 { 77 return getPrincipal().getLookup().getPersistenceManagerFactory(); 78 } 79 80 protected void cache_addDirtyObjectIDs(Collection objectIDs) 81 throws ModuleException 82 { 83 getPrincipal().getLookup().getCacheManager().addDirtyObjectIDs(objectIDs); 84 } 85 86 protected void cache_addDirtyObjectID(Object objectID) 87 throws ModuleException 88 { 89 ArrayList l = new ArrayList (1); 90 l.add(objectID); 91 getPrincipal().getLookup().getCacheManager().addDirtyObjectIDs(l); 92 } 93 94 103 protected PersistenceManager getPersistenceManager() 104 throws ModuleException 105 { 106 return getPrincipal().getLookup().getPersistenceManager(); 107 } 108 109 protected InitialContext getInitialContext() 110 throws ModuleException 111 { 112 return getPrincipal().getLookup().getInitialContext(); 113 } 114 115 128 protected InitialContext getInitialContext(String organisationID) 129 throws ModuleException 130 { 131 return getPrincipal().getLookup().getInitialContext(organisationID); 132 } 133 134 149 protected Hashtable getInitialContextProps(String organisationID) 150 throws ModuleException 151 { 152 return getPrincipal().getLookup().getInitialContextProps(organisationID); 153 } 154 155 protected IpanemaServerManagerFactory getIpanemaServerManagerFactory() 156 throws ModuleException 157 { 158 return getPrincipal().getLookup().getIpanemaServerManagerFactory(); 159 } 160 161 protected IpanemaServerManager getIpanemaServerManager() 162 throws ModuleException 163 { 164 return getPrincipal().getLookup().getIpanemaServerManager(); 165 } 166 167 protected String getOrganisationID() 168 throws ModuleException 169 { 170 return getPrincipal().getOrganisationID(); 171 } 172 173 protected String getUserID() 174 throws ModuleException 175 { 176 return new String (getPrincipal().getUserID()); 177 } 178 179 protected boolean userIsOrganisation() 180 throws ModuleException 181 { 182 return getPrincipal().userIsOrganisation(); 183 } 184 185 protected String getPrincipalString() 186 throws ModuleException 187 { 188 return getPrincipal().toString(); 189 } 190 } 191 | Popular Tags |