SlideShare una empresa de Scribd logo
1 de 14
XPCO
M

CROSS PLATFORM COMPONENT OBJECT
MODELING
A Brief Overview
Catalogue
 Introduction
 Benefits
 Drawbacks
 Concepts
 Example

Code

 Working

 References
Introduction








XPCOM is a cross platform component object model, similar
to Microsoft COM.
It has multiple language bindings, allowing XPCOM
components to be used and implemented in JavaScript, Java,
and Python in addition to C++.
Interfaces in XPCOM are defined in a dialect of IDL
called XPIDL.
XPCOM itself provides a set of core components and
classes, e.g. file and memory management, threads, basic
data structures (strings, arrays, variants), etc.
Benefits


XPCOM components can be used by any programming
language Mozilla supports.



Objects implemented as XPCOM can be global to an
application, and are not dependent on the scope of any one
window. You can use an XPCOM service to share data
between windows.



XPCOM encourages modular programming - programming
logic can be encapsulated within a component.
Drawbacks


Objects must be accessed from their defined interfaces.
Javascript shortcuts such as the global window object cannot
be accessed.




The only exception to this rule, is if you set a magical
property wrappedJSObject on your component implemented in
JavaScript, the object this property refers to will be accessible
from the calling side. You can set ”this.wrappedJSObject =
this” in your component's constructor and avoid writing any
interfaces altogether.

It is easier to have memory leaks.
Concepts


Components:




A component is simply an object that implements interfaces, and
is registered with the component manager.

Interfaces:


Interfaces are used to define what functions and attributes an
XPCOM component provides. nsISupports is an interface that all
classes must implement. It provides a function to request the
interfaces on a class.
Concepts


Factories:




(Cont.)

Factories are objects used to instantiate components. Each
factory object implements the nsIFactory interface.

Modules:


Multiple classes can be defined in a file. A module is an object
that is used to register, unregister and provide factories for
classes. It implements the nsIModule interface.
Example Code
Example Code

(Cont.)
Example Code

(Cont.)
Working


I. Startup & Registration


During the startup process if the file compreg.dat is missing or
the file .autoreg exists, the application knows that it needs to
register components. It then loads files from each of the
components folders, including the components folder in each
extension directory. It then calls the function NSGetModule on
each file to get the object that implements the nsIModule
Interface. The module object is then used to register your

module. This is used to simplify the process of retrieving
the module later in class creation. The registerSelf function
is called to do the actual registering. When removing a
class, the unregisterSelf function is called.
Working


II. Class Creation





(Cont.)

The code calls getClassObject on your module.
This returns a class factory. The factory then has a method called
createInstance which is used to create the actual class object.

III. Accessing the component



You can now access your component by the code written.
Mozilla also provides a component construction process to easy
creation with JavaScript.
References


http://kb.mozillazine.org



http://en.wikipedia.org/wiki/XPCOM



https://developer.mozilla.org/en/docs/XPCOM



http://www.ibm.com/developerworks/webservices/library/coxpcom/index.html
Thank You
Jay Patel
(M.Sc. IT - Part 1)

Más contenido relacionado

La actualidad más candente (8)

.Net framework
.Net framework.Net framework
.Net framework
 
Namespaces in C#
Namespaces in C#Namespaces in C#
Namespaces in C#
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for Java
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .Net
 
What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9
 
Microsoft .NET Framework
Microsoft .NET FrameworkMicrosoft .NET Framework
Microsoft .NET Framework
 

Destacado

Architecting Security across global networks
Architecting Security across global networksArchitecting Security across global networks
Architecting Security across global networks
EQS Group
 

Destacado (13)

Tributo A The Beatles
Tributo A The BeatlesTributo A The Beatles
Tributo A The Beatles
 
Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...
Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...
Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...
 
trust1
trust1trust1
trust1
 
1 consegna diagnosi certificata a scuola
1   consegna diagnosi certificata a scuola1   consegna diagnosi certificata a scuola
1 consegna diagnosi certificata a scuola
 
iJournalism: Putting it All Together
iJournalism: Putting it All TogetheriJournalism: Putting it All Together
iJournalism: Putting it All Together
 
Modalità di prenotazione per la diagnosiaslna1
Modalità di prenotazione per la diagnosiaslna1Modalità di prenotazione per la diagnosiaslna1
Modalità di prenotazione per la diagnosiaslna1
 
Métodos ágiles de programación
Métodos ágiles de programaciónMétodos ágiles de programación
Métodos ágiles de programación
 
extending-php
extending-phpextending-php
extending-php
 
ARMY Education Transcript
ARMY Education TranscriptARMY Education Transcript
ARMY Education Transcript
 
Applied anatomy
Applied anatomyApplied anatomy
Applied anatomy
 
MBA Colour
MBA ColourMBA Colour
MBA Colour
 
Architecting Security across global networks
Architecting Security across global networksArchitecting Security across global networks
Architecting Security across global networks
 
Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...
Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...
Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...
 

Similar a Pcom xpcom

.Net framework
.Net framework.Net framework
.Net framework
Raghu nath
 
.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIES
Prof Ansari
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
Saurabh Narula
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net framework
Faisal Aziz
 

Similar a Pcom xpcom (20)

.Net framework
.Net framework.Net framework
.Net framework
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NET
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
Maxbox starter19
Maxbox starter19Maxbox starter19
Maxbox starter19
 
.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIES
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
Net Interview questions
Net Interview questionsNet Interview questions
Net Interview questions
 
Interview Question of Aspdotnet
Interview Question of AspdotnetInterview Question of Aspdotnet
Interview Question of Aspdotnet
 
Online lg prodect
Online lg prodectOnline lg prodect
Online lg prodect
 
COM Introduction
COM IntroductionCOM Introduction
COM Introduction
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net framework
 
Topic 1 PBO
Topic 1 PBOTopic 1 PBO
Topic 1 PBO
 
distributing computing
distributing computingdistributing computing
distributing computing
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGi
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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)
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Pcom xpcom

  • 1. XPCO M CROSS PLATFORM COMPONENT OBJECT MODELING A Brief Overview
  • 2. Catalogue  Introduction  Benefits  Drawbacks  Concepts  Example Code  Working  References
  • 3. Introduction     XPCOM is a cross platform component object model, similar to Microsoft COM. It has multiple language bindings, allowing XPCOM components to be used and implemented in JavaScript, Java, and Python in addition to C++. Interfaces in XPCOM are defined in a dialect of IDL called XPIDL. XPCOM itself provides a set of core components and classes, e.g. file and memory management, threads, basic data structures (strings, arrays, variants), etc.
  • 4. Benefits  XPCOM components can be used by any programming language Mozilla supports.  Objects implemented as XPCOM can be global to an application, and are not dependent on the scope of any one window. You can use an XPCOM service to share data between windows.  XPCOM encourages modular programming - programming logic can be encapsulated within a component.
  • 5. Drawbacks  Objects must be accessed from their defined interfaces. Javascript shortcuts such as the global window object cannot be accessed.   The only exception to this rule, is if you set a magical property wrappedJSObject on your component implemented in JavaScript, the object this property refers to will be accessible from the calling side. You can set ”this.wrappedJSObject = this” in your component's constructor and avoid writing any interfaces altogether. It is easier to have memory leaks.
  • 6. Concepts  Components:   A component is simply an object that implements interfaces, and is registered with the component manager. Interfaces:  Interfaces are used to define what functions and attributes an XPCOM component provides. nsISupports is an interface that all classes must implement. It provides a function to request the interfaces on a class.
  • 7. Concepts  Factories:   (Cont.) Factories are objects used to instantiate components. Each factory object implements the nsIFactory interface. Modules:  Multiple classes can be defined in a file. A module is an object that is used to register, unregister and provide factories for classes. It implements the nsIModule interface.
  • 11. Working  I. Startup & Registration  During the startup process if the file compreg.dat is missing or the file .autoreg exists, the application knows that it needs to register components. It then loads files from each of the components folders, including the components folder in each extension directory. It then calls the function NSGetModule on each file to get the object that implements the nsIModule Interface. The module object is then used to register your module. This is used to simplify the process of retrieving the module later in class creation. The registerSelf function is called to do the actual registering. When removing a class, the unregisterSelf function is called.
  • 12. Working  II. Class Creation    (Cont.) The code calls getClassObject on your module. This returns a class factory. The factory then has a method called createInstance which is used to create the actual class object. III. Accessing the component   You can now access your component by the code written. Mozilla also provides a component construction process to easy creation with JavaScript.