private Asset mergeServiceDescriptors(final List<Node> descs) { final List<String> lines = new ArrayList<>(); descs.forEach(n -> { try (BufferedReader in = new BufferedReader(new InputStreamReader(n.getAsset().openStream()))) { String line; while ((line = in.readLine()) != null) { lines.add(line); } } catch (IOException e) { throw new RuntimeException(e); } }); return new ServiceProviderAsset(lines.toArray(new String[lines.size()])); }
private Asset mergeServiceDescriptors(final List<Node> descs) { final List<String> lines = new ArrayList<>(); descs.forEach(n -> { try (BufferedReader in = new BufferedReader(new InputStreamReader(n.getAsset().openStream()))) { String line; while ((line = in.readLine()) != null) { lines.add(line); } } catch (IOException e) { throw new RuntimeException(e); } }); return new ServiceProviderAsset(lines.toArray(new String[lines.size()])); }
@Override public T addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath("services", serviceInterface.getName()); return addAsManifestResource(asset, path); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnNullArgumnet() throws Exception { new ServiceProviderAsset((Class<?>[]) null); }
@Override public T addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath("services", serviceInterface.getName()); return addAsManifestResource(asset, path); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnNullArgumnetValue() throws Exception { new ServiceProviderAsset((Class<?>) null); }
@Override public T addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath(getServiceProvidersPath(), serviceInterface.getName()); return add(asset, path); }
@Override public T addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath(getServiceProvidersPath(), serviceInterface.getName()); return add(asset, path); }
@Override public T addAsServiceProvider(String serviceInterface, String... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath("services", serviceInterface); return addAsManifestResource(asset, path); }
@Override public T addAsServiceProvider(String serviceInterface, String... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath("services", serviceInterface); return addAsManifestResource(asset, path); }
@Override public T addAsServiceProvider(String serviceInterface, String... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath(getServiceProvidersPath(), serviceInterface); return add(asset, path); }
@Override public T addAsServiceProvider(String serviceInterface, String... serviceImpls) throws IllegalArgumentException { Validate.notNull(serviceInterface, "ServiceInterface must be specified"); Validate.notNullAndNoNullValues(serviceImpls, "ServiceImpls must be specified and can not contain null values"); Asset asset = new ServiceProviderAsset(serviceImpls); ArchivePath path = new BasicPath(getServiceProvidersPath(), serviceInterface); return add(asset, path); }
@Test public void shouldCreateServiceProviderFile() throws Exception { Asset asset = new ServiceProviderAsset(TestImpl1.class, TestImpl2.class); byte[] expectedContent = (TestImpl1.class.getName() + "\n" + TestImpl2.class.getName() + "\n").getBytes(); byte[] content = IOUtil.asByteArray(asset.openStream()); Assert.assertArrayEquals(expectedContent, content); }