PlannerBean.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package com.borland.training.meetings.sessions;
- import javax.ejb.*;
- import java.util.*;
- import com.borland.training.meetings.entities.*;
- public class PlannerBean implements SessionBean {
- private SessionContext sessionContext;
- private Date nextStartTime;
- private Collection attendees;
- transient private TimeFinder timeFinder;
- public void ejbCreate(Collection attendeeIds, java.util.Date startTime) {
- try {
- AttendeeValueFactory factory = AttendeeValueFactory.getInstance();
- Iterator iterator = attendeeIds.iterator();
- attendees = new Vector();
- Attendee attendee = null;
- while(iterator.hasNext()) {
- attendee = factory.findAttendee((Long) iterator.next());
- attendees.add(attendee);
- }
- nextStartTime = startTime;
- timeFinder = TimeFinder.getInstance();
- }
- catch(Exception e) {
- throw new javax.ejb.EJBException(e);
- }
- }
- public void ejbRemove() {
- }
- public void ejbActivate() {
- }
- public void ejbPassivate() {
- }
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- }
- public TimePeriod nextAvailableTimePeriod() {
- try {
- TimePeriod availablePeriod = timeFinder.firstAvailableTime(attendees, nextStartTime);
- if(availablePeriod != null) {
- nextStartTime = availablePeriod.getFinishTime();
- }
- return availablePeriod;
- }
- catch (Exception e) {
- throw new javax.ejb.EJBException(e);
- }
- }
- }