Consultor Eletrônico



Kbase 19339: Code example for using an Apptivity SmartBean with other GUI
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/12/1999
KB 19339: Code example for using an Apptivity Smart Bean
with an other non Apptivity GUI.

It is possible to access an Apptivity Smart Bean loaded in a Component
Manager's JVM from an different Graphical User Interface than
the Apptivity client's netscape.application GUI.

The tested code below is based on Apptivity's Incrementer example
using an java.AWT frame as Graphical User Interface.

package NonGuiTest;

import java.awt.*;
import java.applet.*;
import java.net.*;
import java.util.*;
import progress.apptivity.client.*;
import jdbc.math.*;
import java.awt.event.*;
import UseIncrementerEJBHomeTable;

public class MyAction implements ActionListener {
private IData myenv; //Interface to the non Apptivity GUI
abEnv theApp;
abProject prj;
IncrementerBusinessBean.IncrementerRemote incBean;
public MyAction(IData myenv) {
this.myenv = myenv;
}
public void actionPerformed(ActionEvent actEvent)
{
String command = ((java.awt.Button)actEvent.getSource()).getActionCommand();

if (command.equalsIgnoreCase("test")){
if (prj == null) // create the Apptivity CORBA client instance
{
try {
prj = new abProject((Applet)null);
// Get abEnv from the Apptivity CORBA Client
theApp = prj.theApp();
theApp.blockOnInitComplete();
} catch (Exception e) {e.printStackTrace();}

abEJBHomeTable table_of_SmartBeans = theApp.getEJBHomeTable();

if (table_of_SmartBeans != null) {
System.out.println("Got the SmartBeans table: " +
table_of_SmartBeans.toString());
}
else {System.out.println("No EJBHomeTable received");
System.exit(1);}
// Get the IncrementerHome
IncrementerBusinessBean.IncrementerHome t_beanHome =

((UseIncrementerEJBHomeTable)table_of_SmartBeans).getIncrementerHome();

// create the Bean instance
try {
incBean = t_beanHome.create();}
catch (java.rmi.RemoteException re) {re.printStackTrace();}
catch (javax.ejb.CreateException ce) {ce.printStackTrace();}
}

// Get the value from the non Apptivity GUI
int j = (new Integer(myenv.getString1()).intValue());
int k = j;

//pass it to the IncrementerBean; this is a remote call
try {
k = incBean.addOne(j);}
catch(java.rmi.RemoteException re)
{System.out.println("caught RemoteException: ");}

// transfer the result to the non Apptivity GUI
myenv.setString2((new Integer(k)).toString());
}
}
}

Reference to written documentation :

Apptivity Deployment_Guide.pdf
Kbase-Entry : 18595