This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • ejbtimer-javaee6 - A simple EJB timer service application

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{scrollbar}

Application Overview

This sample demonstrates a calender based timer service that triggers certain callbacks to enterprise beans at a specified time or interval programmatically. The cron-style timer service is managed by the EJB container and can be created using @Schedule annotation.

Also this sample introduces the annotation way to define servlets, stateless session beans and Persistence Context.

Application Content

ejbtimer-javaee6 application consists of following list of packages and classes.

...

indent
0
0
\|\_ header.html
indent
0
0
\|\_ intro.html

Application Implementation

geronimo-web.xml specifies the module's information and the url for the web application

...

Code Block
java
java
titleLog.java
@Entity
public class Log implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	String createTime;
	String event;

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getEvent() {
		return event;
	}

	public void setEvent(String event) {
		this.event = event;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof Log)) {
			return false;
		}
		Log other = (Log) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.test.entity.Log[id=" + id + "]";
	}

}

Get the source code

Please reference Samples General Information for information on obtaining and building the source for this and other samples.

Build the web application

Once all the sources get checked out the next step is to build ejbtimer-javaee6. It requires Maven 2 for building the binaries.

...

This process will take a couple of minutes. The binaries will be generated in the corresponding target directory .

Deploy the web application

Deploying sample application is pretty straight forward as we are going to use the Geronimo Console.

  1. Scroll down to Deploy New from the Console Navigation panel.
  2. Load ejbtimer-javaee6-war-3.0-SNAPSHOT.war from ejbtimer-javaee6-war/target folder in to the Archive input box.
  3. Press Install button to deploy application in the server.

Test the web application

The app is visible at http://localhost:8080/ejbtimer-javaee6/

...