/**
   * Invoke the AppOne with the scoped client context. The initial connection will use the
   * 'quickuser1', to differentiate the cluster connection it will be use the user 'quickuser2' to
   * see if the clustered context is used or not.
   *
   * @param text Simple text which will be logged at server side.
   * @return simple collection of the returned results
   */
  private String invokeAppOne(String text) {
    Context iCtx = null;

    final Properties ejbClientContextProps = new Properties();
    ejbClientContextProps.put("endpoint.name", "appMain->appOne_endpoint");
    // --- Property to enable scoped EJB client context which will be tied
    // to the JNDI context ---
    ejbClientContextProps.put("org.jboss.ejb.client.scoped.context", true);
    // Property which will handle the ejb: namespace during JNDI lookup
    ejbClientContextProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    ejbClientContextProps.put(
        "remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    // add a property which lists the connections that we are configuring.
    // In this example, we are just configuring a single connection.
    final String connectionName = "appOneConnection";
    ejbClientContextProps.put("remote.connections", connectionName);
    // add the properties to connect the app-one host
    ejbClientContextProps.put("remote.connection." + connectionName + ".host", "localhost");
    ejbClientContextProps.put("remote.connection." + connectionName + ".port", "4547");
    ejbClientContextProps.put("remote.connection." + connectionName + ".username", "quickuser1");
    ejbClientContextProps.put("remote.connection." + connectionName + ".password", "quick123+");
    ejbClientContextProps.put("remote.clusters", "ejb");
    ejbClientContextProps.put("remote.cluster.ejb.username", "quickuser2");
    ejbClientContextProps.put("remote.cluster.ejb.password", "quick+123");

    try {
      // this context will not use the server configured
      // 'outbound-connection' and also did not use the
      // jboss-ejb-client.xml.
      iCtx = new InitialContext(ejbClientContextProps);
      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++) {
        // invoke on the bean
        final String appOneResult = bean.invoke(text);
        if (i > 0) {
          result.append(", ");
        }
        result.append(appOneResult);
      }
      result.append("}");

      LOGGER.info("AppOne (loop) returns : " + result);
      return result.toString();

    } catch (NamingException e) {
      LOGGER.error("Could not invoke appOne", e);
      return null;
    } finally {
      saveContextClose(iCtx);
    }
  }
Пример #2
0
 public void callEJBAppOneRemote() {
   LOOGER.info(
       "Try to invoke the remote AppOne to log the given text and get the invocation results. Proxy="
           + oneApp);
   this.invocation.setResult(oneApp.invoke(this.invocation.getText()));
 }