jersey icon indicating copy to clipboard operation
jersey copied to clipboard

ComponentProvider not working when use `register` strategy !!!

Open blling opened this issue 7 years ago • 6 comments

As the docs https://jersey.github.io/documentation/latest/user-guide.html#deployment.classpath-scanning said, i set ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE to true and regist a self defined ComponentProvider named TestComponentProvider as follows:

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;

public class ApplicationConfig extends ResourceConfig {
    
    public ApplicationConfig() {
        // ...
        register(new TestComponentProvider());
        property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
    }
}
import org.glassfish.jersey.internal.inject.InjectionManager;
import org.glassfish.jersey.server.spi.ComponentProvider;

import java.util.Set;

public class TestComponentProvider implements ComponentProvider {
    @Override
    public void initialize(InjectionManager injectionManager) {
        System.out.println("-------------------->TestComponentProvider");
    }

    @Override
    public boolean bind(Class<?> component, Set<Class<?>> providerContracts) {
        return false;
    }

    @Override
    public void done() {

    }
}

but TestComponentProvider did not regist successfully, anyone knows why?

blling avatar Feb 08 '18 07:02 blling

Anothor surprising thing is that even if i set ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE to true, Jersey will also read ComponentProvider from META-INF 😞

blling avatar Feb 08 '18 07:02 blling

Reproduce repository is here: https://github.com/blling/jersey-spring-jetty

blling avatar Feb 08 '18 12:02 blling

cc @jansupol could you take a look?

blling avatar Feb 08 '18 22:02 blling

cc @tomas-langer ?

blling avatar Feb 09 '18 14:02 blling

cc @pavelbucek?

blling avatar Feb 10 '18 11:02 blling

Hi @jansupol , I have the same problem with guice-brige, and since its tagged as Bug I'd assume it's confirmed. As lacking of the doc, could you please hint another way to the InjectionManager for use? Thanks!

zhaob avatar Mar 15 '18 08:03 zhaob