The stateless session bean is a fantastic implementation choice for business processes which require no server-side state to be retained in between client invocations. If all information needed to process a request can be found in the request itself, the SLSB may be used as a highly efficient endpoint. In this example we build an encryption service capable of performing both one-way hashing and encryption/decryption operations.
Additionally, we show here that SLSBs may indeed have their own internal state, so long as that it’s not leaked out to the client during requests. Finally, we introduce the use of XML via environment entries to externalize configurable elements of the service.
Wiki article: http://community.jboss.org/docs/DOC-15567
Following is a full listing of all source code used in this runnable example.
package org.jboss.ejb3.examples.ch05.encryption; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.KeySpec; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; ...