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


Java Validator类代码示例

本文整理汇总了Java中org.netbeans.api.autoupdate.InstallSupport.Validator的典型用法代码示例。如果您正苦于以下问题:Java Validator类的具体用法?Java Validator怎么用?Java Validator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Validator类属于org.netbeans.api.autoupdate.InstallSupport包,在下文中一共展示了Validator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSelf

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
public void testSelf() throws Exception {
    File f = new File(new File(new File(ud, "config"), "Modules"), "com-example-testmodule-cluster.xml");
    f.delete();

    assertFalse("No Config file before: " + f, f.exists());

    MockServices.setServices(UP.class);
    UpdateUnit update = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest());

    assertNotNull("There is an NBM to update", update);
    OperationContainer<InstallSupport> oc = OperationContainer.createForUpdate();
    oc.add(update, update.getAvailableUpdates().get(0));
    final InstallSupport support = oc.getSupport();
    Validator down = support.doDownload(null, true);
    Installer inst = support.doValidate(down, null);
    Restarter res = support.doInstall(inst, null);
    System.setProperty("netbeans.close.no.exit", "true");
    support.doRestart(res, null);
    UpdaterInternal.update(null, null, null);

    assertFalse("No Config file created in for upgrade: " + f, f.exists());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:UpdateDisabledModuleTest.java

示例2: handleDownload

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
private Validator handleDownload(final InstallSupport support) {
    if (canceled) {
        log.fine("Quit handleDownload() because an previous installation was canceled.");
        return null;
    }
    validator = null;
    boolean finish = false;
    while (! finish) {
        finish = tryPerformDownload(support);
    }
    
    return validator;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:InstallStep.java

示例3: doDownload

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
static Validator doDownload(InstallSupport support) throws OperationException {
    final String displayName = "Downloading new version of WakaTime plugin...";
    ProgressHandle downloadHandle = ProgressHandleFactory.createHandle(
        displayName,
        new Cancellable () {
            @Override
            public boolean cancel () {
                return true;
            }
        }
    );
    return support.doDownload(downloadHandle, true);
}
 
开发者ID:wakatime,项目名称:netbeans-wakatime,代码行数:14,代码来源:UpdateHandler.java

示例4: doVerify

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException {
    final String displayName = "Validating WakaTime plugin...";
    ProgressHandle validateHandle = ProgressHandleFactory.createHandle(
        displayName,
        new Cancellable () {
            @Override
            public boolean cancel () {
                return true;
            }
        }
    );
    Installer installer = support.doValidate(validator, validateHandle);
    return installer;
}
 
开发者ID:wakatime,项目名称:netbeans-wakatime,代码行数:15,代码来源:UpdateHandler.java

示例5: installPlugin

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
public void installPlugin(UpdateElement updateElement) {
    log("");
    log("-----------------------------------------------------------");
    log("|  INSTALLING FOLLOWING PLUGIN :                          |");
    log("-----------------------------------------------------------");
    log("[" + updateElement.getDisplayName() + "]" + updateElement.getCodeName());


    int numberOfPluginsToInstall = 0;

    OperationContainer<InstallSupport> install = OperationContainer.createForInstall();

    OperationInfo info = null;
    try {
        info = install.add(updateElement);
    } catch (IllegalArgumentException illegalArgumentException) {
        fail("Cannot install plugin [" + updateElement.getDisplayName() + "] " + updateElement.getCodeName() + " - probably it has already been installed by some other test. Check .log files of previously executed tests.");
        illegalArgumentException.printStackTrace();
    }

    log("Broken dependencies:");
    log(info.getBrokenDependencies().toString());
    numberOfPluginsToInstall++;
    for (OperationInfo i : install.listAll()) {
        Set<UpdateElement> reqElements = i.getRequiredElements();
        log("List of required plugins is:");
        for (UpdateElement reqElm : reqElements) {
            if (!currentlyUpdatePlugins.contains(reqElm) &&
                    !currentlyInstalledPlugins.contains(reqElm) &&
                    !currentlyPendingInstalls.contains(reqElm)) {
                install.add(reqElm);
                log("[" + reqElm.getDisplayName() + "]" + reqElm.getCodeName());
                numberOfPluginsToInstall++;
            }
        }
    }
    log("Number Of Plugins to install:" + numberOfPluginsToInstall);
    List<OperationInfo<InstallSupport>> lst = install.listAll();
    assertTrue("List of invalid is not empty.", install.listInvalid().isEmpty());
    assertTrue("Dependencies broken for plugin '" + updateElement.getDisplayName() + "'." + info.getBrokenDependencies().toString(), info.getBrokenDependencies().size() == 0);
    InstallSupport is = install.getSupport();
    try {
        Validator v = is.doDownload(null, true);
        assertNotNull("Validator for " + updateElement + " is not null.", v);
        Installer installer;
        try {
            installer = is.doValidate(v, null);
            Restarter r = is.doInstall(installer, null);
            if (r == null) {
            } else {
                is.doRestartLater(r);

            }
        } catch (OperationException oex) {
            fail("Unsuccessful operation!");
            oex.printStackTrace();
        }
    } catch (Exception e) {
        fail("Cannot download required plugin or some dependency - probably it doesn't exist");
        e.printStackTrace();
    }
    log("-----------------------------------------------------------");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:64,代码来源:InstallTest.java

示例6: doValidate

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
@SuppressWarnings("ThrowableResultIgnored")
public boolean doValidate (final Validator validator, final ProgressHandle progress/*or null*/) throws OperationException {
    assert validator != null;
    Callable<Boolean> validationCallable = new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            synchronized(LOCK) {
                assert currentStep != STEP.FINISHED;
                if (currentStep == STEP.CANCEL) return false;
                currentStep = STEP.VALIDATION;
            }
            final OperationContainer<InstallSupport> container = support.getContainer();
            assert container.listInvalid ().isEmpty () : support + ".listInvalid().isEmpty() but " + container.listInvalid () + "\ncontainer: " + container;

            // start progress
            if (progress != null) {
                progress.start (wasDownloaded);
            }
            
            int aggregateVerified = 0;
            
            try {
                for (OperationInfo info : infos) {
                    if (cancelled()) return false;
                    UpdateElementImpl toUpdateImpl = Trampoline.API.impl(info.getUpdateElement());
                    boolean hasCustom = toUpdateImpl.getInstallInfo().getCustomInstaller() != null;
                    if (hasCustom) {
                        // XXX: validation of custom installed
                        assert false : "InstallSupportImpl cannot support CustomInstaller!";
                    } else {
                        aggregateVerified += doValidate (info, progress, aggregateVerified);
                    }
                }
            } finally {
                // end progress
                if (progress != null) {
                    progress.progress("");
                    progress.finish();
                }
            }
            return true;
        }
    };
    boolean retval =  false;
    try {
        runningTask = getExecutionService ().submit (validationCallable);
        retval = runningTask.get ();
    } catch (CancellationException ex) {
        LOG.log (Level.FINE, "InstallSupport.doValidate was cancelled", ex); // NOI18N
        return false;
    } catch(InterruptedException iex) {
        if (iex.getCause() instanceof OperationException) {
            throw (OperationException) iex.getCause();
        }
        Exceptions.printStackTrace(iex);
    } catch(ExecutionException iex) {
        if (iex.getCause() instanceof SecurityException) {
            throw new OperationException(OperationException.ERROR_TYPE.MODIFIED, iex.getLocalizedMessage());
        } else {
            if (iex.getCause() instanceof OperationException) {
                throw (OperationException) iex.getCause();
            }
            Exceptions.printStackTrace(iex);
        }
    }
    return retval;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:68,代码来源:InstallSupportImpl.java

示例7: install

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
@NbBundle.Messages({
    "# {0} - module name",
    "# {1} - module version",
    "MSG_Installing=Installing {0}@{1}",
    "# {0} - paterns",
    "MSG_InstallNoMatch=Cannot install. No match for {0}."
})
private void install(final Env env, String... pattern) throws CommandException {
    if (! initialized()) {
        refresh(env);
    }

    Pattern[] pats = findMatcher(env, pattern);

    List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits();
    OperationContainer<InstallSupport> operate = OperationContainer.createForInstall();
    for (UpdateUnit uu : units) {
        if (uu.getInstalled() != null) {
            continue;
        }
        if (!matches(uu.getCodeName(), pats)) {
            continue;
        }
        if (uu.getAvailableUpdates().isEmpty()) {
            continue;
        }
        UpdateElement ue = uu.getAvailableUpdates().get(0);
        env.getOutputStream().println(
                Bundle.MSG_Installing(uu.getCodeName(), ue.getSpecificationVersion()));
        operate.add(ue);
    }
    final InstallSupport support = operate.getSupport();
    if (support == null) {
        env.getOutputStream().println(Bundle.MSG_InstallNoMatch(Arrays.asList(pats)));
        return;
    }
    try {
        env.getOutputStream().println("modules=" + operate.listAll().size()); // NOI18N
        ProgressHandle downloadHandle = new CLIInternalHandle("downloading-modules", env).createProgressHandle(); // NOI18N
        downloadHandle.setInitialDelay(0);
        final Validator res1 = support.doDownload(downloadHandle, null, false);

        Installer res2 = support.doValidate(res1, null);

        ProgressHandle installHandle = new CLIInternalHandle("installing-modules", env).createProgressHandle(); // NOI18N
        installHandle.setInitialDelay(0);
        Restarter res3 = support.doInstall(res2, installHandle);
        if (res3 != null) {
            support.doRestart(res3, null);
        }
    } catch (OperationException ex) {
        // a hack
        if (OperationException.ERROR_TYPE.INSTALL.equals(ex.getErrorType())) {
            // probably timeout of loading
            env.getErrorStream().println(ex.getLocalizedMessage());
            throw (CommandException) new CommandException(34, ex.getMessage()).initCause(ex);
        } else {
            try {
                support.doCancel();
                throw (CommandException) new CommandException(32, ex.getMessage()).initCause(ex);
            } catch (OperationException ex1) {
                throw (CommandException) new CommandException(32, ex1.getMessage()).initCause(ex1);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:ModuleOptions.java

示例8: doDownload

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
static Validator doDownload(InstallSupport support) throws OperationException {
    final String displayName = "Downloading new version of Jeddict plugin...";
    ProgressHandle downloadHandle = ProgressHandleFactory.createHandle(displayName, () -> true);
    return support.doDownload(downloadHandle, true);
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:6,代码来源:UpdateHandler.java

示例9: doVerify

import org.netbeans.api.autoupdate.InstallSupport.Validator; //导入依赖的package包/类
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException {
    final String displayName = "Validating Jeddict plugin...";
    ProgressHandle validateHandle = ProgressHandleFactory.createHandle(displayName, () -> true);
    Installer installer = support.doValidate(validator, validateHandle);
    return installer;
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:7,代码来源:UpdateHandler.java


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