// Get the resource as module (may be null)
Runtime runtime = RuntimeLocator.getRequiredRuntime();
Module module = runtime.getModule(identity);
Resource modres = module != null ? module.adapt(Resource.class) : resource;
return new AbstractResourceHandle(modres, module) {
@Override
public void uninstall() {
UndeployTask task = new UndeployTask();
task.setUsername(user.getName());
task.setPassword(password);