User: slaboure
Date: 01/08/15 09:44:35
Added: src/examples/org/jboss/docs/appletclient/applet
AppletEjbCaller.java
Log:
Client Applet for the appletclient example.
Revision Changes Path
1.1
manual/src/examples/org/jboss/docs/appletclient/applet/AppletEjbCaller.java
Index: AppletEjbCaller.java
===================================================================
/*
* JBoss, the OpenSource J2EE WebOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.docs.appletclient.applet;
import java.util.* ;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
import org.jboss.docs.appletclient.interfaces.*;
import javax.naming.* ;
import javax.rmi.* ;
/**
* Example bean for testing Applet client. Applet.
*
* @author Sacha Labourey ([EMAIL PROTECTED])
*
* @version $Revision: 1.1 $
*/
public class AppletEjbCaller extends JApplet
{
JPanel buttonPanel = new JPanel();
JButton callEjbButton = new JButton();
JPanel labelPanel = new JPanel();
JLabel ejbMessageLabel = new JLabel();
// Construct the Applet
//
public AppletEjbCaller () {}
// Initialize the applet
//
public void init()
{
try
{
this.setSize(new Dimension(400, 65));
callEjbButton.setText("Get server message");
callEjbButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
callEjbButton_actionPerformed(e);
}
});
ejbMessageLabel.setText("no call performed yet.");
this.getContentPane().add(buttonPanel, BorderLayout.CENTER);
buttonPanel.add(callEjbButton, null);
this.getContentPane().add(labelPanel, BorderLayout.SOUTH);
labelPanel.add(ejbMessageLabel, null);
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**Get Applet information*/
public String getAppletInfo()
{
return "JBoss EJB client Applet demo";
}
void callEjbButton_actionPerformed(ActionEvent e)
{
try
{
Properties jndiProps = new Properties() ;
String myServer = this.getCodeBase().getHost ();
jndiProps.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory" ) ;
jndiProps.setProperty("java.naming.provider.url", myServer ) ;
jndiProps.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces" ) ;
TestAppletHome home = (TestAppletHome)PortableRemoteObject.narrow( new
InitialContext(jndiProps).lookup( "TestAppletBean" ), TestAppletHome.class) ;
TestApplet remote = home.create() ;
ejbMessageLabel.setText( remote.getMessage() ) ;
}
catch ( SecurityException se )
{
se.printStackTrace ();
ejbMessageLabel.setText (se.toString ());
}
catch( Exception ex )
{
System.err.println( "APPLET" );
ex.printStackTrace();
}
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development