1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jboss.as.quickstarts.ejb.multi.server;
18
19 import java.util.Date;
20 import java.util.Properties;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
23
24 import javax.naming.Context;
25 import javax.naming.InitialContext;
26
27 import org.jboss.as.quickstarts.ejb.multi.server.app.MainApp;
28 import org.jboss.ejb.client.ContextSelector;
29 import org.jboss.ejb.client.EJBClientConfiguration;
30 import org.jboss.ejb.client.EJBClientContext;
31 import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
32 import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;
33
34
35
36
37
38
39
40
41
42
43
44 public class Client {
45
46
47
48
49
50 public static void main(String[] args) throws Exception {
51
52 Logger.getLogger("org.jboss").setLevel(Level.OFF);
53 Logger.getLogger("org.xnio").setLevel(Level.OFF);
54
55 Properties p = new Properties();
56 p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
57 p.put("remote.connections", "one");
58 p.put("remote.connection.one.port", "4447");
59 p.put("remote.connection.one.host", "localhost");
60 p.put("remote.connection.one.username", "quickuser");
61 p.put("remote.connection.one.password", "quick-123");
62
63 EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
64 ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
65 EJBClientContext.setSelector(selector);
66
67 Properties props = new Properties();
68 props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
69 InitialContext context = new InitialContext(props);
70
71 final boolean useScopedExample = Boolean.getBoolean("UseScopedContext");
72 final String rcal = "ejb:jboss-ejb-multi-server-app-main/ejb//" + (useScopedExample ? "MainAppSContextBean" : "MainAppBean") + "!" + MainApp.class.getName();
73 final MainApp remote = (MainApp) context.lookup(rcal);
74 final String result = remote.invokeAll("Client call at "+new Date());
75
76 System.out.println("InvokeAll succeed: "+result);
77 }
78
79 }