0 Replies Latest reply on Jul 31, 2017 5:03 AM by Scott Stark

    Shouldn't there be an addAsServiceProvider option to augment an existing service provider?

    Scott Stark Master

      So I was testing a new WFSwarm fraction that needed to add an Undertow io.undertow.servlet.ServletExtension to a JAX-RS war, and ran into the issue illustrated by this little test case:


      * Validate that adding multiple service providers results in the assest containing all providers
      public void testDupServiceProviders() throws IOException {

        WebArchive webArchive = ShrinkWrap

        .create(WebArchive.class, "RolesAllowedTest.war")

        .addAsServiceProvider("io.undertow.servlet.ServletExtension", DummyExtension.class.getName())

        .addAsServiceProvider("io.undertow.servlet.ServletExtension", Dummy2Extension.class.getName());

        Node extNode = webArchive.get("WEB-INF/classes/META-INF/services/io.undertow.servlet.ServletExtension");

        ServiceProviderAsset asset = (ServiceProviderAsset) extNode.getAsset();


        InputStream is = asset.openStream();

         byte[] tmp = new byte[1024];

         int length = is.read(tmp);

        System.out.println(new String(tmp, 0, length));







      I was expecting that that both the DummyExtension and the Dummy2Extension would be included in the io.undertow.servlet.ServletExtension asset, but is appears the second overwrites the first, which explains why by fraction's DeploymentProcessor was not able to add the extension. Before creating a feature request and looking at implementing it, I wanted to verify that it would be acceptable to have a new set of service provider methods called something like addOrCombineAsServiceProvider that add the indicated ServiceProvider asset if it does not exist, and combines additional service providers into the existing asset otherwise.