当前位置: 首页>>代码示例>>Java>>正文


Java IOService.endBatch方法代码示例

本文整理汇总了Java中org.uberfire.io.IOService.endBatch方法的典型用法代码示例。如果您正苦于以下问题:Java IOService.endBatch方法的具体用法?Java IOService.endBatch怎么用?Java IOService.endBatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.uberfire.io.IOService的用法示例。


在下文中一共展示了IOService.endBatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sessionDestroyed

import org.uberfire.io.IOService; //导入方法依赖的package包/类
@Override
public void sessionDestroyed(HttpSessionEvent se) {
    final ConfigIOServiceProducer ioServiceProducer = ConfigIOServiceProducer.getInstance();
    final IOService ioService = ioServiceProducer.configIOService();
    final FileSystem fileSystem = ioServiceProducer.configFileSystem();

    @SuppressWarnings("unchecked")
    final Set<LockInfo> locks = (Set<LockInfo>) se.getSession()
            .getAttribute(VFSLockServiceImpl.LOCK_SESSION_ATTRIBUTE_NAME);

    if (locks != null) {
        try {
            ioService.startBatch(fileSystem);
            for (LockInfo lock : locks) {
                try {
                    final Path lockPath = Paths.convert(PathFactory.newLock(lock.getFile()));
                    // Lock could have change ownership due to a forced lock release
                    if (ioService.readAllString(lockPath).equals(lock.lockedBy())) {
                        ioService.delete(lockPath);
                    }
                } catch (NoSuchFileException e) {
                    // Logging this with a lower level as it can happen when a user triggers 
                    // a forced lock release or when the locked file itself was deleted.
                    logger.debug("Problem when releasing lock on session end (lock no longer exists): " + lock,
                                 e);
                } catch (Throwable t) {
                    logger.warn("Problem when releasing lock on session end: " + lock,
                                t);
                }
            }
        } finally {
            ioService.endBatch();
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:36,代码来源:LockCleanupSessionListener.java

示例2: migrate

import org.uberfire.io.IOService; //导入方法依赖的package包/类
public static void migrate(Path dir, IOService ioService, XStream xs, KieServerTemplateStorage templateStorage) {

        logger.debug("Attempting to find and migrate 6.2 type kie server templates inside directory '{}'...", dir);
        try {
            ioService.startBatch(dir.getFileSystem());
            for (final Path path : ioService.newDirectoryStream(dir, new DirectoryStream.Filter<Path>() {
                @Override
                public boolean accept(Path entry) throws IOException {
                    return entry.toString().endsWith("-info.xml");
                }
            })) {

                logger.debug("Found 6.2 type kie server template file '{}', migrating it...", path);
                try {
                    final KieServerInstance kieServerInstance = (KieServerInstance) xs.fromXML(ioService.readAllString(path));

                    logger.debug("Loaded KieServerInstance {}", kieServerInstance);
                    ServerTemplate serverTemplate = new ServerTemplate();
                    serverTemplate.setId(kieServerInstance.getIdentifier());
                    serverTemplate.setName(kieServerInstance.getName());

                    KieServerSetup serverSetup = kieServerInstance.getKieServerSetup();
                    if (serverSetup != null) {
                        Set<KieContainerResource> containerResources = kieServerInstance.getKieServerSetup().getContainers();
                        logger.debug("Server with id {} has containers {}", kieServerInstance.getIdentifier(), containerResources);
                        if (containerResources != null) {
                            for (KieContainerResource containerRef : containerResources) {

                                ContainerSpec containerSpec = new ContainerSpec(containerRef.getContainerId(),
                                        containerRef.getContainerId(),
                                        serverTemplate,
                                        containerRef.getReleaseId(),
                                        containerRef.getStatus(),
                                        new HashMap<Capability, ContainerConfig>());

                                logger.debug("Migrating container '{}' to container spec '{}'", containerRef, containerSpec);
                                serverTemplate.addContainerSpec(containerSpec);
                            }
                        }

                    }
                    Set<KieServerInstanceInfo> instanceInfos = kieServerInstance.getManagedInstances();
                    if (instanceInfos != null) {
                        logger.debug("Server with id {} has server instances {}", kieServerInstance.getIdentifier(), instanceInfos);
                        for (KieServerInstanceInfo instanceInfo : instanceInfos) {

                            logger.debug("Migrating server instance '{}'", instanceInfo);
                            serverTemplate.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), instanceInfo.getLocation()));

                            serverTemplate.setCapabilities(instanceInfo.getCapabilities());
                        }
                    }
                    logger.debug("About to store migrated server template {}", serverTemplate);
                    // store migrated information
                    templateStorage.store(serverTemplate);
                    logger.info("Server template {} migrated successfully, removing old version...", serverTemplate);
                    // delete old to do not attempt second time migration
                    try {
                        ioService.startBatch(path.getFileSystem());
                        ioService.delete(path);
                    } finally {
                        ioService.endBatch();
                    }
                    logger.debug("Old version of server template '{}' has been removed", kieServerInstance);
                } catch (Exception ex) {
                    logger.error("Error while migrating old version (6.2.) of kie server instance from path {}", path, ex);
                }
            }

        } catch ( final NotDirectoryException ignore ) {
            logger.debug("No directory found, ignoring migration of kie server templates");
        } finally {
            ioService.endBatch();
        }
    }
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:76,代码来源:ServerTemplateMigration.java


注:本文中的org.uberfire.io.IOService.endBatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。