!
"# $ $
% ' & ( )
% &
! " # $ #
% ! &&&# #& # ' ( ! '%
! &&&# )
# !# #
! &&&# #
* ! &&&# #
+ ) ! &&&# # , )
! &&&# #
.
/ ." 0
1 ' $ . 2 '. 3
', , 0
* 44 5,0
6 .' 1
, 7 0
+ . -# 7 1
, $ . # 0
6 8 9 ' '#
-
' .
; '
' 6< ;' jidl;
* 5, 0
jidl =) = > ' 7 '
? ', ' 0
' ' javac.
'
* + ,
$ 8
A
, ' BC! 2
30
D
0
@
'
& ( - ! =
; =' ' ' F 0
6 F ' ' ,'
'$ ' ? , 6<0
7 $G ' F H ,' 0
' $G '= ; F ' '
' ,' 0
; ? ,' #
'
& ( -
; =' ' ' F 0
6 F ' ' ,'
'$ ' ? , 6<0
$G ' F ' '
$G H , 'J , ? ,0
' ? #
-
'
L ; ' ' ,7 ' ?, !'0
3
$
%/
*0 * 2 3
$ * ./
1
1
$ 1
$
4 ) 1
'
* + , 5 )
#include “hello_skel.h”
package hello; Inicializa o ORB
public class Server
{
public static void main(String args[])
{
orb = [Link](args, props);
Inicializa o Adaptador
// Resolve Root POA de Objetos
[Link] rootPOA = [Link](
orb.resolve_initial_references("RootPOA"));
[Link] manager = rootPOA.the_POAManager();
[Link]();
// Cria o objeto
Hello_impl helloImpl = new Hello_impl();
Hello hello = helloImpl._this(orb);
:
'
* + , 5 )
// Grava a referencia do objeto em um arquivo Converte o objeto hello
String ref = orb.object_to_string(hello);
String refFile = "[Link]"; para uma string
[Link] file = new [Link](refFile);
[Link] out = new [Link](file);
[Link](ref);
[Link]();
// Executa o servidor Servidor fica aguardando por requisições
[Link](); de clientes
} //fim do método main
} //fim da classe Server
public class Hello_impl extends HelloPOA
{ Implementação do método say_hello()
public void say_hello()
{
[Link]("Hello world!");
}
}
'
* + , 5 )
package hello;
public class Client
{
public static void main(String args[])
{
[Link] obj = null;
int status = 0;
[Link] orb = null;
Inicializa o ORB
orb = [Link](args, props);
Obtém a Ref. do Objeto remoto
a partir de uma string
try{
String refFile = "[Link]"; armazenada em arquivo
BufferedReader in = new BufferedReader(new FileReader(refFile));
String ref = [Link]();
obj = orb.string_to_object(ref);
}
@
'
* + , 5 )
// Converte para uma referencia ao objeto Hello
Hello hello = [Link](obj); Converte a Referência para
um objeto do tipo Hello
// Chama o metodo remoto
hello.say_hello(); Realiza a chamada ao método
say_hello no objeto remoto
[Link](status);
} //fim método main
} //fim classe Client
'
* ( 5/ 3 /%
interface Agenda
{
string consultaNome(in string nome);
boolean insereItem(in string nome, in string fone);
long statusMem();
void listaItens();
};
E
'
* ( 5 )
package agenda;
public class Agenda_cli
{
public static void main(String args[])
{
int status = 0;
String input; String nome, fone; Inicializa o ORB
boolean res;
[Link] orb = null; [Link] obj = null;
orb = [Link](args, props);
Obtém a Ref. do Objeto remoto
a partir de uma string
String refFile = "[Link]"; armazenada em arquivo
BufferedReader in = new BufferedReader(new FileReader(refFile));
String ref = [Link]();
obj = orb.string_to_object(ref);
:
'
* ( 5 )
// Converte para uma referencia ao objeto Hello
Agenda agenda = [Link](obj);
Converte a Referência para
res = [Link](nome, fone); um objeto do tipo Agenda
if (!res) [Link]("Agenda cheia!");
[Link]();
fone = [Link](nome);
if ([Link]("0"))
[Link]("Nao encontrado!");
else
[Link]("O telefone e': " + fone);
[Link]("Registros na memoria: " + [Link]());
return 0;
} //fim do método main
} //fim da classe Agenda_cli
@
I
'
* ( 5 )
package agenda;
public class Agenda_srv
{
public static void main(String args[]) Inicializa o ORB
{
int status = 0; [Link] orb = null;
orb = [Link](args, props);
[Link] rootPOA =
[Link](orb.resolve_initial_references("RootPOA"));
[Link] manager = rootPOA.the_POAManager();
[Link]();
Inicializa o Adaptador
de Objetos
'
* ( 5 )
// Cria o objeto
Agenda_impl agendaImpl = new Agenda_impl();
Agenda agenda = agendaImpl._this(orb);
Converte o objeto hello
// Grava a referencia ao objeto em um arquivo para uma string
String ref = orb.object_to_string(agenda);
String refFile = "[Link]";
[Link] file = new [Link](refFile);
[Link] out = new [Link](file);
[Link](ref);
[Link]();
// Executa o servidor Servidor fica aguardando por requisições
[Link](); de clientes
[Link](status);
} // fim do método main
} //fim da classe Agenda_srv
K
'
* ( 5 )
public class Agenda_impl extends AgendaPOA
{
final int MAX = 20;
private class Agenda
{
String nome;
Implementação da classe e métodos
String fone;
que serão invocados pelo cliente
};
private Agenda [] ag;
private int numItens;
public Agenda_impl()
{
numItens = 0;
ag = new Agenda[MAX];
for (int i=0; i < MAX; i++)
ag[i] = new Agenda();
} K
'
* ( 5 )
public String consultaNome(String chave)
{
}
public boolean insereItem(String nome, String fone)
{
Implementação dos métodos que serão
}
invocados pelo cliente
public int statusMem()
{
}
public void listaItens()
{
}
} //fim classe Agenda_impl
' $G ' F
/ ' ' ' ' F 0
M' ' ' ',
H ,' ' J = #6 . = ? , ###
Referência de Objeto
IDL:CCS:1.0 lasdix:2133
lasdix:2133 controller:C1
controller:C1
Informação utilizada pelo ORB e
AO para localizar o objeto alvo.
Informações necessárias para que um ORB
estabeleça uma conexão com o servidor.
Informação utilizada para localizar descrições da
interface no Repositório de Interfaces