Take a look at the spring component scanner for an implementation of
how to search the class path. Then it is just a series of
ResourceReference.class.isAssignableFrom(clz) queries and applying
your specific logic.

For example we use the following code to scan for specific patterns in
html files (such as style= attributes in html code, which we consider
illegal—use classes and stylesheets instead).

ResourcePatternResolver, PathMatchingResourcePatternResolver are
classes that comes from Spring.

ResourcePatternResolver resourcePatternResolver = new
PathMatchingResourcePatternResolver();
for (String packageName : getPackageNames())
{
    String usePackageName = packageName;
    if (!usePackageName.endsWith("."))
        usePackageName += ".";
    String filePatter =
        ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
            + ClassUtils.convertClassNameToResourcePath(usePackageName)
+ "**/*.html";
    try
    {
        Resource[] resources = resourcePatternResolver.getResources(filePatter);
        for (Resource resource : resources)
        {
            if (resource.isReadable())
            {
                List<String> matches =
getMatches(resource.getInputStream(), pattern);
                String fileName = resource.getURI().getPath();
                if (errorWhenFound)
                {
                    if (!matches.isEmpty())
                        addError(fileName + ": " + matches);
                }
                else
                {
                    if (matches.isEmpty())
                        addError(fileName);
                }
            }
        }
    }
    catch (IOException e)
    {
        addError(e.getMessage());
    }
}
assertNoErrors(message);

Martijn

On Tue, Mar 2, 2010 at 12:56 PM, Sergey Olefir <solf.li...@gmail.com> wrote:
>
>
> Err, I guess I don't quite understand what you're proposing... My
> understanding is that I need to know all class names that are used by
> application as part of ResourceReference (and possibly something else too).
> How would I scan for that?
>
>
> Martijn Dashorst wrote:
>>
>> Create a unit test case that scans your application for resources and
>> checks if the class is set. If not, fail. If set, check if it is
>> unique, if not fail.
>>
>> Martijn
>>
>
> --
> View this message in context: 
> http://old.nabble.com/How-to-encrypt-obfuscate-resource-reference--tp27744679p27754984.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to