Example usage for java.util ServiceLoader load

List of usage examples for java.util ServiceLoader load

Introduction

In this page you can find the example usage for java.util ServiceLoader load.

Prototype

@CallerSensitive
public static <S> ServiceLoader<S> load(Class<S> service) 

Source Link

Document

Creates a new service loader for the given service type, using the current thread's java.lang.Thread#getContextClassLoader context class loader .

Usage

From source file:org.apache.geode.distributed.ServerLauncher.java

private Cache createCache(Properties gemfireProperties) {
    ServiceLoader<ServerLauncherCacheProvider> loader = ServiceLoader.load(ServerLauncherCacheProvider.class);
    for (ServerLauncherCacheProvider provider : loader) {
        Cache cache = provider.createCache(gemfireProperties, this);
        if (cache != null) {
            return cache;
        }/*from   w w w .j  av a 2s. co  m*/
    }

    return DEFAULT_CACHE_PROVIDER.createCache(gemfireProperties, this);
}

From source file:org.apache.geronimo.mavenplugins.car.AbstractCarMojo.java

protected Framework getFramework(String extraPackages) throws BundleException {
    setLoggingLevel();//from   ww w  . java2  s. c  o m

    Map<String, String> properties = new HashMap<String, String>();
    //        properties.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");

    // The following set of packages are the ones that will be exported by the
    // framework bundle from the core system.  We need to explicitly specify
    // these to give explicit versions to many of the javax.* packages so that
    // they'll match any of the versions exported by the Geronimo spec jars.
    // This list and the version numbers needs to be synchronized with the list
    // in the karaf framework config.properties file.
    properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.6.0,"
            + "org.osgi.framework.launch; version=1.0.0," + "org.osgi.framework.startlevel; version=1.0.0,"
            + "org.osgi.framework.wiring; version=1.0.0," + "org.osgi.framework.hooks.service; version=1.1.0,"
            + "org.osgi.framework.hooks.bundle; version=1.0.0,"
            + "org.osgi.framework.hooks.resolver; version=1.0.0,"
            + "org.osgi.framework.hooks.weaving; version=1.0.0,"
            + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.1.0,"
            + "org.osgi.service.url; version=1.0.0," + "org.osgi.util.tracker; version=1.5.0,"
            + "javax.accessibility," + "javax.annotation.processing," + "javax.activity," + "javax.crypto,"
            + "javax.crypto.interfaces," + "javax.crypto.spec," + "javax.imageio," + "javax.imageio.event,"
            + "javax.imageio.metadata," + "javax.imageio.plugins.bmp," + "javax.imageio.plugins.jpeg,"
            + "javax.imageio.spi," + "javax.imageio.stream," + "javax.jws;version=2.0,"
            + "javax.jws.soap;version=2.0," + "javax.lang.model," + "javax.lang.model.element,"
            + "javax.lang.model.type," + "javax.lang.model.util," + "javax.management,"
            + "javax.management.loading," + "javax.management.modelmbean," + "javax.management.monitor,"
            + "javax.management.openmbean," + "javax.management.relation," + "javax.management.remote,"
            + "javax.management.remote.rmi," + "javax.management.timer," + "javax.naming,"
            + "javax.naming.directory," + "javax.naming.event," + "javax.naming.ldap," + "javax.naming.spi,"
            + "javax.net," + "javax.net.ssl," + "javax.print," + "javax.print.attribute,"
            + "javax.print.attribute.standard," + "javax.print.event," + "javax.rmi," + "javax.rmi.CORBA,"
            + "javax.rmi.ssl," + "javax.script," + "javax.security.auth," + "javax.security.auth.callback,"
            + "javax.security.auth.kerberos," + "javax.security.auth.login," + "javax.security.auth.spi,"
            + "javax.security.auth.x500," + "javax.security.cert," + "javax.security.sasl,"
            + "javax.sound.midi," + "javax.sound.midi.spi," + "javax.sound.sampled,"
            + "javax.sound.sampled.spi," + "javax.sql," + "javax.sql.rowset," + "javax.sql.rowset.serial,"
            + "javax.sql.rowset.spi," + "javax.swing," + "javax.swing.border," + "javax.swing.colorchooser,"
            + "javax.swing.event," + "javax.swing.filechooser," + "javax.swing.plaf,"
            + "javax.swing.plaf.basic," + "javax.swing.plaf.metal," + "javax.swing.plaf.multi,"
            + "javax.swing.plaf.synth," + "javax.swing.table," + "javax.swing.text," + "javax.swing.text.html,"
            + "javax.swing.text.html.parser," + "javax.swing.text.rtf," + "javax.swing.tree,"
            + "javax.swing.undo," + "javax.tools,"
            + "javax.transaction;javax.transaction.xa;version=1.1;partial=true;mandatory:=partial,"
            + "javax.xml," + "javax.xml.namespace;version=1.0," + "javax.xml.crypto," + "javax.xml.crypto.dom,"
            + "javax.xml.crypto.dsig," + "javax.xml.crypto.dsig.dom," + "javax.xml.crypto.dsig.keyinfo,"
            + "javax.xml.crypto.dsig.spec," + "javax.xml.datatype," + "javax.xml.parsers,"
            + "javax.xml.transform," + "javax.xml.transform.dom," + "javax.xml.transform.sax,"
            + "javax.xml.transform.stax," + "javax.xml.transform.stream," + "javax.xml.validation,"
            + "javax.xml.xpath," + "org.ietf.jgss," + "org.omg.CORBA," + "org.omg.CORBA_2_3,"
            + "org.omg.CORBA_2_3.portable," + "org.omg.CORBA.DynAnyPackage," + "org.omg.CORBA.ORBPackage,"
            + "org.omg.CORBA.portable," + "org.omg.CORBA.TypeCodePackage," + "org.omg.CosNaming,"
            + "org.omg.CosNaming.NamingContextExtPackage," + "org.omg.CosNaming.NamingContextPackage,"
            + "org.omg.Dynamic," + "org.omg.DynamicAny," + "org.omg.DynamicAny.DynAnyFactoryPackage,"
            + "org.omg.DynamicAny.DynAnyPackage," + "org.omg.IOP," + "org.omg.IOP.CodecFactoryPackage,"
            + "org.omg.IOP.CodecPackage," + "org.omg.Messaging," + "org.omg.PortableInterceptor,"
            + "org.omg.PortableInterceptor.ORBInitInfoPackage," + "org.omg.PortableServer,"
            + "org.omg.PortableServer.CurrentPackage," + "org.omg.PortableServer.POAManagerPackage,"
            + "org.omg.PortableServer.POAPackage," + "org.omg.PortableServer.portable,"
            + "org.omg.PortableServer.ServantLocatorPackage," + "org.omg.SendingContext,"
            + "org.omg.stub.java.rmi," + "org.omg.stub.javax.management.remote.rmi," + "org.w3c.dom,"
            + "org.w3c.dom.bootstrap," + "org.w3c.dom.css," + "org.w3c.dom.events," + "org.w3c.dom.html,"
            + "org.w3c.dom.ls," + "org.w3c.dom.ranges," + "org.w3c.dom.stylesheets," + "org.w3c.dom.traversal,"
            + "org.w3c.dom.views," + "org.w3c.dom.xpath," + "org.xml.sax," + "org.xml.sax.ext,"
            + "org.xml.sax.helpers");

    properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "net.sf.cglib.asm," + "net.sf.cglib.core,"
            + "net.sf.cglib.proxy," + "net.sf.cglib.reflect," + "sun.misc," + "sun.reflect,"
            + "org.apache.commons.jexl;version=\"1.1\"," + "org.apache.commons.jexl.context;version=\"1.1\","
            + "org.apache.commons.jexl.resolver;version=\"1.1\"," + "org.apache.geronimo.main,"
            + "org.apache.geronimo.cli," + "org.apache.geronimo.cli.client," + "org.apache.geronimo.cli.daemon,"
            + "org.apache.geronimo.common," + "org.apache.geronimo.common.propertyeditor,"
            + "org.apache.geronimo.crypto," + "org.apache.geronimo.gbean,"
            + "org.apache.geronimo.gbean.annotation," + "org.apache.geronimo.gbean.runtime," +

            "org.apache.geronimo.kernel," + "org.apache.geronimo.kernel.basic,"
            + "org.apache.geronimo.kernel.classloader," + "org.apache.geronimo.kernel.config,"
            + "org.apache.geronimo.kernel.config.xstream," + "org.apache.geronimo.kernel.lifecycle,"
            + "org.apache.geronimo.kernel.management," + "org.apache.geronimo.kernel.osgi,"
            + "org.apache.geronimo.kernel.proxy," + "org.apache.geronimo.kernel.repository,"
            + "org.apache.geronimo.kernel.rmi," + "org.apache.geronimo.kernel.util," +

            "org.apache.geronimo.system.configuration," + "org.apache.geronimo.system.configuration.cli,"
            + "org.apache.geronimo.system.configuration.condition," + "org.apache.geronimo.system.jmx,"
            + "org.apache.geronimo.system.logging," + "org.apache.geronimo.system.logging.log4j,"
            + "org.apache.geronimo.system.main," + "org.apache.geronimo.system.plugin,"
            + "org.apache.geronimo.system.plugin.model," + "org.apache.geronimo.system.properties,"
            + "org.apache.geronimo.system.repository," + "org.apache.geronimo.system.resolver,"
            + "org.apache.geronimo.system.serverinfo," + "org.apache.geronimo.system.threads,"
            + "org.apache.geronimo.system.util," + "org.apache.geronimo.transformer,"
            + "org.apache.geronimo.mavenplugins.car," + "org.apache.karaf.jaas.boot;version=\"2.2.1\","
            + "org.apache.yoko," + "org.apache.yoko.osgi," + "org.apache.yoko.rmispec.util,"
            + "org.apache.geronimo.hook" + extraPackages

    );
    /*
            
                        "org.apache.log4j;version=\"1.2.12\"," +
                        "org.apache.log4j.helpers;version=\"1.2.12\"," +
                        "org.apache.log4j.spi;version=\"1.2.12\"," +
                        "org.apache.log4j.xml;version=\"1.2.12\"," +
            
                        "org.codehaus.classworlds," +
                        "org.codehaus.classworlds.realm," +
            
                        "org.codehaus.plexus," +
                        "org.codehaus.plexus.archiver," +
                        "org.codehaus.plexus.archiver.jar," +
                        "org.codehaus.plexus.archiver.tar," +
                        "org.codehaus.plexus.archiver.util," +
                        "org.codehaus.plexus.archiver.zip," +
                        "org.codehaus.plexus.component," +
                        "org.codehaus.plexus.component.annotations," +
                        "org.codehaus.plexus.component.composition," +
                        "org.codehaus.plexus.component.configurator," +
                        "org.codehaus.plexus.component.configurator.converters," +
                        "org.codehaus.plexus.component.configurator.expression," +
                        "org.codehaus.plexus.component.discovery," +
                        "org.codehaus.plexus.component.factory," +
                        "org.codehaus.plexus.component.manager," +
                        "org.codehaus.plexus.component.repository," +
                        "org.codehaus.plexus.component.repository.exception," +
                        "org.codehaus.plexus.component.repository.io," +
                        "org.codehaus.plexus.configuration," +
                        "org.codehaus.plexus.configuration.processor," +
                        "org.codehaus.plexus.configuration.xml," +
                        "org.codehaus.plexus.context," +
                        "org.codehaus.plexus.embed," +
                        "org.codehaus.plexus.lifecycle," +
                        "org.codehaus.plexus.lifecycle.phase," +
                        "org.codehaus.plexus.logging," +
                        "org.codehaus.plexus.logging.console," +
                        "org.codehaus.plexus.personality," +
                        "org.codehaus.plexus.personality.plexus," +
                        "org.codehaus.plexus.personality.plexus.lifecycle," +
                        "org.codehaus.plexus.personality.plexus.lifecycle.phase," +
                        "org.codehaus.plexus.util," +
                        "org.codehaus.plexus.util.xml," +
            
                        "org.apache.maven," +
                        "org.apache.maven.plugin," +
                        "org.apache.maven.lifecyle," +
                        "org.apache.maven.shared," +
                        "org.apache.maven.shared.filtering," +
            
                        "com.thoughtworks.xstream," +
                        "com.thoughtworks.xstream.alias," +
                        "com.thoughtworks.xstream.converters," +
                        "com.thoughtworks.xstream.converters.basic," +
                        "com.thoughtworks.xstream.converters.reflection," +
                        "com.thoughtworks.xstream.core," +
                        "com.thoughtworks.xstream.io," +
                        "com.thoughtworks.xstream.io.xml," +
                        "com.thoughtworks.xstream.mapper," +
                        "javax.management," +
                        "javax.rmi.ssl," +
                        "javax.xml.parsers," +
                        "javax.xml.transform," +
                        "net.sf.cglib.asm," +
                        "net.sf.cglib.core," +
                        "net.sf.cglib.proxy," +
                        "net.sf.cglib.reflect," +
                        "org.apache.xbean.recipe;version=\"3.6\"," +
                        "org.objectweb.asm," +
                        "org.objectweb.asm.commons," +
                        "org.osgi.framework;version=\"1.4\"," +
                                "org.slf4j;version=\"1.5.6\"," +
                                "org.slf4j.impl;version=\"1.5.6\"," +
                                "org.slf4j.bridge;version=\"1.5.6\"," +
                        "org.w3c.dom," +
                        "org.xml.sax," +
                        "org.xml.sax.helpers," +
                        "sun.misc," +
                        "org.apache.xmlbeans," +
                        "org.apache.xml.resolver," +
                        "org.apache.commons.cli," +
                        "javax.enterprise.deploy," +
                        "javax.enterprise.deploy.model," +
                        "javax.enterprise.deploy.shared," +
                        "javax.enterprise.deploy.spi");
    */

    properties.put(Constants.FRAMEWORK_BOOTDELEGATION, "sun.*,com.sun.*");

    File storageDir = new File(basedir, "target/bundle-cache");
    properties.put(Constants.FRAMEWORK_STORAGE, storageDir.getAbsolutePath());

    if (log.isDebugEnabled()) {
        properties.put("felix.log.level", "4");
    }

    /*
     * A hack for Equinox to restore FrameworkProperties to the initial state.
     * If the FrameworkProperties is not restored to the initial state, Equinox
     * will create a separate classloader and load the Geronimo kernel classes
     * from deployed geronimo-kernel bundle instead of the system bundle.
     * That will result in ClassCastException.
     */
    resetFrameworkProperties();

    ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class);
    Framework framework = loader.iterator().next().newFramework(properties);
    framework.start();
    //enable mvn url handling
    //        new org.ops4j.pax.url.mvn.internal.Activator().start(framework.getBundleContext());
    //don't allow mvn urls
    if (systemProperties == null) {
        systemProperties = new HashMap<String, String>();
    }
    systemProperties.put("geronimo.build.car", "true");
    //Fix JIRA GERONIMO-5400
    if (null == System.getProperty("openejb.log.factory")) {
        systemProperties.put("openejb.log.factory", "org.apache.openejb.util.PaxLogStreamFactory");
    }
    systemProperties.put("karaf.startLocalConsole", "false");
    systemProperties.put("openejb.geronimo", "true");
    setSystemProperties();
    return framework;
}

From source file:org.mrgeo.data.DataProviderFactory.java

protected static void initialize(final Configuration conf) throws DataProviderException {
    if (adHocProviderFactories == null) {
        log.info("Initializing ad hoc provider factories");
        adHocProviderFactories = new HashMap<String, AdHocDataProviderFactory>();
        // Find the mrsImageProviders
        final ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader
                .load(AdHocDataProviderFactory.class);
        for (final AdHocDataProviderFactory dp : dataProviderLoader) {
            if (configSettings != null) {
                dp.setConfiguration(configSettings);
            }/*from w  w  w  . jav a 2  s. c o  m*/
            if (dp.isValid()) {
                log.info("Found ad hoc data provider factory " + dp.getClass().getName());
                adHocProviderFactories.put(dp.getPrefix(), dp);
                dp.initialize(conf);
            } else {
                log.info("Skipping ad hoc data provider " + dp.getClass().getName()
                        + " because isValid returned false");
            }
        }
    }

    if (mrsImageProviderFactories == null) {
        log.info("Initializing image provider factories");

        mrsImageProviderFactories = new HashMap<String, MrsImageDataProviderFactory>();

        // Find the mrsImageProviders
        final ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader
                .load(MrsImageDataProviderFactory.class);
        for (final MrsImageDataProviderFactory dp : dataProviderLoader) {
            try {
                if (configSettings != null) {
                    dp.setConfiguration(configSettings);
                }
                if (dp.isValid()) {
                    log.info("Found mrs image data provider factory {} {}", dp.getPrefix(),
                            dp.getClass().getName());
                    mrsImageProviderFactories.put(dp.getPrefix(), dp);
                    dp.initialize(conf);
                } else {
                    log.info("Skipping mrs image data provider " + dp.getClass().getName()
                            + " because isValid returned false");
                }
            } catch (Exception e) {
                // no op, just won't put the provider in the list
                log.warn("Ignoring " + dp.getClass().getName(), e);
            }
        }
    }
    if (vectorProviderFactories == null) {
        log.info("Initializing vector provider factories");

        boolean debugEnabled = log.isDebugEnabled();
        vectorProviderFactories = new HashMap<String, VectorDataProviderFactory>();

        if (debugEnabled) {
            log.debug("Finding vector provider factories");
        }
        // Find the vectorProviders
        final ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader
                .load(VectorDataProviderFactory.class);
        int count = 0;
        for (final VectorDataProviderFactory dp : dataProviderLoader) {
            try {
                if (debugEnabled) {
                    log.debug("Checking if vector factory is valid: " + dp.getClass().getName()
                            + " with config " + ((conf == null) ? "null" : "not null"));
                }
                if (configSettings != null) {
                    dp.setConfiguration(configSettings);
                }
                if (dp.isValid()) {
                    if (debugEnabled) {
                        log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: "
                                + dp.getPrefix());
                    }
                    vectorProviderFactories.put(dp.getPrefix(), dp);
                    dp.initialize(conf);
                    count++;
                } else {
                    if (debugEnabled) {
                        log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: "
                                + dp.getPrefix());
                    }
                    log.info("Skipping vector data provider " + dp.getClass().getName()
                            + " because isValid returned false");
                }
            } catch (Exception e) {
                log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception",
                        e);
            }
        }
        if (count == 0) {
            log.warn("No vector factory providers were found");
        }
    }

    findPreferredProvider(conf);
}

From source file:org.apache.geode.internal.cache.GemFireCacheImpl.java

/**
 * Initialize any services that provided as extensions to the cache using the service loader
 * mechanism./* w  ww.  java 2s  .c  o m*/
 */
private void initializeServices() {
    ServiceLoader<CacheService> loader = ServiceLoader.load(CacheService.class);
    for (CacheService service : loader) {
        service.init(this);
        this.services.put(service.getInterface(), service);
        system.handleResourceEvent(ResourceEvent.CACHE_SERVICE_CREATE, service);
    }
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

/**
 * @param args the command line arguments
 *//*from  www  . j  a  va  2 s  .  c o  m*/
public static void main(String args[]) {
    QLog.initial(args, 2);
    Locale.setDefault(Locales.getInstance().getLangCurrent());
    Uses.showSplash();
    //     plugins
    if (QLog.l().isPlaginable()) {
        Uses.loadPlugins("./plugins/");
    }

    try {
        config = new PropertiesConfiguration("config/reception.properties");
    } catch (ConfigurationException ex) {
        throw new ClientException(ex);
    }

    final IClientNetProperty netProperty = new ClientNetProperty(args);
    // ?    ? .
    //    main   ?   ,
    //  ?     15-20 ?? java.net.SocketException: Malformed reply from SOCKS server  
    /*
     Socket skt = null;
     try {
     skt = new Socket(netProperty.getAddress(), 61111);
     skt.close();
     } catch (IOException ex) {
     }
     */

    final boolean res;
    try {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
                    .getInstalledLookAndFeels()) {
                //System.out.println(info.getName());
                /*Metal Nimbus CDE/Motif Windows   Windows Classic  */
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException ex) {
        }
        fReception = new FReception(netProperty);
        Uses.setLocation(fReception);
        res = fReception.load();
    } catch (Exception ex) {
        Uses.closeSplash();
        throw new ClientException(ex);
    }

    // ? ,  ?  ? .
    //  ??? 
    for (final IStartReception event : ServiceLoader.load(IStartReception.class)) {
        QLog.l().logger()
                .info(" SPI ??. ?: " + event.getDescription());
        try {
            new Thread(() -> {
                event.start(fReception);
            }).start();
        } catch (Throwable tr) {
            QLog.l().logger().error(
                    " SPI ?? ?? . ?: "
                            + tr);
        }
    }

    Uses.closeSplash();
    if (res) {
        java.awt.EventQueue.invokeLater(() -> {
            try {
                fReception.setVisible(true);
            } catch (Exception ex) {
                Uses.closeSplash();
                throw new ClientException(ex);
            } finally {
                Uses.closeSplash();
            }
        });
    } else {
        System.exit(13);
    }
}

From source file:de.dal33t.powerfolder.Controller.java

private void initDistribution() {
    try {/*from ww  w .ja va2 s.  c om*/
        if (ConfigurationEntry.DIST_CLASSNAME.hasValue(getController())) {
            Class<?> distClass = Class.forName(ConfigurationEntry.DIST_CLASSNAME.getValue(getController()));
            distribution = (Distribution) distClass.newInstance();
        }

        if (distribution == null) {
            ServiceLoader<Distribution> brandingLoader = ServiceLoader.load(Distribution.class);
            for (Distribution br : brandingLoader) {
                if (distribution != null) {
                    logWarning("Found multiple distribution classes: " + br.getName() + ", already using "
                            + distribution.getName());
                    break;
                }
                distribution = br;
            }
        }

        if (distribution == null) {
            if (ProUtil.isRunningProVersion()) {
                distribution = new PowerFolderPro();
            } else {
                distribution = new PowerFolderBasic();
            }
            logFine("Distributon not found. Falling back to " + distribution.getName());
        }
        distribution.init(this);
        logInfo("Running distribution: " + distribution.getName());
    } catch (Exception e) {
        logSevere(
                "Failed to initialize distribution " + (distribution == null ? "null" : distribution.getName()),
                e);

        // Fallback
        try {
            if (distribution == null) {
                if (ProUtil.isRunningProVersion()) {
                    distribution = new PowerFolderPro();
                } else {
                    distribution = new PowerFolderBasic();
                }
            }
            logInfo("Running distribution: " + distribution.getName());
            distribution.init(this);
        } catch (Exception e2) {
            logSevere("Failed to initialize fallback distribution", e2);
        }
    }
}

From source file:com.buaa.cfs.fs.FileSystem.java

private static void loadFileSystems() {
    synchronized (FileSystem.class) {
        if (!FILE_SYSTEMS_LOADED) {
            ServiceLoader<FileSystem> serviceLoader = ServiceLoader.load(FileSystem.class);
            for (FileSystem fs : serviceLoader) {
                SERVICE_FILE_SYSTEMS.put(fs.getScheme(), fs.getClass());
            }//from   ww  w .ja  v a  2  s.  co m
            FILE_SYSTEMS_LOADED = true;
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonCloudTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloudTestActionPerformed
        //  ??? /*from w  ww .  j ava 2 s. co m*/
        final StringBuilder sb = new StringBuilder(getLocaleMessage("admin.cloud_test_dialog.results") + ":\n");
        try {
            for (final IPing event : ServiceLoader.load(IPing.class)) {
                if (event.getUID() == 01L) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    sb.append(event.getDescription()).append(" ")
                            .append(getLocaleMessage("admin.cloud_test_dialog.result")).append(": ")
                            .append(event.ping()).append("\n");
                }
            }
        } catch (Throwable ex) {
            QLog.l().logger().error("SPI error: ", ex);
            sb.append(getLocaleMessage("admin.cloud_test_dialog.error"));
        }
        final String res = "URL=\"" + ServerProps.getInstance().getProps().getSkyServerUrl() + "\"\n\n"
                + sb.toString();
        sb.setLength(0);
        JOptionPane.showConfirmDialog(null, res, getLocaleMessage("admin.cloud_test_dialog.title"),
                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonSendDataToSkyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSendDataToSkyActionPerformed
        //  ??? /* w  w  w  . j  a v  a 2s. c om*/
        final Thread th = new Thread(() -> {
            int all = 0;
            all = QServiceTree.getInstance().getNodes().stream().filter((service) -> (service.isLeaf()))
                    .map((_item) -> 1).reduce(all, Integer::sum);
            all += QUserList.getInstance().getSize();
            int tmp = 0;
            try {
                for (final IDataExchange event : ServiceLoader.load(IDataExchange.class)) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    for (QService service : QServiceTree.getInstance().getNodes()) {
                        if (service.isLeaf()) {
                            event.sendServiceName(ServerProps.getInstance().getProps().getBranchOfficeId(),
                                    service.getId(), service.getName());
                            tmp++;
                            final String s = "" + tmp + "/" + all + "  " + tmp * 100 / all + "%";
                            SwingUtilities.invokeLater(() -> {
                                buttonSendDataToSky.setText(s);
                            });
                        }
                    }
                    for (QUser user : QUserList.getInstance().getItems()) {
                        event.sendUserName(ServerProps.getInstance().getProps().getBranchOfficeId(), user.getId(),
                                user.getName());
                        tmp++;
                        final String s = "" + tmp + "/" + all + "  " + tmp * 100 / all + "%";
                        SwingUtilities.invokeLater(() -> {
                            buttonSendDataToSky.setText(s);
                        });
                    }
                }
            } catch (Throwable ex) {
                QLog.l().logger().error("? ? ?  .", ex);
                JOptionPane.showConfirmDialog(null,
                        getLocaleMessage("admin.cloud_senddata_dialog.message_err") + "\n" + ex.getMessage(),
                        getLocaleMessage("admin.cloud_senddata_dialog.title"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            }
            JOptionPane.showConfirmDialog(null,
                    getLocaleMessage("admin.cloud_senddata_dialog.message") + " " + tmp + "/" + all,
                    getLocaleMessage("admin.cloud_senddata_dialog.title"), JOptionPane.DEFAULT_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);
            SwingUtilities.invokeLater(() -> {
                buttonSendDataToSky.setText(getLocaleMessage("buttonSendDataToSky.text"));
            });
        });
        th.start();

    }

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

private void buttonCheckZoneBoardServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCheckZoneBoardServActionPerformed
        //  ??? //from   w ww. j av  a 2 s  . com
        final StringBuilder sb = new StringBuilder(getLocaleMessage("admin.zoneboard_test_dialog.results") + ":\n");
        try {
            for (final IPing event : ServiceLoader.load(IPing.class)) {
                if (event.getUID() == 02L) {
                    QLog.l().logger().info(
                            " SPI ??. ?: " + event.getDescription());
                    sb.append(event.getDescription()).append(" ")
                            .append(getLocaleMessage("admin.zoneboard_test_dialog.result")).append(": ")
                            .append(event.ping()).append("\n");
                }
            }
        } catch (Throwable ex) {
            QLog.l().logger()
                    .error("    ?. ", ex);
            sb.append(getLocaleMessage("admin.zoneboard_test_dialog.error"));
        }
        final String res = sb.toString();
        sb.setLength(0);
        JOptionPane.showConfirmDialog(null, res, getLocaleMessage("admin.zoneboard_test_dialog.title"),
                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);

    }