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.app;
18
19 import javax.annotation.PostConstruct;
20 import javax.annotation.Resource;
21 import javax.ejb.EJB;
22 import javax.enterprise.inject.Model;
23 import javax.enterprise.inject.Produces;
24 import javax.inject.Named;
25
26 import org.jboss.logging.Logger;
27
28
29
30
31
32
33 @Model
34 public class JsfController {
35 private static final Logger LOOGER = Logger.getLogger(JsfController.class);
36 private EjbInvocation invocation;
37
38
39
40
41
42
43
44
45 @EJB(beanName = "MainAppBean", beanInterface = MainApp.class)
46 MainApp mainApp;
47
48
49
50
51
52 @Resource(mappedName = "ejb:jboss-ejb-multi-server-app-main/ejb/MainAppSContextBean!org.jboss.as.quickstarts.ejb.multi.server.app.MainApp")
53 MainApp mainAppScopedContext;
54
55
56
57
58
59
60
61
62 @Resource(lookup = "ejb:jboss-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
63 AppOne oneApp;
64
65
66
67
68
69 @Resource(mappedName = "ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
70 AppTwo twoApp;
71
72
73
74
75 @PostConstruct
76 public void initForm() {
77 this.invocation = new EjbInvocation();
78 }
79
80 @Produces
81 @Named
82 public EjbInvocation getInvocation() {
83 return this.invocation;
84 }
85
86 public void callEJBMainLocal() {
87 LOOGER.info("Try to invoke the local MainApp to log the given text and get the invocation results. Proxy=" + mainApp);
88 this.invocation.setResult(mainApp.invokeAll(this.invocation.getText()));
89 }
90
91 public void callEJBMainScopedContextLocal() {
92 LOOGER.info("Try to invoke the local MainAppSContext to log the given text and get the invocation results. Proxy=" + mainAppScopedContext);
93 this.invocation.setResult(mainAppScopedContext.invokeAll(this.invocation.getText()));
94 }
95
96 public void callEJBAppOneRemote() {
97 LOOGER.info("Try to invoke the remote AppOne to log the given text and get the invocation results. Proxy=" + oneApp);
98 this.invocation.setResult(oneApp.invoke(this.invocation.getText()));
99 }
100
101 public void callEJBAppTwoRemote() {
102 LOOGER.info("Try to invoke the remote AppTwo to log the given text and get the invocation results. Proxy=" + twoApp);
103 this.invocation.setResult(twoApp.invoke(this.invocation.getText()));
104 }
105 }