1 16 package org.outerj.daisy.frontend; 17 18 import org.outerj.daisy.repository.Repository; 19 import org.outerj.daisy.repository.RepositoryManager; 20 import org.outerj.daisy.repository.Credentials; 21 import org.outerj.daisy.repository.clientimpl.RemoteRepositoryImpl; 22 import org.apache.avalon.framework.service.Serviceable; 23 import org.apache.avalon.framework.service.ServiceManager; 24 import org.apache.avalon.framework.service.ServiceException; 25 import org.apache.avalon.framework.activity.Initializable; 26 import org.apache.avalon.framework.thread.ThreadSafe; 27 28 33 public class GuestRepositoryProviderImpl implements GuestRepositoryProvider, Serviceable, Initializable, ThreadSafe { 34 private ServiceManager serviceManager; 35 private Repository templateRepository; 36 37 public void service(ServiceManager serviceManager) throws ServiceException { 38 this.serviceManager = serviceManager; 39 } 40 41 public void initialize() throws Exception { 42 RepositoryManager repositoryManager = (RepositoryManager)serviceManager.lookup("daisy-repository-manager"); 43 try { 44 templateRepository = repositoryManager.getRepository(new Credentials("guest", "guest")); 45 } finally { 46 serviceManager.release(repositoryManager); 47 } 48 } 49 50 public Repository getGuestRepository() { 51 return (Repository)((RemoteRepositoryImpl)templateRepository).clone(); 52 } 53 } 54 | Popular Tags |