[
https://issues.apache.org/jira/browse/TRINIDAD-2234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13225499#comment-13225499
]
Andy Schwartz commented on TRINIDAD-2234:
-----------------------------------------
The attached patch:
https://issues.apache.org/jira/secure/attachment/12517604/trinidad-skin-pregen.patch
Provides a solution for both this issue as well as for:
TRINIDAD-2235 Skinning: stable names for generated style sheets
Still more work to do (mostly code cleanup) but very close to fully functional.
The class doc for SkinPregenerationService provides most of the API details:
/**
* InternalView implementation that provides skin pregeneration service.
*
* Skin pregeneration is enabled by specifying the following system
* property:
*
* -Dorg.apache.myfaces.trinidad.SKIN_PREGENERATION_SERVICE=on
*
* When enabled, a request to the "-pregenerate-skins" view id can be
* used to force pregeneration for specific skins. Each request must
* specifiy a single "id" query parameter. The value of this query parameter
* must be an id of one of the skins registered with trinidad (eg. via
* an "id" element in a trinidad-skins.xml file).
*
* For example, in an application that uses prefix mapping for the FacesServlet,
* enabling the skin pregeneration service exposes the following uri:
*
* - /context root/faces/-pregenerate-skins?id=minimal.desktop
*
* Which triggers pregeneration of style sheets for the minimal.desktop skin
* when hit.
*
* By default, only style sheets for common variant values are generated.
* In particular:
*
* - plaform: android | iphone | linux | macos | windows
* - agent: ie | gecko | webkit
* - locale: default (unmatched) locale
* - reading direction: ltr
* - accessibility: standard contrast, medium fonts
*
* The "variants" request parameter can be used to force generation of all
* possible variants, eg:
*
* - "/context root/faces/-pregenerate-skins?id=minimal.desktop?variants=all
*
* The following optional request parameters may also be used to provide
contextual
* information about how the pregeneration should be performed:
*
* - containerType: servlet | portlet. (Defaults to "servlet".)
* - requestType: nonsecure | secure. (Defaults to "nonsecure".)
* - styleClassType: compressed | uncompressed. (Defaults to "compressed".)
*
* All of the contextual request parameters support multiple values. For
example,
* the following request:
*
*
/-pregenerate-skins?id=minimal.desktop&styleClassType=compressed&styleClassType=uncompressed
*
* Pregenerates both servlet and portlet style sheets for the common variants
of the the
* minimal.desktop skin.
*
* By default, pregenerated style sheets are written into the web application's
* style sheet cache directory (typically, tmpdir/adf/styles/cache). However,
* a target directory for the pregenerated output can be specified via the
* following system property:
*
*
-Dorg.apache.myfaces.trinidad.SKIN_PREGENERATION_SERVICE_TARGET_DIRECTORY=directory
path
*
*
* Requests that result in successful skin pregeneration result in status 200
* responses. Failed requests (eg. for invalid skin ids) result in non-200
* status codes.
*
* For security purposes, pregeneration must never be enabled in end user
facing,
* production deployments - ie. skin pregeneration is CPU and I/O intensive, and
* must not be exposed to arbitrary users. To avoid the potential for abuse,
* enabling skin pregeneration has the side effect of disabling the rest of the
* application. As such, applications that are enabled for skin pregeneration
* can only be used for this single purpose.
*/
There are some other minor new APIs, including:
- Stable names APIs (see TRINIDAD-2235)
- A new enums-related utility class: org.apache.myfaces.trinidad.util.Enums.
- A couple of minor additions to org.apache.myfaces.trinidad.context.Version
(toConcreteVersion(), MAX/MIN_VERSION constants).
Also:
- Fixed up Version.compareTo to properly handle numeric version comparisons.
(Before this, new Version("10").compareTo(new Version"9") would return < 0.)
- Started adding some skin-related test infrastructure. (More to do on this.)
> Pregeneration of skin style sheets
> ----------------------------------
>
> Key: TRINIDAD-2234
> URL: https://issues.apache.org/jira/browse/TRINIDAD-2234
> Project: MyFaces Trinidad
> Issue Type: New Feature
> Components: Skinning
> Affects Versions: 2.0.1-core
> Reporter: Andy Schwartz
> Assignee: Andy Schwartz
> Priority: Minor
> Attachments: trinidad-skin-pregen.patch
>
>
> Trinidad skinning dynamically generates style sheets at runtime to meet
> context-specific (ie. platform/agent/locale/accessibility-specific) skinning
> requirements. While dynamic generation of style sheets is beneficial in that
> it allows fine tuning of which styles are delivered for particular contexts,
> it can complicate some use cases.
> One case that dynamic generation makes particularly difficult is where the
> application and its resources are split across separate hosts/domains. In
> this case, resources are typically hosted on a dedicated server that can be:
> a) Shared across multiple applications, thus improving the likelihood of
> browser cache hits. And...
> b) More easily fronted by a CDN (without also having to route all application
> traffic through a CDN ).
> Since a single skin definition can result in an arbitrary number of generated
> style sheets, it is not possible to host Trinidad skin/style sheets on a
> dedicated server - ie. there is currently no reliable way to pre-generate all
> possible variants of any given skin.
> This issue requests that we add a new skin pregeneration feature that would
> allow all style sheet variants for any skin to be generated prior to
> application deployment. This would facilitate the the split
> application/resources scenario described above.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira