SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
Apex Code Analysis using the
Tooling API and Canvas
Andrew Fawcett, FinancialForce.com, CTO
@andyinthecloud
All about FinancialForce.com
Revolutionizing the Back Office
#1 Accounting, Billing and PSA Apps on the Salesforce platform

▪ Native apps
▪ San Francisco HQ, 595 Market St
▪ R&D in San Francisco, Harrogate UK, and Granada ES
▪ We are hiring! Meet us at Rehab!
Introduction
Why do I need to know more about my Apex code?
▪ Its hard to see code complexity from within the trenches
• Helps those unfamiliar learn complex code bases

▪ Tightly coupled code is harder to maintain and evolve

Goals of this Session
• What are the technologies that can help?
• Understand how to analyze your code with the Tooling API?
• Provide a take away demo of the Tooling API you can extend
Canvas: UI Integration with Salesforce
Provides a means of extending the Salesforce User Interface
▪ Chatter Tab
▪ Visualforce Tabs
▪ Publisher Actions
▪ Other areas see Canvas Developer Guide

Open to any new or existing external web page
▪ Pages can be developed and hosted within any web platform
▪ Developer SDK’s for Java and JavaScript are provided
▪ Pages must follow a specific authentication flow
Where do Canvas apps appear in Salesforce?
Chatter
Tab
Where do Canvas apps appear in Salesforce?
Visualforce Page
Where do Canvas apps appear in Salesforce?
Publisher Action
Canvas Architecture
Access Method: Signed Request (Recommended)

Canvas aware Web Site
(hold consumer secret)
https://mysite.com/mypage

Salesforce User Interface
(holds consumer secret)
Initial HTTP POST passing signed_request

Canvas Frame

User Web Page Interactions

1.

Receives HTTP POST, decodes
and validates request
2. Stores CanvasRequest and
presents page to user
3. Optionally calls back to Salesforce
via API’s using oAuth token

Salesforce API Interactions (using oAuth Token from CanvasRequest)
How do I make my web page Canvas aware?
Two Salesforce SDK’s
▪ Salesforce Canvas JavaScript SDK
▪ Salesforce Canvas Java SDK
• Includes JavaScript SDK

Handle Decoding and Parsing of the “CanvasRequest”
▪ Sent to the page when the user clicks in the Salesforce UI
▪ HTTP POST to the page via ‘signed_request’ parameter
• Contains amongst other information, oAuth token for Salesforce API access!
What is the Tooling API?
What: Manage Apex Code and Pages on the Platform
▪ More granular API than Metadata API built for …
• Building alternative IDE’s (Integrated Developer Environment)
– MavensMate
– Force.com IDE

• Build development tools
– Tools that perform further analysis on code via Symbol Table
What is the Tooling API?
▪ Use REST API bindings if you’re using a language that isn’t strongly typed, like
JavaScript.
▪ Use SOAP API bindings if you’re using a strongly typed language like Java that generates
Web service client code.
Tooling API Architecture and Objects
New Objects in the Salesforce Database
▪ Creating, querying, updating and deleting records
• NOTE: Only via Tooling API CRUD operations

▪ MetadataContainer Object
• Think, “Workspace” in your IDE for files being worked on
Tooling API Architecture and Objects
New Objects in the Salesforce Database
▪ Key Objects are ….
Use without MetadataContainer

Use with MetadataContainer

•
•
•
•

•
•
•
•

ApexClass
ApexPage
ApexComponent
ApexTrigger

ApexClassMember
ApexPageMember
ApexComponentMember
ApexTriggerMember
What is a Symbol Table?
Child of ApexClass, ApexClassMember and ApexTriggerMember
▪ Variables
▪ Methods
▪ Inner Classes
▪ External References
• Lists references to the above from other Apex Classes and Apex Triggers
• NOTE: Only available after a compile!
Birds Eye View : Symbol Table Object

Only available after an Apex
compilation!
Apex UML Canvas Application: Demo

NOTE: Code shown is from my “Building Strong Foundation: Apex Enterprise Patterns” session
Apex UML Canvas Application: Architecture
▪ Hosted on Heroku
▪ Jetty Web Server
• Java Spring MVC Framework
• SOAP Tooling API (via JAX-WS)
– via wsimport Maven plugin

▪ Web Page
• jQuery
• UMLCanvas JS Library

▪ Maven Build System
Configuring a Canvas Application in Salesforce
▪ Makes HTTP POST to URL https://localhost:8443/app/canvas
• Note: /app/ is managed by Spring MVC and forwards to Java Controllers…

▪ Setup > Create > Applications
Integrating the Canvas SDK with Spring MVC
CanvasController.java
▪ Handles the HTTP POST made by Salesforce to /canvas
▪ Uses Salesforce Canvas SDK to decode and store in HTTP session
@Controller
@RequestMapping("/canvas")
public class CanvasController {
@RequestMapping(method = RequestMethod.POST)
public String canvasRequest(@RequestParam("signed_request") String signedRequest, HttpSession session)
{
String secret = System.getenv("CANVAS_CONSUMER_SECRET");
CanvasRequest request = SignedRequest.verifyAndDecode(signedRequest, secret);
session.setAttribute("canvasRequest", request);
return "redirect:umlcanvas";
}
}
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java
▪ Redirection from /canvas to /umlcanvas
▪ Page load, rendered by umlcanvas.jsp
@Controller
@RequestMapping("/umlcanvas")
public class UmlCanvasController {
@RequestMapping(method = RequestMethod.GET)
public String load(HttpSession session, Map<String, Object> map) throws Exception
{
// List classes on the page
ToolingAPIConnection toolingAPI = createToolingAPIConnection(session);
ApexClass[] apexClasses =
toolingAPI.service.query(
"SELECT Id, Name, SymbolTable " +
"FROM ApexClass"
, toolingAPI.session).getRecords().toArray(new ApexClass[0]);
for(ApexClass apexClass : apexClasses)
Apex UML Canvas : Code Walkthrough
umlcanvas.jsp

▪ Java Servlet Page (JSP)
▪ AJAX calls to
UmlCanvasController.java
▪ JavaScript calls UmlCanvas
JavaScript library to
render UML
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java
▪ jQuery Ajax calls controller as user selects classes
1.

/umlcanvas/{apexclass}/symboltable
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java
1.

/umlcanvas/{apexclass}/symboltable

2.

/umlcanvas/{apexclass}/compile

3.

/umlcanvas/containerasyncrequest/{id}

4.

/umlcanvas/containerasyncrequest/{id}/{classname}/symboltable
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java : /{apexclass}/symboltable
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java : /{apexclass}/compile
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java : /{apexclass}/compile
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java : /{apexclass}/compile
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java : /{apexclass}/compile
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java :
/containerasyncrequest/{id}
Apex UML Canvas : Code Walkthrough
UmlCanvasController.java :
/navigator/containerasyncrequest/{id}/{classname}/symboltable
Tooling API Other Features
▪ Debug Logs
▪ Execute Anonymous Apex Code
▪ Static Resources
▪ Inject Execution of Apex or SOQL Code for Debug
▪ Checkpoints to capture Heap Dumps
▪ Manage Custom Fields
▪ Accces Code Coverage Results
Other Uses of Tooling API
Ant Integration : Execute Apex Code from Ant!

Salesforce SE Execute an Apex class using Ant build script
Summary
Read Documentation closely!
▪ Force.com Tooling API Developer’s Guide
▪ Force.com Canvas Developer’s Guide

Symbol Table
▪ Has some gaps, still maturing

Spring MVC rocks!
▪ Great for those not familiar with Java Servlet API
▪ Shades of JavaScript Remoting
Andrew Fawcett
CTO,
@andyinthecloud
Apex Code Analysis Using the Tooling API and Canvas

Contenu connexe

Tendances

Tendances (20)

Visualforce & Force.com Canvas: Unlock your Web App inside of Salesforce.com ...
Visualforce & Force.com Canvas: Unlock your Web App inside of Salesforce.com ...Visualforce & Force.com Canvas: Unlock your Web App inside of Salesforce.com ...
Visualforce & Force.com Canvas: Unlock your Web App inside of Salesforce.com ...
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Development Best Practices
Development Best PracticesDevelopment Best Practices
Development Best Practices
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetup
 
Building Your Portfolio Site on Salesforce Experience Cloud
Building Your Portfolio Site on Salesforce Experience CloudBuilding Your Portfolio Site on Salesforce Experience Cloud
Building Your Portfolio Site on Salesforce Experience Cloud
 
Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
 
Modeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in SalesforceModeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in Salesforce
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Secure Coding: Field-level Security, CRUD, and Sharing
Secure Coding: Field-level Security, CRUD, and SharingSecure Coding: Field-level Security, CRUD, and Sharing
Secure Coding: Field-level Security, CRUD, and Sharing
 
Dive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas FrameworkDive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas Framework
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
SOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || SalesforceSOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || Salesforce
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard Problems
 
Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best Practices
 
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
 
Webinar: Take Control of Your Org with Salesforce Optimizer
Webinar: Take Control of Your Org with Salesforce OptimizerWebinar: Take Control of Your Org with Salesforce Optimizer
Webinar: Take Control of Your Org with Salesforce Optimizer
 
Lwc presentation
Lwc presentationLwc presentation
Lwc presentation
 
Real Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsReal Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform Events
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
 

En vedette

Financial force psa and salesforce crm
Financial force psa and salesforce crmFinancial force psa and salesforce crm
Financial force psa and salesforce crm
jwpurl
 

En vedette (17)

Uml
UmlUml
Uml
 
Aligning Sales & Marketing: Not Mission Impossible
Aligning Sales & Marketing: Not Mission ImpossibleAligning Sales & Marketing: Not Mission Impossible
Aligning Sales & Marketing: Not Mission Impossible
 
Ritesh Mehandiratta Resume
Ritesh Mehandiratta ResumeRitesh Mehandiratta Resume
Ritesh Mehandiratta Resume
 
Accelerate Business Velocity with NetSuite and Salesforce Integration
Accelerate Business Velocity with NetSuite and Salesforce IntegrationAccelerate Business Velocity with NetSuite and Salesforce Integration
Accelerate Business Velocity with NetSuite and Salesforce Integration
 
Karthik resume 2016
Karthik resume   2016Karthik resume   2016
Karthik resume 2016
 
Introducing Eclipse MoDisco
Introducing Eclipse MoDiscoIntroducing Eclipse MoDisco
Introducing Eclipse MoDisco
 
Professional Services Automation
Professional Services AutomationProfessional Services Automation
Professional Services Automation
 
Service Automation: Enabling The Self Service Generation - Jan-Willem Middleburg
Service Automation: Enabling The Self Service Generation - Jan-Willem MiddleburgService Automation: Enabling The Self Service Generation - Jan-Willem Middleburg
Service Automation: Enabling The Self Service Generation - Jan-Willem Middleburg
 
Financial force psa and salesforce crm
Financial force psa and salesforce crmFinancial force psa and salesforce crm
Financial force psa and salesforce crm
 
Driving Profitability with Professional Services Automation
Driving Profitability with Professional Services AutomationDriving Profitability with Professional Services Automation
Driving Profitability with Professional Services Automation
 
Partner Success Services (Overview & Framework)
Partner Success Services (Overview & Framework)Partner Success Services (Overview & Framework)
Partner Success Services (Overview & Framework)
 
Automation & Professional Services
Automation & Professional ServicesAutomation & Professional Services
Automation & Professional Services
 
Microsoft PSA: Service Automation in Action
Microsoft PSA: Service Automation in ActionMicrosoft PSA: Service Automation in Action
Microsoft PSA: Service Automation in Action
 
Educateca 3º ano desafios
Educateca 3º ano desafiosEducateca 3º ano desafios
Educateca 3º ano desafios
 
Ficha de avaliação de estudo do meio - 3º ano
Ficha de avaliação de estudo do meio - 3º anoFicha de avaliação de estudo do meio - 3º ano
Ficha de avaliação de estudo do meio - 3º ano
 
Fichas de Avaliação Estudo do Meio_3.º Ano
Fichas de Avaliação Estudo do Meio_3.º AnoFichas de Avaliação Estudo do Meio_3.º Ano
Fichas de Avaliação Estudo do Meio_3.º Ano
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 

Similaire à Apex Code Analysis Using the Tooling API and Canvas

Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
lucenerevolution
 
SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...
Liam Cleary [MVP]
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 

Similaire à Apex Code Analysis Using the Tooling API and Canvas (20)

Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patterns
 
SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...
 
qooxdoo - Open Source Ajax Framework
qooxdoo - Open Source Ajax Frameworkqooxdoo - Open Source Ajax Framework
qooxdoo - Open Source Ajax Framework
 
Create Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutesCreate Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutes
 
Building intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQueryBuilding intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQuery
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
 
Building intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQueryBuilding intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQuery
 
Web development concepts using microsoft technologies
Web development concepts using microsoft technologiesWeb development concepts using microsoft technologies
Web development concepts using microsoft technologies
 
Atlas Php
Atlas PhpAtlas Php
Atlas Php
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 

Plus de Salesforce Developers

Plus de Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 
Introduction to MuleSoft
Introduction to MuleSoftIntroduction to MuleSoft
Introduction to MuleSoft
 
Modern App Dev: Modular Development Strategies
Modern App Dev: Modular Development StrategiesModern App Dev: Modular Development Strategies
Modern App Dev: Modular Development Strategies
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

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 New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"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 ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Apex Code Analysis Using the Tooling API and Canvas

  • 1. Apex Code Analysis using the Tooling API and Canvas Andrew Fawcett, FinancialForce.com, CTO @andyinthecloud
  • 2. All about FinancialForce.com Revolutionizing the Back Office #1 Accounting, Billing and PSA Apps on the Salesforce platform ▪ Native apps ▪ San Francisco HQ, 595 Market St ▪ R&D in San Francisco, Harrogate UK, and Granada ES ▪ We are hiring! Meet us at Rehab!
  • 3. Introduction Why do I need to know more about my Apex code? ▪ Its hard to see code complexity from within the trenches • Helps those unfamiliar learn complex code bases ▪ Tightly coupled code is harder to maintain and evolve Goals of this Session • What are the technologies that can help? • Understand how to analyze your code with the Tooling API? • Provide a take away demo of the Tooling API you can extend
  • 4. Canvas: UI Integration with Salesforce Provides a means of extending the Salesforce User Interface ▪ Chatter Tab ▪ Visualforce Tabs ▪ Publisher Actions ▪ Other areas see Canvas Developer Guide Open to any new or existing external web page ▪ Pages can be developed and hosted within any web platform ▪ Developer SDK’s for Java and JavaScript are provided ▪ Pages must follow a specific authentication flow
  • 5. Where do Canvas apps appear in Salesforce? Chatter Tab
  • 6. Where do Canvas apps appear in Salesforce? Visualforce Page
  • 7. Where do Canvas apps appear in Salesforce? Publisher Action
  • 8. Canvas Architecture Access Method: Signed Request (Recommended) Canvas aware Web Site (hold consumer secret) https://mysite.com/mypage Salesforce User Interface (holds consumer secret) Initial HTTP POST passing signed_request Canvas Frame User Web Page Interactions 1. Receives HTTP POST, decodes and validates request 2. Stores CanvasRequest and presents page to user 3. Optionally calls back to Salesforce via API’s using oAuth token Salesforce API Interactions (using oAuth Token from CanvasRequest)
  • 9. How do I make my web page Canvas aware? Two Salesforce SDK’s ▪ Salesforce Canvas JavaScript SDK ▪ Salesforce Canvas Java SDK • Includes JavaScript SDK Handle Decoding and Parsing of the “CanvasRequest” ▪ Sent to the page when the user clicks in the Salesforce UI ▪ HTTP POST to the page via ‘signed_request’ parameter • Contains amongst other information, oAuth token for Salesforce API access!
  • 10. What is the Tooling API? What: Manage Apex Code and Pages on the Platform ▪ More granular API than Metadata API built for … • Building alternative IDE’s (Integrated Developer Environment) – MavensMate – Force.com IDE • Build development tools – Tools that perform further analysis on code via Symbol Table
  • 11. What is the Tooling API? ▪ Use REST API bindings if you’re using a language that isn’t strongly typed, like JavaScript. ▪ Use SOAP API bindings if you’re using a strongly typed language like Java that generates Web service client code.
  • 12. Tooling API Architecture and Objects New Objects in the Salesforce Database ▪ Creating, querying, updating and deleting records • NOTE: Only via Tooling API CRUD operations ▪ MetadataContainer Object • Think, “Workspace” in your IDE for files being worked on
  • 13. Tooling API Architecture and Objects New Objects in the Salesforce Database ▪ Key Objects are …. Use without MetadataContainer Use with MetadataContainer • • • • • • • • ApexClass ApexPage ApexComponent ApexTrigger ApexClassMember ApexPageMember ApexComponentMember ApexTriggerMember
  • 14. What is a Symbol Table? Child of ApexClass, ApexClassMember and ApexTriggerMember ▪ Variables ▪ Methods ▪ Inner Classes ▪ External References • Lists references to the above from other Apex Classes and Apex Triggers • NOTE: Only available after a compile!
  • 15. Birds Eye View : Symbol Table Object Only available after an Apex compilation!
  • 16. Apex UML Canvas Application: Demo NOTE: Code shown is from my “Building Strong Foundation: Apex Enterprise Patterns” session
  • 17. Apex UML Canvas Application: Architecture ▪ Hosted on Heroku ▪ Jetty Web Server • Java Spring MVC Framework • SOAP Tooling API (via JAX-WS) – via wsimport Maven plugin ▪ Web Page • jQuery • UMLCanvas JS Library ▪ Maven Build System
  • 18. Configuring a Canvas Application in Salesforce ▪ Makes HTTP POST to URL https://localhost:8443/app/canvas • Note: /app/ is managed by Spring MVC and forwards to Java Controllers… ▪ Setup > Create > Applications
  • 19. Integrating the Canvas SDK with Spring MVC CanvasController.java ▪ Handles the HTTP POST made by Salesforce to /canvas ▪ Uses Salesforce Canvas SDK to decode and store in HTTP session @Controller @RequestMapping("/canvas") public class CanvasController { @RequestMapping(method = RequestMethod.POST) public String canvasRequest(@RequestParam("signed_request") String signedRequest, HttpSession session) { String secret = System.getenv("CANVAS_CONSUMER_SECRET"); CanvasRequest request = SignedRequest.verifyAndDecode(signedRequest, secret); session.setAttribute("canvasRequest", request); return "redirect:umlcanvas"; } }
  • 20. Apex UML Canvas : Code Walkthrough UmlCanvasController.java ▪ Redirection from /canvas to /umlcanvas ▪ Page load, rendered by umlcanvas.jsp @Controller @RequestMapping("/umlcanvas") public class UmlCanvasController { @RequestMapping(method = RequestMethod.GET) public String load(HttpSession session, Map<String, Object> map) throws Exception { // List classes on the page ToolingAPIConnection toolingAPI = createToolingAPIConnection(session); ApexClass[] apexClasses = toolingAPI.service.query( "SELECT Id, Name, SymbolTable " + "FROM ApexClass" , toolingAPI.session).getRecords().toArray(new ApexClass[0]); for(ApexClass apexClass : apexClasses)
  • 21. Apex UML Canvas : Code Walkthrough umlcanvas.jsp ▪ Java Servlet Page (JSP) ▪ AJAX calls to UmlCanvasController.java ▪ JavaScript calls UmlCanvas JavaScript library to render UML
  • 22. Apex UML Canvas : Code Walkthrough UmlCanvasController.java ▪ jQuery Ajax calls controller as user selects classes 1. /umlcanvas/{apexclass}/symboltable
  • 23. Apex UML Canvas : Code Walkthrough UmlCanvasController.java 1. /umlcanvas/{apexclass}/symboltable 2. /umlcanvas/{apexclass}/compile 3. /umlcanvas/containerasyncrequest/{id} 4. /umlcanvas/containerasyncrequest/{id}/{classname}/symboltable
  • 24. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /{apexclass}/symboltable
  • 25. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /{apexclass}/compile
  • 26. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /{apexclass}/compile
  • 27. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /{apexclass}/compile
  • 28. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /{apexclass}/compile
  • 29. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /containerasyncrequest/{id}
  • 30. Apex UML Canvas : Code Walkthrough UmlCanvasController.java : /navigator/containerasyncrequest/{id}/{classname}/symboltable
  • 31. Tooling API Other Features ▪ Debug Logs ▪ Execute Anonymous Apex Code ▪ Static Resources ▪ Inject Execution of Apex or SOQL Code for Debug ▪ Checkpoints to capture Heap Dumps ▪ Manage Custom Fields ▪ Accces Code Coverage Results
  • 32. Other Uses of Tooling API Ant Integration : Execute Apex Code from Ant! Salesforce SE Execute an Apex class using Ant build script
  • 33. Summary Read Documentation closely! ▪ Force.com Tooling API Developer’s Guide ▪ Force.com Canvas Developer’s Guide Symbol Table ▪ Has some gaps, still maturing Spring MVC rocks! ▪ Great for those not familiar with Java Servlet API ▪ Shades of JavaScript Remoting