Example usage for java.lang Thread setName

List of usage examples for java.lang Thread setName

Introduction

In this page you can find the example usage for java.lang Thread setName.

Prototype

public final synchronized void setName(String name) 

Source Link

Document

Changes the name of this thread to be equal to the argument name .

Usage

From source file:com.frostwire.gui.bittorrent.YouTubeVideoUrlDownload.java

private void start() {
    Thread t = new Thread(new Runnable() {

        @Override// www  .j  a  v a2 s .  c  o  m
        public void run() {
            try {
                LinkCollector collector = LinkCollector.getInstance();
                LinkCrawler crawler = new LinkCrawler();
                crawler.setFilter(LinkFilterController.getInstance());
                crawler.crawl(videoUrl);
                crawler.waitForCrawling();

                if (_state.equals(STATE_STOPPED)) {
                    return;
                }

                _state = STATE_FINISHED;
                progress = 100;

                final List<FilePackage> packages = new ArrayList<FilePackage>();

                for (CrawledLink link : crawler.getCrawledLinks()) {
                    CrawledPackage parent = PackageInfo.createCrawledPackage(link);
                    parent.setControlledBy(collector);
                    link.setParentNode(parent);
                    ArrayList<CrawledLink> links = new ArrayList<CrawledLink>();
                    links.add(link);
                    packages.add(createFilePackage(parent, links));
                }

                /*
                for (CrawledPackage pkg : new ArrayList<CrawledPackage>(collector.getPackages())) {
                for (CrawledLink link : new ArrayList<CrawledLink>(pkg.getChildren())) {
                    ArrayList<CrawledLink> links = new ArrayList<CrawledLink>();
                    links.add(link);
                    packages.addAll(collector.removeAndConvert(links));
                }
                }*/

                GUIMediator.safeInvokeAndWait(new Runnable() {
                    public void run() {
                        try {

                            PartialYouTubePackageDialog dlg = new PartialYouTubePackageDialog(
                                    GUIMediator.getAppFrame(), videoUrl, packages);

                            dlg.setVisible(true);
                            if (dlg.getFilesSelection() != null) {
                                for (FilePackage filePackage : dlg.getFilesSelection()) {
                                    BTDownloadMediator.instance().openYouTubeItem(filePackage);
                                }
                            }
                        } catch (Throwable e) {
                            LOG.error("Error reading youtube package:" + e.getMessage(), e);
                            _state = STATE_ERROR;
                        }
                    }
                });

                GUIMediator.safeInvokeAndWait(new Runnable() {
                    public void run() {
                        BTDownloadMediator.instance().remove(YouTubeVideoUrlDownload.this);
                    }
                });
            } catch (Throwable e) {
                LOG.error("Error crawling youtube: " + videoUrl, e);
                _state = STATE_ERROR;
            }
        }
    });
    t.setDaemon(true);
    t.setName("YouTube Crawl: " + videoUrl);
    t.start();
}

From source file:edu.brown.hstore.HStoreSite.java

/**
 * Initializes all the pieces that we need to start this HStore site up
 * This should only be called by our run() method
 *///from w  w  w. j ava 2s. co  m
protected HStoreSite init() {
    if (debug.val)
        LOG.debug("Initializing HStoreSite " + this.getSiteName());
    this.hstore_coordinator = this.initHStoreCoordinator();

    // First we need to tell the HStoreCoordinator to start-up and initialize its connections
    if (debug.val)
        LOG.debug("Starting HStoreCoordinator for " + this.getSiteName());
    this.hstore_coordinator.start();

    ThreadGroup auxGroup = this.threadManager.getThreadGroup(ThreadGroupType.AUXILIARY);

    // Start TransactionQueueManager
    Thread t = new Thread(auxGroup, this.txnQueueManager);
    t.setDaemon(true);
    t.setUncaughtExceptionHandler(this.exceptionHandler);
    t.start();

    // Start VoltNetwork
    t = new Thread(this.voltNetwork);
    t.setName(HStoreThreadManager.getThreadName(this, HStoreConstants.THREAD_NAME_VOLTNETWORK));
    t.setDaemon(true);
    t.setUncaughtExceptionHandler(this.exceptionHandler);
    t.start();

    // Start CommandLogWriter
    t = new Thread(auxGroup, this.commandLogger);
    t.setDaemon(true);
    t.setUncaughtExceptionHandler(this.exceptionHandler);
    t.start();

    // Start AntiCacheManager Queue Processor
    if (this.anticacheManager != null && this.anticacheManager.getEvictableTables().isEmpty() == false) {
        t = new Thread(auxGroup, this.anticacheManager);
        t.setDaemon(true);
        t.setUncaughtExceptionHandler(this.exceptionHandler);
        t.start();
    }

    // TransactionPreProcessors
    if (this.preProcessors != null) {
        for (TransactionPreProcessor tpp : this.preProcessors) {
            t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.PROCESSING), tpp);
            t.setDaemon(true);
            t.setUncaughtExceptionHandler(this.exceptionHandler);
            t.start();
        } // FOR
    }
    // TransactionPostProcessors
    if (this.postProcessors != null) {
        for (TransactionPostProcessor tpp : this.postProcessors) {
            t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.PROCESSING), tpp);
            t.setDaemon(true);
            t.setUncaughtExceptionHandler(this.exceptionHandler);
            t.start();
        } // FOR
    }

    // Then we need to start all of the PartitionExecutor in threads
    if (debug.val)
        LOG.debug(String.format("Starting PartitionExecutor threads for %s partitions on %s",
                this.local_partitions.size(), this.getSiteName()));
    for (int partition : this.local_partitions.values()) {
        PartitionExecutor executor = this.getPartitionExecutor(partition);
        // executor.initHStoreSite(this);

        t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.EXECUTION), executor);
        t.setDaemon(true);
        t.setPriority(Thread.MAX_PRIORITY); // Probably does nothing...
        t.setUncaughtExceptionHandler(this.exceptionHandler);
        this.executor_threads[partition] = t;
        t.start();
    } // FOR

    // Start Transaction Cleaners
    int i = 0;
    for (TransactionCleaner cleaner : this.txnCleaners) {
        String name = String.format("%s-%02d",
                HStoreThreadManager.getThreadName(this, HStoreConstants.THREAD_NAME_TXNCLEANER), i);
        t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.CLEANER), cleaner);
        t.setName(name);
        t.setDaemon(true);
        t.setUncaughtExceptionHandler(this.exceptionHandler);
        t.start();
        i += 1;
    } // FOR

    this.initPeriodicWorks();

    // Transaction Profile CSV Dumper
    if (hstore_conf.site.txn_profiling && hstore_conf.site.txn_profiling_dump) {
        File csvFile = new File(hstore_conf.global.log_dir + File.separator + this.getSiteName().toLowerCase()
                + "-profiler.csv");
        this.txn_profiler_dumper = new TransactionProfilerDumper(csvFile);
        LOG.info(String.format("Transaction profile data will be written to '%s'", csvFile));
    }

    // Add in our shutdown hook
    // Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook()));

    return (this);
}

From source file:hudson.model.Hudson.java

private synchronized void load() throws IOException {
    long startTime = System.currentTimeMillis();
    XmlFile cfg = getConfigFile();//ww w .  j  a  v a  2s  .co  m
    if (cfg.exists()) {
        // reset some data that may not exit in the disk file
        // so that we can take a proper compensation action later.
        primaryView = null;
        views.clear();
        cfg.unmarshal(this);
    }
    clouds.setOwner(this);

    File projectsDir = new File(root, "jobs");
    if (!projectsDir.isDirectory() && !projectsDir.mkdirs()) {
        if (projectsDir.exists())
            throw new IOException(projectsDir + " is not a directory");
        throw new IOException("Unable to create " + projectsDir
                + "\nPermission issue? Please create this directory manually.");
    }
    File[] subdirs = projectsDir.listFiles(new FileFilter() {
        public boolean accept(File child) {
            return child.isDirectory() && Items.getConfigFile(child).exists();
        }
    });
    items.clear();
    if (PARALLEL_LOAD) {
        // load jobs in parallel for better performance
        LOGGER.info("Loading in " + TWICE_CPU_NUM + " parallel threads");
        List<Future<TopLevelItem>> loaders = new ArrayList<Future<TopLevelItem>>();
        for (final File subdir : subdirs) {
            loaders.add(threadPoolForLoad.submit(new Callable<TopLevelItem>() {
                public TopLevelItem call() throws Exception {
                    Thread t = Thread.currentThread();
                    String name = t.getName();
                    t.setName("Loading " + subdir);
                    try {
                        long start = System.currentTimeMillis();
                        TopLevelItem item = (TopLevelItem) Items.load(Hudson.this, subdir);
                        if (LOG_STARTUP_PERFORMANCE)
                            LOGGER.info("Loaded " + item.getName() + " in "
                                    + (System.currentTimeMillis() - start) + "ms by " + name);
                        return item;
                    } finally {
                        t.setName(name);
                    }
                }
            }));
        }

        for (Future<TopLevelItem> loader : loaders) {
            try {
                TopLevelItem item = loader.get();
                items.put(item.getName(), item);
            } catch (ExecutionException e) {
                LOGGER.log(Level.WARNING, "Failed to load a project", e.getCause());
            } catch (InterruptedException e) {
                e.printStackTrace(); // this is probably not the right thing to do
            }
        }
    } else {
        for (File subdir : subdirs) {
            try {
                long start = System.currentTimeMillis();
                TopLevelItem item = (TopLevelItem) Items.load(this, subdir);
                if (LOG_STARTUP_PERFORMANCE)
                    LOGGER.info(
                            "Loaded " + item.getName() + " in " + (System.currentTimeMillis() - start) + "ms");
                items.put(item.getName(), item);
            } catch (Error e) {
                LOGGER.log(Level.WARNING, "Failed to load " + subdir, e);
            } catch (RuntimeException e) {
                LOGGER.log(Level.WARNING, "Failed to load " + subdir, e);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Failed to load " + subdir, e);
            }
        }
    }
    rebuildDependencyGraph();

    {// recompute label objects
        for (Node slave : slaves)
            slave.getAssignedLabels();
        getAssignedLabels();
    }

    // initialize views by inserting the default view if necessary
    // this is both for clean Hudson and for backward compatibility.
    if (views.size() == 0 || primaryView == null) {
        View v = new AllView(Messages.Hudson_ViewName());
        v.owner = this;
        views.add(0, v);
        primaryView = v.getViewName();
    }

    // read in old data that doesn't have the security field set
    if (authorizationStrategy == null) {
        if (useSecurity == null || !useSecurity)
            authorizationStrategy = AuthorizationStrategy.UNSECURED;
        else
            authorizationStrategy = new LegacyAuthorizationStrategy();
    }
    if (securityRealm == null) {
        if (useSecurity == null || !useSecurity)
            setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
        else
            setSecurityRealm(new LegacySecurityRealm());
    } else {
        // force the set to proxy
        setSecurityRealm(securityRealm);
    }

    if (useSecurity != null && !useSecurity) {
        // forced reset to the unsecure mode.
        // this works as an escape hatch for people who locked themselves out.
        authorizationStrategy = AuthorizationStrategy.UNSECURED;
        setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
    }

    // Initialize the filter with the crumb issuer
    setCrumbIssuer(crumbIssuer);

    // auto register root actions
    actions.addAll(getExtensionList(RootAction.class));

    LOGGER.info(String.format("Took %s ms to load", System.currentTimeMillis() - startTime));
    if (KILL_AFTER_LOAD)
        System.exit(0);
}

From source file:org.apache.lens.server.query.QueryExecutionServiceImpl.java

private void startEstimatePool() {
    int minPoolSize = conf.getInt(ESTIMATE_POOL_MIN_THREADS, DEFAULT_ESTIMATE_POOL_MIN_THREADS);
    int maxPoolSize = conf.getInt(ESTIMATE_POOL_MAX_THREADS, DEFAULT_ESTIMATE_POOL_MAX_THREADS);
    int keepAlive = conf.getInt(ESTIMATE_POOL_KEEP_ALIVE_MILLIS, DEFAULT_ESTIMATE_POOL_KEEP_ALIVE_MILLIS);

    final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
    final AtomicInteger thId = new AtomicInteger();
    // We are creating our own thread factory, just so that we can override thread name for easy debugging
    ThreadFactory threadFactory = new ThreadFactory() {
        @Override//from  ww w . j  a v  a  2 s .  co  m
        public Thread newThread(Runnable r) {
            Thread th = defaultFactory.newThread(r);
            th.setName("estimate-" + thId.incrementAndGet());
            return th;
        }
    };

    log.debug("starting estimate pool");

    ThreadPoolExecutor estimatePool = new ThreadPoolExecutor(minPoolSize, maxPoolSize, keepAlive,
            TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(), threadFactory);
    estimatePool.allowCoreThreadTimeOut(false);
    estimatePool.prestartCoreThread();
    this.estimatePool = estimatePool;
}

From source file:org.apache.lens.server.query.QueryExecutionServiceImpl.java

private void startLauncherPool() {
    int minPoolSize = conf.getInt(LAUNCHER_POOL_MIN_THREADS, DEFAULT_LAUNCHER_POOL_MIN_THREADS);
    int maxPoolSize = conf.getInt(LAUNCHER_POOL_MAX_THREADS, DEFAULT_LAUNCHER_POOL_MAX_THREADS);
    int keepAlive = conf.getInt(LAUNCHER_POOL_KEEP_ALIVE_MILLIS, DEFAULT_LAUNCHER_POOL_KEEP_ALIVE_MILLIS);

    final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
    final AtomicInteger thId = new AtomicInteger();
    // We are creating our own thread factory, just so that we can override thread name for easy debugging
    ThreadFactory threadFactory = new ThreadFactory() {
        @Override/* w ww  . ja v a 2 s  .co  m*/
        public Thread newThread(Runnable r) {
            Thread th = defaultFactory.newThread(r);
            th.setName("launcher-" + thId.incrementAndGet());
            return th;
        }
    };

    log.debug("starting query launcher pool");

    ThreadPoolExecutor launcherPool = new ThreadPoolExecutor(minPoolSize, maxPoolSize, keepAlive,
            TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(), threadFactory);
    launcherPool.allowCoreThreadTimeOut(false);
    launcherPool.prestartCoreThread();
    this.queryLauncherPool = launcherPool;
}

From source file:com.twinsoft.convertigo.eclipse.editors.connector.HtmlConnectorDesignComposite.java

private void generateXml() {
    Thread th = new Thread(new Runnable() {
        public void run() {
            final Document dom = getWebViewer().getDom();

            if (dom == null) {
                ConvertigoPlugin.errorMessageBox("Mozilla retrieved Dom is null!");
                return;
            }//  www . j  a v a2  s  .  c o  m
            //Engine.logBeans.debug3("(HtmlConnectorDesignComposite) xmlizing dom:\n"+ XMLUtils.prettyPrintDOM(dom), null);

            // synchronized (htmlConnector) {
            Document currentDom = htmlConnector.getCurrentXmlDocument();

            // Report from 4.5: fix #401
            HtmlTransaction htmlTransaction = null;
            try {
                htmlTransaction = (HtmlTransaction) htmlConnector.getDefaultTransaction();
            } catch (Exception e1) {
            }

            if (htmlTransaction != null) {
                boolean isStateFull = htmlTransaction.isStateFull();
                xmlizingTransaction = htmlTransaction;
                xmlizingTransaction.setCurrentXmlDocument(dom);
                xmlizingTransaction.setStateFull(true);

                getDisplay().asyncExec(new Runnable() {
                    public void run() {
                        ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault()
                                .getConnectorEditor(htmlConnector);
                        if (connectorEditor == null)
                            transactionFinished(new EngineEvent(xmlizingTransaction));
                        else
                            connectorEditor.getDocument(xmlizingTransaction.getName(), false);
                    }
                });

                while (xmlizingTransaction != null) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                }
                htmlTransaction.setCurrentXmlDocument(currentDom);
                htmlTransaction.setStateFull(isStateFull);
            }
            // }
        }
    });
    th.setName("Document completed Update");
    th.start();
}

From source file:com.github.vatbub.tictactoe.view.Main.java

private void connectToRelayServer() {
    setLoadingStatusText("The server is waking up, hang tight...", true);
    showLoadingScreen();/*  w  ww . j  av a 2 s  .co  m*/
    Thread connectionThread = new Thread(() -> {
        int maxRetries = 10;
        int remainingRetries = maxRetries;
        AtomicBoolean readyWithoutException = new AtomicBoolean(false);
        Exception lastException = null;

        while (remainingRetries > 0 && !readyWithoutException.get()) {
            try {
                int finalRemainingRetries = remainingRetries;
                KryoGameConnections.connect(() -> {
                    if (maxRetries == finalRemainingRetries)
                        // should only appear the first time
                        setLoadingStatusText("Connecting to the server...");
                }, () -> Platform.runLater(() -> {
                    readyWithoutException.set(true);
                    hideLoadingScreen();
                    showOnlineMenu();
                }));
            } catch (Exception e) {
                remainingRetries--;
                setLoadingStatusText("This is taking longer than usual, hang tight (Retry "
                        + (maxRetries - remainingRetries) + " of " + maxRetries + ")...");
                FOKLogger.log(Main.class.getName(), Level.SEVERE,
                        "Could not connect to the relay server: " + e.getMessage(), e);
                lastException = e;
            }
        }

        if (!readyWithoutException.get()) {
            if (lastException == null) {
                Platform.runLater(() -> showErrorMessage("Something went wrong.", "Unknown"));
            } else {
                Exception finalLastException = lastException;
                Platform.runLater(() -> showErrorMessage(finalLastException));
            }
        }
    });
    connectionThread.setName("connectionThread");
    connectionThread.start();
}

From source file:com.buaa.cfs.security.UserGroupInformation.java

/** Spawn a thread to do periodic renewals of kerberos credentials */
private void spawnAutoRenewalThreadForUserCreds() {
    if (isSecurityEnabled()) {
        //spawn thread only if we have kerb credentials
        if (user.getAuthenticationMethod() == AuthenticationMethod.KERBEROS && !isKeytab) {
            Thread t = new Thread(new Runnable() {

                @Override/*from   w  ww.  jav a  2s . c o  m*/
                public void run() {
                    String cmd = conf.get("hadoop.kerberos.kinit.command", "kinit");
                    KerberosTicket tgt = getTGT();
                    if (tgt == null) {
                        return;
                    }
                    long nextRefresh = getRefreshTime(tgt);
                    while (true) {
                        try {
                            long now = Time.now();
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("Current time is " + now);
                                LOG.debug("Next refresh is " + nextRefresh);
                            }
                            if (now < nextRefresh) {
                                Thread.sleep(nextRefresh - now);
                            }
                            Shell.execCommand(cmd, "-R");
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("renewed ticket");
                            }
                            reloginFromTicketCache();
                            tgt = getTGT();
                            if (tgt == null) {
                                LOG.warn("No TGT after renewal. Aborting renew thread for " + getUserName());
                                return;
                            }
                            nextRefresh = Math.max(getRefreshTime(tgt), now + MIN_TIME_BEFORE_RELOGIN);
                        } catch (InterruptedException ie) {
                            LOG.warn("Terminating renewal thread");
                            return;
                        } catch (IOException ie) {
                            LOG.warn("Exception encountered while running the"
                                    + " renewal command. Aborting renew thread. " + ie);
                            return;
                        }
                    }
                }
            });
            t.setDaemon(true);
            t.setName("TGT Renewer for " + getUserName());
            t.start();
        }
    }
}

From source file:org.fao.geonet.OgpAppHandler.java

private void fillCaches(final ServiceContext context) {
    final Format formatService = context.getBean(Format.class); // this will initialize the formatter

    Thread fillCaches = new Thread(new Runnable() {
        @Override// w  w  w  .  j  a v  a2s.c  o m
        public void run() {
            final ServletContext servletContext = context.getServlet().getServletContext();
            context.setAsThreadLocal();
            ApplicationContextHolder.set(_applicationContext);
            GeonetWro4jFilter filter = (GeonetWro4jFilter) servletContext
                    .getAttribute(GeonetWro4jFilter.GEONET_WRO4J_FILTER_KEY);

            @SuppressWarnings("unchecked")
            List<String> wro4jUrls = _applicationContext.getBean("wro4jUrlsToInitialize", List.class);

            for (String wro4jUrl : wro4jUrls) {
                Log.info(Geonet.GEONETWORK, "Initializing the WRO4J group: " + wro4jUrl + " cache");
                final MockHttpServletRequest servletRequest = new MockHttpServletRequest(servletContext, "GET",
                        "/static/" + wro4jUrl);
                final MockHttpServletResponse response = new MockHttpServletResponse();
                try {
                    filter.doFilter(servletRequest, response, new MockFilterChain());
                } catch (Throwable t) {
                    Log.info(Geonet.GEONETWORK,
                            "Error while initializing the WRO4J group: " + wro4jUrl + " cache", t);
                }
            }

            final Page<Metadata> metadatas = _applicationContext.getBean(MetadataRepository.class)
                    .findAll(new PageRequest(0, 1));
            if (metadatas.getNumberOfElements() > 0) {
                Integer mdId = metadatas.getContent().get(0).getId();
                context.getUserSession().loginAs(
                        new User().setName("admin").setProfile(Profile.Administrator).setUsername("admin"));
                @SuppressWarnings("unchecked")
                List<String> formattersToInitialize = _applicationContext.getBean("formattersToInitialize",
                        List.class);

                for (String formatterName : formattersToInitialize) {
                    Log.info(Geonet.GEONETWORK, "Initializing the Formatter with id: " + formatterName);
                    final MockHttpServletRequest servletRequest = new MockHttpServletRequest(servletContext);
                    final MockHttpServletResponse response = new MockHttpServletResponse();
                    try {
                        formatService.exec("eng", FormatType.html.toString(), mdId.toString(), null,
                                formatterName, Boolean.TRUE.toString(), false, FormatterWidth._100,
                                new ServletWebRequest(servletRequest, response));
                    } catch (Throwable t) {
                        Log.info(Geonet.GEONETWORK,
                                "Error while initializing the Formatter with id: " + formatterName, t);
                    }
                }
            }
        }
    });
    fillCaches.setDaemon(true);
    fillCaches.setName("Fill Caches Thread");
    fillCaches.setPriority(Thread.MIN_PRIORITY);
    fillCaches.start();
}

From source file:com.twinsoft.convertigo.eclipse.wizards.setup.SetupWizard.java

public void register(final String username, final String password, final String firstname,
        final String lastname, final String email, final String country, final String company,
        final String companyHeadcount, final RegisterCallback callback) {
    Thread th = new Thread(new Runnable() {

        public void run() {
            synchronized (SetupWizard.this) {
                boolean success = false;
                String message;/*  w  ww  . j a  v a2s.c  o m*/

                try {
                    String[] url = { registrationServiceUrl };
                    HttpClient client = prepareHttpClient(url);
                    PostMethod method = new PostMethod(url[0]);
                    HeaderName.ContentType.setRequestHeader(method, MimeType.WwwForm.value());
                    // set parameters for POST method
                    method.setParameter("__sequence", "checkEmail");
                    method.setParameter("username", username);
                    method.setParameter("password", password);
                    method.setParameter("firstname", firstname);
                    method.setParameter("lastname", lastname);
                    method.setParameter("email", email);
                    method.setParameter("country", country);
                    method.setParameter("company", company);
                    method.setParameter("companyHeadcount", companyHeadcount);

                    // execute HTTP post with parameters
                    int statusCode = client.executeMethod(method);
                    if (statusCode == HttpStatus.SC_OK) {
                        Document document = XMLUtils.parseDOM(method.getResponseBodyAsStream());
                        NodeList nd = document.getElementsByTagName("errorCode");

                        if (nd.getLength() > 0) {
                            Node node = nd.item(0);
                            String errorCode = node.getTextContent();

                            if ("0".equals(errorCode)) {
                                success = true;
                                message = "Registration submited, please check your email.";
                            } else {
                                method = new PostMethod(registrationServiceUrl);

                                // set parameters for POST method to get the
                                // details of error messages
                                method.setParameter("__sequence", "getErrorMessages");
                                client.executeMethod(method);
                                document = XMLUtils.parseDOM(method.getResponseBodyAsStream());
                                nd = document.getElementsByTagName("label");
                                Node nodeDetails = nd.item(Integer.parseInt(errorCode));

                                ConvertigoPlugin.logError(nodeDetails.getTextContent());
                                message = "Failed to register: " + nodeDetails.getTextContent();
                            }
                        } else {
                            success = true;
                            message = "debug";
                        }
                    } else {
                        message = "Unexpected HTTP status: " + statusCode;
                    }
                } catch (Exception e) {
                    message = "Generic failure: " + e.getClass().getSimpleName() + ", " + e.getMessage();
                    ConvertigoPlugin.logException(e, "Error while trying to send registration");
                }
                callback.onRegister(success, message);
            }
        }

    });
    th.setDaemon(true);
    th.setName("SetupWizard.register");
    th.start();
}