1 7 package com.inversoft.verge.repository; 8 9 10 import javax.servlet.http.HttpServletRequest ; 11 import javax.servlet.jsp.PageContext ; 12 13 import com.inversoft.beans.BeanException; 14 import com.inversoft.verge.repository.config.Config; 15 import com.inversoft.verge.repository.config.ItemConfig; 16 import com.inversoft.verge.util.WebBean; 17 18 19 27 public class RepositoryBean extends WebBean { 28 29 private Config config; 30 31 32 37 public RepositoryBean(Config config) throws BeanException { 38 super(); 40 assert (config != null) : "config == null"; 41 42 this.config = config; 43 44 initialize(config.getID(), config.getScope()); 45 setBeanClass(((ItemConfig) config).getBeanClass()); 46 } 47 48 53 public RepositoryBean(String id, HttpServletRequest request) 54 throws BeanException { 55 super(); 57 config = Repository.getInstance().lookupConfig(request, id); 58 if (config == null) { 59 throw new BeanException("Invalid repository id: " + id); 60 } 61 62 initialize(id, config.getScope()); 63 setBeanClass(((ItemConfig) config).getBeanClass()); 64 } 65 66 67 79 public Object getInstance(PageContext pageContext, HttpServletRequest request) 80 throws BeanException { 81 return Repository.getInstance().lookupItem(request, config); 82 } 83 } 84 | Popular Tags |