1 package hero.session; 2 3 31 import hero.interfaces.BnProjectLocal; 32 import hero.interfaces.BnProjectLocalHome; 33 import hero.interfaces.BnNodeLocalHome; 34 import hero.interfaces.BnNodeLocal; 35 import hero.interfaces.Constants; 36 import hero.util.EventConstants; 37 import hero.util.HeroException; 38 39 import java.util.ArrayList ; 40 import java.util.Collection ; 41 import java.util.Iterator ; 42 43 import javax.ejb.CreateException ; 44 import javax.ejb.SessionBean ; 45 import javax.ejb.SessionContext ; 46 47 import org.apache.log4j.Logger; 48 49 50 96 97 public class AdminSessionBean implements SessionBean , EventConstants { 98 99 100 private static final Logger trace = Logger.getLogger(AdminSessionBean.class); 105 106 110 private SessionContext mContext; 111 112 116 123 public Collection getModels() throws HeroException { 124 trace.info("start by " + mContext.getCallerPrincipal().getName()); 125 Collection result = new ArrayList (); 126 BnProjectLocalHome projhome; 127 try { 128 projhome = hero.interfaces.BnProjectUtil.getLocalHome(); 129 Collection models =projhome.findByAdmin(mContext.getCallerPrincipal().getName(), Constants.ADMIN, Constants.Pj.MODEL); 130 Iterator mdls = models.iterator(); 131 while (mdls.hasNext()) 132 { 133 BnProjectLocal pj = (BnProjectLocal)mdls.next(); 134 result.add(pj.getBnProjectLightValue()); 135 } 136 return result; 137 } catch (javax.naming.NamingException ne) { 138 trace.error(ne.getMessage()); 139 throw new HeroException(ne.getMessage()); 140 } catch (javax.ejb.FinderException fe) { 141 trace.error(fe.getMessage()); 142 throw new HeroException(fe.getMessage()); 143 } 144 } 145 146 153 public Collection getInstances() throws HeroException { 154 trace.info("start by " + mContext.getCallerPrincipal().getName()); 155 BnProjectLocalHome projhome; 156 Collection result = new ArrayList (); 157 try { 158 projhome = hero.interfaces.BnProjectUtil.getLocalHome(); 159 Collection instances =projhome.findByAdmin(mContext.getCallerPrincipal().getName(), Constants.ADMIN, Constants.Pj.INSTANCE); 160 Iterator inst = instances.iterator(); 161 while (inst.hasNext()) 162 { 163 BnProjectLocal pj = (BnProjectLocal)inst.next(); 164 result.add(pj.getBnProjectLightValue()); 165 } 166 return result; 167 } catch (javax.naming.NamingException ne) { 168 trace.error(ne.getMessage()); 169 throw new HeroException(ne.getMessage()); 170 } catch (javax.ejb.FinderException fe) { 171 trace.error(fe.getMessage()); 172 throw new HeroException(fe.getMessage()); 173 } 174 } 175 176 183 public Collection getActivities() throws HeroException { 184 trace.info("start by " + mContext.getCallerPrincipal().getName()); 185 BnNodeLocalHome nodehome; 186 Collection result = new ArrayList (); 187 try { 188 nodehome = hero.interfaces.BnNodeUtil.getLocalHome(); 189 Collection activities = nodehome.findAdminActivities(mContext.getCallerPrincipal().getName(), Constants.ADMIN, Constants.Pj.INSTANCE, Constants.Pj.COOPERATIVE); 190 Iterator act = activities.iterator(); 191 while (act.hasNext()) 192 { 193 BnNodeLocal nd = (BnNodeLocal)act.next(); 194 result.add(nd.getBnNodeValue()); 195 } 196 return result; 197 } catch (javax.naming.NamingException ne) { 198 trace.error(ne.getMessage()); 199 throw new HeroException(ne.getMessage()); 200 } catch (javax.ejb.FinderException fe) { 201 trace.error(fe.getMessage()); 202 throw new HeroException(fe.getMessage()); 203 } 204 } 205 206 214 215 public void ejbCreate() throws CreateException { 216 trace.debug("ejbCreate"); 217 } 218 219 public void setSessionContext(final javax.ejb.SessionContext context) { 220 mContext = context; 221 } 222 223 public void ejbRemove() { 224 } 225 226 public void ejbActivate() { 227 } 228 229 public void ejbPassivate() { 230 } 231 232 } 233 | Popular Tags |