An Online Lottery
Wenchang YAN
Abstract
This proposal is about building a website hosting online lottery. The Internet gives us the chance to expand the lottery business. The advantages of the online lottery to the traditional paper lottery are numerous. That people playing online can save lots of cost; It lets more people to get the chance to play without any time and place restrictions; The online lottery can also reduce the time of the game cycle so that people can play more. Basically the only thing one needs to do is to have a computer with Internet access.
The current technology provides all the phases to construct such a website. Of course there are lots of technology that suffices to give the support to the online lottery. The Enterprise JavaBeans (EJB), however, is one of the most appropriate choice. The rest of this proposal gives some detail of the EJB technology, and explains how we can use it in our online lottery project. We also outlines the way that EJB works with the lottery engine as well.
Objective
To construct a lottery website using the Enterprise JavaBeans.
What is EJB?
The recent JavaTM 2 Platform, Enterprise Edition (J2EETM) supports the EJB. Here is the definition that is given on the official Sun's J2EE website, http://jsp2.java.sun.com/products/ejb/.
EJB, the widely-adopted server-side component architecture for JavaTM 2 Platform, Enterprise Edition (J2EETM), enables rapid development of mission-critical application that are versatile, reusable and portable across middleware while protecting IT investment and preventing vendor lock-in.
EJB is not a product, it is a specification, which defines the EJB component architecture and the interfaces between the Enterprise JavaBeans technology-enabled server and the component. Vendors like BEA, Sun, Oracle and IBM are providing commercial products that implement the EJB specification.
The EJB specification defines an architecture for the development and deployment of transactional, distributed object application-based, server-side software components. Organizations can build their own components or purchase components from third-party vendors. These server-side components, called enterprise beans, are distributed objects that are hosted in Enterprise JavaBean containers and provide remote services for clients distributed throughout the network. Nowadays, various Internet services move the focus from the client side to the server side. This is where the idea of Thin-Client fits in. Although there are lots of technology similar to EJB, like CORBA and COM+, EJB is different from them. You can find more details from this website, http://jsp2.java.sun.com/products/ejb/ejbvscom.html.
Why EJB?
There are lots of websites serve the lottery games, most of them are free to play if you are not hesitate to click on the banner ads you are required to view before you can enter the lotto. Here are a list of those.
The EJB technology is one of the best choice for the online lottery model.
The EJBTM server-side component model simplifies development of middleware components that are transactional, scalable, and portable. Enterprise JavaBeans servers reduce the complexity of developing middleware by providing automatic support for middleware services such as transactions, security, database connectivity, and more. Generally speaking, the key benefits of the EJB technology include,
Protection of IT investment: Wrap and embrace existing infrastructure, application and data stores; Existing middleware solutions are being adapted by the well-established vendors to support the EJB technology via a thin portability layer; Portable across multiple servers and databases; Serve multi-lingual clients - Browsers, Java technology, ActiveX, or CORBA clients; EJB technology simplifies and enhances CORBA and DCOM.
How does it work?
Enterprise beans are software components that run in a special environment called and EJB container. The container hosts and manages an enterprise bean in the same manner that the Java Web Server hosts a servlet or a web browser hosts a Java applet. An enterprise bean cannot function outside of an EJB container. The EJB container manages every aspect of an enterprise bean at runtimes including remote access to the bean, security, persistence, transactions, concurrency, and access to and pooling of resources.
When a client application invokes a remoter method on an enterprise bean, the container first intercepts the invocation to ensure persistence, transactions, and security are applied properly to every operation a client perform on the bean. The container manages security, transactions and persistence automatically for the bean, so the bean developer doesn't have to write this type of logic into the bean code itself. The developer can focus on encapsulating business rules, while the container takes care of everything else.
An enterprise bean depends on the container for everything it needs. If an enterprise bean needs to access a JDBC connection or another enterprise bean, it does so through the container; if an enterprise bean needs to access the identity of its caller, obtain a reference to itself, or access properties it does so through the container. The enterprise bean interacts with its container through one of three mechanisms: callback methods, the EJBContext interface, or the Java Naming and Directory Interface (JNDI).
For more details on EJB technology, please refer to the following useful references.
The online lottery model
Our lottery model implements EJB technology and maps to the classical model/view/controller paradigm as follows:
The website will have the database to keep the personal user information which mainly includes the player's personal file. The other two databases will also be set up. One records the related information of the different services (e.g. different types of lotteries) the website supplies, the other stores the dynamic transaction information every time each player visits the site and plays the lotto, like the player's name, the picking number, picking time and account number, etc.,
The two entity beans, named Player and Playing, are constructed for interaction with the data persistence.
The two session beans, named LottoEngine and AccountInfo, are set up to manage the business and transaction of all the online lottery businesses and dynamic user playing information.
All the model components are shown in the following deployment descriptor file Lotto.ejbml.
The project must also include several JSP and servlet client for rendering the feedback of the user input, providing the user interface, and keep track of all the business transactions.
Tools needed
Lots of web sites give useful information on EJB and other information related to this online lottery project.
EJB is result of the joint effort of many industrial players. Sun and the Java Society are the leaders in this field. This website gives you the most current development information of the EJB technology. It also updates the news about this technology. The EJB learning center provides lots of educational materials on EJB including EJB tutorial, EJB platform and component specifications, and free seminars and online short classes. I studied the tutorial before I wrote this proposal.
The LuckySurf website is not like the other online lottery. It's more focused on the lottery business itself. iWin.com is a famous place for playing lottery. It also has the other fun stuff like games and sports book. PlasmaNet Inc. is an online lottery store. It owns lots of websites and trademark. Freelotto.com is one of them. Grouplotto is much like the LuckySurf website. It's more concentrated on its main lottery business. Most of these online lotteries let people play free lottery. You don't need to put any money into it.. The only thing you need to do is to click on those banner ads. I guess this is what online lotto business different from the traditional lotto. Some of those websites use ASP, while some of them depend heavily on various Java technology.
IBM is one of the leading players of the EJB technology. Its VisualAge for Java is one the best Java IDE on the market which also supports EJB. Furthermore, IBM's distributed lots of products that let the user use its database system DB2 with EJB. You can find more industry-flavored reports, articles and other supports on its website.
This a personal website dedicates to EJB. You can find almost everything you need to know about EJB. Lots of useful links are listed on this page. Fun surfing !
Java Skyline is anther useful resource to learn EJB. As a beginner, I find some detailed examples on this website. You can find lots of concrete EJB examples here. Java Skyline is also an online learning center. If you need to understand and play with the other Java technology like JNDI and JDBC, then come to visit this site. You can also find useful stuff of other Java technology here.
This is a consolidator site specifically designed for Java. You can start searching everything about EJB from this portal.
Some of them are electric books available for downloading.
Lotto.ejbml
<ejbml>
<!---------------------------------------------------------->
<!------- Player Entity Bean ---------------->
<!---------------------------------------------------------->
<entity-bean
name="Player"
descriptor="Lotto/PlayerDeployment"
package="Lotto"
home="Lotto.PlayerHome"
remote="Lotto.Player"
bean="Lotto.PlayerBean"
primary-key="Lotto.PlayerPK"
tx-attribute="TX_SUPPORTS"
>
<property
name="databasePassword"
value="mouse"
/>
<property
name="dataSourceName"
value="Player"
/>
<property
name="databaseUser"
value="user"
/>
<property
name="databaseTable"
value="Player"
/>
<container-managed
storage-helper="com.ejbhome.generator.helpers.RelationalPersistenceCodeHelper"
table="player"
data-source="Player"
user="user"
password="mouse"
>
<field
name="customer_name"
/>
<field
name="email_address"
/>
<field
name="account_number"
/>
<!-- other fields including
home_address, gender, household_income, occupation and DOB, etc -->
</container-managed>
</entity-bean>
<!---------------------------------------------------------->
<!------- Playing Entity Bean ---------------->
<!---------------------------------------------------------->
<entity-bean
name="Playing"
descriptor="Lotto/PlayingDeployment"
package="Lotto"
home="Lotto.PlayingHome"
remote="Lotto.Playing"
bean="Lotto.PlayingBean"
primary-key="Lotto.PlayingPK"
tx-attribute="TX_SUPPORTS"
>
<property
name="databasePassword"
value="mouse"
/>
<property
name="dataSourceName"
value="Playing"
/>
<property
name="databaseUser"
value="user"
/>
<property
name="databaseTable"
value="playing"
/>
<container-managed
storage-helper="com.ejbhome.generator.helpers.RelationalPersistenceCodeHelper"
table="playing"
data-source="Playing"
user="user"
password="mouse"
>
<field
name="account_number"
/>
<field
name="customer_name"
/>
<field
name="lottery_type"
/>
<!-- Other fields include draw_number,
draw_date, draw_time, game_type, etc. -->
</container-managed>
</entity-bean>
<!---------------------------------------------------------->
<!------- LottoEngine Session Bean: The main model maitains the online
lottery ---------------->
<!---------------------------------------------------------->
<session-bean
name="LottoEngine"
descriptor="Lotto/LottoEngineDeployment"
package="Lotto"
home="Lotto.LottoEngineHome"
remote="Lotto.LottoEngine"
bean="Lotto.LottoEngineBean"
type="stateful"
timeout="3484"
tx-attribute="TX_SUPPORTS"
>
</session-bean>
<!---------------------------------------------------------->
<!------- AccountInfo Session Bean: The dynamic server modifies the
player's infomation ---------------->
<!---------------------------------------------------------->
<session-bean
name="AccountInfo"
descriptor="Lotto/AccountInfoDeployment"
package="Lotto"
home="Lotto.AccountInfoHome"
remote="Lotto.AccountInfo"
bean="Lotto.AccountInfoBean"
type="stateful"
timeout="3484"
tx-attribute="TX_SUPPORTS"
>
</session-bean>
</ejbml>