Liquibase 4.3.3 Setting ResourceAccessor With ServiceLocator

Hello,

I am having difficulties migrating from Liquibase 3.6.3 to Liquibase 4.3.3

In my 3.6.3 implementation, I have the following piece of code to override my Resource Accessor.

public class MyCustomResourceAccessor implements ResourceAccessor {

    private final ResourceAccessor inner;

    public MyCustomResourceAccessor(ResourceAccessor... resourceAccessors) {
    	if (resourceAccessors.length == 1) {
    		this.inner = resourceAccessors[0];
    	} else {
    		this.inner = new CompositeResourceAccessor(resourceAccessors);
    	}
    }

	@Override
	public Set<InputStream> getResourcesAsStream(String path) throws IOException {
		return inner.getResourcesAsStream(path);
	}

	@Override
	public Set<String> list(String relativeTo, String path, boolean includeFiles, boolean includeDirectories, boolean recursive) throws IOException {
		return inner.list(relativeTo, path, includeFiles, includeDirectories, recursive);
	}

    @Override
    public ClassLoader toClassLoader() {
        return new RewritingClassLoader(inner.toClassLoader());
    }
}

I then register it using

ServiceLocator.getInstance().setResourceAccessor(new MyCustomResourceAccessor(new ClassLoaderResourceAccessor()));

In Liquibase 4, the API changed and I am having issues figuring out how to properly migrate the above logic. Especially the registration part with the ServiceLocator Instance.

Could someone help me in figuring out this new concept in the latest versions?

Thank you for your time and help!

Hi @zeus23 ,

I believe the developer channel on discord may be helpful. That’s where many of our code contributor community chat. @MikeOlivas / @NathanVoxland would probably be able to help with the API change. It is a little above my head.

1 Like

Hi @zeus23, @nvoxland did change the ResourceAccessor functionality in 4.x. He would be the best person to respond here.

1 Like