OPEN NOTEPAD USING CORBA
By karthick
, in
OPEN NOTEPAD USING CORBA
,
0 Comments
Idl file notepad.idl
module
notepad
{
interface
note
{
string
display();
};
};
Implementation file noteimpl.java
import
notepad.*;
import
org.omg.CORBA.*;
import
java.io.*;
public
class noteimpl extends notePOA
{
private
ORB orb;
public
noteimpl(ORB orb)
{
this.orb
= orb;
}
public
String display()
{
return("C:\\WINDOWS\\system32\\notepad");
}
}
Server file noteserv.java
import
notepad.*;
import
org.omg.CosNaming.*;
import
org.omg.CosNaming.NamingContextPackage.*;
import
org.omg.CORBA.*;
import
org.omg.PortableServer.*;
import
org.omg.PortableServer.POA;
public
class noteserv
{
public
static void main(String args[])
{
try
{
ORB orb
= ORB.init(args,null);
noteimpl
impl = new noteimpl(orb);
POA
rootpoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
org.omg.CORBA.Object
ref = rootpoa.servant_to_reference(impl);
note
wref = noteHelper.narrow(ref);
org.omg.CORBA.Object
objref = orb.resolve_initial_references("NameService");
NamingContextExt
ncRef = NamingContextExtHelper.narrow(objref);
NameComponent
nc = new NameComponent("note","");
NameComponent
path[] = {nc};
ncRef.rebind(path,wref);
System.out.println("Server
ready & waiting.....");
orb.run();
}
catch(Exception
e)
{
System.err.println("ERROR"+e);
}
System.out.println("Server
Exiting............");
}
}
Client file notecli.java
import
notepad.*;
import
java.io.*;
import
org.omg.CosNaming.*;
import
org.omg.CosNaming.NamingContextPackage.*;
import
org.omg.CORBA.*;
public
class notecli
{
public
static void main(String args[])throws IOException
{
try
{
ORB orb
= ORB.init(args,null);
org.omg.CORBA.Object
objRef = orb.resolve_initial_references("NameService");
NamingContextExt
ncRef = NamingContextExtHelper.narrow(objRef);
NameComponent
nc = new NameComponent("note","");
NameComponent
path[] = {nc};
note
impl = noteHelper.narrow(ncRef.resolve(path));
Runtime
r=Runtime.getRuntime();
r.exec(impl.display());
}
catch(Exception
e)
{
System.out.println("ERROR:"+e);
}
}
}
Compilation
D:\kar\New
Folder\serv>set path=C:\Program Files\Java\jdk1.6.0\bin
D:\kar\New
Folder\serv>idlj -fall note.idl
D:\kar\New
Folder\serv>cd notepad
D:\kar\New
Folder\serv\notepad>path.bat
D:\kar\New
Folder\serv\notepad>set path=C:\Program Files\Java\jdk1.6.0\bin
D:\kar\New
Folder\serv\notepad>javac *.java
Note: notePOA.java
uses unchecked or unsafe operations.
Note:
Recompile with -Xlint:unchecked for details.
D:\kar\New
Folder\serv\notepad>cd..
D:\kar\New
Folder\serv>javac *.java
D:\kar\New
Folder\serv>tnameserv
Initial
Naming Context:
IOR:000000000000002b49444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f
6e746578744578743a312e30000000000001000000000000009a000102000000000e3139322e3136
382e312e32303200038400000045afabcb0000000020000f42400000000100000000000000020000
0008526f6f74504f41000000000d544e616d65536572766963650000000000000008000000010000
00011400000000000002000000010000002000000000000100010000000205010001000100200001
0109000000010001010000000026000000020002
TransientNameServer:
setting port for initial object references to: 900
Ready.
Open new window
D:\kar\New
Folder\serv>set path=C:\Program Files\Java\jdk1.6.0\bin
D:\kar\New
Folder\serv>java noteserv
Server
ready & waiting.....
Open new window
D:\kar\New
Folder\serv>java notecli
D:\kar\New
Folder\serv>
Output
0 Response to "OPEN NOTEPAD USING CORBA"
Post a Comment