private ResourceHandle installResourceInternal(Resource res, Map<Requirement, Resource> mapping) throws ProvisionException {
RepositoryContent content = res.adapt(RepositoryContent.class);
if (content == null) {
return new DefaultResourceHandle(res);
}
final String runtimeName = res.getIdentity().getSymbolicName();
final ServerDeploymentHelper serverDeployer = new ServerDeploymentHelper(serverDeploymentManager);
try {
InputStream input = getWrappedResourceContent(res, mapping);
serverDeployer.deploy(runtimeName, input);
} catch (Throwable th) {
throw new ProvisionException("Cannot provision resource: " + res, th);
}
return new DefaultResourceHandle(res) {
@Override
public void uninstall() throws ProvisionException {
try {
serverDeployer.undeploy(runtimeName);