Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.Transactions


    private int convertPortStr(final String port)
            throws TransactionFailure {
        try {
            return Integer.parseInt(port);
        } catch (Exception e) {
            throw new TransactionFailure(
                    strings.get("InvalidPortNumber", port));
        }
    }
View Full Code Here


     * @throws TransactionFailure if port number is not a numeric value.
     */
    private void verifyPortBasePortIsValid(String portName, int portNum)
            throws TransactionFailure {
        if (portNum <= 0 || portNum > PORT_MAX_VAL) {
            throw new TransactionFailure(
                strings.get("InvalidPortBaseRange", portNum, portName));
        }
        if (checkPorts && !NetUtils.isPortFree(portNum)) {
            throw new TransactionFailure(
                strings.get("PortBasePortInUse", portNum, portName));
        }
        _logger.log(Level.FINER,ConfigApiLoggerInfo.portBaseHelperPort, portNum);
    }
View Full Code Here

    public PortManager(Cluster cluster, Config config, Domain theDomain,
            Server theNewServer) throws TransactionFailure {
        try {
            if (theNewServer == null || theDomain == null)
                throw new TransactionFailure(Strings.get("internal.error", "null argument in PortManager constructor"));

            newServer = theNewServer;
            domain = theDomain;
            serverName = newServer.getName();

            // bnevins 7-23-2010
            // we are probably being called from inside the create decorator for a server.
            // the server is not yet committed.  We can't call ducktype methods
            // on the server yet.  So we do this self-serve call to get the host

            //host = newServer.getHost();

            host = new ServerHelper(theNewServer, config).getAdminHost();

            allPorts = new TreeSet<Integer>();
            newServerPorts = new ServerPorts(cluster, config, domain, newServer);

            isLocal = NetUtils.isThisHostLocal(host);


            allServers = domain.getServers().getServer();

            // why all this nonsense?  ConcurrentModificationException!!!
            for (Iterator<Server> it = allServers.iterator(); it.hasNext();) {
                Server curr = it.next();
                if (serverName.equals(curr.getName())) {
                    it.remove();
                }
            }
            serversOnHost = new ArrayList<ServerPorts>();
        }
        catch (TransactionFailure tf) {
            throw tf;
        }
        catch (Exception e) {
            // this Exception will not take just a Throwable.  I MUST give a string
            throw new TransactionFailure(e.toString(), e);
        }
    }
View Full Code Here

                }
            }
            return generateAssignedPortMessage(finalPorts);
        }
        catch (Exception e) {
            throw new TransactionFailure(e.toString(), e);
        }
    }
View Full Code Here

                return num;
            }
            else
                ++num;
        }
        throw new TransactionFailure(Strings.get("PortManager.noFreePort"));
    }
View Full Code Here

        for (int inum = num; inum < max; inum++) {
            if (!allPorts.contains(inum))
                return inum;
        }
        throw new TransactionFailure(Strings.get("PortManager.noFreePort", num, max));
    }
View Full Code Here

                 * helper to return the DN for that alias (or the DN if that's
                 * what the user specified).
                 */
                instance.setDn(helper.getDN(value, isAlias));
            } catch (Exception ex) {
                throw new TransactionFailure("create", ex);
            }
        }
View Full Code Here

       
        //System.out.println( "setAttributesInConfigBean: " + amxAttrs);

        final AttributeList successfulAttrs = new AttributeList();

        final Transactions transactions = mConfigBean.getHabitat().getComponent(Transactions.class);

        if (xmlAttrs.size() != 0)
        {
            //cdebug( "DelegateToConfigBeanDelegate.setAttributes(): " + attrsIn.size() + " attributes: {" +
            //     CollectionUtil.toString(amxAttrs.keySet()) + "} mapped to xml names {" + CollectionUtil.toString(xmlAttrs.keySet()) + "}");

            final MyTransactionListener myListener = new MyTransactionListener(mConfigBean);
            transactions.addTransactionsListener(myListener);

            // results should contain only those that succeeded which will be all or none
            // depending on whether the transaction worked or not
            try
            {
                final MakeChangesApplyer mca = new MakeChangesApplyer(mConfigBean, xmlAttrs);
                mca.apply();

                // use 'attrsIn' vs 'attrs' in case not all values are 'String'
                successfulAttrs.addAll(attrsIn);
            }
            catch (final TransactionFailure tf)
            {
                // empty results -- no Exception should be thrown per JMX spec
                cdebug(ExceptionUtil.toString(tf));
                throw(tf);
            }
            finally
            {
                transactions.waitForDrain();

                transactions.removeTransactionsListener(myListener);
            }
        }

        return successfulAttrs;
    }
View Full Code Here

                File libraryFile = new File(libDir, libraryName);
                if (libraryFile.exists()) {
                    FileUtils.deleteFile(libraryFile);
                    PropertyChangeEvent pe = new PropertyChangeEvent(libDir,
                        "remove-library", libraryFile, null);
                    UnprocessedChangeEvent uce = new UnprocessedChangeEvent(
                        pe, "remove-library");
                    unprocessed.add(uce);
                } else {
                    msg.append(localStrings.getLocalString("lfnf","Library file not found", libraryFile.getAbsolutePath()));
                }
View Full Code Here

                                    }
                                } else if (a.equals(SERVER_LOG_FILE_PROPERTY)) {
                                    //check if file name was changed and send notification
                                    if (!val.equals(serverLogFileDetail)) {
                                        PropertyChangeEvent pce = new PropertyChangeEvent(this, a, serverLogFileDetail, val);
                                        UnprocessedChangeEvents ucel = new UnprocessedChangeEvents(new UnprocessedChangeEvent(pce, "server log filename changed."));
                                        List<UnprocessedChangeEvents> b = new ArrayList();
                                        b.add(ucel);
                                        ucl.unprocessedTransactedEvents(b);
                                    }
                                } else if (a.equals(HANDLER_PROPERTY)) {
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.config.Transactions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.