SlideShare a Scribd company logo
1 of 21
Making your managed package
extensible with Apex Plugins

Stephen Willcock, FinancialForce.com, Director of Product Innovation
@stephenwillcock
Safe harbor
 Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

 This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
 materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results
 expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be
 deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other
 financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any
 statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

 The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new
 functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our
 operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of
 intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we
 operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new
 releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization
 and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of
 salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This
 documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of
 our Web site.

 Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently
 available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based
 upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-
 looking statements.
All about FinancialForce.com
Stephen Willcock
Director, Product Innovation
@stephenwillcock
What is an Apex Plugin?

An Apex plugin for a managed package is an external class that is
called from within the package


The package has no dependency on the class, which is
instantiated dynamically by runtime configuration
Why use a Plugin?

Plugins allow changes to the execution of packaged Apex
processes
            Managed Package
                                            Runtime Configuration:
                                            Runtime Configuration:
              Opportunity Adjuster         Use “CustomAdjuster” for
                                           Use “CustomAdjuster” for
                                           Adjusting Opportunities
                                            Adjusting Opportunities



                                          CustomAdjuster plugin
                        Call the plugin
Where to use a Plugin?
   Visualforce UIs
   Triggers
   @RemoteAction methods
   Apex APIs
   Batch Apex
   Generic plugins for common calculations
   “Apex Validation Rules”
   “Apex Workflow Rules”
Example use case

Application for adjusting Opportunity values
Visualforce UI
Customizable adjustment and validation
Implementation
 Managed Package

  public class AdjustOpportunityController


  global class Plugin                          Runtime Configuration:
                                               Runtime Configuration:
                                              Use “CustomAdjuster” for
                                              Use “CustomAdjuster” for
  public static IAdjustOpportunities          Adjusting Opportunities
                                               Adjusting Opportunities
  getInstanceIAdjustOpportunities()

                                             global class CustomAdjuster
  global interface IAdjustOpportunities      implements IAdjustOpportunities
Implementation   global class Plugin
                                               Packaged
                                               Code

global interface IAdjustOpportunities
{
    void adjust(Opportunity opportunity,
        List<OpportunityLineItem> lineItems,
        Decimal proportion);
}
Implementation   global class Plugin
                                       Packaged
                                       Code
Implementation   global class Plugin
                                             Packaged
                                             Code

public static Plugin.IAdjustOpportunities
    getInstanceIAdjustOpportunities()
{
    Object result = getInstance
        ('IAdjustOpportunities');
    return (Plugin.IAdjustOpportunities)
        (result == null
        ? new DefaultAdjustOpportunities()
        : result);
}
Implementation   global class Plugin
                                       Packaged
                                       Code
Implementation   global class Plugin
                                                  Packaged
                                                  Code

 // do the adjustment here...

 for(OpportunityLineItem item : opportunityLineItems)
   item.UnitPrice = item.UnitPrice +
       (item.UnitPrice * adjustmentProportion);

 opportunity.Amount = opportunity.Amount +
   (opportunity.Amount * adjustmentProportion);
Implementation   public with sharing class
                                                    Packaged
                   AdjustOpportunityController      Code

void adjust()
{
    Plugin.IAdjustOpportunities adjuster =
        Plugin.getInstanceIAdjustOpportunities();

    adjuster.adjust(getOpportunity(),
        getOpportunityLines(),
        getAdjustmentProportion());
}
Plugin
Implementation   global class CustomAdjuster     Code
Configuration options

Manual custom settings
Discovery by name pattern
Assisted custom settings
Plug-and-play




                Demo
Considerations

Consider the lifecycle / context of a plugin instance
    Triggers: bulk usage / before and after triggers
    Instantiation within a loop / discarding instances
    Visualforce viewstate

Interface granularity
Extend or override?
Only default plugin constructors are used
Versioning of global interfaces by name
Unplug

Resources
   Sample code and package installation URL available from
    https://github.com/financialforcedev/df12-apex-plugins
   Martin Fowler, Patterns of Enterprise Application Architecture:
      • Plugin http://martinfowler.com/eaaCatalog/plugin.html
      • Separated Interface http://martinfowler.com/eaaCatalog/separatedInterface.html
   @stephenwillcock

Questions?
Making your managed package extensible with Apex Plugins

More Related Content

Similar to Making your managed package extensible with Apex Plugins

Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App EngineInphina Technologies
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App EngineIndicThreads
 
Opticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer PlatformOpticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer PlatformOptimizely
 
Guide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinGuide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinRapidValue
 
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project  HRSer.docxHRServicesPOX.classpathHRServicesPOX.project  HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project HRSer.docxadampcarr67227
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)Woonsan Ko
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Chris Ramsdale
 
I Love APIs 2015: Continuous Integration the Virtuous Cycle
I Love APIs 2015: Continuous Integration the Virtuous CycleI Love APIs 2015: Continuous Integration the Virtuous Cycle
I Love APIs 2015: Continuous Integration the Virtuous CycleApigee | Google Cloud
 
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Uglychristianbourgeois
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
CRM Science - Dreamforce '14: Generic Package Extension Architecture for App...
CRM Science - Dreamforce '14:  Generic Package Extension Architecture for App...CRM Science - Dreamforce '14:  Generic Package Extension Architecture for App...
CRM Science - Dreamforce '14: Generic Package Extension Architecture for App...CRMScienceKirk
 
Тестирование Spring-based приложений
Тестирование Spring-based приложенийТестирование Spring-based приложений
Тестирование Spring-based приложенийVitebsk Miniq
 
[Slide Deck] - Mobile Observability Internals at Gojek
[Slide Deck] - Mobile Observability Internals at Gojek[Slide Deck] - Mobile Observability Internals at Gojek
[Slide Deck] - Mobile Observability Internals at Gojekraditya gumay
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02rhemsolutions
 
Java Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreJava Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreAlexis Williams
 

Similar to Making your managed package extensible with Apex Plugins (20)

Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Opticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer PlatformOpticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer Platform
 
Guide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in KotlinGuide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in Kotlin
 
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project  HRSer.docxHRServicesPOX.classpathHRServicesPOX.project  HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
I Love APIs 2015: Continuous Integration the Virtuous Cycle
I Love APIs 2015: Continuous Integration the Virtuous CycleI Love APIs 2015: Continuous Integration the Virtuous Cycle
I Love APIs 2015: Continuous Integration the Virtuous Cycle
 
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
CRM Science - Dreamforce '14: Generic Package Extension Architecture for App...
CRM Science - Dreamforce '14:  Generic Package Extension Architecture for App...CRM Science - Dreamforce '14:  Generic Package Extension Architecture for App...
CRM Science - Dreamforce '14: Generic Package Extension Architecture for App...
 
Тестирование Spring-based приложений
Тестирование Spring-based приложенийТестирование Spring-based приложений
Тестирование Spring-based приложений
 
[Slide Deck] - Mobile Observability Internals at Gojek
[Slide Deck] - Mobile Observability Internals at Gojek[Slide Deck] - Mobile Observability Internals at Gojek
[Slide Deck] - Mobile Observability Internals at Gojek
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
JBoss World 2010
JBoss World 2010JBoss World 2010
JBoss World 2010
 
Android - Api & Debugging in Android
Android - Api & Debugging in AndroidAndroid - Api & Debugging in Android
Android - Api & Debugging in Android
 
Java Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreJava Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy Anymore
 

Recently uploaded

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 

Recently uploaded (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 

Making your managed package extensible with Apex Plugins

  • 1. Making your managed package extensible with Apex Plugins Stephen Willcock, FinancialForce.com, Director of Product Innovation @stephenwillcock
  • 2. Safe harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements.
  • 4. Stephen Willcock Director, Product Innovation @stephenwillcock
  • 5. What is an Apex Plugin? An Apex plugin for a managed package is an external class that is called from within the package The package has no dependency on the class, which is instantiated dynamically by runtime configuration
  • 6. Why use a Plugin? Plugins allow changes to the execution of packaged Apex processes Managed Package Runtime Configuration: Runtime Configuration: Opportunity Adjuster Use “CustomAdjuster” for Use “CustomAdjuster” for Adjusting Opportunities Adjusting Opportunities CustomAdjuster plugin Call the plugin
  • 7. Where to use a Plugin?  Visualforce UIs  Triggers  @RemoteAction methods  Apex APIs  Batch Apex  Generic plugins for common calculations  “Apex Validation Rules”  “Apex Workflow Rules”
  • 8. Example use case Application for adjusting Opportunity values Visualforce UI Customizable adjustment and validation
  • 9. Implementation Managed Package public class AdjustOpportunityController global class Plugin Runtime Configuration: Runtime Configuration: Use “CustomAdjuster” for Use “CustomAdjuster” for public static IAdjustOpportunities Adjusting Opportunities Adjusting Opportunities getInstanceIAdjustOpportunities() global class CustomAdjuster global interface IAdjustOpportunities implements IAdjustOpportunities
  • 10. Implementation global class Plugin Packaged Code global interface IAdjustOpportunities { void adjust(Opportunity opportunity, List<OpportunityLineItem> lineItems, Decimal proportion); }
  • 11. Implementation global class Plugin Packaged Code
  • 12. Implementation global class Plugin Packaged Code public static Plugin.IAdjustOpportunities getInstanceIAdjustOpportunities() { Object result = getInstance ('IAdjustOpportunities'); return (Plugin.IAdjustOpportunities) (result == null ? new DefaultAdjustOpportunities() : result); }
  • 13. Implementation global class Plugin Packaged Code
  • 14. Implementation global class Plugin Packaged Code // do the adjustment here... for(OpportunityLineItem item : opportunityLineItems) item.UnitPrice = item.UnitPrice + (item.UnitPrice * adjustmentProportion); opportunity.Amount = opportunity.Amount + (opportunity.Amount * adjustmentProportion);
  • 15. Implementation public with sharing class Packaged AdjustOpportunityController Code void adjust() { Plugin.IAdjustOpportunities adjuster = Plugin.getInstanceIAdjustOpportunities(); adjuster.adjust(getOpportunity(), getOpportunityLines(), getAdjustmentProportion()); }
  • 16. Plugin Implementation global class CustomAdjuster Code
  • 17. Configuration options Manual custom settings Discovery by name pattern Assisted custom settings
  • 19. Considerations Consider the lifecycle / context of a plugin instance  Triggers: bulk usage / before and after triggers  Instantiation within a loop / discarding instances  Visualforce viewstate Interface granularity Extend or override? Only default plugin constructors are used Versioning of global interfaces by name
  • 20. Unplug Resources  Sample code and package installation URL available from https://github.com/financialforcedev/df12-apex-plugins  Martin Fowler, Patterns of Enterprise Application Architecture: • Plugin http://martinfowler.com/eaaCatalog/plugin.html • Separated Interface http://martinfowler.com/eaaCatalog/separatedInterface.html  @stephenwillcock Questions?

Editor's Notes

  1. Plugin is an established design pattern FinancialForce.com uses a number of design patterns published in Martin Fowler, Patterns of Enterprise Application Architecture Andy’ Fawcett’s session: Applying Enterprise Application Design Patterns on Force.com
  2. Visualforce UIs - +fieldsets
  3. Update December 2013: Implement fix for Salesforce Winter 13 change in behaviour. Issue: https://sites.secure.force.com/success/issues_view?id=a1p30000000SVY3AAO
  4. In Winter ‘13 we will not need to make this class global
  5. Assisted: discover candidates from which a user selects and persists in cust setting
  6. Extend / override - responsibility of package or plugin?
  7. Chatter wall for this session