My name is Gurkan Erdogdu and I am the CTO of the MechSoft Mechanical and Software Solutions. I have been active in the Java and Java EE platform more than 10 years. Strong supporter for the Free and Open Source Software, and actively participating within the Open Source based foundations like, Apache Software Foundation, JBoss, and recently Open Web Foundation. I am the member of the Apache Software Foundation and Open Web Foundation. Writing blog at gurkanerdogdu@blogspot.com. Gurkan has posted 24 posts at DZone. View Full User Profile

Introduction to Siwpas: Java EE Compatible Web Profile Server

10.13.2010
| 4950 views |
  • submit to reddit

Siwpas, Simple Web Profile Application Server provides runtime for "Java EE 6.0 Web Profile" platform.SIwpas is licensed under an ASL.

What is Java EE Web Profile?

According to the web profile specification, web profile container must support following technologies,

  • Servlet 3.0
  • JavaServer Pages (JSP) 2.2
  • Expression Language (EL) 2.2
  • Debugging Support for Other Languages (JSR-45) 1.0
  • Standard Tag Library for JavaServer Pages (JSTL) 1.2
  • JavaServer Faces (JSF) 2.0
  • Common Annotations for theJava Platform (JSR-250) 1.1
  • Enterprise JavaBeans (EJB) 3.1 Lite
  • Java Transaction API (JTA) 1.1
  • Java Persistence API (JPA) 2.0
  • Bean Validation 1.0
  • Managed Beans 1.0
  • Interceptors 1.1
  • Contexts and Dependency Injection for the Java EE Platform 1.0
  • Dependency Injection for Java 1.0 

Siwpas supports all of the above technologies to provide Java EE Web Profile compatible runtime. It is implemented based on "Apache Tomcat 7 Servlet & JSP container" and several Apache Software Foundation Java EE projects.

You could download and get more information from the JCP Page of the specification: JSR 316: JavaTM Platform, Enterprise Edition 6 (Java EE 6) Specification,
http://jcp.org/en/jsr/detail?id=316

Siwpas Features

Using EJB 3.1 Features in WAR

Java EE Web Profile enables you to use "EJB 3.1" features embedded directly in your Java EE Web components. You can use following EJB 3.1 features directly
in your web application/s.

  • @Stateless, @Stateful and @Singleton EJB components,
  • @Local, @LocalBean (no interface) client views of EJB components,
  • Transaction, Interceptor, Security container services.

EJB components share same JNDI context with web application that they are deployed into. It means that  EJB components can lookup any references from web application jndi context. You can also use EJB portable global jndi names to inject EJB components into your web components. Global jndi names are portable. It means that you are not required to change jndi names of your context lookups in other Java EE containers.

For example, you can lookup EJB component's proxies from JNDI context like,

InitialContext context = new InitialContext();

//Looking up from global jndi context
context.lookup("java:global/module_name/bean_name")
context.lookup("java:global/module_name/bean_name!Interface Name")

//Looking up from application jndi context
context.lookup("java:app/module_name/bean_name");
context.lookup("java:app/module_name/bean_name!Interface Name")

//Looking up from module jndi context
context.lookup("java:module/bean_name")
context.lookup("java:module/bean_name!Interface Name")

Module name is your web application name. Bean name is EJB component name. Interface name is name of the interface that EJB component implements.

Web components  are able to inject EJB components using "CDI (Context and Dependency Injection)" technology or directly using "@EJB" annotation.

For example, you can use EJB components as "JSF managed beans" or inject them as business services into POJO based JSF managed beans.

Example: Using EJB component as managed beans

@Stateless
@LocalBean
@Named("paymentService")
@RequestScoped
public class PaymentService{

public String pay(){
.......
}

}

OR

inject EJB into POJO based managed bean,

@Named("paymentService")
public class PaymentBean{

//Injection using CDI
@Inject PaymentService paymentService;

//Injection using @EJB
@EJB PaymentService paymentService;

public String pay(){
paymentService.pay();
}
}

Using CDI Features in WAR

SIwpas fully supports JSR-299 specification via Apache OpenWebBeans project. Moreover, you can use JSR-299 based interceptors and decorators for EJB components.
You can inject EJB components into CDI Beans and vice-versa.

Moreover, SIwpas supports for injecting the following resources into your CDI Beans

  • @Resource annotation to inject : DataSource, UserTransaction, ValidatorFactory, Validator, TransactionManager, TransactionSynchronizationRegistry, ORB
  • @EJB annotation to inject EJB components,

You can also use JSR-299 based interceptors and decorators for your EJB components.

Example:

@Interceptor @PaymentLog
public PaymentInterceptor{

@AroundInvoke
public Object beforePayment(InvocationContext ctx) throws Exception{
logger.log(....);
return ctx.proceed();
}
}

@Stateless
public class PaymentService implements IPaymentService{

@PaymentLog
public void pay(...){
...
}
}

 Here, @PaymentLog is an interceptor binding. It binds "PaymentInterceptor" to PaymentService pay() method.

You can also use Decorators for EJB components. It is enough to declare decorator class that also implements EJB component client interface.

@Decorator
public PaymentDecorator implements IPaymentService{
private @Inject @Delegate IPaymentService paymentService;

public void pay(...){
//Any business operation you want to do before actual paymentService
System.out.println(.....);

//Actual business method execution
this.paymentService.pay(...);
}
}

You do not forget to add interceptor & decorator definitions into your "beans.xml" for enabling them.

SIwpas Other Features

Lots of cool and new features are provided with Java EE 6 platform. SIwpas supports all of them.

For example,

  • @DataSourceDefinitions and @DataSourceDefinition annotation support,
  • @Resource(lookup="lookup name") annotation support,
  • @ManagedBean annotation support for POJOs,
  • Servlet 3.0 features, like @WebServlet, @WebListener for defining servlets and listeners,
  • EL 2.2 features,
  • And more...

Future of Siwpas
We will provide a cool "SIwpas Console" to manage and introspect internals of SIwpas application server. Our aim is to implement SIwpas console using JSF 2. It will enable you to configure and manage every aspects of SIwpas, such as, EJB container configuration, listing jndi entries, deploy/undeploy applications, performance charts, protocol configuration and much more.

As you have already know that Oracle TCK's for  testing Java EE containers are not open source. Therefore, we do not know whether we will request certification from Oracle or not  for being compatible with Java EE Web Profile specification. If Oracle could provide us free TCK suite to test our application server, we could definitely use it :) I wish JCP and TCKs would be more open.

Siwpas Project Information

Project Web Page
http://siwpas.mechsoft.com.tr

Project Issue Page
http://siwpas.mechsoft.com.tr/bugs

Download Location

http://siwpas.mechsoft.com.tr/downloads

Enjoy!

Gurkan Erdogdu

ASF Member,http://apache.org

PMC Chair, Apache OpenWebBeans

CTO, MechSoft Mechanical and Software Solutions, http://www.mechsoft.com.tr

Published at DZone with permission of its author, Gurkan Erdogdu.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)