1:package is346; 2: 3:public class TrackDelegate { 4: private TrackSessionFacadeHome trackSessionFacadeHome; 5: private TrackSessionFacade trackSessionFacade; 6: public TrackDelegate() throws Exception { 7: initializeTrackSessionFacadeHome(); 8: trackSessionFacade = trackSessionFacadeHome.create(); 9: } 10: 11: public void createTrack(TrackDto trackDto) throws Exception { 12: trackSessionFacade.createTrack(trackDto); 13: } 14: 15: public void removeTrack(Integer id) throws Exception { 16: trackSessionFacade.removeTrack(id); 17: } 18: 19: public void removeTrack(TrackDto trackDto) throws Exception { 20: trackSessionFacade.removeTrack(trackDto); 21: } 22: 23: public void updateTrack(TrackDto trackDto) throws Exception { 24: trackSessionFacade.updateTrack(trackDto); 25: } 26: 27: public void updateTracks(TrackDto[] trackDtos) throws Exception { 28: trackSessionFacade.updateTracks(trackDtos); 29: } 30: 31: public TrackDto trackFindByPrimaryKey(Integer id) throws Exception { 32: return trackSessionFacade.trackFindByPrimaryKey(id); 33: } 34: 35: private void initializeTrackSessionFacadeHome() throws Exception { 36: String FACADE_NAME = "TrackSessionFacade"; 37: Class FACADE_CLASS = is346.TrackSessionFacadeHome.class; 38: if (trackSessionFacadeHome == null) { 39: try { 40: ServiceLocator locator = ServiceLocator.getInstance(); 41: trackSessionFacadeHome = (TrackSessionFacadeHome) locator.getEjbHome( 42: FACADE_NAME, FACADE_CLASS); 43: if (trackSessionFacadeHome == null) { 44: throw new Exception("Did not get home for " + FACADE_NAME); 45: } 46: } 47: catch (ServiceLocatorException e) { 48: throw new Exception(e.getMessage()); 49: } 50: } 51: } 52:}