[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: Bean call bean on muti machines with multi JBoss server

changemylife do-not-reply at jboss.com
Wed Oct 10 23:39:04 EDT 2007


  But my design is:
  On the Server1, I have the bean called BeanA. It's simply:
@Remote
  | public interface Check {
  | 	public boolean isValid(double a, double b);
  | }
and bean class:
public @Stateless class CheckBean implements Check {
  | 	
  | 	public boolean isValid(double a, double b) {
  | 		if (b == 0)
  | 			return false;
  | 		else
  | 			return true;
  | 		
  | 	}
  | }
  Ok, I deploy BeanA on Server1.

  Now, On the Server2, I have the bean called BeanB
@Remote
  | public interface Divide {
  | 	public double divideNumber(double a, double b);
  | }
And bean class:
public @Stateless class DivideBean implements Divide {
  | 
  | 	private Context context;
  | 	
  | 	public double divideNumber(double a, double b) {
  | 	   Context ctx = lookupServer();
  | 	   double result = 0;
  | 	   try {
  | 	       Check check = (Check)ctx.lookup("CheckBean\remote");
  | 	                        boolean flag = check.isValid(a, b);
  | 	       if (flag)
  | 		result = a / b;
  | 	       else
  | 		result = 0;
  | 	    } catch (NamingException e) {
  | 		e.printStackTrace();
  | 	    }
  | 		return result;
  | 	}
  | 	
  | 	private Context lookupServer(){
  | 		
  | 		Properties properties = new Properties();
  | 		properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | 		properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
  | 		properties.put("java.naming.provider.url","server1:1099"); <-- lookup on Server1
  | 		
  | 		try {
  | 			context = new InitialContext(properties);
  | 		} catch (NamingException e) {
  | 			e.printStackTrace();
  | 			throw new RuntimeException(e);
  | 		}
  | 		return context;
  | 	}
  | }
  Ok, I deploy BeanB on Server2. But here, I must copy BeanA and paste deploy folder on Server2. How I don't do this (maybe configure to Server2 recognize BeanA)
  
  The Client application on the difference machine:
Properties properties = new Properties();
  | properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
  | properties.put("java.naming.provider.url","server2:1099"); <--- lookup on Server2
  | 
  | Context ctx = new InitialContext();
  | 
  | Divide div = (Divide)ctx.lookup("DivideBean/remote");
  | div.divideNumber(10,2)

 Have some ideas ?

 Thanks.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4093841#4093841

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4093841



More information about the jboss-user mailing list