Creates a new {@link Res} instance.

@param closeFunction the function for releasing the resource
@param resource the resource instance
@param <R> the resource type
@return
359595
public static <R> Res<R> res(CloseFunction<R> closeFunction, R resource) {
    return new Res<>(closeFunction, resource);
  }
557019
@Override
    protected Smb2CloseResponse createResponse ( CIFSContext tc, ServerMessageBlock2Request<Smb2CloseResponse> req ) {
        return new Smb2CloseResponse(tc.getConfig(), this.fileId, this.fileName);
    }
1255713
public function create($resource, $resouce_id, $data)
    {
        return $this->client->post("$resource/$resouce_id/comments", [$this->wrapper => $data])->response();
    }
605995
public static ServiceAdapter<Closeable> forCloseable() {
		return new SimpleServiceAdapter<Closeable>(false, true) {
			@Override
			protected void start(Closeable instance) {
			}

			@Override
			protected void stop(Closeable instance) throws Exception {
				instance.close();
			}
		};
	}
712947
static Properties loadClose(final InputStream in, final Object source) {
        final Properties props = new Properties();
        if (null != in) {
            try {
                props.load(in);
            } catch (final IOException e) {
                LowLevelLogUtil.logException("Unable to read " + source, e);
            } finally {
                try {
                    in.close();
                } catch (final IOException e) {
                    LowLevelLogUtil.logException("Unable to close " + source, e);
                }
            }
        }
        return props;
    }
932992
public Object newInstance(String resource) {
        try {
            String name = resource.startsWith("/") ? resource : "/" + resource;
            File file = new File(this.getClass().getResource(name).toURI());
            return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
        } catch (Exception e) {
            throw new GroovyClassInstantiationFailed(classLoader, resource, e);
        }
    }
1040420
private static void close(CloseableHttpClient httpClient, CloseableHttpResponse response) {
        try {
            if (response != null) {
                response.close();
            }
            if (httpClient != null) {
                httpClient.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
36698
public static CloseableHttpClient createKeyMaterialHttpClient(KeyStore keystore,String keyPassword,int timeout,int retryExecutionCount) {
		return createKeyMaterialHttpClient(keystore, keyPassword, supportedProtocols,timeout,retryExecutionCount);
	}
1091313
protected static CloseableHttpResponse getResource(String fullURL) throws IOException,
      URISyntaxException {
    URI uri = new URIBuilder(fullURL).build();

    try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
      /* read url */
      HttpGet httpget = new HttpGet(uri);
      LOG.debug("Executing request " + httpget.getRequestLine());
      return httpclient.execute(httpget);

    }

  }
202018
@Override
    protected void releaseResourceImpl(HylaFAXClient resource)
    {
        try
        {
            //release client
            resource.quit();
        }
        catch(Exception exception)
        {
            //log error
            this.LOGGER.logDebug(new Object[]{"Error while closing client."},exception);
        }
    }
1360798
def create(self, resource):
        
        uri = self.URI + self.RESOURCES_PATH
        return self._client.create(resource=resource, uri=uri)
803937
public static ResourceHandle use(Resource resource) {
        return resource instanceof ResourceHandle
                ? ((ResourceHandle) resource) : new ResourceHandle(resource);
    }
1353662
private Metadata createMetadata(String resource) {
    Metadata metadata = new Metadata();
    if (resource != null) {
      metadata.put(GRPC_RESOURCE_PREFIX_KEY, resource);
    }
    return metadata;
  }
43114
public Configuration createFromResource(String resourceName) {
        Exceptions.nullArgument("resourceName", resourceName);

        Configuration configuration;
        try {
            InputStream stream = null;
            try {
                stream = Utils.openResourceStream(resourceName);

                if (stream != null) {
                    configuration = create(stream);
                } else {
                    throw new TextProcessorFactoryException("Can't find or open resource \"" + resourceName + "\".");
                }
            } finally {
                if (stream != null) {
                    stream.close();
                }
            }
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        }

        return configuration;
    }
329854
@Override
    protected void releaseResourceImpl(CommPortAdapter resource)
    {
        try
        {
            resource.close();
        }
        catch(IOException exception)
        {
            throw new FaxException("Unable to close COMM port adapter.",exception);
        }
    }
1195901
private void closeFileObject(String typeName, FileObject fileObject) {
        /*
         * If typeName is non-null, the file object was opened as a
         * source or class file by the user.  If a file was opened as
         * a resource, typeName will be null and the file is *not*
         * subject to annotation processing.
         */
        if ((typeName != null)) {
            if (!(fileObject instanceof JavaFileObject))
                throw new AssertionError("JavaFileOject not found for " + fileObject);
            JavaFileObject javaFileObject = (JavaFileObject)fileObject;
            switch(javaFileObject.getKind()) {
            case SOURCE:
                generatedSourceNames.add(typeName);
                generatedSourceFileObjects.add(javaFileObject);
                openTypeNames.remove(typeName);
                break;

            case CLASS:
                generatedClasses.put(typeName, javaFileObject);
                openTypeNames.remove(typeName);
                break;

            default:
                break;
            }
        }
    }
44793
public static Resource from(String resource) {
      if (StringUtils.isNullOrBlank(resource)) {
         return new StringResource();
      }
      Matcher matcher = protocolPattern.matcher(resource);
      if (matcher.find()) {
         String schema = matcher.group("PROTOCOL");
         String options = matcher.group("OPTIONS");
         String path = matcher.group("PATH");

         if (StringUtils.isNullOrBlank(options)) {
            options = "";
         } else {
            options = options.replaceFirst("\\[", "").replaceFirst("\\]$", "");
         }
         ResourceProvider provider = resourceProviders.get(schema.toLowerCase());


         if (provider == null) {
            try {
               return new URIResource(new URI(resource));
            } catch (URISyntaxException e) {
               throw new IllegalStateException(schema + " is an unknown protocol.");
            }
         }


         if (provider.requiresProtocol()) {
            path = schema + ":" + path;
         }

         return provider.createResource(path, Val.of(options).asMap(String.class, String.class));
      }

      return new FileResource(resource);
   }