广

Java编程

  • IOS开发
  • android开发
  • PHP编程
  • JavaScript
  • ASP.NET
  • ASP编程
  • JSP编程
  • Java编程
  • 易语言
  • Ruby编程
  • Perl编程
  • AJAX
  • 正则表达式
  • C语言
  • 编程开发

    Java CORBA入门

    2018-10-13 10:38:57 次阅读 稿源:互联网
    零七广告

      Below is a simple example of a CORBA program
      download the source file 
      
      <b>1. prodUCe a idl file like this</b>
         hello.idl
         module HelloApp {
           interface Hello    {         
               string sayHello();
          };
        };
      
      <b>2. produce stub and skeleton files through idltoJava.exe</b>
         idltojava hello.idl
         idltojava is now named as idlj.exe and is included in the JDK. 
      
      <b>3. write a server program like this </b>
      
      // HelloServer.java 
        
      import HelloApp.*;
      
      import org.omg.CosNaming.*;
      import org.omg.CosNaming.NamingContextPackage.*;
      import org.omg.CORBA.*;
      
      import java.io.*;
      class HelloServant extends _HelloImplBase 
      {
          public String sayHello()
          {
             return "Hello world !!"; 
          }   
        
      }
      
      public class HelloServer {
      
          public static void main(String args[])
          {
       try{
           // create and initialize the ORB
           ORB orb = ORB.init(args, null);
      
           // create servant and register it with the ORB
           HelloServant helloRef = new HelloServant();
           orb.connect(helloRef);
      
           // get the root naming context
           org.omg.CORBA.Object objRef = 
       orb.resolve_initial_references("NameService");
           NamingContext ncRef = NamingContextHelper.narrow(objRef);
      
           // bind the Object Reference in Naming
           NameComponent nc = new NameComponent("Hello", "");
     

    零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。

    零七广告
    零七广告
    零七广告
    零七广告