1:package is346; 2: 3:public class ArtistDelegate { 4: private ArtistSessionFacadeHome artistSessionFacadeHome; 5: private ArtistSessionFacade artistSessionFacade; 6: public ArtistDelegate() throws Exception { 7: initializeArtistSessionFacadeHome(); 8: artistSessionFacade = artistSessionFacadeHome.create(); 9: } 10: 11: public void createArtist(ArtistDto artistDto) throws Exception { 12: artistSessionFacade.createArtist(artistDto); 13: } 14: 15: public void removeArtist(Integer id) throws Exception { 16: artistSessionFacade.removeArtist(id); 17: } 18: 19: public void removeArtist(ArtistDto artistDto) throws Exception { 20: artistSessionFacade.removeArtist(artistDto); 21: } 22: 23: public void updateArtist(ArtistDto artistDto) throws Exception { 24: artistSessionFacade.updateArtist(artistDto); 25: } 26: 27: public void updateArtists(ArtistDto[] artistDtos) throws Exception { 28: artistSessionFacade.updateArtists(artistDtos); 29: } 30: 31: public ArtistDto artistFindByPrimaryKey(Integer id) throws Exception { 32: return artistSessionFacade.artistFindByPrimaryKey(id); 33: } 34: 35: private void initializeArtistSessionFacadeHome() throws Exception { 36: String FACADE_NAME = "ArtistSessionFacade"; 37: Class FACADE_CLASS = is346.ArtistSessionFacadeHome.class; 38: if (artistSessionFacadeHome == null) { 39: try { 40: ServiceLocator locator = ServiceLocator.getInstance(); 41: artistSessionFacadeHome = (ArtistSessionFacadeHome) locator.getEjbHome( 42: FACADE_NAME, FACADE_CLASS); 43: if (artistSessionFacadeHome == 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:}