working on it ...

Filters

Explore Public Snippets

Sort by

Found 3 snippets matching: "java corba"

    public by lbottaro  406535  1  7  9

    Simple CORBA java server

    This code shows an example of simple corba server in java. A CORBA server needs a local ORB object. The server instantiates an ORB and registers its servant objects so that the ORB can find the server when it receives an invocation for it. the server is a process that instantiates one or more servant objects. Each servant implements the
    // The package containing our stubs.
    import HelloApp.*;
    
    // HelloServer will use the naming service.
    import org.omg.CosNaming.*;
    
    // The package containing special exceptions thrown by the name service.
    import org.omg.CosNaming.NamingContextPackage.*;
    
    // All CORBA applications need these classes.
    import org.omg.CORBA.*;
    
    public class HelloServer 
    {
      public static void main(String args[])
      {
        try{
           // Create and initialize the ORB
          ORB orb = ORB.init(args, null);
          
          // Create the 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", "");
          NameComponent path[] = {nc};
          ncRef.rebind(path, helloRef);
          
          // Wait for invocations from clients
          java.lang.Object sync = new java.lang.Object();
          synchronized(sync){
            sync.wait();
          }
              } catch(Exception e) {
            System.err.println("ERROR: " + e);
            e.printStackTrace(System.out);
          }  
      }
    }
    
    class HelloServant extends _HelloImplBase
    {
      public String sayHello()
      {
        return "\nHello world!!\n";
        }
    }
        

    public by lbottaro  2053  0  7  1

    Simple CORBA IDL interface

    This code shows an example of a IDL interface to be used in a simple Java Corba application. The IDL interface defines the contract between the client and server parts of your application, specifying what operations and attributes are available. Since OMG IDL is purely declarative language and programming-language independent, a mapping to J
    module HelloApp
    {
      interface Hello
      {
        string sayHello();
      };
    }; 
       

    public by lbottaro  2551  0  6  2

    Simple CORBA java client

    This code represents a simple CORBA java application client. Each CORBA client needs a local ORB object to perform the marshaling and IIOP work. Each client instantiates an org.omg.CORBA.ORB object and initializes it. Once the application has an ORB, it can ask the ORB to locate the actual service it needs, in this case the Hello server. W
    import HelloApp.*;           // The package containing our stubs.
    import org.omg.CosNaming.*;  // HelloClient will use the naming service.
    import org.omg.CORBA.*;      // All CORBA applications need these classes.
    
    
    public class HelloClient
    {
      public static void main(String args[])
      {
        try{
          
          // Create and initialize the ORB
          ORB orb = ORB.init(args, null);
          
          // Get the root naming context
          org.omg.CORBA.Object objRef = 
              orb.resolve_initial_references("NameService");
          NamingContext ncRef = NamingContextHelper.narrow(objRef);
          
          // Resolve the object reference in naming
          NameComponent nc = new NameComponent("Hello", "");
          NameComponent path[] = {nc};
          Hello helloRef = HelloHelper.narrow(ncRef.resolve(path));
          
          // Call the Hello server object and print results
          String hello = helloRef.sayHello();
          System.out.println(hello);
              
        } catch(Exception e) {
            System.out.println("ERROR : " + e);
            e.printStackTrace(System.out);
          }  
      }
    }
       

    List Complete ( 3 snippets total )

    • Public Snippets
    • Channels Snippets