The default PackageResolver for gwtoolbox has changed?

I spent the last 4 hours to understand why gwtoolbox is not injecting dependencies. It was a painful process; there was not any log, just a NullPointerException since there is nothing to inject in the container.

Anyway the problem occurred after upgrading gwtoolbox to 2.0-SNAPSHOT from 0.7. Finally I figured out that they changed default PackageResolver strategy in the new version. Before I wasn’t specifying any PackageResolver, meaning; I was relying on the default package resolver.

When they changed the default package resolver, my project was unable to discover components at compile time. Since no component was discovered at compile time, the container was empty at runtime and that was why there wasn’t any log.

As can be seen from the following code that the default package resolver is some kind of relaxed version of REGEXP.

public static Pattern resolvePattern(String expression, PackageResolver resolver) {
    switch (resolver) {

        case REGEXP:
            return Pattern.compile(expression);

        case PREFIX:
            String pattern = Pattern.quote(expression);
            return Pattern.compile(pattern + ".*");

        case SUFFIX:
            pattern = Pattern.quote(expression);
            return Pattern.compile(".*" + pattern);

        case DEFAULT:
            StringBuilder builder = new StringBuilder();
            int offset = 0;
            int i;
            while ((i = expression.indexOf('*', offset)) > -1) {
                String part = Pattern.quote(expression.substring(offset, i));
                builder.append(part);
                builder.append(".*");
                offset = i + 1;
            }
            if (offset < expression.length()) {
                builder.append(expression.substring(offset));
            }
            return Pattern.compile(builder.toString());

        default:
            throw new UnsupportedOperationException("Package resolver '" + resolver.name() + " is currently unsupported");
    }
}

Just be aware and do not spend 4 hours like me 🙂

Read More Post

STAY CONNECTED

Most Popular

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know
17 Dec

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know

If you’re heading to Singapore for a few weeks or many months, maybe for work or study or just to

Manifesting Your Dream Career: Finding Your Passion And Purpose
01 Aug

Manifesting Your Dream Career: Finding Your Passion And Purpose

Are you passionate about finding your dream career? Manifesting can help you align your career with your passions and purpose.

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service
27 Feb

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service

Finding a reliable auto service provider is paramount in the bustling world of vehicle maintenance and repair. That's where Carolina

Floratam: The Robust Grass Solution From Council Growers SOD
25 Jan

Floratam: The Robust Grass Solution From Council Growers SOD

Floratam grass, a popular St. Augustine variety, has become a go-to choice for homeowners and landscapers seeking a lush, durable

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair
25 Jan

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair

For vehicle owners, the braking system is among the most critical components for safety and performance. Carolina Mobile Autoservice, a

Safeguarding Your Property: Expert Water Damage Services By MBC Capital
24 Jan

Safeguarding Your Property: Expert Water Damage Services By MBC Capital

Water damage can significantly impact homes and businesses, often leaving a trail of destruction and disruption in its wake. Understanding