Hippo Connect Amsterdam 2016 Presentation about some hidden gems Hippo Delivery tier and Hippo Forge projects could give to your projects and business.
12. Gems in Hippo Delivery Tier
#2 HDC (Hierarchical
Diagnostic Context) API
“Determine performance problems faster!”
13. HDC API
● Lightweight performance diagnostic tool, for both SITE and CMS.
● Hierarchical Diagnostics Reporting on request processing:
- HstFilter (3011ms): {hostName=www.example.com, uri=/site/, query=null}
`- Pipeline processing (3002ms): {pipeline=null}
|- HstComponentInvokerProfiler (0ms): {method=doBeforeRender, window=main,
component=com.example.components.BaseComponent, ref=r46_r1}
|- HstComponentInvokerProfiler (471ms): {method=doBeforeRender, window=latestjobs,
component=com.example.components.common.LatestItems, ref=r46_r1_r1_r1,
HippoBeanIterationCount=1}
| `- query (466ms):
{statement=//*[(@hippo:paths='a5a24dd3-04a0-4ed1-a59a-ffc960ae69f2') and
(@hippo:availability='live') and ((@jcr:primaryType='hippogogreen:job'))] order by
@hippogogreen:closingdate descending}
...
14. HDC API
● Lightweight performance diagnostic tool, for both SITE and CMS.
● Hierarchical Diagnostics Reporting on request processing:
- HstFilter (3011ms): {hostName=www.example.com, uri=/site/, query=null}
`- Pipeline processing (3002ms): {pipeline=null}
|- HstComponentInvokerProfiler (0ms): {method=doBeforeRender, window=main,
component=com.example.components.BaseComponent, ref=r46_r1}
|- HstComponentInvokerProfiler (471ms): {method=doBeforeRender, window=latestjobs,
component=com.example.components.common.LatestItems, ref=r46_r1_r1_r1,
HippoBeanIterationCount=1}
| `- query (466ms):
{statement=//*[(@hippo:paths='a5a24dd3-04a0-4ed1-a59a-ffc960ae69f2') and
(@hippo:availability='live') and ((@jcr:primaryType='hippogogreen:job'))] order by
@hippogogreen:closingdate descending}
...
Runtime Configuration
15. HDC API
● What if I want to measure the performance of my own business logic?
* More at https://www.onehippo.org/library/concepts/request-handling/hst-page-diagnostics.html
// RelatedArticles.java
public void doBeforeRender(HstRequest req, HstResponse res) throws HstComponentException {
// ...
List<Articles> articles = getRelatedArticlesIntelligently();
req.setAtttribute("articles", articles);
// ...
}
16. HDC API
● What if I want to measure the performance of my own business logic?
* More at https://www.onehippo.org/library/concepts/request-handling/hst-page-diagnostics.html
// RelatedArticles.java
public void doBeforeRender(HstRequest req, HstResponse res) throws HstComponentException {
Task relDocsTask = null;
try {
if (HDC.isStarted()) relDocsTask = HDC.getCurrentTask().startSubtask("relDocs");
List<Articles> articles = getRelatedArticlesIntelligently();
req.setAtttribute("articles", articles);
relDocsTask.setAttribute("count", articles.size());
} finally {
if (relDocsTask != null) relDocsTask.stop();
}
}
17. HDC API
● What if I want to measure the performance of my own business logic?
// RelatedArticles.java
public void doBeforeRender(HstRequest req, HstResponse res) throws HstComponentException {
Task relDocsTask = null;
try {
if (HDC.isStarted()) relDocsTask = HDC.getCurrentTask().startSubtask("relDocs");
List<Articles> articles = getRelatedArticlesIntelligently();
req.setAtttribute("articles", articles);
relDocsTask.setAttribute("count", articles.size());
} finally {
if (relDocsTask != null) relDocsTask.stop();
}
}
* More at https://www.onehippo.org/library/concepts/request-handling/hst-page-diagnostics.html
|- HstComponentInvokerProfiler (1235ms):
{component=c.e.c.RelatedArticles, ...}
| `- relDocs (1117ms): {count=330}
...
Outcome
18. Gems in Hippo Delivery Tier
#3 Spring Managed
HstComponent
“Cleaner with Real Dependency Injection!”
19. Spring Managed HstComponent
package com.example.components;
public class Search extends AbstractSearchComponent {
public void doBeforeRender(HstRequest req, HstResponse res) throws HstComponentException {
// Manual look up the service component, 'catalogServiceBean' ...
CatalogService catService =
HstServices.getComponentManager().getComponent("catalogServiceBean");
request.setAttribute("item", catService.getItem(req.getParameter("pid")));
}
}
Old, Manual Style
20. Spring Managed HstComponent
package com.example.components;
@Component // for auto-scanning!
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) // "prototype" always!
@Service("com.example.components.Search") // FQCN as @Service!
public class Search extends AbstractSearchComponent {
@Autowired
private CatalogService catService;
public void doBeforeRender(HstRequest req, HstResponse res) throws HstComponentException {
request.setAttribute("item", catService.getItem(req.getParameter("pid")));
}
}
New, Auto-wiring Style
21. ● Annotation scanning on Spring managed HST Components
<!-- e.g. site/src/main/resources/META-INF/hst-assembly/overrides/base.xml-->
<!-- (HST)Components Annotation Scanning -->
<context:component-scan base-package="com.example.components" />
Spring Managed HstComponent
* More at https://www.onehippo.org/library/concepts/web-application/spring-managed-hst-components.html
● Special Attentions!
○ Always set @Scope to prototype!
○ Always set @Service to the FQCN of the component class!
26. HST ESI Processor
Browser ESI
Processor Dispatchable
local path
Page
Cache
<html>
<h1>Hello, World!</h1>
<!--esi:include src="/special..." -->
</html>
<div>Hi ${user}! Here’s a
special deal for you!</div>
<html>
<h1>Hello, World!</h1>
</html>
<div>Hi Hippo! Here’s a
special deal for you!</div>
HST HST
Component
● HST ESI Processor dispatches to . . .
a Component Rendering URL or Local URI Path (Servlet/JSP).
○ Note: HST ESI does NOT support Remote URLs for simplicity!
27. HST ESI Processor
● What if I want to include remote URLs using ESI tags?
○ APA Reverse Proxy Project:
■ Java Servlet or Filter library as Reverse Proxy
■ portals.apache.org/applications/webcontent2/reverse-proxy-module.html
○ Map Local Path to Remote URLs!
■ e.g. /site/products/ → http://example.com/products/ ,
/site/products/123 → http://example.com/products/123
* More at https://www.onehippo.org/library/concepts/web-application/hst-2-edge-side-includes-support.html
<!--esi:include src="/site/products/123" -->
29. Gems in Hippo Forge Projects
#1 Integration with
External Content
“Link Document to External Content with Metadata
(e.g. in CMIS, Commerce, DB, … ).”
30. Integration with External Content
● External Document Picker Forge Plugin:
○ Concept: Separation of UI and Data Service.
■ UI Plugin
● UI for searching and displaying of external document item(s), retrieved by
ExternalDocumentServiceFacade component.
■ ExternalDocumentServiceFacade Data Service interface
● Configured for the UI Plugin; Invoked by the UI Plugin.
● All Data Handling under the hood against backend.
○ Title, icon and description for each external document.
○ Store metadata of selected item(s) into Hippo document.
* More at http://exdocpickerbase.forge.onehippo.org/
32. Integration with External Content
ExternalDocumentServiceFacade
is responsible for data to
display each item.
33. Integration with External Content
Again,
ExternalDocumentServiceFacade
is responsible for data to
display each selection.
34. Gems in Hippo Forge Projects
#2 Content EXIM
“Import Document / Binary Data to Hippo!”
35. Content EXIM
● Lightweight Library to EXport/IMport
Documents and Binaries to/from JSON or XML
● Uses Standard Hippo Workflow/Gallery APIs.
● Groovy Updater as primary execution engine
● Example Groovy Scripts to start with:
○ to export/import documents and image/assets.
○ to create documents from CSV.
○ to create image sets from image files.
* More at http://content-exim.forge.onehippo.org/
41. Gems in Hippo Forge Projects
#4 Spring Security Integration
“Secure My Services through JWT, SAML or OAuth!”
42. Spring Security Integration
● Spring Security Framework:
○ Powerful and highly customizable authentication and access-control framework.
○ Basic Auth, Spring Security SAML, Spring Security OAuth, etc.
● HST Spring Security Framework Integration Forge adds:
○ Hippo Authentication Provider with Hippo UserDetailsService.
○ Spring Security Valve injected in HST pipeline.
■ Sitemap Item with @hst:authenticated, @hst:roles, @hst:users.
■ JAX-RS Services with JEE Security Annotations such as @RolesAllowed.
* More at http://hst-springsec.forge.onehippo.org/