Archive for May, 2007

May 25 2007

Failure

Published by under .NET,IT


We haven’t won ;-( Congratulations to our mates from Poznan University of Technology. Top 2 places in the cup.

I would like to thank to: Lukasz Pobereznik, Agnieszka Zielinska, Jakub Jarzabek, Leszek Siwik, Pawel Krainski and Marek Naborczyk for participating in vayron.net project.
It was a great pleasure to work with you.We are considering taking part in Imagine Cup next year. Maybe it will be more successful than 2006 and 2007…

No responses yet

May 16 2007

Imagine Cup 2007

Published by under .NET,IT

We are going to participate in Imagine Cup national finals in Warsaw next week!
Our project Vayron.NET is competing in category ‘Software Design’.

If you are curious please visit http://vayron.net and join the game.

Keep your fingers crossed!

No responses yet

May 04 2007

Injecting EJB 3.0 beans into Struts 2.0

Published by under IT,Java

EJB 3.0 provides easy bean injection. While developing web layer in Struts 2.0 you can use similar mechanism as well. Struts 2.0 is using Spring libraries for implementing Inversion of Control design pattern.

EJB 3.0 is based on using Java 1.5 annotations. It simplifies deployment process.

Let define example Session Bean.

@Stateless(mappedName=”ejb/EmployeeManager”)
public class EmployeeManagerSB implements IEmployeeManager {

public Long createAccount(String loginName) {
// Implementation of creating an account…
}

}

It implements interface:

@Remote
@Local

public interface IEmployeeManager {

Long createAccount(String loginName);

}

To use EmployeeManager session bean in Struts 2.0 reference to this object has to be retrieved.

Let define Struts action class which will use EmployeeManager session bean.

@Validation()
public class NewEmployeeAction extends ActionSupport {

private IEmployeeManager employeeManager;
private String loginName;
private long id;
private String redirectURL;

public String execute() throws Exception {
Long id = this.employeeManager.createAccount(this.loginName);
this.setId(id.longValue());
return SUCCESS;
}

public IEmployeeManager getEmployeeManager() {
return employeeManager;
}

public void setEmployeeanager(IEmployeeManager employeeManager) {
this.employeeManager = employeeManager;
}

public String getLoginName() {
return loginName;
}

@RequiredStringValidator(message = “Please enter a login name”, trim = true)
public void setLoginName(String loginName) {
this.loginName = loginName;
}

public long getId() {
return id;
}

public String getRedirectURL() {
return redirectURL;
}

public void setRedirectURL(String redirectURL) {
this.redirectURL = redirectURL;
}

}

Framework is taking care of injecting proper object while creating this action object. In Struts 2.0 the only thing that has to be done to do this is defining it in applicationContext.xml configuration file.

<jee:jndi-lookup id=”employeeManager” name=”ejb/EmployeeManager“>

<bean id=”newEmployeeAction” class=”pl.edu.agh.sius2007.jspynet.struts.NewEmployeeAction”>
<property name=”employeeManager” ref=”employeeManager”>
</bean>

The only configuration in Struts is defining two beans.

  • employeeManager which will be retrieved from JNDI;
  • newEmployeeAction which is Struts action.

employeeManager bean will be retrieved automatically and injected into newEmployeeAction.

No responses yet