SlideShare uma empresa Scribd logo
1 de 12
CORBA by Example G. Roy Antony Arnold Lecturer / CSE Infant Jesus College of Engineering Tuticorin, Tamilnadu, India
CORBA Program Steps: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
1: Create IDL File The file will be called Hello.idl and will hold a module called SimpleExample.  The contents of this file are shown below. module SimpleExample { interface Hello { string getGreeting(); }; };
2: Compile IDL file idlj –fall Hello.idl This causes a sub-directory with the same name as the module (i.e.,SimpleExample) to be created, holding the six files listed below. •  Hello.java Contains the Java version of our IDL interface. It extends interface HelloOperations , as well as org.omg.CORBA.Object (providingstandard CORBA object functionality) and org.omg.CORBA.portable.IDLEntity.
•  HelloHelper.java  : Provides auxiliary functionality, notably the narrow method required to cast CORBA object references into Hello references. •  HelloHolder.java :  Holds a public instance member of type Hello. If there were any out or inout arguments, this file would also provide operations for them. •  HelloOperations.java :  Contains the Java method signatures for all operations in our IDL file. In this application, it contains the single method getGreeting. •  _HelloImplBase.java :  An abstract class comprising the server skeleton. It provides basic CORBA functionality for the server and implements the Hello interface. Each servant (interface implementation) that we create for this service must extend _HelloImplBase. •  _HelloStub.java :  This is the client stub, providing CORBA functionality for the client. Like _HelloImplBase.java, it implements the Hello interface.
3: Implement the Interface The implementation of an interface is called a ‘servant’, so we shall name our implementation class HelloServant. This class must extend _HelloImplBase. Here is the code: class HelloServant extends _HelloImplBase { public String getGreeting()‏ { return ("Hello there!"); } } This class will be placed inside the same file as our server code.
4: Create the Server The following three standard CORBA packages: •  org.omg.CosNaming (for the naming service); •  org.omg.CosNaming.NamingContextPackage (for special exceptions thrown by the naming service); •  org.omg.CORBA There are several steps required of the server… (i) Create and initialize the ORB. This is effected by calling static method init of class ORB. This method takes two arguments: a String array and a Properties object. The first of these is usually set to the argument list received by main, while the second is almost invariably set to null: ORB orb = ORB.init(args,null);
4: (contd)‏ (ii) Create a servant. HelloServant servant = new HelloServant(); (iii) Register the servant with the ORB. This allows the ORB to pass invocations to the servant and is achieved by means of the ORB class’s connect method: orb.connect(servant); (iv) Get a reference to the root naming context. Method resolve_initial_references of class ORB is called with the String argument “NameService” (defined for all CORBA ORBs) and returns a CORBA Object reference that points to the naming context: org.omg.CORBA.Object objectRef = orb.resolve_initial_references("NameService");
4: (contd)‏ (v) ‘Narrow’ the context reference. In order for the generic Object reference from the previous step to be usable, it must be ‘narrowed’ (i.e., typecast ‘down’ into its appropriate type). This is achieved by the use of method narrow of class NamingContextHelper : NamingContext namingContext = NamingContextHelper.narrow(objectRef); (vi) Create a NameComponent object for our interface. The NameComponent constructor takes two String arguments, the first of which supplies a name for our service. The second argument can be used to specify a category for the first argument, but is typically left as an empty string: NameComponent nameComp = new NameComponent("Hello", "");
4: (contd)‏ (vii) Specify the path to the interface. This is effected by creating an array of NameComponent objects, each of which is a component of the path (in ‘descending’ order), with the last component specifying the name of the NameComponent reference that points to the service. For a service in the same directory, the array will contain a single element, as shown below. NameComponent[] path = (nameComp}; (viii) Bind the servant to the interface path. The rebind method of the NamingContext object created earlier is called with arguments that specify the path and service respectively: namingContext.rebind(path,servant);
4: (contd)‏ (ix) Wait for client calls. Unlike our previous server programs, this is not achieved via an explicitly ‘infinite’ loop. A call is made to method wait of (Java class) Object. This call is isolated within a code block that is declared synchronized, as shown below. java.lang.Object syncObj = new java.lang.Object(); synchronized(syncObj)‏ { syncObj.wait(); }
import SimpleCORBAExample.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class HelloServer { public static void main(String[] args) { try { ORB orb = ORB.init(args,null); HelloServant servant = new HelloServant(); orb.connect(servant); org.omg.CORBA.Object objectRef = orb.resolve_initial_references("NameService"); NamingContext namingContext = NamingContextHelper.narrow(objectRef); NameComponent nameComp = new NameComponent("Hello", ""); NameComponent[] path = {nameComp}; namingContext.rebind(path,servant); java.lang.Object syncObj = new java.lang.Object(); synchronized(syncObj) { syncObj.wait(); } } catch (Exception ex) { System.out.println("*** Server error! ***"); ex.printStackTrace(); } } } class HelloServant extends _HelloImplBase { public String getGreeting() { return ("Hello there!"); } }

Mais conteúdo relacionado

Mais procurados

Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
Raghu nath
 
Chapter10
Chapter10Chapter10
Chapter10
lopjuan
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
elliando dias
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
Mayuresh Wadekar
 

Mais procurados (20)

Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
 
Corba
CorbaCorba
Corba
 
Chapter10
Chapter10Chapter10
Chapter10
 
Corba
CorbaCorba
Corba
 
CORBA
CORBACORBA
CORBA
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
 
CORBA & RMI in java
CORBA & RMI in javaCORBA & RMI in java
CORBA & RMI in java
 
CORBA - Introduction and Details
CORBA - Introduction and DetailsCORBA - Introduction and Details
CORBA - Introduction and Details
 
C O R B A Unit 4
C O R B A    Unit 4C O R B A    Unit 4
C O R B A Unit 4
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
 
Corba
CorbaCorba
Corba
 
Corba in power system
Corba in power systemCorba in power system
Corba in power system
 
Common Object Request Broker Architecture
Common Object Request Broker ArchitectureCommon Object Request Broker Architecture
Common Object Request Broker Architecture
 
CORBA
CORBACORBA
CORBA
 
Unit iv
Unit ivUnit iv
Unit iv
 
CORBA
CORBACORBA
CORBA
 
19.cobra
19.cobra19.cobra
19.cobra
 
Corba
CorbaCorba
Corba
 
Presentation On Com Dcom
Presentation On Com DcomPresentation On Com Dcom
Presentation On Com Dcom
 
85305524 i-t-case-study
85305524 i-t-case-study85305524 i-t-case-study
85305524 i-t-case-study
 

Semelhante a Corba by Example

Unit8 java
Unit8 javaUnit8 java
Unit8 java
mrecedu
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
旻琦 潘
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
Raimonds Simanovskis
 

Semelhante a Corba by Example (20)

Corba
CorbaCorba
Corba
 
Chapter2
Chapter2Chapter2
Chapter2
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
 
Unit8 java
Unit8 javaUnit8 java
Unit8 java
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Global objects in Node.pdf
Global objects in Node.pdfGlobal objects in Node.pdf
Global objects in Node.pdf
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
CORBA.ppt
CORBA.pptCORBA.ppt
CORBA.ppt
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api's
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Best Of Jdk 7
Best Of Jdk 7Best Of Jdk 7
Best Of Jdk 7
 
Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Cocoapods and Most common used library in Swift
Cocoapods and Most common used library in SwiftCocoapods and Most common used library in Swift
Cocoapods and Most common used library in Swift
 
Node js getting started
Node js getting startedNode js getting started
Node js getting started
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 

Mais de Roy Antony Arnold G

Mais de Roy Antony Arnold G (20)

6 sigma
6 sigma6 sigma
6 sigma
 
Run chart
Run chartRun chart
Run chart
 
Reliability growth models for quality management
Reliability growth models for quality managementReliability growth models for quality management
Reliability growth models for quality management
 
6 sigma
6 sigma6 sigma
6 sigma
 
Quality management models
Quality management modelsQuality management models
Quality management models
 
Pareto diagram
Pareto diagramPareto diagram
Pareto diagram
 
Ishikawa diagram
Ishikawa diagramIshikawa diagram
Ishikawa diagram
 
Histogram
HistogramHistogram
Histogram
 
Customer satisfaction
Customer satisfactionCustomer satisfaction
Customer satisfaction
 
Control chart
Control chartControl chart
Control chart
 
Complexity metrics and models
Complexity metrics and modelsComplexity metrics and models
Complexity metrics and models
 
Check lists
Check listsCheck lists
Check lists
 
Capability maturity model
Capability maturity modelCapability maturity model
Capability maturity model
 
Structure chart
Structure chartStructure chart
Structure chart
 
Seven new tools
Seven new toolsSeven new tools
Seven new tools
 
Scatter diagram
Scatter diagramScatter diagram
Scatter diagram
 
Qms
QmsQms
Qms
 
Relations diagram
Relations diagramRelations diagram
Relations diagram
 
Rayleigh model
Rayleigh modelRayleigh model
Rayleigh model
 
Defect removal effectiveness
Defect removal effectivenessDefect removal effectiveness
Defect removal effectiveness
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Corba by Example

  • 1. CORBA by Example G. Roy Antony Arnold Lecturer / CSE Infant Jesus College of Engineering Tuticorin, Tamilnadu, India
  • 2.
  • 3. 1: Create IDL File The file will be called Hello.idl and will hold a module called SimpleExample. The contents of this file are shown below. module SimpleExample { interface Hello { string getGreeting(); }; };
  • 4. 2: Compile IDL file idlj –fall Hello.idl This causes a sub-directory with the same name as the module (i.e.,SimpleExample) to be created, holding the six files listed below. • Hello.java Contains the Java version of our IDL interface. It extends interface HelloOperations , as well as org.omg.CORBA.Object (providingstandard CORBA object functionality) and org.omg.CORBA.portable.IDLEntity.
  • 5. • HelloHelper.java : Provides auxiliary functionality, notably the narrow method required to cast CORBA object references into Hello references. • HelloHolder.java : Holds a public instance member of type Hello. If there were any out or inout arguments, this file would also provide operations for them. • HelloOperations.java : Contains the Java method signatures for all operations in our IDL file. In this application, it contains the single method getGreeting. • _HelloImplBase.java : An abstract class comprising the server skeleton. It provides basic CORBA functionality for the server and implements the Hello interface. Each servant (interface implementation) that we create for this service must extend _HelloImplBase. • _HelloStub.java : This is the client stub, providing CORBA functionality for the client. Like _HelloImplBase.java, it implements the Hello interface.
  • 6. 3: Implement the Interface The implementation of an interface is called a ‘servant’, so we shall name our implementation class HelloServant. This class must extend _HelloImplBase. Here is the code: class HelloServant extends _HelloImplBase { public String getGreeting()‏ { return ("Hello there!"); } } This class will be placed inside the same file as our server code.
  • 7. 4: Create the Server The following three standard CORBA packages: • org.omg.CosNaming (for the naming service); • org.omg.CosNaming.NamingContextPackage (for special exceptions thrown by the naming service); • org.omg.CORBA There are several steps required of the server… (i) Create and initialize the ORB. This is effected by calling static method init of class ORB. This method takes two arguments: a String array and a Properties object. The first of these is usually set to the argument list received by main, while the second is almost invariably set to null: ORB orb = ORB.init(args,null);
  • 8. 4: (contd)‏ (ii) Create a servant. HelloServant servant = new HelloServant(); (iii) Register the servant with the ORB. This allows the ORB to pass invocations to the servant and is achieved by means of the ORB class’s connect method: orb.connect(servant); (iv) Get a reference to the root naming context. Method resolve_initial_references of class ORB is called with the String argument “NameService” (defined for all CORBA ORBs) and returns a CORBA Object reference that points to the naming context: org.omg.CORBA.Object objectRef = orb.resolve_initial_references("NameService");
  • 9. 4: (contd)‏ (v) ‘Narrow’ the context reference. In order for the generic Object reference from the previous step to be usable, it must be ‘narrowed’ (i.e., typecast ‘down’ into its appropriate type). This is achieved by the use of method narrow of class NamingContextHelper : NamingContext namingContext = NamingContextHelper.narrow(objectRef); (vi) Create a NameComponent object for our interface. The NameComponent constructor takes two String arguments, the first of which supplies a name for our service. The second argument can be used to specify a category for the first argument, but is typically left as an empty string: NameComponent nameComp = new NameComponent("Hello", "");
  • 10. 4: (contd)‏ (vii) Specify the path to the interface. This is effected by creating an array of NameComponent objects, each of which is a component of the path (in ‘descending’ order), with the last component specifying the name of the NameComponent reference that points to the service. For a service in the same directory, the array will contain a single element, as shown below. NameComponent[] path = (nameComp}; (viii) Bind the servant to the interface path. The rebind method of the NamingContext object created earlier is called with arguments that specify the path and service respectively: namingContext.rebind(path,servant);
  • 11. 4: (contd)‏ (ix) Wait for client calls. Unlike our previous server programs, this is not achieved via an explicitly ‘infinite’ loop. A call is made to method wait of (Java class) Object. This call is isolated within a code block that is declared synchronized, as shown below. java.lang.Object syncObj = new java.lang.Object(); synchronized(syncObj)‏ { syncObj.wait(); }
  • 12. import SimpleCORBAExample.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class HelloServer { public static void main(String[] args) { try { ORB orb = ORB.init(args,null); HelloServant servant = new HelloServant(); orb.connect(servant); org.omg.CORBA.Object objectRef = orb.resolve_initial_references("NameService"); NamingContext namingContext = NamingContextHelper.narrow(objectRef); NameComponent nameComp = new NameComponent("Hello", ""); NameComponent[] path = {nameComp}; namingContext.rebind(path,servant); java.lang.Object syncObj = new java.lang.Object(); synchronized(syncObj) { syncObj.wait(); } } catch (Exception ex) { System.out.println("*** Server error! ***"); ex.printStackTrace(); } } } class HelloServant extends _HelloImplBase { public String getGreeting() { return ("Hello there!"); } }