Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

em linha

Home C�digos de fonte E-Livros Downloads Contatar-nos Sobre n�s

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting


Exemplo de EJB

Previous Next





A estrutura do diret�rio

Criar a seguinte estrutura do diret�rio sob algum diret�rio l�gico do pai, tal como o _example de c:\ejb. Esta estrutura do diret�rio � para finalidades do desenvolvimento somente; as limas da distribui��o ser�o fechadas em uma lima do frasco em um momento e desdobradas aos jboss.

src/
|__client/
| |___com/
| |___examples/
| limas |___client de java
|__server/
| |__com/
| |___examples/
| o |___server (feij�o) java arquiva
|__shared
| |__com/
| |___examples/
| |___remote e limas home de java
|
montar
frascos |___client e do usu�rio
|
alvo
|___client/
| |___com/
| | |___examples/
| | |___client, telecontrole e classes home de java
| |___jndi.properties
|___server/
|__com/
| |___examples/
| |___server (feij�o), telecontrole e classes home de java
|___META-INF/
|___ejb-jar.xml
 





A classe do feij�o

criar a classe do feij�o como o src \ usu�rio \ COM \ exemplos \ HelloBean.java. Esta classe � um feij�o stateless da sess�o e contem nossa l�gica do neg�cio. Neste caso imprime - para fora excitar e sempre �til �Hello! Mundo�.


package com.examples;

import javax.ejb.*;

public class HelloBean implements SessionBean
{
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext sc){}

public String sayHello ()
{
System.out.println ("Someone called sayHello()");
return �Hello! World�;
}
}
 





A rela��o remota

Criar a rela��o remota como src \ compartilhou \ COM \ exemplos \ Hello.java. Esta � a rela��o que os clientes remotos falam em vez a falar diretamente � classe do feij�o, HelloBean. Observar que seu somente m�todo � o sayHello (), que � o m�todo de neg�cio em HelloBean.


package com.examples;

import javax.ejb.*;
import java.rmi.*;

public interface Hello extends EJBObject
{
public String sayHello() throws RemoteException;
}
 




A rela��o Home

Criar a rela��o home como src \ compartilhou \ COM \ exemplos \ HelloHome.java. Esta rela��o estar� usada criar um exemplo Hello da rela��o quando n�s queremos executar a l�gica do neg�cio do sayHello ().


package com.examples;

import javax.ejb.*;
import java.rmi.*;

public interface Hello extends EJBObject
{
public String sayHello() throws RemoteException;
}
 




O cliente

criar o cliente como o src \ cliente \ COM \ exemplos \ HelloClient.java. Este � o cliente �remoto� que usar� nosso feij�o da sess�o. Primeiramente, usa o InitialContext come�ar um punho a HelloHome. Usa ent�o a rela��o de HelloHome criar hello. hello � uma rela��o remota que representa nossa classe do feij�o. Depois que hello est� usado executar a l�gica do neg�cio (sayHello), o feij�o est� liberado atrav�s do m�todo remover.



package com.examples;

import javax.ejb.*;
import java.rmi.*;
import javax.rmi.*;
import javax.naming.*;

public class HelloClient
{
public static void main (String[] args) throws Exception
{
Context c = new InitialContext();
Object o = c.lookup ("Hello");

HelloHome home =
(HelloHome)PortableRemoteObject.narrow (o,HelloHome.class);
Hello hello = home.create();
System.out.println (hello.sayHello());
hello.remove();
}
}
 




ejb-jar.xml

Criar a lima de ejb-jar.xml no alvo \ usu�rio \ META-INF. Este descriptor da distribui��o contem a informa��o que o recipiente dos jboss EJB necessita a fim desdobrar e funcionar nosso EJB.


<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>com.examples.HelloHome</home>
<remote>com.examples.Hello</remote>
<ejb-class>com.examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
 




jndi.properties

Criar a lima de jndi.properties no alvo \ cliente. Esta lima define as propriedades que s�o requeridas a fim usar JNDI encontrar EJBs na rede.


java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099




Previous Next

Keywords: EJB Example,jboss ejb example,ejb client example,jboss example,ejb sample,j2ee example,xdoclet example,weblogic example,cmp example,jboss examples,ejb sample code,ejb examples,jboss sample,j2ee sample,sample j2ee application,j2ee examples,web services example,ejb jar xml example,ejb web services,sample weblogic xml,sample ejb jar xml


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizes
Oracle Quiz
MySQL Quiz
Operating System Quizes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizes
Testing Quiz
Firewalls Quiz
SAP Module Quizes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizes
Corba Quiz
Networking Quiz
Microsoft Office Quizes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizes
Financial Accounting Quiz
Managerial Accounting Quiz

Privacy Policy
Copyright � 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.