View Javadoc

1   package org.telscenter.pas.service;
2   
3   import java.beans.beancontext.BeanContextServiceProvider;
4   import java.beans.beancontext.BeanContextServices;
5   import java.util.Iterator;
6   
7   import org.telscenter.pas.beans.PasProject;
8   import org.telscenter.pas.ui.frames.PasFrame;
9   
10  public class PasProjectServiceProvider implements BeanContextServiceProvider {
11  
12  	private IHingeState hingeService = new IHingeState() {
13  		String state = null;
14  
15  		public String[] getDefinedStates() {
16  			return new String[] { "one", "two" };
17  		}
18  
19  		public String getState() {
20  			return state;
21  		}
22  
23  		public void setState(String value) {
24  			state = value;
25  		}
26  
27  	};
28  
29  	private IHintService hintService;
30  
31  //	private IMessagingService messagingService;
32  	
33  	private INavigationService navigationService;
34  
35  	private INoteService noteService;
36  
37  	private final PasFrame pasFrame;
38  
39  	private PasProject pasProject;
40  
41  	private IWorkReportService workReportService;
42  	
43  	private IPasFrameService pasFrameService;
44  
45  	public PasProjectServiceProvider(PasProject project) {
46  		this.pasProject = project;
47  		this.pasFrame = project.getProjectFrame();
48  		initPasServices();
49  	}
50  
51  	@SuppressWarnings("unchecked")
52  	public Iterator getCurrentServiceSelectors(BeanContextServices bcs,
53  			Class serviceClass) {
54  		// TODO Auto-generated method stub
55  		return null;
56  	}
57  
58  	// ServiceProvider
59  
60  	public IHingeState getHingeService() {
61  		return hingeService;
62  	}
63  
64  	public IHintService getHintService() {
65  		return hintService;
66  	}
67  
68  /*	public IMessagingService getMessagingService() {
69  		return messagingService;
70  	}
71  */
72  	public INavigationService getNavigationService() {
73  		return navigationService;
74  	}
75  
76  	public INoteService getNoteService() {
77  		return noteService;
78  	}
79  
80  	@SuppressWarnings("unchecked")
81  	public Object getService(BeanContextServices bcs, Object requestor,
82  			Class serviceClass, Object serviceSelector) {
83  		if (serviceClass == IHintService.class) {
84  			return hintService;
85  		} else if (serviceClass == INavigationService.class) {
86  			return navigationService;
87  		} else if (serviceClass == INoteService.class) {
88  			return noteService;
89  		} else if (serviceClass == IHingeState.class) {
90  			return hingeService;
91  //		} else if (serviceClass == IMessagingService.class) {
92  //			return messagingService;
93  		} else if (serviceClass == IPasFrameService.class) {
94  			return pasFrameService;
95  		} else
96  			return null;
97  	}
98  
99  	public PasProject getPasProject() {
100 		return pasProject;
101 	}
102 
103 	public IWorkReportService getWorkReportService() {
104 		return workReportService;
105 	}
106 
107 	protected void initPasServices() {
108 		navigationService = new NavigationService(pasProject);
109 		noteService = new NoteService(pasFrame);
110 		hintService = new HintService(pasFrame);
111 		workReportService = new WorkReportService(pasProject, navigationService);
112 		
113 //		 FIXME this SHOULD be used as a mediator
114 		pasFrameService = new PasFrameService(pasFrame);
115 		
116 		// FIXME this needs to pass in the current OfferingUuid
117 		// FIXME Mantaray is disabled because it has problems with JWS
118 //		messagingService = new MantarayMessagingService(OfferingUuid.getNullId());
119 		
120 		
121 	}
122 
123 	/***
124 	 * @param bcs
125 	 */
126 	public void register(BeanContextServices bcs) {
127 		bcs.addService(INoteService.class, PasProjectServiceProvider.this);
128 		bcs.addService(IHintService.class, PasProjectServiceProvider.this);
129 		bcs.addService(INavigationService.class,
130 				PasProjectServiceProvider.this);
131 		bcs.addService(IPasFrameService.class, PasProjectServiceProvider.this);
132 		bcs.addService(IHingeState.class, PasProjectServiceProvider.this);
133 		
134 	}
135 
136 	public void releaseService(BeanContextServices bcs, Object requestor,
137 			Object service) {
138 		// TODO Auto-generated method stub
139 
140 	}
141 
142 	public void setHingeService(IHingeState hingeService) {
143 		this.hingeService = hingeService;
144 	}
145 
146 	public void setHintService(IHintService hintService) {
147 		this.hintService = hintService;
148 	}
149 
150 /*	public void setMulticastMessageService(
151 			IMessagingService multicastMessageService) {
152 		this.messagingService = multicastMessageService;
153 	}
154 */
155 	
156 	public void setNavigationService(INavigationService navigationService) {
157 		this.navigationService = navigationService;
158 	}
159 
160 	public void setNoteService(INoteService noteService) {
161 		this.noteService = noteService;
162 	}
163 
164 	public void setPasProject(PasProject pasProject) {
165 		this.pasProject = pasProject;
166 	}
167 
168 	public void setWorkReportService(IWorkReportService workReportService) {
169 		this.workReportService = workReportService;
170 	}
171 
172 	public IPasFrameService getPasFrameService() {
173 		return pasFrameService;
174 	}
175 
176 	public void setPasFrameService(IPasFrameService pasFrameService) {
177 		this.pasFrameService = pasFrameService;
178 	}
179 
180 }