當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentReference類代碼示例

本文整理匯總了Java中org.jboss.as.repository.ContentReference的典型用法代碼示例。如果您正苦於以下問題:Java ContentReference類的具體用法?Java ContentReference怎麽用?Java ContentReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContentReference類屬於org.jboss.as.repository包,在下文中一共展示了ContentReference類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadContent

import org.jboss.as.repository.ContentReference; //導入依賴的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);
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:27,代碼來源:ManagedDMRContentTypeResource.java

示例2: addFromHash

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
public static byte[] addFromHash(ContentRepository contentRepository, ModelNode contentItemNode, String deploymentName, PathAddress address, OperationContext context) throws OperationFailedException {
    byte[] hash = contentItemNode.require(CONTENT_HASH.getName()).asBytes();
    ContentReference reference = ModelContentReference.fromModelAddress(address, hash);
    if (!contentRepository.syncContent(reference)) {
        if (context.isBooting()) {
            if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
                // The deployment content is missing, which would be a fatal boot error if we were going to actually
                // install services. In ADMIN-ONLY mode we allow it to give the admin a chance to correct the problem
                ServerLogger.ROOT_LOGGER.reportAdminOnlyMissingDeploymentContent(reference.getHexHash(), deploymentName);
            } else {
                throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContentAtBoot(reference.getHexHash(), deploymentName);
            }
        } else {
            throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContent(reference.getHexHash());
        }
    }
    return hash;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:19,代碼來源:DeploymentHandlerUtil.java

示例3: addFromHash

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
byte[] addFromHash(byte[] hash, String deploymentOverlayName, final String contentName, final PathAddress address, final OperationContext context) throws OperationFailedException {
    ContentReference reference = ModelContentReference.fromModelAddress(address, hash);
    if(remoteRepository != null) {
        remoteRepository.getDeploymentFiles(reference);
    }
    if (!contentRepository.syncContent(reference)) {
        if (context.isBooting()) {
            if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
                // The deployment content is missing, which would be a fatal boot error if we were going to actually
                // install services. In ADMIN-ONLY mode we allow it to give the admin a chance to correct the problem
                ServerLogger.ROOT_LOGGER.reportAdminOnlyMissingDeploymentOverlayContent(HashUtil.bytesToHexString(hash), deploymentOverlayName, contentName);

            } else {
                throw ServerLogger.ROOT_LOGGER.noSuchDeploymentOverlayContentAtBoot(HashUtil.bytesToHexString(hash), deploymentOverlayName, contentName);
            }
        } else {
            throw ServerLogger.ROOT_LOGGER.noSuchDeploymentOverlayContent(HashUtil.bytesToHexString(hash));
        }
    }
    return hash;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:22,代碼來源:DeploymentOverlayContentAdd.java

示例4: handleRequest

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
public void handleRequest(DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context)
        throws IOException {
    HostControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d", context.getOperationId());
    final RemoteFileRequestAndHandler.RootFileReader reader = new RemoteFileRequestAndHandler.RootFileReader() {
        public File readRootFile(byte rootId, String filePath) throws RequestProcessingException {
            byte[] hash = HashUtil.hexStringToByteArray(filePath);
            return deploymentFileRepository.getDeploymentRoot(new ContentReference(filePath, hash));
        }
    };
    ServerToHostRemoteFileRequestAndHandler.INSTANCE.handleRequest(input, reader, resultHandler, context);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:ServerToHostProtocolHandler.java

示例5: handleRequest

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
void handleRequest(String hostId, DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException {
    DomainControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d from %s", context.getOperationId(), hostId);
    final RootFileReader reader = new RootFileReader() {
        public File readRootFile(byte rootId, String filePath) throws RequestProcessingException {
            final HostFileRepository localFileRepository = domainController.getLocalFileRepository();

            switch (rootId) {
                case DomainControllerProtocol.PARAM_ROOT_ID_FILE: {
                    return localFileRepository.getFile(filePath);
                }
                case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: {
                    return localFileRepository.getConfigurationFile(filePath);
                }
                case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: {
                    byte[] hash = HashUtil.hexStringToByteArray(filePath);
                    return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash));
                }
                default: {
                    throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId);
                }
            }
        }
    };

    remoteSupport.handleRequest(input, reader, resultHandler, context);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:28,代碼來源:MasterDomainControllerOperationHandlerImpl.java

示例6: getDeploymentRoot

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
public File getDeploymentRoot(ContentReference reference) {
    File file = localFileRepository.getDeploymentRoot(reference);
    if(! file.exists()) {
        return getFile(reference.getHexHash(), DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT);
    }
    return file;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:9,代碼來源:RemoteDomainConnectionService.java

示例7: pullDownContent

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
Set<String> pullDownContent(final Resource domainRootResource) {
    // Make sure we have all needed deployment and management client content
    for (final String id : relevantDeployments) {
        final Set<ContentReference> hashes = deploymentHashes.remove(id);
        if (hashes != null) {
            requiredContent.addAll(hashes);
        }
    }
    for (final ContentReference reference : requiredContent) {
        parameters.getFileRepository().getDeploymentFiles(reference);
        parameters.getContentRepository().addContentReference(reference);
    }

    if (updateRolloutPlans) {
        final PathElement rolloutPlansElement = PathElement.pathElement(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
        final Resource existing = domainRootResource.removeChild(rolloutPlansElement);
        if (existing != null) {
            final ModelNode hashNode = existing.getModel().get(HASH);
            if (hashNode.isDefined()) {
                removedContent.add(
                        new ContentReference(PathAddress.pathAddress(rolloutPlansElement).toCLIStyleString(), hashNode.asBytes()));
            }
        }
        ManagedDMRContentTypeResource rolloutPlansResource =
                new ManagedDMRContentTypeResource(PathAddress.pathAddress(rolloutPlansElement), ROLLOUT_PLAN,
                        rolloutPlansHash, parameters.getContentRepository());
        domainRootResource.registerChild(rolloutPlansElement, rolloutPlansResource);
    }

    final Set<String> servers = new HashSet<>();
    for (String group : affectedGroups) {
        servers.addAll(serversByGroup.get(group));
    }
    return servers;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:36,代碼來源:SyncServerStateOperationHandler.java

示例8: checkAddedReferences

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
void checkAddedReferences(byte[] bytes, PathAddress... addresses) {
    Assert.assertEquals(addresses.length, addedContentReferences.size());
    Assert.assertEquals(addresses.length, fetchedFiles.size());
    for (PathAddress address : addresses) {
        ContentReference ref = addedContentReferences.get(address.toCLIStyleString());
        Assert.assertNotNull(ref);
        Assert.assertEquals(HashUtil.bytesToHexString(bytes), ref.getHexHash());

        ref = fetchedFiles.get(address.toCLIStyleString());
        Assert.assertNotNull(ref);
        Assert.assertEquals(HashUtil.bytesToHexString(bytes), ref.getHexHash());
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:14,代碼來源:SyncModelServerStateTestCase.java

示例9: checkRemovedReferences

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
void checkRemovedReferences(byte[] bytes, PathAddress...addresses) {
    Assert.assertEquals(addresses.length, removedReferences.size());
    for (PathAddress address : addresses) {
        ContentReference ref = removedReferences.get(address.toCLIStyleString());
        Assert.assertNotNull(ref);
        Assert.assertEquals(HashUtil.bytesToHexString(bytes), ref.getHexHash());
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:9,代碼來源:SyncModelServerStateTestCase.java

示例10: syncContent

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
public boolean syncContent(ContentReference reference) {
    if (!contentRepository.hasContent(reference.getHash())) {
        getDeploymentFiles(reference); // Make sure it's in sync
    }
    return contentRepository.hasContent(reference.getHash());
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:8,代碼來源:RemoteFileRepositoryService.java

示例11: getDeploymentRoot

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
public File getDeploymentRoot(ContentReference reference) {
    final File file = localRepository.getDeploymentRoot(reference);
    if (!file.exists()) {
        return getFile(reference, DomainServerProtocol.PARAM_ROOT_ID_DEPLOYMENT);
    }
    return file;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:9,代碼來源:RemoteFileRepositoryService.java

示例12: getFile

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
private File getFile(final ContentReference reference, final byte repoId) {
    final RemoteFileRepositoryExecutor executor = this.remoteFileRepositoryExecutor;
    if (executor == null) {
        throw ServerLogger.ROOT_LOGGER.couldNotFindHcFileRepositoryConnection();
    }
    File file = remoteFileRepositoryExecutor.getFile(reference.getHexHash(), repoId, localDeploymentFolder);
    addContentReference(reference);
    return file;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:10,代碼來源:RemoteFileRepositoryService.java

示例13: deleteDeployment

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
@Override
public void deleteDeployment(ContentReference reference) {
    if (hasContent(reference.getHash())) {//Don't delete referenced content in the back
        removeContent(reference);
    } else {
        localRepository.deleteDeployment(reference);
        removeContent(reference);
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:10,代碼來源:RemoteFileRepositoryService.java

示例14: testFromDeploymentName_String_String

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
/**
 * Test of fromDeploymentName method, of class ModelContentReference.
 */
@Test
public void testFromDeploymentName_String_String() {
    String name = "wildfly-ejb-in-war.war";
    String hash = "48d7b49e084860769d5ce03dc2223466aa46be3a";
    PathAddress address = PathAddress.pathAddress(PathElement.pathElement("deployment", "wildfly-ejb-in-war.war"));
    ContentReference result = ModelContentReference.fromDeploymentName(name, hash);
    ContentReference expResult = new ContentReference(address.toCLIStyleString(), "48d7b49e084860769d5ce03dc2223466aa46be3a");
    assertThat(result, is(expResult));
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:ModelContentReferenceTest.java

示例15: testFromDeploymentName_String_byteArr

import org.jboss.as.repository.ContentReference; //導入依賴的package包/類
/**
 * Test of fromDeploymentName method, of class ModelContentReference.
 */
@Test
public void testFromDeploymentName_String_byteArr() {
    String name = "wildfly-ejb-in-war.war";
    byte[] hash = HashUtil.hexStringToByteArray("48d7b49e084860769d5ce03dc2223466aa46be3a");
    PathAddress address = PathAddress.pathAddress(PathElement.pathElement("deployment", "wildfly-ejb-in-war.war"));
    ContentReference result = ModelContentReference.fromDeploymentName(name, hash);
    ContentReference expResult = new ContentReference(address.toCLIStyleString(), "48d7b49e084860769d5ce03dc2223466aa46be3a");
    assertThat(result, is(expResult));
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:ModelContentReferenceTest.java


注:本文中的org.jboss.as.repository.ContentReference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。