FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/CORBA/server/src/server/Main.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
CORBA
/
server
/
src
/
server
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
65 lines (61 loc) · 2.55 KB
Breadcrumbs
java-code-example
/
CORBA
/
server
/
src
/
server
/
Main.java
Copy path
File metadata and controls
executable file
·
65 lines (61 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Main.java
*
* Created on 14 ëþòîãî 2008, 19:03
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package
server
;
import
org
.
omg
.
CosNaming
.*;
import
org
.
omg
.
CORBA
.*;
import
org
.
omg
.
PortableServer
.*;
/**
* êëàññ, êîòîðûé ðåàëèçóåò èíòåðôåéñ äëÿ óäàëåííîãî âûçîâà
* ñîçäàíèå êîäà äëÿ îáúåêòà ñåðâåðà
*/
class
EnvPOAImpl
extends
EnvPOA
{
/** ðåàëèçàöèÿ èíòåðôåéñà CORBA - ðàñøèðåíèå êëàññà EnvPOA(org.omg.PortableServer.Servant.)
* @param name ïîëó÷åíèå ïàðàìåòðà îò óäàëåííîãî îáúåêòà
* @return âîçâðàùåíèå ïàðàìåòðà òèïà ñòðîêà óäàëåííîìó îáúåêòó
*/
public
String
getenv
(
String
name
) {
System
.
out
.
println
(
"server get argument:"
+
name
);
return
"remote method say: "
+
name
;
}
}
public
class
Main
{
/**
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
) {
try
{
// ñòàðò è èíèöèàëèçàöèÿ ORB áðîêåðà
System
.
out
.
println
(
"Creating and initializing the ORB..."
);
org
.
omg
.
CORBA
.
ORB
orb
=
org
.
omg
.
CORBA
.
ORB
.
init
(
args
,
null
);
//
System
.
out
.
println
(
"Registering server implementation with the ORB..."
);
POA
rootpoa
=(
POA
)
orb
.
resolve_initial_references
(
"RootPOA"
);
rootpoa
.
the_POAManager
().
activate
();
// ñîçäàíèå îáúåêòà-ñåðâåðà
EnvPOAImpl
impl
=
new
EnvPOAImpl
();
// ïðåîáðàçîâàíèå îáúåêòà-ñåðâåðà â CORBA îáúåêò
org
.
omg
.
CORBA
.
Object
ref
=
rootpoa
.
servant_to_reference
(
impl
);
// âûâîäèì IOR(óíèêàëüíûé èäåíòèôèêàòîð îáúåêòà) ññûëêó ñ ïîìîùüþ ìåòîäà object_to_string
System
.
out
.
println
(
orb
.
object_to_string
(
ref
));
// ïîëó÷åíèå ññûëêè íà ñåðâèñ èìåíîâàíèÿ
org
.
omg
.
CORBA
.
Object
namingContextObj
=
orb
.
resolve_initial_references
(
"NameService"
);
NamingContext
namingContext
=
NamingContextHelper
.
narrow
(
namingContextObj
);
// ñîçäàåòñÿ íóæíîå èìÿ îáúåêòà
NameComponent
[]
path
={
new
NameComponent
(
"Env"
,
"Object"
)};
// ñâÿçûâàíèå îáúåêòà ñ åãî èìåíåì
System
.
out
.
println
(
"Binding server implementation to name service..."
);
namingContext
.
rebind
(
path
,
ref
);
// ïåðåõîäèì â ñîñòîÿíèå îæèäàíèÿ ñî ñòîðîíû êëèåíòîâ
System
.
out
.
println
(
"Waiting for invocations from clients..."
);
orb
.
run
();
}
catch
(
Exception
e
){
System
.
out
.
println
(
"error in create or work CORBA Server "
+
e
.
getMessage
());
}
}
}
Back
|
FazBrowse Home
|
New Git URL