# FacadeBean.ejb Sample

This topic inludes the source code for the FacadeBean.ejb Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/EJBs/messageDriven/

## Sample Source Code

`01 package messageDriven; 02 03 import java.util.ArrayList; 04 import java.util.Collection; 05 import java.util.Iterator; 06 import javax.ejb.*; 07 import javax.naming.InitialContext; 08 import javax.naming.NamingException; 09 import weblogic.ejb.*; 10 11 /** 12 * @ejbgen:session default-transaction="Supports" 13 * ejb-name="Facade_M" 14 * 15 * @ejbgen:jndi-name local="ejb.FacadeLocalHome_M" 16 * 17 * @ejbgen:ejb-local-ref link="SimpleToken_M" 18 * 19 * @ejbgen:file-generation remote-class="false" remote-class-name = "Facade" remote-home="false" remote-home-name = "FacadeHome" local-class="true" local-class-name="FacadeLocal_M" local-home="true" local-home-name="FacadeLocalHome_M" 20 */ 21 public class FacadeBean 22 extends GenericSessionBean 23 implements SessionBean 24 { 25 private SimpleTokenHome_M tokenHome; 26 private SimpleToken_M token; 27 private Iterator tokenIter; 28 29 public void ejbCreate() { 30 try { 31 javax.naming.Context ic = new InitialContext(); 32 tokenHome = (SimpleTokenHome_M)ic.lookup("java:/comp/env/ejb/SimpleToken_M"); 33 } 34 catch(NamingException ne) { 35 System.out.println("Encountered the following naming exception: " + ne.getMessage()); 36 } 37 } 38 39 /** 40 * @ejbgen:local-method 41 */ 42 public Collection findAllTokens() throws FinderException 43 { 44 Collection allTokensVO = new ArrayList(); 45 tokenIter = tokenHome.findAll().iterator(); 46 while(tokenIter.hasNext()) { 47 token = (SimpleToken_M) tokenIter.next(); 48 allTokensVO.add(new SimpleTokenValue(token.getDate(),token.getEnteredByClass(),token.getName(),token.getObjectHash())); 49 } 50 return allTokensVO; 51 } 52 53 /** 54 * @ejbgen:local-method 55 */ 56 public Collection findAllTokensOrdered() throws FinderException 57 { 58 Collection allTokensVO = new ArrayList(); 59 tokenIter = tokenHome.findAllOrdered().iterator(); 60 while(tokenIter.hasNext()) { 61 token = (SimpleToken_M) tokenIter.next(); 62 allTokensVO.add(new SimpleTokenValue(token.getDate(),token.getEnteredByClass(),token.getName(),token.getObjectHash())); 63 } 64 return allTokensVO; 65 } 66 } 67`