Class MinimizeTransformer
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.xml.AbstractXMLPipe
-
- org.apache.cocoon.transformation.AbstractTransformer
-
- org.apache.cocoon.transformation.ServiceableTransformer
-
- org.ametys.plugins.core.ui.minimize.MinimizeTransformer
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,Configurable
,Contextualizable
,LogEnabled
,Serviceable
,SitemapModelComponent
,Transformer
,XMLConsumer
,XMLPipe
,XMLProducer
,XMLConsumer
,ContentHandler
,LexicalHandler
- Direct Known Subclasses:
FrontMinimizeTransformer
public class MinimizeTransformer extends ServiceableTransformer implements Contextualizable, Configurable
This transformer will minimize every scripts together
-
-
Field Summary
Fields Modifier and Type Field Description private static Set<String>
__ALL_MEDIA
private static String
__DEFAULT_URI_PATTERN
protected Context
_context
The avalon contextprotected String
_currentContextPath
The current contextprivate Map<String,Map<String,String>>
_filesQueue
private HashCache
_hashCache
protected Boolean
_inlineCssMedias
Should css medias be taken in account?private boolean
_isCurrentTagQueued
protected Boolean
_isSuperDevMode
Is developer mode?protected String
_locale
The current localprotected List<Pattern>
_patterns
The list of patterns available for minimizationprivate Set<String>
_queueMedia
private String
_queueTag
-
Fields inherited from class org.apache.cocoon.transformation.ServiceableTransformer
manager, objectModel, parameters, resolver, source
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
-
-
Constructor Summary
Constructors Constructor Description MinimizeTransformer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addToQueue(String tagName, Attributes attrs)
Add a new tag to the current queue.private boolean
_areAlwaysInlinableMedias(Set<String> medias)
protected String
_getMinimizeUrl()
Get the url of the minimizerprivate boolean
_isMinimizable(String tagName, Attributes attrs)
Check if the current tag can be minimized by this transformerprivate void
_processQueue()
Process the current files queue by saxing it as one file, which name is the hash of the sum of files.protected String
_removeContextPath(String uri)
Remove the context path from the uri to be able to analyse correctly the patternsprivate Set<String>
_toMediaList(String media)
void
configure(Configuration configuration)
void
contextualize(Context context)
void
endElement(String uri, String loc, String raw)
protected String
getHashSalt()
Return the salt used by the hash cachevoid
service(ServiceManager smanager)
void
setup(SourceResolver res, Map obj, String src, Parameters par)
void
startDocument()
void
startElement(String uri, String loc, String raw, Attributes a)
-
Methods inherited from class org.apache.cocoon.transformation.ServiceableTransformer
dispose, recycle
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMapping
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
-
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
-
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
-
-
-
Field Detail
-
__DEFAULT_URI_PATTERN
private static final String __DEFAULT_URI_PATTERN
- See Also:
- Constant Field Values
-
__ALL_MEDIA
private static final Set<String> __ALL_MEDIA
-
_isSuperDevMode
protected Boolean _isSuperDevMode
Is developer mode?
-
_inlineCssMedias
protected Boolean _inlineCssMedias
Should css medias be taken in account?
-
_currentContextPath
protected String _currentContextPath
The current context
-
_queueMedia
private Set<String> _queueMedia
-
_isCurrentTagQueued
private boolean _isCurrentTagQueued
-
_hashCache
private HashCache _hashCache
-
-
Constructor Detail
-
MinimizeTransformer
public MinimizeTransformer()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableTransformer
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
_getMinimizeUrl
protected String _getMinimizeUrl()
Get the url of the minimizer- Returns:
- The minimizer url
-
setup
public void setup(SourceResolver res, Map obj, String src, Parameters par) throws ProcessingException, SAXException, IOException
- Specified by:
setup
in interfaceSitemapModelComponent
- Overrides:
setup
in classServiceableTransformer
- Throws:
ProcessingException
SAXException
IOException
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classAbstractXMLPipe
- Throws:
SAXException
-
startElement
public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classAbstractXMLPipe
- Throws:
SAXException
-
endElement
public void endElement(String uri, String loc, String raw) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classAbstractXMLPipe
- Throws:
SAXException
-
_isMinimizable
private boolean _isMinimizable(String tagName, Attributes attrs)
Check if the current tag can be minimized by this transformer- Parameters:
tagName
- The tag nameattrs
- The attribute- Returns:
- True if minimizable
-
_removeContextPath
protected String _removeContextPath(String uri)
Remove the context path from the uri to be able to analyse correctly the patterns- Parameters:
uri
- The incomming uri- Returns:
- The uri with no context path
-
_addToQueue
private void _addToQueue(String tagName, Attributes attrs) throws SAXException
Add a new tag to the current queue. If the new tag is not compatible with the current queue, it is processed first and emptied before adding the new type of tag.- Parameters:
tagName
- The tag nameattrs
- The tag attribute- Throws:
SAXException
- If an error occurred
-
_areAlwaysInlinableMedias
private boolean _areAlwaysInlinableMedias(Set<String> medias)
-
_processQueue
private void _processQueue() throws SAXException
Process the current files queue by saxing it as one file, which name is the hash of the sum of files. This hash is cached, to allow the retrieval of the real files from the hash value. The files parameters, such as the media value of css files, are also stored in the cache.- Throws:
SAXException
- If an error occurred
-
getHashSalt
protected String getHashSalt()
Return the salt used by the hash cache- Returns:
- The salt string
-
_toMediaList
private Set<String> _toMediaList(String media)
-
-