[jboss-user] [EJB 3.0] - Re: Automatic Destroy State in Stateful Session Bean
grdzeli_kaci
do-not-reply at jboss.com
Wed Oct 4 14:09:48 EDT 2006
ok, I find another problem :
1.i have interface
| package com.magti.businesslayer.ejb3entity.oracle;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface MyState {
| public void initialize();
| }
|
2. Implementation :
| package com.magti.businesslayer.ejb3entity.oracle;
|
| import javax.ejb.Remote;
| import javax.ejb.Stateless;
|
| @Stateless
| @Remote(MyState.class)
| public class StateBean implements MyState
| {
| String name = null;
|
| public void initialize()
| {
| if (name == null)
| {
| System.out.println("Null");
| name = "Initialize";
| }
| else
| {
| System.out.println("Not Null -> "+name);
| }
| }
| }
|
3. Test Client
package com.magti.businesslayer.ejb3entity.oracle;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class TestMain
{
public static void main(String[] args)
{
try
{
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
jndiProps.setProperty(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interface");
jndiProps.setProperty(Context.PROVIDER_URL,
"jnp://192.168.9.136:1099");
InitialContext ctx = new InitialContext(jndiProps);
MyState state = (MyState) ctx.lookup("StateBean/remote");
state.initialize();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
|
| when i run client fierst time i get this result :
| 21:47:33,652 INFO [STDOUT] Null
|
| second time :
| 21:47:34,652 INFO [STDOUT] Null
|
| third time :
| 21:47:35,652 INFO [STDOUT] Initialize
|
| forth time
| 21:47:36,652 INFO [STDOUT] Initialize
|
| fifth time :
| 21:47:37,652 INFO [STDOUT] Initialize
|
| .....
| .....
|
|
| can anybody explain me why ?
|
| this session bean is stateless.
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976122#3976122
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976122
More information about the jboss-user
mailing list