本文整理汇总了Java中org.jboss.vfs.VirtualFile类的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile类的具体用法?Java VirtualFile怎么用?Java VirtualFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualFile类属于org.jboss.vfs包,在下文中一共展示了VirtualFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirectoryEntries
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
/** {@inheritDoc} */
public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) {
final ZipNode zipNode = getZipNode(mountPoint, target);
if (zipNode == null) {
return Collections.emptyList();
}
final Map<String, ZipNode> children = zipNode.children;
if (children == null) {
return Collections.emptyList();
}
final Collection<ZipNode> values = children.values();
final List<String> names = new ArrayList<String>(values.size());
for (ZipNode node : values) {
names.add(node.name);
}
return names;
}
示例2: buildFunctionModelFile
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
public void buildFunctionModelFile(String name, String path) throws IOException, XMLStreamException {
for (String f:files.keySet()) {
if (f.endsWith(path)) {
path = f;
break;
}
}
VirtualFile file =this.files.get(path);
if (file == null) {
throw new IOException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40075, name));
}
List<FunctionMethod> udfMethods = FunctionMetadataReader.loadFunctionMethods(file.openStream());
ValidatorReport report = new ValidatorReport("UDF load"); //$NON-NLS-1$
FunctionMetadataValidator.validateFunctionMethods(udfMethods,report);
if(report.hasItems()) {
throw new IOException(QueryPlugin.Util.getString("ERR.015.001.0005", report)); //$NON-NLS-1$
}
this.methods.put(name, new UDFSource(udfMethods));
}
示例3: deploy
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT) != null) {
return;
}
final String deploymentName = deploymentUnit.getName();
final VirtualFile deploymentContents = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS);
// internal deployments do not have any contents, so there is nothing to mount
if (deploymentContents == null)
return;
if (deploymentName.endsWith(DYNAMIC_VDB_STRUCTURE)) {
// use the contents directly
// nothing was mounted
final ResourceRoot resourceRoot = new ResourceRoot(deploymentContents, null);
ModuleRootMarker.mark(resourceRoot);
deploymentUnit.putAttachment(Attachments.DEPLOYMENT_ROOT, resourceRoot);
deploymentUnit.putAttachment(Attachments.MODULE_SPECIFICATION, new ModuleSpecification());
}
}
示例4: deploy
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (TeiidAttachments.isTranslator(deploymentUnit)) {
return;
}
List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
for (ResourceRoot resourceRoot : resourceRoots) {
final VirtualFile deploymentRoot = resourceRoot.getRoot();
if (deploymentRoot.getChild("META-INF/services/org.teiid.translator.ExecutionFactory").exists()) { //$NON-NLS-1$
TeiidAttachments.setAsTranslatorDeployment(deploymentUnit);
//deploymentUnit.putAttachment(Attachments.IGNORE_OSGI, Boolean.TRUE);
break;
}
}
}
示例5: findConfigFile
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
/**
* Finds the configuration file to be used and returns the first one found.
* <p/>
* Preference is for {@literal logging.properties} or {@literal jboss-logging.properties}.
*
* @param file the file to check
*
* @return the configuration file if found, otherwise {@code null}
*
* @throws DeploymentUnitProcessingException if an error occurs.
*/
private VirtualFile findConfigFile(final VirtualFile file) throws DeploymentUnitProcessingException {
VirtualFile result = null;
try {
final List<VirtualFile> configFiles = file.getChildren(ConfigFilter.INSTANCE);
for (final VirtualFile configFile : configFiles) {
final String fileName = configFile.getName();
if (DEFAULT_PROPERTIES.equals(fileName) || JBOSS_PROPERTIES.equals(fileName)) {
if (result != null) {
LoggingLogger.ROOT_LOGGER.debugf("The previously found configuration file '%s' is being ignored in favour of '%s'", result, configFile);
}
return configFile;
} else if (LOG4J_PROPERTIES.equals(fileName) || LOG4J_XML.equals(fileName) || JBOSS_LOG4J_XML.equals(fileName)) {
result = configFile;
}
}
} catch (IOException e) {
throw LoggingLogger.ROOT_LOGGER.errorProcessingLoggingConfiguration(e);
}
return result;
}
示例6: loadContent
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private void loadContent(byte[] initialHash) {
VirtualFile vf = contentRepository.getContent(initialHash);
if (vf == null) {
throw ManagedDMRContentLogger.ROOT_LOGGER.noContentFoundWithHash(HashUtil.bytesToHexString(initialHash));
}
InputStream is = null;
try {
is = vf.openStream();
ModelNode node = ModelNode.fromStream(is);
if (node.isDefined()) {
for (Property prop : node.asPropertyList()) {
ModelNode value = prop.getValue();
byte[] hash = hashContent(value);
synchronized (content) {
content.put(prop.getName(), new ManagedContent(value, hash));
}
}
}
this.model.get(ModelDescriptionConstants.HASH).set(initialHash);
contentRepository.addContentReference(new ContentReference(address.toCLIStyleString(), initialHash));
} catch (IOException e) {
throw new ContentStorageException(e);
} finally {
safeClose(is);
}
}
示例7: isExplodedSubUnitOverlay
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private boolean isExplodedSubUnitOverlay(DeploymentUnit deploymentUnit, VirtualFile mountPoint, String path) {
final List<ResourceRoot> childRes = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
if (childRes != null) {
for (ResourceRoot rs: childRes) {
if (path.startsWith(rs.getRoot().getName())) {
String relativePath = mountPoint.getPathNameRelativeTo(rs.getRoot());
if (relativePath != null
&& relativePath.length() > 0
&& SubExplodedDeploymentMarker.isSubExplodedResourceRoot(rs)) {
return true;
}
}
}
}
return false;
}
示例8: getResource
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
/** {@inheritDoc} */
public Resource getResource(final String name) {
return doPrivileged(new PrivilegedAction<Resource>() {
public Resource run() {
try {
final VirtualFile file = root.getChild(PathUtils.canonicalize(name));
if (!file.exists()) {
return null;
}
return new VFSEntryResource(file.getPathNameRelativeTo(root), file, file.toURL());
} catch (MalformedURLException e) {
// must be invalid...? (todo: check this out)
return null;
}
}
});
}
示例9: handlingExistingClassPathEntry
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private void handlingExistingClassPathEntry(final ArrayDeque<RootEntry> resourceRoots, final DeploymentUnit topLevelDeployment, final VirtualFile topLevelRoot, final Map<VirtualFile, ResourceRoot> subDeployments, final Map<VirtualFile, AdditionalModuleSpecification> additionalModules, final Set<VirtualFile> existingAccessibleRoots, final ResourceRoot resourceRoot, final Attachable target, final VirtualFile classPathFile) throws DeploymentUnitProcessingException {
if (existingAccessibleRoots.contains(classPathFile)) {
ServerLogger.DEPLOYMENT_LOGGER.debugf("Class-Path entry %s in %s ignored, as target is already accessible", classPathFile, resourceRoot.getRoot());
} else if (additionalModules.containsKey(classPathFile)) {
final AdditionalModuleSpecification moduleSpecification = additionalModules.get(classPathFile);
//as class path entries are exported, transitive dependencies will also be available
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleSpecification.getModuleIdentifier());
} else if (subDeployments.containsKey(classPathFile)) {
//now we need to calculate the sub deployment module identifier
//unfortunately the sub deployment has not been setup yet, so we cannot just
//get it from the sub deployment directly
final ResourceRoot otherRoot = subDeployments.get(classPathFile);
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, ModuleIdentifierProcessor.createModuleIdentifier(otherRoot.getRootName(), otherRoot, topLevelDeployment, topLevelRoot, false));
} else {
ModuleIdentifier identifier = createAdditionalModule(resourceRoot, topLevelDeployment, topLevelRoot, additionalModules, classPathFile, resourceRoots);
target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, identifier);
}
}
示例10: createResourceRoot
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
/**
* Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s
* in the {@link DeploymentUnit deploymentUnit}
*
*
* @param file The file for which the resource root will be created
* @return Returns the created {@link ResourceRoot}
* @throws java.io.IOException
*/
private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
try {
Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
String relativeName = file.getPathNameRelativeTo(deploymentRoot);
MountedDeploymentOverlay overlay = overlays.get(relativeName);
Closeable closable = null;
if(overlay != null) {
overlay.remountAsZip(false);
} else if(file.isFile()) {
closable = VFS.mountZip(file, file, TempFileProviderService.provider());
}
final MountHandle mountHandle = new MountHandle(closable);
final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle);
ModuleRootMarker.mark(resourceRoot);
ResourceRootIndexer.indexResourceRoot(resourceRoot);
return resourceRoot;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例11: deploy
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot root : resourceRoots) {
VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
if (child.exists()) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
break;
}
}
}
}
示例12: addResourceRoot
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories)
throws DeploymentUnitProcessingException {
try {
final VirtualFile root = resource.getRoot();
if (resource.getExportFilters().isEmpty()) {
specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
.getRootName(), root, resource.isUsePhysicalCodeSource())));
} else {
final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true);
for (final FilterSpecification filter : resource.getExportFilters()) {
filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude());
}
specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
.getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create()));
}
// start with the root
permFactories.add(new ImmediatePermissionFactory(
new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ)));
// also include all children, recursively
permFactories.add(new ImmediatePermissionFactory(
new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ)));
} catch (IOException e) {
throw ServerLogger.ROOT_LOGGER.failedToCreateVFSResourceLoader(resource.getRootName(), e);
}
}
示例13: parse
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private void parse(final VirtualFile file,final XMLMapper mapper, final JBossAllXmlParseContext context) throws DeploymentUnitProcessingException {
final FileInputStream fis;
final File realFile;
try {
realFile = file.getPhysicalFile();
fis = new FileInputStream(realFile);
} catch (IOException e) {
//should never happen as we check for existence
throw new DeploymentUnitProcessingException(e);
}
try {
parse(fis, realFile, mapper, context);
} finally {
safeClose(fis);
}
}
示例14: readFile
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
public static String readFile(VirtualFile file) throws IOException {
BufferedInputStream stream = null;
try {
stream = new BufferedInputStream(file.openStream());
byte[] buff = new byte[1024];
StringBuilder builder = new StringBuilder();
int read = -1;
while ((read = stream.read(buff)) != -1) {
builder.append(new String(buff, 0, read, StandardCharsets.UTF_8));
}
return builder.toString();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
//ignore
}
}
}
}
示例15: processAnnotationIndex
import org.jboss.vfs.VirtualFile; //导入依赖的package包/类
private void processAnnotationIndex(DeploymentUnit deploymentUnit) {
DotName dotName = DotName.createSimple(BootstrapDatabase.class.getName());
CompositeIndex index = deploymentUnit.getAttachment(COMPOSITE_ANNOTATION_INDEX);
if (index == null) {
return;
}
List<AnnotationInstance> indexAnnotations = index.getAnnotations(dotName);
if (indexAnnotations.isEmpty()) {
return;
}
ResourceRoot deploymentRoot = deploymentUnit.getAttachment(DEPLOYMENT_ROOT);
VirtualFile root = deploymentRoot.getRoot();
DbBootstrapLogger.ROOT_LOGGER.tracef("match on %s", root.getPathName());
try {
final Module module = deploymentUnit.getAttachment(MODULE);
processAnnotatedClasses(indexAnnotations, module.getClassLoader());
} catch (Exception e) {
DbBootstrapLogger.ROOT_LOGGER.error("Unable to process the internal jar files", e);
}
}