Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2013-2016 Guoqiang Chen, Shanghai, China. All rights reserved.
*
* Author: Guoqiang Chen
* Email: [email protected]
* WebURL: https://github.com/subchen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jetbrick.io.resource;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import jetbrick.util.ExceptionUtils;
// jboss/wildfly vfs url
public final class JbossVfsResource extends AbstractResource {
private final Object resource;
public JbossVfsResource(URL url) {
this.resource = vfsInvokeMethod(VFS_METHOD_GET_ROOT_URL, null, new Object[] { url });
this.relativePathName = getURL().toString();
}
private JbossVfsResource(Object resource) {
this.resource = resource;
this.relativePathName = getURL().toString();
}
@Override
public InputStream openStream() {
if (resource == null) {
throw new ResourceNotFoundException();
}
InputStream is = (InputStream) vfsInvokeMethod(VIRTUAL_FILE_METHOD_OPEN_STREAM, resource, EMPTY_PARAMETERS);
if (is == null) {
throw new ResourceNotFoundException(getURL().toString());
}
return is;
}
@Override
public File getFile() {
return (File) vfsInvokeMethod(VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE, resource, EMPTY_PARAMETERS);
}
@Override
public URI getURI() {
return (URI) vfsInvokeMethod(VIRTUAL_FILE_METHOD_TO_URI, resource, EMPTY_PARAMETERS);
}
@Override
public URL getURL() {
return (URL) vfsInvokeMethod(VIRTUAL_FILE_METHOD_TO_URL, resource, EMPTY_PARAMETERS);
}
@Override
public boolean isDirectory() {
return (Boolean) vfsInvokeMethod(VIRTUAL_FILE_METHOD_IS_DIRECTORY, resource, EMPTY_PARAMETERS);
}
@Override
public boolean isFile() {
return (Boolean) vfsInvokeMethod(VIRTUAL_FILE_METHOD_IS_FILE, resource, EMPTY_PARAMETERS);
}
@Override
public String getFileName() {
return (String) vfsInvokeMethod(VIRTUAL_FILE_METHOD_GET_NAME, resource, EMPTY_PARAMETERS);
}
@Override
public boolean exist() {
return (Boolean) vfsInvokeMethod(VIRTUAL_FILE_METHOD_EXISTS, resource, EMPTY_PARAMETERS);
}
@Override
public long length() {
return (Long) vfsInvokeMethod(VIRTUAL_FILE_METHOD_GET_SIZE, resource, EMPTY_PARAMETERS);
}
@Override
public long lastModified() {
return (Long) vfsInvokeMethod(VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED, resource, EMPTY_PARAMETERS);
}
public List getChildren() {
@SuppressWarnings("unchecked")
List