changcheng / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

Simplify NamingStrategy & HashStrategy configuration using ConfigurableWroManagerFactory #454

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be helpful to configure NamingStrategy the same way processors are 
configured. 

When ConfigurableWroManagerFactory is used, the NamingStrategy should read a 
property from configuration file, example:
namingStrategy=md5
or
namingStrategy=sha1

where md5 and sha1 are the aliases of available NamingStrategy implementations.
The alias with corresponding implementations should be provided using 
ServiceRegistry pattern.

Original issue reported on code.google.com by alex.obj...@gmail.com on 4 Jun 2012 at 1:12

GoogleCodeExporter commented 9 years ago
Besides namingStrategy, the HashStrategy (former HashBuilder) is configurable 
in a similar fashion:

hashStrategy=SHA-1
Possible values are: CRC32, MD5, SHA-1
Default value is SHA-1.

The possible values for NamingStrategy are: noOp, timestamp, hashEncoder-CRC32
Default value is noOp.

Original comment by alex.obj...@gmail.com on 17 Jun 2012 at 7:01

GoogleCodeExporter commented 9 years ago
Another feature implemented as part of this issue is simplified contribution of 
NamingStrategy using one of the following:
1) Extending ConfigurableProviderSupport
2) Implementing NamingStrategyProvider interface
and declaring these as services in META-INF/services
Example:
1) Using ConfigurableProviderSupport:
   - Create META-INF/services/ro.isdc.wro.util.provider.ConfigurableProvider
   - Add the fully qualified name of the class implementing ConfigurableProvider interface or extending ConfigurableProviderSupport class.
2) Using NamingStrategyProvider interface:
   - Create META-INF/services/ro.isdc.wro.model.resource.support.naming.NamingStrategyProvider
   - Add the fully qualified name of the class implementing NamingStrategyProvider

The similar simplified contribution is available for HashStrategy. The only 
difference is instead implementing NamingStrategyProvider, use 
HashStrategyProvider:
   - Create META-INF/services/ro.isdc.wro.model.resource.support.hash.HashStrategyProvider
   - Add the fully qualified name of the class implementing HashStrategyProvider

Original comment by alex.obj...@gmail.com on 17 Jun 2012 at 7:16

GoogleCodeExporter commented 9 years ago
Issue 559 has been merged into this issue.

Original comment by alex.obj...@gmail.com on 24 Sep 2012 at 8:45

GoogleCodeExporter commented 9 years ago
Does this feature enable run-time naming strategy changes or is it only for 
build-time?  If it can be used at run-time, are there any configuration 
examples to look at?  

I tried adding a DefaultHashEncoderNamingStrategy and then my own custom naming 
strategy, to the run-time configuration of WRO (see code below), but it had no 
effect on the generated bundle names.  Also, in my custom naming strategy 
implementation, the rename() method was never called. 

ConfigurableWroManagerFactory managerFactory = new 
ConfigurableWroManagerFactory();
managerFactory.setNamingStrategy(new DefaultHashEncoderNamingStrategy());

Thanks for any assistance.

Original comment by devdanw...@gmail.com on 5 Jun 2013 at 11:05

GoogleCodeExporter commented 9 years ago
By default, only maven plugin uses namingStrategy. If you need it to work for 
runtime solution, you should use something like 
https://github.com/Orange-OpenSource/wro4j-taglib .

Original comment by alex.obj...@gmail.com on 6 Jun 2013 at 7:45