idx
int64 0
41.2k
| question
stringlengths 74
4.21k
| target
stringlengths 5
888
|
|---|---|---|
2,400
|
public String compile ( JoinableResourceBundle bundle , String content , String path , GeneratorContext context ) { JawrLessSource source = new JawrLessSource ( bundle , content , path , rsHandler ) ; try { CompilationResult result = compiler . compile ( source , lessConfig ) ; addLinkedResources ( path , context , source . getLinkedResources ( ) ) ; return result . getCss ( ) ; } catch ( Less4jException e ) { throw new BundlingProcessException ( "Unable to generate content for resource path : '" + path + "'" , e ) ; } }
|
Compile the LESS source to a CSS source
|
2,401
|
public Set < String > getResourceNames ( String folder ) { String path = super . getResourcePath ( folder ) ; Set < String > assets = locator . listAssets ( path ) ; Set < String > resourceNames = new HashSet < > ( ) ; for ( String asset : assets ) { int idx = asset . indexOf ( path ) ; if ( idx != - 1 ) { String name = asset . substring ( idx + path . length ( ) ) ; idx = name . indexOf ( JawrConstant . URL_SEPARATOR ) ; if ( idx != - 1 ) { name = name . substring ( 0 , idx + 1 ) ; } resourceNames . add ( name ) ; } } return resourceNames ; }
|
List assets within a folder .
|
2,402
|
protected StringBuffer getHeaderSection ( HttpServletRequest request ) { StringBuffer sb = new StringBuffer ( mainScriptTemplate . toString ( ) ) ; sb . append ( "JAWR.app_context_path='" ) . append ( request . getContextPath ( ) ) . append ( "';\n" ) ; return sb ; }
|
Returns the header section for the client side handler
|
2,403
|
private String getPathPrefix ( HttpServletRequest request , JawrConfig config ) { if ( request . isSecure ( ) ) { if ( null != config . getContextPathSslOverride ( ) ) { return config . getContextPathSslOverride ( ) ; } } else { if ( null != config . getContextPathOverride ( ) ) { return config . getContextPathOverride ( ) ; } } String mapping = null == config . getServletMapping ( ) ? "" : config . getServletMapping ( ) ; String path = PathNormalizer . joinPaths ( request . getContextPath ( ) , mapping ) ; path = path . endsWith ( "/" ) ? path : path + '/' ; return path ; }
|
Determines which prefix should be used for the links according to the context path override if present or using the context path and possibly the jawr mapping .
|
2,404
|
private void addAllBundles ( List < JoinableResourceBundle > bundles , Map < String , String > variants , StringBuffer buf , boolean useGzip ) { for ( Iterator < JoinableResourceBundle > it = bundles . iterator ( ) ; it . hasNext ( ) ; ) { JoinableResourceBundle bundle = it . next ( ) ; appendBundle ( bundle , variants , buf , useGzip ) ; if ( it . hasNext ( ) ) buf . append ( "," ) ; } }
|
Adds a javascript Resourcebundle representation for each member of a List containing JoinableResourceBundles
|
2,405
|
private void appendBundle ( JoinableResourceBundle bundle , Map < String , String > variants , StringBuffer buf , boolean useGzip ) { buf . append ( "r(" ) . append ( JavascriptStringUtil . quote ( bundle . getId ( ) ) ) . append ( "," ) ; String path = bundle . getURLPrefix ( variants ) ; if ( useGzip ) { if ( path . charAt ( 0 ) == '/' ) { path = path . substring ( 1 ) ; } buf . append ( JavascriptStringUtil . quote ( BundleRenderer . GZIP_PATH_PREFIX + path ) ) ; } else { if ( path . charAt ( 0 ) != '/' ) { path = "/" + path ; } buf . append ( JavascriptStringUtil . quote ( path ) ) ; } boolean skipItems = false ; if ( bundle . getItemPathList ( ) . size ( ) == 1 && null == bundle . getExplorerConditionalExpression ( ) ) { skipItems = bundle . getItemPathList ( ) . get ( 0 ) . getPath ( ) . equals ( bundle . getId ( ) ) ; } if ( ! skipItems ) { buf . append ( ",[" ) ; for ( Iterator < BundlePath > it = bundle . getItemPathList ( variants ) . iterator ( ) ; it . hasNext ( ) ; ) { path = it . next ( ) . getPath ( ) ; if ( this . config . getGeneratorRegistry ( ) . isPathGenerated ( path ) ) { path = PathNormalizer . createGenerationPath ( path , this . config . getGeneratorRegistry ( ) , null ) ; } if ( "" . equals ( this . config . getContextPathOverride ( ) ) && path . startsWith ( "/" ) ) path = path . substring ( 1 ) ; buf . append ( JavascriptStringUtil . quote ( path ) ) ; if ( it . hasNext ( ) ) buf . append ( "," ) ; } buf . append ( "]" ) ; if ( null != bundle . getExplorerConditionalExpression ( ) ) { buf . append ( ",'" ) . append ( bundle . getExplorerConditionalExpression ( ) ) . append ( "'" ) ; } } if ( null != bundle . getAlternateProductionURL ( ) ) { if ( skipItems ) buf . append ( ",null,null" ) ; else if ( null == bundle . getExplorerConditionalExpression ( ) ) buf . append ( ",null" ) ; buf . append ( "," ) . append ( JavascriptStringUtil . quote ( bundle . getAlternateProductionURL ( ) ) ) ; } buf . append ( ")" ) ; }
|
Creates a javascript object that represents a bundle
|
2,406
|
public Properties getAllMessages ( Locale locale ) { Properties props = new Properties ( ) ; Properties mergedProps = null ; if ( locale == null ) { locale = Locale . getDefault ( ) ; } mergedProps = getMergedProperties ( locale ) . getProperties ( ) ; Set < Entry < Object , Object > > entries = mergedProps . entrySet ( ) ; for ( Entry < Object , Object > entry : entries ) { String key = ( String ) entry . getKey ( ) ; if ( LocaleUtils . matchesFilter ( key , filters ) ) { try { String msg = getMessage ( key , new Object [ 0 ] , locale ) ; if ( ! warDeployed ) { msg = new String ( msg . getBytes ( CHARSET_ISO_8859_1 ) , CHARSET_UTF_8 ) ; } props . put ( key , msg ) ; } catch ( NoSuchMessageException e ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Message key [" + key + "] not found." ) ; } catch ( UnsupportedEncodingException e ) { LOGGER . warn ( "Unable to convert value of message bundle associated to key '" + key + "' because the charset is unknown" ) ; } } } return props ; }
|
Returns all the messages
|
2,407
|
public BundlePathMapping build ( ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Creating bundle path List for " + this . bundle . getId ( ) ) ; } BundlePathMapping bundlePathMapping = new BundlePathMapping ( this . bundle ) ; bundlePathMapping . setPathMappings ( strPathMappings ) ; List < PathMapping > pathMappings = bundlePathMapping . getPathMappings ( ) ; Map < String , VariantSet > variants = new TreeMap < > ( ) ; if ( pathMappings != null ) { for ( PathMapping pathMapping : pathMappings ) { boolean isGeneratedPath = generatorRegistry . isPathGenerated ( pathMapping . getPath ( ) ) ; if ( pathMapping . isDirectory ( ) ) { addItemsFromDir ( bundlePathMapping , pathMapping , false ) ; } else if ( pathMapping . isRecursive ( ) ) { addItemsFromDir ( bundlePathMapping , pathMapping , true ) ; } else if ( pathMapping . getPath ( ) . endsWith ( fileExtension ) ) { addPathMapping ( bundlePathMapping , asPath ( pathMapping . getPath ( ) , isGeneratedPath ) ) ; } else if ( generatorRegistry . isPathGenerated ( pathMapping . getPath ( ) ) ) { addPathMapping ( bundlePathMapping , pathMapping . getPath ( ) ) ; } else if ( pathMapping . getPath ( ) . endsWith ( LICENSES_FILENAME ) ) { bundlePathMapping . getLicensesPathList ( ) . add ( asPath ( pathMapping . getPath ( ) , isGeneratedPath ) ) ; } else { throw new BundlingProcessException ( "Wrong mapping [" + pathMapping + "] for bundle [" + this . bundle . getName ( ) + "]. Please check configuration. " ) ; } if ( isGeneratedPath ) { variants = VariantUtils . concatVariants ( variants , generatorRegistry . getAvailableVariants ( pathMapping . getPath ( ) ) ) ; } } } bundle . setVariants ( variants ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Finished creating bundle path List for " + this . bundle . getId ( ) ) ; } return bundlePathMapping ; }
|
Detects all files that belong to the bundle and adds them to the bundle path mapping .
|
2,408
|
private void addPathMapping ( BundlePathMapping bundlePathMapping , String pathMapping ) { addFilePathMapping ( bundlePathMapping , pathMapping ) ; if ( ! bundle . getInclusionPattern ( ) . isIncludeOnlyOnDebug ( ) ) { bundlePathMapping . getItemPathList ( ) . add ( new BundlePath ( bundle . getBundlePrefix ( ) , pathMapping ) ) ; } if ( ! bundle . getInclusionPattern ( ) . isExcludeOnDebug ( ) ) { bundlePathMapping . getItemDebugPathList ( ) . add ( new BundlePath ( bundle . getBundlePrefix ( ) , pathMapping ) ) ; } }
|
Adds a path mapping to the bundle
|
2,409
|
protected void addFilePathMapping ( BundlePathMapping bundlePathMapping , String pathMapping ) { long timestamp = 0 ; String filePath = resourceReaderHandler . getFilePath ( pathMapping ) ; if ( filePath != null ) { timestamp = resourceReaderHandler . getLastModified ( filePath ) ; List < FilePathMapping > filePathMappings = bundlePathMapping . getFilePathMappings ( ) ; boolean found = false ; for ( FilePathMapping filePathMapping : filePathMappings ) { if ( filePathMapping . getPath ( ) . equals ( filePath ) ) { found = true ; break ; } } if ( ! found ) { filePathMappings . add ( new FilePathMapping ( bundle , filePath , timestamp ) ) ; } } }
|
Adds the path mapping to the file path mapping
|
2,410
|
private String asPath ( String path , boolean generatedResource ) { String result = path ; if ( ! generatedResource ) { result = PathNormalizer . asPath ( path ) ; } return result ; }
|
Normalizes a path and adds a separator at its start if it s not a generated resource .
|
2,411
|
public void createBundles ( ) throws Exception { File tempDir = new File ( tempDirPath ) ; if ( ! tempDir . exists ( ) ) { tempDir . mkdirs ( ) ; } else { FileUtils . cleanDirectory ( tempDir ) ; } File destDir = new File ( destDirPath ) ; if ( ! destDir . exists ( ) ) { destDir . mkdirs ( ) ; } else { FileUtils . cleanDirectory ( destDir ) ; } List < String > servlets = new ArrayList < String > ( ) ; if ( servletsToInitialize != null ) { String [ ] servletNames = servletsToInitialize . split ( SERVLET_NAME_SEPARATOR ) ; for ( int i = 0 ; i < servletNames . length ; i ++ ) { servlets . add ( servletNames [ i ] . trim ( ) ) ; } } BundleProcessor bundleProcessor = new BundleProcessor ( ) ; bundleProcessor . process ( rootPath , tempDirPath , destDirPath , springConfigFiles , servlets , generateCDNFiles , keepUrlMapping , servletAPIversion ) ; }
|
Create the bundles .
|
2,412
|
public static void main ( String [ ] args ) throws Exception { Server server = new Server ( 8080 ) ; server . setStopAtShutdown ( true ) ; server . setHandler ( new WebAppContext ( "web" , "/dwr" ) ) ; server . start ( ) ; server . join ( ) ; }
|
Sets up and runs server .
|
2,413
|
public void initVariantProviderStrategy ( GeneratorContext context , Map < String , VariantSet > variantsSetMap ) { List < Map < String , String > > variantMapStrategies = new ArrayList < > ( ) ; Map < String , String > ctxVariantMap = context . getVariantMap ( ) ; VariantSet skinVariantSet = variantsSetMap . get ( JawrConstant . SKIN_VARIANT_TYPE ) ; String skinVariant = ctxVariantMap . get ( JawrConstant . SKIN_VARIANT_TYPE ) ; VariantSet localeVariantSet = variantsSetMap . get ( JawrConstant . LOCALE_VARIANT_TYPE ) ; String localeVariant = ctxVariantMap . get ( JawrConstant . LOCALE_VARIANT_TYPE ) ; variantMapStrategies . add ( getVariantMap ( skinVariant , localeVariant ) ) ; if ( localeVariantSet != null ) { variantMapStrategies . add ( getVariantMap ( skinVariant , localeVariantSet . getDefaultVariant ( ) ) ) ; } variantMapStrategies . add ( getVariantMap ( skinVariantSet . getDefaultVariant ( ) , localeVariant ) ) ; if ( localeVariantSet != null ) { variantMapStrategies . add ( getVariantMap ( skinVariantSet . getDefaultVariant ( ) , localeVariantSet . getDefaultVariant ( ) ) ) ; } variantMapStrategyIterator = variantMapStrategies . iterator ( ) ; }
|
Initialize the variant resource provider strategy
|
2,414
|
private Map < String , String > getVariantMap ( String skinVariant , String localeVariant ) { Map < String , String > variantMap = new HashMap < > ( ) ; variantMap . put ( JawrConstant . SKIN_VARIANT_TYPE , skinVariant ) ; variantMap . put ( JawrConstant . LOCALE_VARIANT_TYPE , localeVariant ) ; return variantMap ; }
|
Returns the variant map from the skin and the locale parameters
|
2,415
|
public void init ( ResourceBundlesHandler bundler , Boolean useRandomParam ) { this . bundler = bundler ; if ( useRandomParam == null ) { this . useRandomParam = bundler . getConfig ( ) . isDebugUseRandomParam ( ) ; } else { this . useRandomParam = useRandomParam ; } }
|
Initializes the bundle link renderer
|
2,416
|
private void renderBundleDependenciesLinks ( String requestedPath , BundleRendererContext ctx , Writer out , boolean debugOn , List < JoinableResourceBundle > dependencies ) throws IOException { if ( dependencies != null && ! dependencies . isEmpty ( ) ) { for ( JoinableResourceBundle dependencyBundle : dependencies ) { if ( debugOn ) { addComment ( "Start adding dependency '" + dependencyBundle . getId ( ) + "'" , out ) ; } renderBundleLinks ( dependencyBundle , requestedPath , ctx , out , debugOn , false ) ; if ( debugOn ) { addComment ( "Finished adding dependency '" + dependencyBundle . getId ( ) + "'" , out ) ; } } } }
|
Renders the bundle links for the bundle dependencies
|
2,417
|
protected void renderBundleLinks ( ResourceBundlePathsIterator it , BundleRendererContext ctx , boolean debugOn , Writer out ) throws IOException { String contextPath = ctx . getContextPath ( ) ; boolean useGzip = ctx . isUseGzip ( ) ; boolean isSslRequest = ctx . isSslRequest ( ) ; Random randomSeed = new Random ( ) ; while ( it . hasNext ( ) ) { BundlePath bundlePath = it . nextPath ( ) ; if ( bundlePath != null ) { String resourceName = bundlePath . getPath ( ) ; if ( resourceName != null ) { if ( bundlePath . isExternalURL ( ) ) { out . write ( renderLink ( resourceName ) ) ; } else if ( debugOn && useRandomParam ) { int random = randomSeed . nextInt ( ) ; if ( random < 0 ) { random *= - 1 ; } out . write ( createBundleLink ( resourceName , bundlePath . getBundlePrefix ( ) , "d=" + random , contextPath , isSslRequest ) ) ; } else if ( ! debugOn && useGzip ) { out . write ( createGzipBundleLink ( resourceName , bundlePath . getBundlePrefix ( ) , contextPath , isSslRequest ) ) ; } else { out . write ( createBundleLink ( resourceName , bundlePath . getBundlePrefix ( ) , null , contextPath , isSslRequest ) ) ; } if ( debugOn && ! ctx . getIncludedResources ( ) . add ( resourceName ) ) { addComment ( "The resource '" + resourceName + "' is already included in the page." , out ) ; } } } } }
|
Renders the bundle links for the resource iterator passed in parameter
|
2,418
|
protected void addComment ( String commentText , Writer out ) throws IOException { StringBuilder sb = new StringBuilder ( "<script type=\"text/javascript\">/* " ) ; sb . append ( commentText ) . append ( " */</script>" ) . append ( "\n" ) ; out . write ( sb . toString ( ) ) ; }
|
Adds an HTML comment to the output stream .
|
2,419
|
protected String createGzipBundleLink ( String resourceName , String bundlePrefix , String contextPath , boolean isSslRequest ) { String resource = resourceName . substring ( 1 , resourceName . length ( ) ) ; return createBundleLink ( BundleRenderer . GZIP_PATH_PREFIX + resource , bundlePrefix , null , contextPath , isSslRequest ) ; }
|
Creates a link to a bundle in the page prepending the gzip prefix to its identifier .
|
2,420
|
protected boolean getUseRandomParamFlag ( JawrConfig config ) { boolean useRandomParamFlag = config . isDebugUseRandomParam ( ) ; if ( useRandomParam != null ) { useRandomParamFlag = Boolean . parseBoolean ( useRandomParam ) ; } return useRandomParamFlag ; }
|
Returns the flag for the use of random param in debug mode
|
2,421
|
protected ResourceBundlesHandler getResourceBundlesHandler ( FacesContext context ) { Object handler = context . getExternalContext ( ) . getApplicationMap ( ) . get ( getResourceBundlesHandlerAttributeName ( ) ) ; if ( null == handler ) throw new IllegalStateException ( "ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred." ) ; ResourceBundlesHandler rsHandler = ( ResourceBundlesHandler ) handler ; return rsHandler ; }
|
Returns the resource handler
|
2,422
|
public static StringBuffer buildRequestSpecificParams ( String contextPath , String dwrPath ) { StringBuffer sb = new StringBuffer ( "<script type=\"text/javascript\">if(!JAWR){var JAWR = {};};" ) ; sb . append ( buildDWRJSParams ( contextPath , dwrPath ) ) ; sb . append ( "</script>" ) . append ( "\n" ) ; return sb ; }
|
Adds a script with DWR needed params including a generated ID that DWR needs .
|
2,423
|
public List < String > getOrphansList ( ) throws DuplicateBundlePathException { JoinableResourceBundleImpl tempBundle = new JoinableResourceOrphanBundleImpl ( "orphansTemp" , "orphansTemp" , this . resourceExtension , new InclusionPattern ( ) , Collections . singletonList ( this . baseDir ) , rsHandler , generatorRegistry ) ; Set < String > licensesPathList = tempBundle . getLicensesPathList ( ) ; for ( Iterator < String > it = licensesPathList . iterator ( ) ; it . hasNext ( ) ; ) { addFileIfNotMapped ( it . next ( ) ) ; } List < BundlePath > allPaths = tempBundle . getItemPathList ( ) ; for ( Iterator < BundlePath > it = allPaths . iterator ( ) ; it . hasNext ( ) ; ) { addFileIfNotMapped ( it . next ( ) . getPath ( ) ) ; } return this . bundleMapping ; }
|
Scan all dirs starting at baseDir and add each orphan resource to the resources map .
|
2,424
|
private void addFileIfNotMapped ( String filePath ) throws DuplicateBundlePathException { for ( JoinableResourceBundle bundle : currentBundles ) { List < BundlePath > items = bundle . getItemPathList ( ) ; List < BundlePath > itemsDebug = bundle . getItemDebugPathList ( ) ; Set < String > licenses = bundle . getLicensesPathList ( ) ; for ( BundlePath path : items ) { if ( path . getPath ( ) . equals ( filePath ) ) { return ; } } for ( BundlePath path : itemsDebug ) { if ( path . getPath ( ) . equals ( filePath ) ) { return ; } } if ( licenses . contains ( filePath ) ) return ; else if ( filePath . equals ( bundle . getId ( ) ) ) { Marker fatal = MarkerFactory . getMarker ( "FATAL" ) ; LOGGER . error ( fatal , "Duplicate bundle id resulted from orphan mapping of:" + filePath ) ; throw new DuplicateBundlePathException ( filePath ) ; } } if ( ! filePath . startsWith ( JawrConstant . WEB_INF_DIR_PREFIX ) && ! filePath . startsWith ( JawrConstant . META_INF_DIR_PREFIX ) ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Adding orphan resource: " + filePath ) ; bundleMapping . add ( filePath ) ; } }
|
Determine whether a resource is already added to some bundle add it to the list if it is not .
|
2,425
|
protected void initAdditionalPropertyBaseNames ( ServletContext context ) { String propertyNames = context . getInitParameter ( SERVLET_CONTEXT_ADDITIONAL_CONFIG_PARAM ) ; propertyBaseNames = new ArrayList < > ( ) ; if ( null != propertyNames ) { StringTokenizer tk = new StringTokenizer ( propertyNames , "," ) ; while ( tk . hasMoreTokens ( ) ) propertyBaseNames . add ( tk . nextToken ( ) ) ; } }
|
Initializes the propertyBaseNames list by reading the jawr . config . sources servlet context param . Subclasses may override this method to use a different strategy .
|
2,426
|
public void renderImage ( String imgSource , Map < String , Object > attributes , final Writer writer ) throws IOException { StringBuilder sb = new StringBuilder ( tagStart ) ; sb . append ( "src=\"" ) . append ( imgSource ) . append ( "\" " ) ; for ( Entry < String , Object > mapEntry : attributes . entrySet ( ) ) { sb . append ( mapEntry . getKey ( ) ) . append ( "=\"" ) . append ( mapEntry . getValue ( ) ) . append ( "\" " ) ; } sb . append ( "/>" ) ; writer . write ( sb . toString ( ) ) ; }
|
Render the actual tag
|
2,427
|
public static String [ ] split ( String str , String separator ) { return Pattern . compile ( separator ) . split ( str , - 1 ) ; }
|
Split the String passed in parameter the trailing empty string are kept .
|
2,428
|
private static String serializeVariantSets ( Map < String , VariantSet > map ) { StringBuilder result = new StringBuilder ( ) ; for ( Entry < String , VariantSet > entry : map . entrySet ( ) ) { result . append ( entry . getKey ( ) ) . append ( ":" ) ; VariantSet variantSet = ( VariantSet ) entry . getValue ( ) ; result . append ( variantSet . getDefaultVariant ( ) ) . append ( ":" ) ; result . append ( getCommaSeparatedString ( variantSet ) ) ; result . append ( ";" ) ; } return result . toString ( ) ; }
|
Serialize the variant sets .
|
2,429
|
private static List < String > getBundleNames ( List < JoinableResourceBundle > bundles ) { List < String > bundleNames = new ArrayList < > ( ) ; for ( Iterator < JoinableResourceBundle > iterator = bundles . iterator ( ) ; iterator . hasNext ( ) ; ) { bundleNames . add ( iterator . next ( ) . getName ( ) ) ; } return bundleNames ; }
|
Returns the list of bundle names
|
2,430
|
private static String getBundlePostProcessorsName ( ChainedResourceBundlePostProcessor processor ) { String bundlePostProcessor = "" ; if ( processor != null ) { bundlePostProcessor = processor . getId ( ) ; } return bundlePostProcessor ; }
|
Returns the bundle post processor name separated by a comma character
|
2,431
|
public void notifyTyping ( String id , String value ) { Util utilAll = new Util ( getUsersToAffect ( ) ) ; utilAll . setValue ( id , Security . replaceXmlCharacters ( value ) ) ; }
|
Something has changed
|
2,432
|
public void notifyFocus ( String id ) { Util utilAll = new Util ( getUsersToAffect ( ) ) ; utilAll . addClassName ( id , "disabled" ) ; String addr = WebContextFactory . get ( ) . getHttpServletRequest ( ) . getRemoteAddr ( ) ; utilAll . setValue ( id + "Tip" , addr ) ; }
|
The user has tabbed in
|
2,433
|
public void notifyBlur ( String id ) { Util utilAll = new Util ( getUsersToAffect ( ) ) ; utilAll . removeClassName ( id , "disabled" ) ; utilAll . setValue ( id + "Tip" , "" ) ; }
|
The user has tabbed out
|
2,434
|
private void initRequestHandler ( ServletContext context , Properties configProps ) throws ServletException { long initialTime = System . currentTimeMillis ( ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Initializing jawr config for request handler named " + getInitParameter ( "handlerName" ) ) ; this . servletContext = context ; this . overrideProperties = configProps ; resourceType = getInitParameter ( "type" ) ; resourceType = null == resourceType ? "js" : resourceType ; if ( resourceType . equals ( "img" ) ) { throw new BundlingProcessException ( "The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead." ) ; } if ( ! ( resourceType . equals ( JawrConstant . JS_TYPE ) || resourceType . equals ( JawrConstant . CSS_TYPE ) || resourceType . equals ( JawrConstant . BINARY_TYPE ) ) ) { throw new BundlingProcessException ( "Unknown resource Type:" + resourceType ) ; } ConfigPropertiesSource propsSrc = initConfigPropertiesSource ( context , configProps ) ; Properties props = propsSrc . getConfigProperties ( ) ; if ( this . overrideProperties != null ) { props . putAll ( overrideProperties ) ; } this . propertiesSource = propsSrc ; initConfigPropertyResolver ( context ) ; initializeJawrContext ( props ) ; if ( ! ThreadLocalJawrContext . isBundleProcessingAtBuildTime ( ) && null != props . getProperty ( CONFIG_RELOAD_INTERVAL ) ) { int interval = Integer . parseInt ( props . getProperty ( CONFIG_RELOAD_INTERVAL ) ) ; LOGGER . warn ( "Jawr started with configuration auto reloading on. " + "Be aware that a daemon thread will be checking for changes to configuration every " + interval + " seconds." ) ; this . configChangeListenerThread = new ConfigChangeListenerThread ( this . resourceType , propsSrc , this . overrideProperties , this , this . bundlesHandler , interval ) ; configChangeListenerThread . start ( ) ; } if ( this . bundlesHandler != null && jawrConfig . getUseSmartBundling ( ) ) { this . watcher = new ResourceWatcher ( this . bundlesHandler , this . rsReaderHandler ) ; this . bundlesHandler . setResourceWatcher ( watcher ) ; try { this . watcher . initPathToResourceBundleMap ( this . bundlesHandler . getGlobalBundles ( ) ) ; this . watcher . initPathToResourceBundleMap ( this . bundlesHandler . getContextBundles ( ) ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Impossible to initialize Jawr Resource Watcher" , e ) ; } this . watcher . start ( ) ; } if ( LOGGER . isInfoEnabled ( ) ) { long totaltime = System . currentTimeMillis ( ) - initialTime ; LOGGER . info ( "Init method successful. jawr started in " + ( totaltime / 1000 ) + " seconds...." ) ; } ThreadLocalJawrContext . reset ( ) ; }
|
Initialize the request handler
|
2,435
|
private JawrApplicationConfigManager initApplicationConfigManager ( ) { JawrApplicationConfigManager appConfigMgr = ( JawrApplicationConfigManager ) servletContext . getAttribute ( JawrConstant . JAWR_APPLICATION_CONFIG_MANAGER ) ; if ( appConfigMgr == null ) { appConfigMgr = new JawrApplicationConfigManager ( ) ; servletContext . setAttribute ( JawrConstant . JAWR_APPLICATION_CONFIG_MANAGER , appConfigMgr ) ; } JawrConfigManager configMgr = new JawrConfigManager ( this , jawrConfig . getConfigProperties ( ) ) ; if ( resourceType . equals ( JawrConstant . JS_TYPE ) ) { appConfigMgr . setJsMBean ( configMgr ) ; } else if ( resourceType . equals ( JawrConstant . CSS_TYPE ) ) { appConfigMgr . setCssMBean ( configMgr ) ; } else { appConfigMgr . setBinaryMBean ( configMgr ) ; } return appConfigMgr ; }
|
Initialize the application config manager
|
2,436
|
private void initConfigPropertyResolver ( ServletContext context ) { String configPropertyResolverClass = getInitParameter ( "configPropertyResolverClass" ) ; configPropResolver = null ; if ( null != configPropertyResolverClass ) { configPropResolver = ( ConfigPropertyResolver ) ClassLoaderResourceUtils . buildObjectInstance ( configPropertyResolverClass ) ; if ( configPropResolver instanceof ServletContextAware ) { ( ( ServletContextAware ) configPropResolver ) . setServletContext ( context ) ; } } }
|
Initialize the config property resolver
|
2,437
|
private ConfigPropertiesSource initConfigPropertiesSource ( ServletContext context , Properties configProps ) throws ServletException { String configLocation = getInitParameter ( "configLocation" ) ; String configPropsSourceClass = getInitParameter ( "configPropertiesSourceClass" ) ; if ( null == configProps && null == configLocation && null == configPropsSourceClass ) throw new ServletException ( "Neither configLocation nor configPropertiesSourceClass init params were set." + " You must set at least the configLocation param. Please check your web.xml file" ) ; ConfigPropertiesSource propsSrc = null ; if ( null != configPropsSourceClass ) { propsSrc = ( ConfigPropertiesSource ) ClassLoaderResourceUtils . buildObjectInstance ( configPropsSourceClass ) ; if ( propsSrc instanceof ServletContextAware ) { ( ( ServletContextAware ) propsSrc ) . setServletContext ( context ) ; } } else if ( configLocation == null && configProps != null ) { propsSrc = new PropsConfigPropertiesSource ( configProps ) ; } else { propsSrc = new PropsFilePropertiesSource ( ) ; } if ( propsSrc instanceof PropsFilePropertiesSource ) ( ( PropsFilePropertiesSource ) propsSrc ) . setConfigLocation ( configLocation ) ; return propsSrc ; }
|
Initialize the config properties source that will provide with all configuration options .
|
2,438
|
protected void initIllegalBundleRequestHandler ( ) { String illegalBundleRequestandlerClassName = jawrConfig . getProperty ( JawrConstant . ILLEGAL_BUNDLE_REQUEST_HANDLER ) ; if ( illegalBundleRequestandlerClassName != null ) { illegalBundleRequestHandler = ( IllegalBundleRequestHandler ) ClassLoaderResourceUtils . buildObjectInstance ( illegalBundleRequestandlerClassName ) ; } else { illegalBundleRequestHandler = new IllegalBundleRequestHandlerImpl ( ) ; } }
|
Initialize the illegal bundle request handler
|
2,439
|
protected ResourceReaderHandler initResourceReaderHandler ( ) { ResourceReaderHandler rsHandler = null ; if ( servletContext != null ) { try { rsHandler = new ServletContextResourceReaderHandler ( servletContext , jawrConfig , generatorRegistry ) ; } catch ( IOException e ) { throw new BundlingProcessException ( e ) ; } } return rsHandler ; }
|
Initialize the resource reader handler
|
2,440
|
protected ResourceBundleHandler initResourceBundleHandler ( ) { ResourceBundleHandler rsHandler = null ; if ( jawrConfig . getUseBundleMapping ( ) && StringUtils . isNotEmpty ( jawrConfig . getJawrWorkingDirectory ( ) ) ) { rsHandler = new ServletContextResourceBundleHandler ( servletContext , jawrConfig . getJawrWorkingDirectory ( ) , jawrConfig . getResourceCharset ( ) , jawrConfig . getGeneratorRegistry ( ) , resourceType ) ; } else { rsHandler = new ServletContextResourceBundleHandler ( servletContext , jawrConfig . getResourceCharset ( ) , jawrConfig . getGeneratorRegistry ( ) , resourceType ) ; } return rsHandler ; }
|
Initialize the resource bundle handler
|
2,441
|
protected JawrConfig createJawrConfig ( Properties props ) { jawrConfig = new JawrConfig ( resourceType , props , configPropResolver ) ; if ( ThreadLocalJawrContext . isBundleProcessingAtBuildTime ( ) ) { jawrConfig . setUseBundleMapping ( true ) ; jawrConfig . setJawrWorkingDirectory ( null ) ; } return jawrConfig ; }
|
Create the Jawr config from the properties
|
2,442
|
public void doGet ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { try { String requestedPath = "" . equals ( jawrConfig . getServletMapping ( ) ) ? request . getServletPath ( ) : request . getPathInfo ( ) ; processRequest ( requestedPath , request , response ) ; } catch ( Exception e ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "ServletException : " , e ) ; } throw new ServletException ( e ) ; } }
|
Handles a resource request by getting the requested path from the request object and invoking processRequest .
|
2,443
|
protected void initThreadLocalJawrContext ( HttpServletRequest request ) { ThreadLocalJawrContext . setJawrConfigMgrObjectName ( JmxUtils . getJawrConfigMBeanObjectName ( request . getContextPath ( ) , resourceType , jawrConfig . getProperty ( JawrConstant . JAWR_JMX_MBEAN_PREFIX ) ) ) ; ThreadLocalJawrContext . setRequest ( request . getRequestURL ( ) . toString ( ) ) ; RendererRequestUtils . setRequestDebuggable ( request , jawrConfig ) ; }
|
Initialize the ThreadLocalJawrContext
|
2,444
|
protected boolean copyRequestedContentToResponse ( String requestedPath , HttpServletResponse response , String contentType ) throws IOException { boolean copyDone = false ; if ( isValidRequestedPath ( requestedPath ) ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Path '" + requestedPath + "' does not belong to a bundle. Forwarding request to the server. " ) ; } try ( InputStream is = servletContext . getResourceAsStream ( requestedPath ) ) { if ( is != null ) { response . setContentType ( contentType ) ; IOUtils . copy ( is , response . getOutputStream ( ) ) ; copyDone = true ; } } } return copyDone ; }
|
Copy the requested content to the response
|
2,445
|
protected boolean handleSpecificRequest ( String requestedPath , HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { boolean processed = false ; if ( CLIENTSIDE_HANDLER_REQ_PATH . equals ( requestedPath ) ) { this . clientSideScriptRequestHandler . handleClientSideHandlerRequest ( request , response ) ; processed = true ; } else { if ( JawrConstant . CSS_TYPE . equals ( resourceType ) && ! JawrConstant . CSS_TYPE . equals ( getExtension ( requestedPath ) ) ) { if ( null == bundlesHandler . resolveBundleForPath ( requestedPath ) && isValidRequestedPath ( requestedPath ) ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Path '" + requestedPath + "' does not belong to a bundle. Forwarding request to the server. " ) ; } request . getRequestDispatcher ( requestedPath ) . forward ( request , response ) ; processed = true ; } } } return processed ; }
|
Handle the specific requests
|
2,446
|
protected BundleHashcodeType isValidBundle ( String requestedPath ) { BundleHashcodeType bundleHashcodeType = BundleHashcodeType . VALID_HASHCODE ; if ( ! jawrConfig . isDebugModeOn ( ) ) { bundleHashcodeType = bundlesHandler . getBundleHashcodeType ( requestedPath ) ; } return bundleHashcodeType ; }
|
Returns true if the bundle is a valid bundle
|
2,447
|
protected void writeContent ( String requestedPath , HttpServletRequest request , HttpServletResponse response ) throws IOException , ResourceNotFoundException { int idx = requestedPath . indexOf ( BundleRenderer . GZIP_PATH_PREFIX ) ; if ( idx != - 1 ) { requestedPath = JawrConstant . URL_SEPARATOR + requestedPath . substring ( idx + BundleRenderer . GZIP_PATH_PREFIX . length ( ) , requestedPath . length ( ) ) ; if ( isValidRequestedPath ( requestedPath ) ) { response . setHeader ( CONTENT_ENCODING , GZIP ) ; bundlesHandler . streamBundleTo ( requestedPath , response . getOutputStream ( ) ) ; } else { throw new ResourceNotFoundException ( requestedPath ) ; } } else { BinaryResourcesHandler imgRsHandler = ( BinaryResourcesHandler ) servletContext . getAttribute ( JawrConstant . BINARY_CONTEXT_ATTRIBUTE ) ; if ( imgRsHandler != null && this . jawrConfig . isDebugModeOn ( ) && resourceType . equals ( JawrConstant . CSS_TYPE ) ) { handleGeneratedCssInDebugMode ( requestedPath , request , response , imgRsHandler ) ; } else { if ( isValidRequestedPath ( requestedPath ) ) { Writer out = response . getWriter ( ) ; bundlesHandler . writeBundleTo ( requestedPath , out ) ; } else { throw new ResourceNotFoundException ( requestedPath ) ; } } } }
|
Writes the content to the output stream
|
2,448
|
private void handleGeneratedCssInDebugMode ( String requestedPath , HttpServletRequest request , HttpServletResponse response , BinaryResourcesHandler binaryRsHandler ) throws ResourceNotFoundException , IOException { Reader rd = rsReaderHandler . getResource ( null , requestedPath ) ; if ( rd == null ) { throw new ResourceNotFoundException ( requestedPath ) ; } String content = IOUtils . toString ( rd ) ; String requestPath = getRequestPath ( request ) ; String result = CssDebugUrlRewriter . rewriteGeneratedBinaryResourceDebugUrl ( requestPath , content , binaryRsHandler . getConfig ( ) . getServletMapping ( ) ) ; Writer out = response . getWriter ( ) ; out . write ( result ) ; }
|
Handle the generated CSS content in debug mode .
|
2,449
|
private String getRequestPath ( HttpServletRequest request ) { String finalUrl = null ; String servletPath = request . getServletPath ( ) ; if ( "" . equals ( jawrConfig . getServletMapping ( ) ) ) { finalUrl = PathNormalizer . asPath ( servletPath ) ; } else { finalUrl = PathNormalizer . asPath ( servletPath + request . getPathInfo ( ) ) ; } return finalUrl ; }
|
Returns the request path
|
2,450
|
protected void setResponseHeaders ( HttpServletResponse resp ) { resp . setHeader ( CACHE_CONTROL_HEADER , CACHE_CONTROL_VALUE ) ; resp . setHeader ( LAST_MODIFIED_HEADER , LAST_MODIFIED_VALUE ) ; resp . setHeader ( ETAG_HEADER , ETAG_VALUE ) ; Calendar cal = Calendar . getInstance ( ) ; cal . roll ( Calendar . YEAR , 10 ) ; resp . setDateHeader ( EXPIRES_HEADER , cal . getTimeInMillis ( ) ) ; }
|
Adds aggressive caching headers to the response in order to prevent browsers requesting the same file twice .
|
2,451
|
public List < String > getDirtyBundleNames ( ) { List < String > bundleNames = new ArrayList < > ( ) ; if ( bundlesHandler != null ) { bundleNames = bundlesHandler . getDirtyBundleNames ( ) ; } return bundleNames ; }
|
Returns the names of the dirty bundles
|
2,452
|
public synchronized void rebuildDirtyBundles ( ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Rebuild dirty bundles" ) ; } StopWatch stopWatch = new StopWatch ( ) ; ThreadLocalJawrContext . setStopWatch ( stopWatch ) ; ThreadLocalJawrContext . setJawrConfigMgrObjectName ( JmxUtils . getMBeanObjectName ( servletContext , resourceType , jawrConfig . getProperty ( JawrConstant . JAWR_JMX_MBEAN_PREFIX ) ) ) ; try { if ( bundlesHandler != null ) { bundlesHandler . rebuildModifiedBundles ( ) ; } if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Jawr configuration successfully reloaded. " ) ; } if ( PERF_PROCESSING_LOGGER . isDebugEnabled ( ) ) { PERF_PROCESSING_LOGGER . debug ( stopWatch . prettyPrint ( ) ) ; } } catch ( InterruptBundlingProcessException e ) { if ( LOGGER . isInfoEnabled ( ) ) { LOGGER . info ( "Bundling processed stopped" ) ; } } catch ( Exception e ) { throw new BundlingProcessException ( "Error while rebuilding dirty bundles : " + e . getMessage ( ) , e ) ; } finally { ThreadLocalJawrContext . reset ( ) ; } }
|
Refresh the dirty bundles
|
2,453
|
public void setPerson ( Person person ) { log . debug ( "Adding person: " + person ) ; if ( person . getId ( ) == - 1 ) { person . setId ( getNextId ( ) ) ; } people . remove ( person ) ; people . add ( person ) ; }
|
Insert a person into the set of people
|
2,454
|
public void deletePerson ( Person person ) { log . debug ( "Removing person: " + person ) ; people . remove ( person ) ; debug ( ) ; }
|
Delete a person from the set of people
|
2,455
|
private Person getRandomPerson ( ) { Person person = new Person ( ) ; person . setId ( getNextId ( ) ) ; String firstname = FIRSTNAMES [ random . nextInt ( FIRSTNAMES . length ) ] ; String surname = SURNAMES [ random . nextInt ( SURNAMES . length ) ] ; person . setName ( firstname + " " + surname ) ; String housenum = ( random . nextInt ( 99 ) + 1 ) + " " ; String road1 = ROADS1 [ random . nextInt ( ROADS1 . length ) ] ; String road2 = ROADS2 [ random . nextInt ( ROADS2 . length ) ] ; String town = TOWNS [ random . nextInt ( TOWNS . length ) ] ; String address = housenum + road1 + " " + road2 + ", " + town ; person . setAddress ( address ) ; float salary = Math . round ( 10 + 90 * random . nextFloat ( ) ) * 1000 ; person . setSalary ( salary ) ; return person ; }
|
Create a random person
|
2,456
|
public String getPath ( String base , String uri ) throws ResourceNotFoundException , IOException { String fileName = uri ; if ( ! fileName . endsWith ( ".scss" ) ) { fileName += ".scss" ; } String parentPath = base . replace ( '\\' , '/' ) ; fileName = fileName . replace ( '\\' , '/' ) ; return PathNormalizer . concatWebPath ( parentPath , fileName ) ; }
|
Returns the path of the resource
|
2,457
|
public String findRelative ( String base , String uri ) throws ResourceNotFoundException , IOException { String path = getPath ( base , uri ) ; String source = resolveAndNormalize ( path ) ; if ( source != null ) { return source ; } path = PathNormalizer . getParentPath ( path ) + "_" + PathNormalizer . getPathName ( path ) ; source = resolveAndNormalize ( path ) ; if ( source != null ) { return source ; } return resolveAndNormalize ( uri ) ; }
|
Return the content of the resource using the base path and the relative URI
|
2,458
|
protected String resolveAndNormalize ( String path ) throws ResourceNotFoundException , IOException { List < Class < ? > > excluded = new ArrayList < > ( ) ; excluded . add ( ISassResourceGenerator . class ) ; Reader rd = null ; try { rd = rsHandler . getResource ( bundle , path , false , excluded ) ; addLinkedResource ( path ) ; } catch ( ResourceNotFoundException e ) { } String content = null ; if ( rd != null ) { content = IOUtils . toString ( rd ) ; if ( ! useAbsoluteUrl ) { CssImageUrlRewriter rewriter = new CssImageUrlRewriter ( ) ; content = rewriter . rewriteUrl ( path , this . scssPath , content ) . toString ( ) ; } content = SassRubyUtils . normalizeMultiByteString ( content ) ; } return content ; }
|
Finds and and normalized the content of the resource
|
2,459
|
protected void addLinkedResource ( String path ) { FilePathMapping linkedResource = getFilePathMapping ( path ) ; if ( linkedResource != null ) { addLinkedResource ( linkedResource ) ; if ( bundle != null ) { bundle . getLinkedFilePathMappings ( ) . add ( new FilePathMapping ( bundle , linkedResource . getPath ( ) , linkedResource . getLastModified ( ) ) ) ; } } }
|
Adds a path to the linked resource
|
2,460
|
private AbstractChainedResourceBundlePostProcessor addOrCreateChain ( AbstractChainedResourceBundlePostProcessor chain , String key ) { AbstractChainedResourceBundlePostProcessor toAdd ; if ( customPostProcessors . get ( key ) == null ) { toAdd = buildProcessorByKey ( key ) ; if ( toAdd instanceof BundlingProcessLifeCycleListener && ! listeners . contains ( toAdd ) ) { listeners . add ( ( BundlingProcessLifeCycleListener ) toAdd ) ; } } else { toAdd = ( AbstractChainedResourceBundlePostProcessor ) customPostProcessors . get ( key ) ; } AbstractChainedResourceBundlePostProcessor newChainResult = null ; if ( chain == null ) { newChainResult = toAdd ; } else { chain . addNextProcessor ( toAdd ) ; newChainResult = chain ; } return newChainResult ; }
|
Creates an AbstractChainedResourceBundlePostProcessor . If the supplied chain is null the new chain is returned . Otherwise it is added to the existing chain .
|
2,461
|
protected ChainedResourceBundlePostProcessor getCustomProcessorWrapper ( ResourceBundlePostProcessor customProcessor , String key , boolean isVariantPostProcessor ) { return new CustomPostProcessorChainWrapper ( key , customProcessor , isVariantPostProcessor ) ; }
|
Returns the custom processor wrapper
|
2,462
|
public void setVariants ( Map < String , VariantSet > variantSets ) { if ( variantSets != null ) { this . variants = new TreeMap < > ( variantSets ) ; variantKeys = VariantUtils . getAllVariantKeys ( this . variants ) ; } }
|
Set the list of variants for variant resources
|
2,463
|
private List < BundlePath > getItemPathList ( List < BundlePath > itemList , Map < String , String > variants ) { if ( variants == null || variants . isEmpty ( ) ) { return itemList ; } List < BundlePath > rets = new ArrayList < > ( ) ; for ( BundlePath bundlePath : itemList ) { String path = bundlePath . getPath ( ) ; if ( generatorRegistry . isPathGenerated ( path ) ) { Set < String > variantTypes = generatorRegistry . getGeneratedResourceVariantTypes ( path ) ; String variantKey = VariantUtils . getVariantKey ( variants , variantTypes ) ; if ( StringUtils . isNotEmpty ( variantKey ) ) { rets . add ( new BundlePath ( bundlePath . getBundlePrefix ( ) , VariantUtils . getVariantBundleName ( path , variantKey , true ) ) ) ; } else { rets . add ( bundlePath ) ; } } else { rets . add ( bundlePath ) ; } } return rets ; }
|
Filters the bundlePath list given in parameter using the specified variants
|
2,464
|
private String getAvailableVariant ( Map < String , String > curVariants ) { String variantKey = null ; if ( variants != null ) { Map < String , String > availableVariants = generatorRegistry . getAvailableVariantMap ( variants , curVariants ) ; variantKey = VariantUtils . getVariantKey ( availableVariants ) ; } return variantKey ; }
|
Resolves a registered path from a variant key .
|
2,465
|
private void generateProperties ( JsonNode node , String parentPrefix , Properties props ) { Iterator < Entry < String , JsonNode > > fields = node . fields ( ) ; while ( fields . hasNext ( ) ) { Entry < String , JsonNode > entry = fields . next ( ) ; String fieldName = entry . getKey ( ) ; JsonNode jsonNode = entry . getValue ( ) ; String nodePrefix = parentPrefix == null ? fieldName : parentPrefix + FIELD_NAME_SEPARATOR + fieldName ; if ( jsonNode . isTextual ( ) || jsonNode . isBoolean ( ) ) { props . put ( nodePrefix , jsonNode . asText ( ) ) ; } else if ( jsonNode . isNumber ( ) ) { props . put ( nodePrefix , Integer . toString ( jsonNode . asInt ( ) ) ) ; } else if ( jsonNode . isArray ( ) ) { String arrayValue = convertToString ( jsonNode ) ; props . put ( nodePrefix , arrayValue ) ; } generateProperties ( jsonNode , nodePrefix , props ) ; } }
|
Generates the properties from a JSON node
|
2,466
|
private String convertToString ( JsonNode jsonArrayNode ) { StringBuilder strBuilder = new StringBuilder ( ) ; Iterator < JsonNode > nodeIterator = jsonArrayNode . iterator ( ) ; while ( nodeIterator . hasNext ( ) ) { JsonNode jsonNode = ( JsonNode ) nodeIterator . next ( ) ; strBuilder . append ( jsonNode . asText ( ) ) ; if ( nodeIterator . hasNext ( ) ) { strBuilder . append ( ARRAY_VALUE_SEPARATOR ) ; } } return strBuilder . toString ( ) ; }
|
Converts the json array node to a String
|
2,467
|
public void setRequestPath ( String mapping , String path ) { this . requestPath = path ; int paramStartIdx = requestPath . indexOf ( "?" ) ; if ( StringUtils . isEmpty ( mapping ) ) { if ( paramStartIdx != - 1 ) { this . servletPath = requestPath . substring ( 0 , paramStartIdx ) ; } else { this . servletPath = requestPath ; } } else { this . servletPath = PathNormalizer . asPath ( mapping ) ; String pathInfo = removeServletMappingFromPath ( path , mapping ) ; this . pathInfo = pathInfo ; } if ( paramStartIdx == - 1 ) { this . requestURI = requestPath ; } else { this . requestURI = requestPath . substring ( 0 , paramStartIdx ) ; } initParameters ( ) ; }
|
Sets the requested path
|
2,468
|
private void initParameters ( ) { int idx = requestPath . indexOf ( "?" ) ; if ( idx != - 1 ) { String strParams = null ; try { strParams = URLDecoder . decode ( requestPath . substring ( idx + 1 ) , "UTF-8" ) ; } catch ( UnsupportedEncodingException neverHappens ) { throw new RuntimeException ( "Something went unexpectedly wrong while decoding a URL for a generator. " , neverHappens ) ; } String [ ] params = strParams . split ( "&" ) ; for ( int i = 0 ; i < params . length ; i ++ ) { String [ ] param = params [ i ] . split ( "=" ) ; parameters . put ( param [ 0 ] , param [ 1 ] ) ; } } else { parameters . clear ( ) ; } }
|
Initialize the parameters from the request path This is a naive implementation which serves only the purpose of bundle generation . It don t even handle multiple parameters value ...
|
2,469
|
private boolean getBooleanValue ( String strVal , boolean defaultValue ) { boolean result = defaultValue ; if ( strVal != null ) { result = Boolean . parseBoolean ( strVal ) ; } return result ; }
|
Returns the boolean value of the string passed in parameter or the default value if the string is null
|
2,470
|
public void setPathMappings ( List < String > pathMappings ) { this . pathMappings . clear ( ) ; if ( pathMappings != null ) { for ( String mapping : pathMappings ) { this . pathMappings . add ( new PathMapping ( bundle , mapping ) ) ; } } }
|
Sets the path mapping
|
2,471
|
protected boolean analyzeAutolinkCondition ( final ComponentTag tag ) { if ( tag . getId ( ) == null ) { if ( checkRef ( tag ) ) { return true ; } } return false ; }
|
Analyze the tag . If return value == true a jawr component will be created .
|
2,472
|
private final boolean checkRef ( ComponentTag tag ) { boolean ok = false ; if ( ! tag . getName ( ) . equals ( "a" ) ) { IValueMap attributes = tag . getAttributes ( ) ; String ref = attributes . getString ( "href" ) ; if ( ref == null ) { ref = attributes . getString ( "src" ) ; } if ( ( ref != null ) && ( isJawrImageTag ( tag ) || ( ref . indexOf ( ":" ) == - 1 ) ) ) { ok = true ; } } return ok ; }
|
Checks if if tag ref is a correct one or not
|
2,473
|
private boolean isJawrImageTag ( ComponentTag tag ) { String tagName = tag . getName ( ) ; return ( tagName . equalsIgnoreCase ( "img" ) || ( tagName . equalsIgnoreCase ( "input" ) && tag . getAttribute ( "type" ) . equals ( "image" ) ) ) ; }
|
Checks if it s a Jawr image tag or not
|
2,474
|
protected void loadConfig ( Properties props , String path , InputStream is ) { try { props . load ( is ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Unable to load jawr configuration at " + path + "." , e ) ; } }
|
Loads the configuration from the stream
|
2,475
|
public BundleHashcodeType getBundleHashcodeType ( String requestedPath ) { if ( binaryResourcePathMap . containsValue ( requestedPath ) ) { return BundleHashcodeType . VALID_HASHCODE ; } BundleHashcodeType bundleHashcodeType = BundleHashcodeType . UNKNOW_BUNDLE ; String [ ] resourceInfo = PathNormalizer . extractBinaryResourceInfo ( requestedPath ) ; String binaryRequest = resourceInfo [ 0 ] ; if ( resourceInfo [ 1 ] != null ) { try { String cacheBustedPath = CheckSumUtils . getCacheBustedUrl ( binaryRequest , getRsReaderHandler ( ) , jawrConfig ) ; addMapping ( binaryRequest , cacheBustedPath ) ; if ( requestedPath . equals ( cacheBustedPath ) ) { bundleHashcodeType = BundleHashcodeType . VALID_HASHCODE ; } else { bundleHashcodeType = BundleHashcodeType . INVALID_HASHCODE ; } } catch ( IOException | ResourceNotFoundException e ) { } } return bundleHashcodeType ; }
|
Checks the bundle hashcode type of the requested binary resource
|
2,476
|
public static InputStream getResourceAsStream ( String resourcePath , Object source ) throws FileNotFoundException { InputStream is = source . getClass ( ) . getResourceAsStream ( resourcePath ) ; if ( null == is ) { ClassLoader cl = source . getClass ( ) . getClassLoader ( ) ; if ( null != cl ) { is = cl . getResourceAsStream ( resourcePath ) ; } } if ( null == is ) { is = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( resourcePath ) ; } if ( null == is ) { MBeanServer mbs = JmxUtils . getMBeanServer ( ) ; if ( mbs != null ) { ObjectName name = ThreadLocalJawrContext . getJawrConfigMgrObjectName ( ) ; if ( name != null ) { try { ClassLoader cl = mbs . getClassLoaderFor ( name ) ; is = cl . getResourceAsStream ( resourcePath ) ; } catch ( Exception e ) { LOGGER . error ( "Unable to instanciate the Jawr MBean '" + name . getCanonicalName ( ) + "'" , e ) ; } } } } if ( null == is ) { try { URL url = getResourceURL ( resourcePath , source ) ; is = new FileInputStream ( new File ( url . getFile ( ) ) ) ; } catch ( ResourceNotFoundException | IOException e ) { throw new FileNotFoundException ( resourcePath + " could not be found. " ) ; } } return is ; }
|
Attempots to load a resource from the classpath either usinf the caller s class loader or the current thread s context classloader .
|
2,477
|
public static URL getResourceURL ( String resourcePath , Object source ) throws ResourceNotFoundException { URL url = source . getClass ( ) . getResource ( resourcePath ) ; if ( null == url ) { ClassLoader cl = source . getClass ( ) . getClassLoader ( ) ; if ( null != cl ) url = cl . getResource ( resourcePath ) ; } if ( null == url ) { url = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( resourcePath ) ; if ( null == url ) { ClassLoader threadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( source . getClass ( ) . getClassLoader ( ) ) ; if ( Thread . currentThread ( ) . getContextClassLoader ( ) != null ) { url = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( resourcePath ) ; } } finally { Thread . currentThread ( ) . setContextClassLoader ( threadClassLoader ) ; } } if ( null == url ) { throw new ResourceNotFoundException ( resourcePath + " could not be found. " ) ; } } return url ; }
|
Attempts to find the URL of a resource from the classpath either usinf the caller s class loader or the current thread s context classloader .
|
2,478
|
public static Enumeration < URL > getResources ( String resourcePath , Object source ) { Enumeration < URL > urls = null ; ClassLoader cl = source . getClass ( ) . getClassLoader ( ) ; try { if ( null != cl ) { urls = cl . getResources ( resourcePath ) ; } if ( null == urls ) { urls = Thread . currentThread ( ) . getContextClassLoader ( ) . getResources ( resourcePath ) ; } if ( null == urls ) { ClassLoader threadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( source . getClass ( ) . getClassLoader ( ) ) ; if ( Thread . currentThread ( ) . getContextClassLoader ( ) != null ) { urls = Thread . currentThread ( ) . getContextClassLoader ( ) . getResources ( resourcePath ) ; } } finally { Thread . currentThread ( ) . setContextClassLoader ( threadClassLoader ) ; } } } catch ( IOException e ) { LOGGER . warn ( "Unable to load " + resourcePath , e ) ; } return urls ; }
|
Attempts to find the URLs of a resource from the classpath either using the caller s class loader or the current thread s context classloader .
|
2,479
|
public static Object buildObjectInstance ( Class < ? > clazz ) { Object rets = null ; try { rets = clazz . newInstance ( ) ; } catch ( Exception e ) { throw new BundlingProcessException ( e . getMessage ( ) + " [The custom class " + clazz . getName ( ) + " could not be instantiated, check whether it is available on the classpath and" + " verify that it has a zero-arg constructor].\n" + " The specific error message is: " + e . getClass ( ) . getName ( ) + ":" + e . getMessage ( ) , e ) ; } return rets ; }
|
Builds a class instance using reflection by using its class . The class must have a zero - arg constructor .
|
2,480
|
public static boolean isClassPresent ( String classname ) { try { Class . forName ( classname ) ; return true ; } catch ( ClassNotFoundException e ) { } return false ; }
|
Checks whether the class is present .
|
2,481
|
public void reset ( ) { this . jawrConfigMgrObjectName = null ; this . debugOverriden = false ; this . bundleProcessingAtBuildTime = false ; this . requestURL = null ; this . stopWatch = null ; this . interruptProcessingBundle . set ( false ) ; }
|
Reset the context .
|
2,482
|
private String getCssPathContent ( String cssPathToImport , String media , BundleProcessingStatus status ) throws IOException { String currentCssPath = status . getLastPathAdded ( ) ; String path = cssPathToImport ; JawrConfig jawrConfig = status . getJawrConfig ( ) ; if ( jawrConfig . getGeneratorRegistry ( ) . isPathGenerated ( path ) ) { ResourceGenerator generator = jawrConfig . getGeneratorRegistry ( ) . getResourceGenerator ( path ) ; if ( generator != null && generator . getResolver ( ) instanceof SuffixedPathResolver ) { path = PathNormalizer . concatWebPath ( currentCssPath , cssPathToImport ) ; } } else if ( ! cssPathToImport . startsWith ( "/" ) ) { path = PathNormalizer . concatWebPath ( currentCssPath , cssPathToImport ) ; } FilePathMappingUtils . buildFilePathMapping ( status . getCurrentBundle ( ) , path , status . getRsReader ( ) ) ; Reader reader = null ; try { reader = status . getRsReader ( ) . getResource ( status . getCurrentBundle ( ) , path , true ) ; } catch ( ResourceNotFoundException e ) { throw new IOException ( "Css to import '" + path + "' was not found" , e ) ; } StringWriter content = new StringWriter ( ) ; IOUtils . copy ( reader , content , true ) ; BinaryResourcesHandler binaryRsHandler = ( BinaryResourcesHandler ) jawrConfig . getContext ( ) . getAttribute ( JawrConstant . BINARY_CONTEXT_ATTRIBUTE ) ; if ( binaryRsHandler != null ) { jawrConfig = binaryRsHandler . getConfig ( ) ; } CssImportedUrlRewriter urlRewriter = new CssImportedUrlRewriter ( jawrConfig ) ; StringBuilder result = new StringBuilder ( ) ; boolean isMediaAttributeSet = StringUtils . isNotEmpty ( media ) ; if ( isMediaAttributeSet ) { result . append ( "@media " ) . append ( media ) . append ( " {\n" ) ; } result . append ( urlRewriter . rewriteUrl ( path , currentCssPath , content . getBuffer ( ) . toString ( ) ) ) ; if ( isMediaAttributeSet ) { result . append ( "\n}\n" ) ; } return result . toString ( ) ; }
|
Retrieve the content of the css to import
|
2,483
|
public Reader createScript ( Charset charset ) { String [ ] names = configParam . split ( "\\|" ) ; Properties props = new Properties ( ) ; Locale currentLocale = getLocaleToApply ( ) ; for ( int x = 0 ; x < names . length ; x ++ ) { ResourceBundle bundle ; try { bundle = ResourceBundle . getBundle ( names [ x ] , currentLocale , control ) ; } catch ( MissingResourceException ex ) { try { bundle = ResourceBundle . getBundle ( names [ x ] , currentLocale , getClass ( ) . getClassLoader ( ) , control ) ; } catch ( Exception e ) { bundle = ResourceBundle . getBundle ( names [ x ] , currentLocale , Thread . currentThread ( ) . getContextClassLoader ( ) , control ) ; } } updateProperties ( bundle , props , charset ) ; } return doCreateScript ( props ) ; }
|
Create the message resource bundles specified and uses a BundleStringJsonifier to generate the properties .
|
2,484
|
protected Locale getLocaleToApply ( ) { Locale currentLocale = locale ; if ( currentLocale == null ) { currentLocale = control . getFallbackLocale ( ) ; } return currentLocale ; }
|
Returns the locale to use to retrieve the ResourceBundle
|
2,485
|
protected Reader doCreateScript ( Properties props ) { BundleStringJsonifier bsj = new BundleStringJsonifier ( props , addQuoteToMessageKey ) ; String script = template . toString ( ) ; String messages = bsj . serializeBundles ( ) . toString ( ) ; script = script . replaceFirst ( "@namespace" , RegexUtil . adaptReplacementToMatcher ( namespace ) ) ; script = script . replaceFirst ( "@messages" , RegexUtil . adaptReplacementToMatcher ( messages ) ) ; return new StringReader ( script ) ; }
|
Returns the JS script from the message properties
|
2,486
|
protected void addLinkedResources ( String path , GeneratorContext context ) { List < Locale > locales = new ArrayList < > ( ) ; Locale currentLocale = context . getLocale ( ) ; if ( currentLocale != null ) { locales . add ( currentLocale ) ; if ( StringUtils . isNotEmpty ( currentLocale . getVariant ( ) ) ) { locales . add ( new Locale ( currentLocale . getCountry ( ) , currentLocale . getLanguage ( ) ) ) ; } if ( StringUtils . isNotEmpty ( currentLocale . getLanguage ( ) ) ) { locales . add ( new Locale ( currentLocale . getCountry ( ) ) ) ; } } locales . add ( control . getFallbackLocale ( ) ) ; Locale baseLocale = new Locale ( "" , "" ) ; if ( ! locales . contains ( baseLocale ) ) { locales . add ( baseLocale ) ; } List < FilePathMapping > fMappings = getFileMappings ( path , context , locales ) ; addLinkedResources ( path , context , fMappings ) ; }
|
Adds the linked resources
|
2,487
|
protected List < FilePathMapping > getFileMappings ( String path , GeneratorContext context , List < Locale > locales ) { List < FilePathMapping > fMappings = new ArrayList < > ( ) ; String fileSuffix = PROPERTIES_FILE_SUFFIX ; String [ ] names = path . split ( RESOURCE_BUNDLE_SEPARATOR ) ; for ( String resourcePath : names ) { resourcePath = resourcePath . replace ( '.' , JawrConstant . URL_SEPARATOR_CHAR ) ; for ( Locale locale : locales ) { String resourceBundlePath = control . toBundleName ( resourcePath , locale ) + fileSuffix ; URL rbURL = LocaleUtils . getResourceBundleURL ( resourceBundlePath , context . getServletContext ( ) ) ; if ( rbURL != null ) { File f = FileUtils . urlToFile ( rbURL ) ; String fileName = f . getAbsolutePath ( ) ; if ( StringUtils . isNotEmpty ( fileName ) ) { long lastModified = rsHandler . getLastModified ( fileName ) ; FilePathMapping fMapping = new FilePathMapping ( fileName , lastModified ) ; fMappings . add ( fMapping ) ; } } } } return fMappings ; }
|
Returns the list of file path mapping associate to the resource bundles locales
|
2,488
|
protected List < String > findAvailableLocales ( String resource ) { List < String > availableLocales = cachedAvailableLocalePerResource . get ( resource ) ; if ( availableLocales == null ) { availableLocales = LocaleUtils . getAvailableLocaleSuffixesForBundle ( resource ) ; cachedAvailableLocalePerResource . put ( resource , availableLocales ) ; } return availableLocales ; }
|
Finds the available locales
|
2,489
|
protected String getCssPath ( String resourceName ) { String path = resourceName ; if ( jawrConfig . getGeneratorRegistry ( ) . isPathGenerated ( path ) ) { path = path . replace ( ':' , '/' ) ; path = JawrConstant . SPRITE_GENERATED_CSS_DIR + path ; } return path ; }
|
Returns the Css path from the resource name
|
2,490
|
private ResourceGenerator loadCommonGenerator ( String resourcePath ) { ResourceGenerator generator = null ; for ( Entry < ResourceGeneratorResolver , Class < ? > > entry : commonGenerators . entrySet ( ) ) { ResourceGeneratorResolver resolver = entry . getKey ( ) ; if ( resolver . matchPath ( resourcePath ) ) { generator = ( ResourceGenerator ) ClassLoaderResourceUtils . buildObjectInstance ( entry . getValue ( ) ) ; if ( ! generator . getResolver ( ) . isSameAs ( resolver ) ) { throw new BundlingProcessException ( "The resolver defined for " + generator . getClass ( ) . getName ( ) + " is different from the one expected by Jawr." ) ; } if ( resolver . getType ( ) . equals ( ResolverType . PREFIXED ) ) { loadGeneratorIfNeeded ( resolver . getResourcePath ( resourcePath ) ) ; } } } if ( generator != null ) { initGenerator ( generator ) ; } return generator ; }
|
Lazy loads generators to avoid the need for undesired dependencies .
|
2,491
|
private void initGenerator ( ResourceGenerator generator ) { initializeGeneratorProperties ( generator ) ; updateRegistries ( generator ) ; ResourceReader proxy = ResourceGeneratorReaderProxyFactory . getResourceReaderProxy ( generator , rsHandler , config ) ; rsHandler . addResourceReader ( proxy ) ; }
|
Initialize the generator
|
2,492
|
private void updateRegistries ( ResourceGenerator generator ) { resolverRegistry . add ( new ResourceGeneratorResolverWrapper ( generator , generator . getResolver ( ) ) ) ; GeneratorComparator genComparator = new GeneratorComparator ( ) ; Collections . sort ( resolverRegistry ) ; if ( generator instanceof StreamResourceGenerator ) { binaryResourceGeneratorRegistry . add ( generator ) ; Collections . sort ( binaryResourceGeneratorRegistry , genComparator ) ; } if ( generator instanceof CssResourceGenerator ) { if ( ( ( CssResourceGenerator ) generator ) . isHandlingCssImage ( ) ) { cssImageResourceGeneratorRegistry . add ( generator ) ; Collections . sort ( cssImageResourceGeneratorRegistry , genComparator ) ; } } if ( generator instanceof BundlingProcessLifeCycleListener ) { bundlingProcesslifeCycleListeners . add ( ( BundlingProcessLifeCycleListener ) generator ) ; } }
|
Update the registries with the generator given in parameter
|
2,493
|
public void registerGenerator ( String clazz ) { ResourceGenerator generator = ( ResourceGenerator ) ClassLoaderResourceUtils . buildObjectInstance ( clazz ) ; if ( null == generator . getResolver ( ) ) { throw new IllegalStateException ( "The getResolver() method must return something at " + clazz ) ; } ResourceGeneratorResolver resolver = generator . getResolver ( ) ; for ( ResourceGeneratorResolver resourceGeneratorResolver : resolverRegistry ) { if ( resourceGeneratorResolver . isSameAs ( resolver ) ) { String generatorName = generator . getClass ( ) . getName ( ) ; if ( ! clazz . equals ( generatorName ) ) { String errorMsg = "Cannot register the generator of class " + generator . getClass ( ) . getName ( ) + " since the same resolver is being used by " + generatorName + ". Please specify a different resolver in the getResolver() method." ; throw new IllegalStateException ( errorMsg ) ; } } } Set < ResourceGeneratorResolver > commonResolvers = commonGenerators . keySet ( ) ; for ( ResourceGeneratorResolver commonGeneratorResolver : commonResolvers ) { if ( commonGeneratorResolver . isSameAs ( resolver ) ) { String generatorName = generator . getClass ( ) . getName ( ) ; LOGGER . warn ( "The custom generator '" + generatorName + "' override a built-in generator" ) ; } } initGenerator ( generator ) ; }
|
Register a generator mapping it to the specified prefix .
|
2,494
|
private void initializeGeneratorProperties ( ResourceGenerator generator ) { if ( generator instanceof InitializingResourceGenerator ) { if ( generator instanceof ConfigurationAwareResourceGenerator ) { ( ( ConfigurationAwareResourceGenerator ) generator ) . setConfig ( config ) ; } if ( generator instanceof TypeAwareResourceGenerator ) { ( ( TypeAwareResourceGenerator ) generator ) . setResourceType ( resourceType ) ; } if ( generator instanceof ResourceReaderHandlerAwareResourceGenerator ) { ( ( ResourceReaderHandlerAwareResourceGenerator ) generator ) . setResourceReaderHandler ( rsHandler ) ; } if ( generator instanceof WorkingDirectoryLocationAware ) { ( ( WorkingDirectoryLocationAware ) generator ) . setWorkingDirectory ( rsHandler . getWorkingDirectory ( ) ) ; } if ( generator instanceof PostInitializationAwareResourceGenerator ) { ( ( PostInitializationAwareResourceGenerator ) generator ) . afterPropertiesSet ( ) ; } } }
|
Initializes the generator properties .
|
2,495
|
public String getDebugModeGenerationPath ( String path ) { ResourceGenerator resourceGenerator = resolveResourceGenerator ( path ) ; return resourceGenerator . getDebugModeRequestPath ( ) ; }
|
Returns the path to use in the generation URL for debug mode .
|
2,496
|
public String getDebugModeBuildTimeGenerationPath ( String path ) { int idx = path . indexOf ( "?" ) ; String debugModeGeneratorPath = path . substring ( 0 , idx ) ; debugModeGeneratorPath = debugModeGeneratorPath . replaceAll ( "\\." , "/" ) ; int jawrGenerationParamIdx = path . indexOf ( JawrRequestHandler . GENERATION_PARAM ) ; String parameter = path . substring ( jawrGenerationParamIdx + JawrRequestHandler . GENERATION_PARAM . length ( ) + 1 ) ; ResourceGenerator resourceGenerator = resolveResourceGenerator ( parameter ) ; String suffixPath = null ; if ( resourceGenerator instanceof SpecificCDNDebugPathResourceGenerator ) { suffixPath = ( ( SpecificCDNDebugPathResourceGenerator ) resourceGenerator ) . getDebugModeBuildTimeGenerationPath ( parameter ) ; } else { suffixPath = parameter . replaceFirst ( GeneratorRegistry . PREFIX_SEPARATOR , JawrConstant . URL_SEPARATOR ) ; } return debugModeGeneratorPath + "/" + suffixPath ; }
|
Returns the path to use in the build time process to generate the resource path for debug mode .
|
2,497
|
private ResourceGenerator resolveResourceGenerator ( String path ) { ResourceGenerator resourceGenerator = null ; for ( ResourceGeneratorResolverWrapper resolver : resolverRegistry ) { if ( resolver . matchPath ( path ) ) { resourceGenerator = resolver . getResourceGenerator ( ) ; if ( resolver . getType ( ) . equals ( ResolverType . PREFIXED ) ) { loadGeneratorIfNeeded ( resolver . getResourcePath ( path ) ) ; } break ; } } if ( resourceGenerator == null ) { resourceGenerator = loadCommonGenerator ( path ) ; } return resourceGenerator ; }
|
Finds the resource generator which will handle the resource whose the path is given in parameter
|
2,498
|
public Map < String , VariantSet > getAvailableVariants ( String path ) { Map < String , VariantSet > availableVariants = new TreeMap < > ( ) ; ResourceGenerator generator = resolveResourceGenerator ( path ) ; if ( generator != null ) { if ( generator instanceof VariantResourceGenerator ) { Map < String , VariantSet > tempResult = ( ( VariantResourceGenerator ) generator ) . getAvailableVariants ( generator . getResolver ( ) . getResourcePath ( path ) ) ; if ( tempResult != null ) { availableVariants = tempResult ; } } else if ( generator instanceof LocaleAwareResourceGenerator ) { List < String > availableLocales = ( ( LocaleAwareResourceGenerator ) generator ) . getAvailableLocales ( generator . getResolver ( ) . getResourcePath ( path ) ) ; if ( availableLocales != null ) { VariantSet variantSet = new VariantSet ( JawrConstant . LOCALE_VARIANT_TYPE , "" , availableLocales ) ; availableVariants . put ( JawrConstant . LOCALE_VARIANT_TYPE , variantSet ) ; } } } return availableVariants ; }
|
Returns the available variant for a path
|
2,499
|
public Set < String > getGeneratedResourceVariantTypes ( String path ) { Set < String > variantTypes = new HashSet < > ( ) ; ResourceGenerator generator = resolveResourceGenerator ( path ) ; if ( generator != null ) { if ( generator instanceof VariantResourceGenerator ) { Set < String > tempResult = ( ( VariantResourceGenerator ) generator ) . getAvailableVariants ( generator . getResolver ( ) . getResourcePath ( path ) ) . keySet ( ) ; if ( tempResult != null ) { variantTypes = tempResult ; } } else if ( generator instanceof LocaleAwareResourceGenerator ) { variantTypes = new HashSet < > ( ) ; variantTypes . add ( JawrConstant . LOCALE_VARIANT_TYPE ) ; } } return variantTypes ; }
|
Returns the variant types for a generated resource
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.