Skip to content

Commit

Permalink
BZ1016853: Fixes for ejb-multi-server quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
sgilda committed Oct 8, 2013
1 parent 8d1dca5 commit b45dbfb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class MainAppBean implements MainApp {
*/
private InitialContext iCtx;

@EJB(lookup = "ejb:jboss-as-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
@EJB(lookup = "ejb:jboss-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
AppOne appOneProxy;
@EJB(lookup = "ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
@EJB(lookup = "ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
AppTwo appTwoProxy;

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ public String invokeAll(String text) {
String lookup = "";
// Call AppTwo with the direct ejb: naming
try {
lookup = "ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName();
lookup = "ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName();
result.append(" > " + invokeAppTwo(lookup, text));
LOGGER.info("Invoke '" + lookup + " OK");
}catch (Exception e) {
Expand Down Expand Up @@ -134,7 +134,7 @@ private String invokeAppOne(String text) {
* The application two can be called via lookup.
* <ul>
* <li>with the standard naming
* <i>ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts
* <i>ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts
* .ejb.multi.server.app.AppTwo</i></li>
* <li><i>java:global/AliasAppTwo</i> the alias provided by the server
* configuration <b>this is not recommended</b></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private String invokeAppOne(String text) {
// 'outbound-connection' and also did not use the
// jboss-ejb-client.xml.
iCtx = new InitialContext(ejbClientContextProps);
final AppOne bean = (AppOne) iCtx.lookup("ejb:jboss-as-ejb-multi-server-app-one/ejb//AppOneBean!" + AppOne.class.getName());
final AppOne bean = (AppOne) iCtx.lookup("ejb:jboss-ejb-multi-server-app-one/ejb//AppOneBean!" + AppOne.class.getName());

StringBuffer result = new StringBuffer("{");
for (int i = 0; i < 8; i++) {
Expand Down Expand Up @@ -189,7 +189,7 @@ private String invokeAppTwo(String text) {
Context iCtxA = null;
try {
iCtxA = new InitialContext(ejbClientContextProps);
beanA = (AppTwo) iCtxA.lookup("ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName());
beanA = (AppTwo) iCtxA.lookup("ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName());
} catch (NamingException e) {LOGGER.error("Could not create InitialContext('appTwoA')");}

// change the necessary properties to call the other server
Expand All @@ -200,7 +200,7 @@ private String invokeAppTwo(String text) {
Context iCtxB = null;
try {
iCtxB = new InitialContext(ejbClientContextProps);
beanB = (AppTwo) iCtxB.lookup("ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName());
beanB = (AppTwo) iCtxB.lookup("ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!" + AppTwo.class.getName());
} catch (NamingException e) {
LOGGER.error("Could not create InitialContext('appTwoB')");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class JsfController {
* Inject a different bean implementation of the same interface.<br/>
* Or use the @Resource annotation with the lookup name only.
*/
@Resource(mappedName = "ejb:jboss-as-ejb-multi-server-app-main/ejb/MainEjbClient34AppBean!org.jboss.as.quickstarts.ejb.multi.server.app.MainApp")
@Resource(mappedName = "ejb:jboss-ejb-multi-server-app-main/ejb/MainEjbClient34AppBean!org.jboss.as.quickstarts.ejb.multi.server.app.MainApp")
MainApp mainEjbClient34App;

/**
Expand All @@ -59,14 +59,14 @@ public class JsfController {
* Therefore a fix/workaround is necessary to be able to compile.
* See <a href="http://jaitechwriteups.blogspot.co.uk/2011/02/resource-and-new-lookup-attribute-how.html">Jaikiran's technical blog<a>
*/
@Resource(lookup = "ejb:jboss-as-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
@Resource(lookup = "ejb:jboss-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
AppOne oneApp;

/**
* Injection with @EJB is not possible for a foreign application in a different server. For this we can use @Resource.
* Here, we use <code>mappedName</code>, which was available prior to Java EE 6, to avoid compilation errors.
*/
@Resource(mappedName = "ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
@Resource(mappedName = "ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
AppTwo twoApp;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
write(response, "<h2>Invoke AppOne on different server</h2>");
try {
AppOne proxy = (AppOne) lookup(response, iCtx,
"ejb:jboss-as-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne");
"ejb:jboss-ejb-multi-server-app-one/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne");
if (proxy != null) {
write(response, "Invocation #1 return node.name => " + proxy.getJBossNodeName() + "<br/>");
// second invocation shows whether the same or a different node is reached
Expand All @@ -76,7 +76,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
write(response, "<h2>Invoke AppTwo on different server</h2>");
try {
AppTwo proxy = (AppTwo) lookup(response, iCtx,
"ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo");
"ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo");
if (proxy != null) {
write(response, "Invocation #1 return node.name => " + proxy.getJBossNodeName() + "<br/>");
// second invocation shows whether the same or a different node is reached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext(props);

final boolean useScopedExample = Boolean.getBoolean("UseEjbClient34");
final String rcal = "ejb:jboss-as-ejb-multi-server-app-main/ejb//" + (useScopedExample ? "MainEjbClient34AppBean" : "MainAppBean") + "!" + MainApp.class.getName();
final String rcal = "ejb:jboss-ejb-multi-server-app-main/ejb//" + (useScopedExample ? "MainEjbClient34AppBean" : "MainAppBean") + "!" + MainApp.class.getName();
final MainApp remote = (MainApp) context.lookup(rcal);
final String result = remote.invokeAll("Client call at "+new Date());

Expand Down
8 changes: 4 additions & 4 deletions ejb-multi-server/deploy-domain.cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
batch
deploy app-one/ear/target/jboss-as-ejb-multi-server-app-one.ear --server-groups=quickstart-ejb-multi-appOne-server
deploy app-two/ear/target/jboss-as-ejb-multi-server-app-two.ear --server-groups=quickstart-ejb-multi-appTwo-server
deploy app-main/ear/target/jboss-as-ejb-multi-server-app-main.ear --server-groups=quickstart-ejb-multi-main-server
deploy app-web/target/jboss-as-ejb-multi-server-app-web.war --server-groups=quickstart-ejb-multi-appWeb-server
deploy app-one/ear/target/jboss-ejb-multi-server-app-one.ear --server-groups=quickstart-ejb-multi-appOne-server
deploy app-two/ear/target/jboss-ejb-multi-server-app-two.ear --server-groups=quickstart-ejb-multi-appTwo-server
deploy app-main/ear/target/jboss-ejb-multi-server-app-main.ear --server-groups=quickstart-ejb-multi-main-server
deploy app-web/target/jboss-ejb-multi-server-app-web.war --server-groups=quickstart-ejb-multi-appWeb-server
run-batch
2 changes: 1 addition & 1 deletion ejb-multi-server/install-domain.cli
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ batch
/host=master/server-config=app-twoB:add(auto-start=true, group=quickstart-ejb-multi-appTwo-server, socket-binding-port-offset=800)

# add an alias for app2 bean to demonstrate how to avoid direct dependency to destination app name
/profile=full/subsystem=naming/binding=java\:global\/AliasAppTwo:add(binding-type=lookup, lookup="ejb:jboss-as-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")
/profile=full/subsystem=naming/binding=java\:global\/AliasAppTwo:add(binding-type=lookup, lookup="ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")


# --- add an additional server and group for web application only
Expand Down
8 changes: 4 additions & 4 deletions ejb-multi-server/undeploy-domain.cli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# remove all deployments from the domain
undeploy --server-groups=quickstart-ejb-multi-appWeb-server jboss-as-ejb-multi-server-app-web.war
undeploy --server-groups=quickstart-ejb-multi-main-server jboss-as-ejb-multi-server-app-main.ear
undeploy --server-groups=quickstart-ejb-multi-appOne-server jboss-as-ejb-multi-server-app-one.ear
undeploy --server-groups=quickstart-ejb-multi-appTwo-server jboss-as-ejb-multi-server-app-two.ear
undeploy --server-groups=quickstart-ejb-multi-appWeb-server jboss-ejb-multi-server-app-web.war
undeploy --server-groups=quickstart-ejb-multi-main-server jboss-ejb-multi-server-app-main.ear
undeploy --server-groups=quickstart-ejb-multi-appOne-server jboss-ejb-multi-server-app-one.ear
undeploy --server-groups=quickstart-ejb-multi-appTwo-server jboss-ejb-multi-server-app-two.ear

0 comments on commit b45dbfb

Please sign in to comment.