Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComponentProvider not working when use register strategy !!! #3770

Open
jerseyrobot opened this issue Feb 8, 2018 · 7 comments
Open

ComponentProvider not working when use register strategy !!! #3770

jerseyrobot opened this issue Feb 8, 2018 · 7 comments

Comments

@jerseyrobot
Copy link
Contributor

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?

@jerseyrobot
Copy link
Contributor Author

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

@jerseyrobot
Copy link
Contributor Author

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

@jerseyrobot
Copy link
Contributor Author

@blling Commented
cc @jansupol could you take a look?

@jerseyrobot
Copy link
Contributor Author

@blling Commented
cc @tomas-langer ?

@jerseyrobot
Copy link
Contributor Author

@blling Commented
cc @pavelbucek?

@jerseyrobot
Copy link
Contributor Author

@zhaob Commented
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!

@jerseyrobot
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant