📄 datapopulatorbean.java
字号:
/* * @author : Neelesh * @Version : 1.0 * * Development Environment : Oracle9i JDeveloper * Name of the File : DataPopulatorBean.java * Creation/Modification History : * * Neelesh 26-Dec-2002 Created * */package oracle.otnsamples.vsm.services;import java.util.ArrayList;import java.util.Collection;import java.util.Date;import javax.ejb.SessionBean;import javax.ejb.SessionContext;import javax.naming.InitialContext;import javax.naming.NamingException;import oracle.otnsamples.vsm.entities.CategoryAttributeLocal;import oracle.otnsamples.vsm.entities.CategoryAttributeLocalHome;import oracle.otnsamples.vsm.entities.CategoryLocal;import oracle.otnsamples.vsm.entities.CategoryLocalHome;import oracle.otnsamples.vsm.entities.CountryLocalHome;import oracle.otnsamples.vsm.entities.CountryPK;import oracle.otnsamples.vsm.entities.CustomerLocal;import oracle.otnsamples.vsm.entities.CustomerLocalHome;import oracle.otnsamples.vsm.entities.InventoryLocalHome;import oracle.otnsamples.vsm.entities.ItemAttributeLocalHome;import oracle.otnsamples.vsm.entities.ItemDetailLocal;import oracle.otnsamples.vsm.entities.ItemDetailLocalHome;import oracle.otnsamples.vsm.entities.ItemLocal;import oracle.otnsamples.vsm.entities.ItemLocalHome;import oracle.otnsamples.vsm.entities.ShopDetailLocal;import oracle.otnsamples.vsm.entities.ShopDetailLocalHome;import oracle.otnsamples.vsm.entities.ShopLocal;import oracle.otnsamples.vsm.entities.ShopLocalHome;import oracle.otnsamples.vsm.entities.SubCategoryLocalHome;/** * The implementation class uses entity beans to populate countries,customers, * smaple categories,shops and items - in English and French */public class DataPopulatorBean implements SessionBean { /** * Container callback for bean creation */ public void ejbCreate() { } /** * Called just after the bean instance is activated */ public void ejbActivate() { } /** * Called just before the bean instance is passivated */ public void ejbPassivate() { } /** * Called just before the bean instance is removed */ public void ejbRemove() { } /** * Sets the session context * * @param <b>ctx</b> session context object */ public void setSessionContext(SessionContext ctx) { } /** * The method populates an initial data set- countries,sample users, * shops,items,categories. */ public void populate() { try { this.populateCategories(); this.populateCountry(); this.populateCustomers(); this.populateShops(); this.populateItems(); } catch(Exception ex) { ex.printStackTrace(); } finally { } } /** * Home lookup method for SubCategoryLocal entity * * @return <b>SubCategoryLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private SubCategoryLocalHome getSubCategoryLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (SubCategoryLocalHome) context.lookup("java:comp/env/ejb/SubCategoryLocal"); } /** * Home lookup method for ShopLocal entity * * @return <b>ShopLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private ShopLocalHome getShopLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (ShopLocalHome) context.lookup("java:comp/env/ejb/ShopLocal"); } /** * Home lookup method for ItemLocal entity * * @return <b>ItemLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private ItemLocalHome getItemLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (ItemLocalHome) context.lookup("java:comp/env/ejb/ItemLocal"); } /** * Home lookup method for CustomerLocal entity * * @return <b>CustomerLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private CustomerLocalHome getUserLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (CustomerLocalHome) context.lookup("java:comp/env/ejb/UserLocal"); } /** * Home lookup method for CategoryLocal entity * * @return <b>CatregoryLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private CategoryLocalHome getCategoryLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (CategoryLocalHome) context.lookup("java:comp/env/ejb/CategoryLocal"); } /** * Home lookup method for InventoryLocal entity * * @return <b>InventoryLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private InventoryLocalHome getInventoryLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (InventoryLocalHome) context.lookup("java:comp/env/ejb/InventoryLocal"); } /** * Home lookup method for CountryLocal entity * * @return <b>CountryLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private CountryLocalHome getCountryLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (CountryLocalHome) context.lookup("java:comp/env/ejb/CountryLocal"); } /** * Home lookup method for ItemAttributeLocal entity * * @return <b>ItemAttributeLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private ItemAttributeLocalHome getItemAttributeLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (ItemAttributeLocalHome) context.lookup("java:comp/env/ejb/ItemAttributeLocal"); } /** * Home lookup method for ItemDetailLocal entity * * @return <b>ItemDetailLocalHome</b> * * @throws <b>NamingException</b> if the entity home was not found */ private ItemDetailLocalHome getItemDetailLocalHome() throws NamingException { final InitialContext context = new InitialContext(); return (ItemDetailLocalHome) context.lookup("java:comp/env/ejb/ItemDetailLocal"); } /** * Populates the countries */ private void populateCountry() { try { CountryLocalHome c = this.getCountryLocalHome(); c.create("10", "Afghanistan"); c.create("100", "Albania"); c.create("101", "Algeria"); c.create("102", "Angola"); c.create("103", "Anguilla"); c.create("104", "Antarctica"); c.create("105", "Antigua And Barbuda"); c.create("106", "Argentina");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -