Package com.sun.enterprise.util

Examples of com.sun.enterprise.util.LocalStringManagerImpl


        private ServerEnvironment env;

        @Override
        public void decorate(AdminCommandContext context, Servers parent, final Server child) throws PropertyVetoException, TransactionFailure {
            final Logger logger = LogDomains.getLogger(Server.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Server.class);
            final ActionReport report = context.getActionReport();
            Transaction t = Transaction.getTransaction(parent);
            Cluster cluster = domain.getClusterForInstance(child.getName());
            boolean isStandAlone = cluster == null ? true : false;

            /* setup supplemental */
            if (!isStandAlone && env.isDas()) {
                context.getActionReport().
                        setResultType(String.class, cluster.getName());
            }

            if (isStandAlone) { // remove config <instance>-config
                String instanceConfig = child.getConfigRef();
                final Config config = configs.getConfigByName(instanceConfig);

                // bnevins June 2010
                // don't delete the config is someone else holds a reference to it!
                if (config != null && domain.getReferenceContainersOf(config).size() > 1) {
                    return;
                }

                // bnevins September 30, 2010
                // don't delete the config if it wasn't auto-generated.
                final String autoGeneratedName = child.getName() + "-config";
                if (!autoGeneratedName.equals(instanceConfig))
                    return;
               
                try {
                    if (config != null) {
                        File configConfigDir = new File(env.getConfigDirPath(), config.getName());
                        FileUtils.whack(configConfigDir);
                    }
                }
                catch (Exception e) {
                    // no big deal - just ignore
                }
                try {
                    if (t != null) {
                        Configs c = t.enroll(configs);
                        List<Config> configList = c.getConfig();
                        configList.remove(config);
                    }
                }
                catch (TransactionFailure ex) {
                    logger.log(Level.SEVERE,
                            localStrings.getLocalString("deleteConfigFailed",
                            "Unable to remove config {0}", instanceConfig), ex);
                    String msg = ex.getMessage() != null ? ex.getMessage()
                            : localStrings.getLocalString("deleteConfigFailed",
                            "Unable to remove config {0}", instanceConfig);
                    report.setMessage(msg);
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    report.setFailureCause(ex);
                    throw ex;
                }
            }
            else { // remove server-ref from cluster
                final String instanceName = child.getName();
                if (t != null) {
                    try {
                        Cluster c = t.enroll(cluster);

                        List<ServerRef> serverRefList = c.getServerRef();
                        ServerRef serverRef = null;

                        for (ServerRef sr : serverRefList) {
                            if (sr.getRef().equals(instanceName)) {
                                serverRef = sr;
                                break;
                            }
                        }
                        if (serverRef != null) {
                            serverRefList.remove(serverRef);
                        }
                    }
                    catch (TransactionFailure ex) {
                        logger.log(Level.SEVERE,
                                localStrings.getLocalString("deleteServerRefFailed",
                                "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName()), ex);
                        String msg = ex.getMessage() != null ? ex.getMessage()
                                : localStrings.getLocalString("deleteServerRefFailed",
                                "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName());
                        report.setMessage(msg);
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        report.setFailureCause(ex);
                        throw ex;
View Full Code Here


         * @throws PropertyVetoException
         */
        @Override
        public void decorate(AdminCommandContext context, final Cluster instance) throws TransactionFailure, PropertyVetoException {
            Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class);
            Transaction t = Transaction.getTransaction(instance);
            //check if cluster software is installed else fail , see issue 12023
            final CopyConfig command = (CopyConfig) runner
                    .getCommand("copy-config", context.getActionReport(), context.getLogger());
            if (command == null ) {
                throw new TransactionFailure(localStrings.getLocalString("cannot.execute.command",
                        "Cluster software is not installed"));
            }
            final String instanceName = instance.getName();
            if (instance.getGmsBindInterfaceAddress() == null) {
                instance.setGmsBindInterfaceAddress(String.format(
                    "${GMS-BIND-INTERFACE-ADDRESS-%s}",
                    instanceName));
            }

            if (configRef==null) {
                Config config = habitat.getService(Config.class, "default-config");
                if (config==null) {
                    config = habitat.<Config>getAllServices(Config.class).iterator().next();
                    logger.warning(localStrings.getLocalString(Cluster.class,
                            "Cluster.no_default_config_found",
                            "No default config found, using config {0} as the default config for the cluster {1}",
                            config.getName(), instance.getName()));
                }

                Configs configs = domain.getConfigs();
                Configs writableConfigs = t.enroll(configs);
                final String configName = instance.getName() + "-config";
                instance.setConfigRef(configName);
                command.copyConfig(writableConfigs,config,configName,logger);
               

            else {

                // cluster using specified config
                Config specifiedConfig = domain.getConfigs().getConfigByName(configRef);
                if (specifiedConfig == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchConfig", "Configuration {0} does not exist.", configRef));
                }
            }

            Property gmsListenerPort = instance.getProperty("GMS_LISTENER_PORT");
View Full Code Here

        @Override
        public void decorate(AdminCommandContext context, Clusters parent, Cluster child) throws
                PropertyVetoException, TransactionFailure{
            Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class);
            final ActionReport report = context.getActionReport();
            String instanceConfig = child.getConfigRef();
            final Config config = configs.getConfigByName(instanceConfig);
            Transaction t = Transaction.getTransaction(parent);

            //check if the cluster contains instances throw error that cluster
            //cannot be deleted
            //issue 12172
            List<ServerRef> serverRefs = child.getServerRef();
            StringBuffer namesOfServers = new StringBuffer();
            if (serverRefs.size() > 0) {
                for (ServerRef serverRef: serverRefs){
                    namesOfServers.append(new StringBuffer( serverRef.getRef()).append( ','));
                }

                final String msg = localStrings.getLocalString(
                        "Cluster.hasInstances",
                        "Cluster {0} contains server instances {1} and must not contain any instances"
                        ,child.getName() ,namesOfServers.toString()
                );

                logger.log(Level.SEVERE, msg);
                throw new TransactionFailure(msg);
            }

            // remove GMS_LISTENER_PORT-clusterName prop from server config
            Config serverConfig = configs.getConfigByName("server-config");
            String propName = String.format(
                "GMS_LISTENER_PORT-%s", child.getName());
            SystemProperty gmsProp = serverConfig.getSystemProperty(propName);
            if (gmsProp != null && t != null) {
                Config c = t.enroll(serverConfig);
                List<SystemProperty> propList = c.getSystemProperty();
                propList.remove(gmsProp);
            }

            // check if the config is null or still in use by some other
            // ReferenceContainer or is not <cluster-name>-config -- if so just return...
            if(config == null || domain.getReferenceContainersOf(config).size() > 1 || !instanceConfig.equals(child.getName() + "-config"))
                return;


            try {
                File configConfigDir = new File(env.getConfigDirPath(), config.getName());
                FileUtils.whack(configConfigDir);
            }
            catch(Exception e) {
                // no big deal - just ignore
            }

            try {
                if (t != null) {
                    Configs c = t.enroll(configs);
                    List<Config> configList = c.getConfig();
                    configList.remove(config);
                }
            } catch (TransactionFailure ex) {
                logger.log(Level.SEVERE,
                        localStrings.getLocalString("deleteConfigFailed",
                                "Unable to remove config {0}", instanceConfig), ex);
                String msg = ex.getMessage() != null ? ex.getMessage()
                        : localStrings.getLocalString("deleteConfigFailed",
                        "Unable to remove config {0}", instanceConfig);
                report.setMessage(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setFailureCause(ex);
                throw ex;
View Full Code Here

         * @throws PropertyVetoException
         */
        @Override
        public void decorate(AdminCommandContext context, final Node instance) throws TransactionFailure, PropertyVetoException {

            LocalStringManagerImpl localStrings =
                    new LocalStringManagerImpl(Node.class);
           
            /* 16034: see if instance creation is turned off on node */
            if (! nodes.nodeCreationAllowed()) {
                throw new TransactionFailure(localStrings.getLocalString(
                    "nodeCreationNotAllowed",
                    "Node creation is disabled. No new nodes may be created."));
            }
            // If these options were passed a value of the empty string then
            // we want to make sure they are null in the Node. The
View Full Code Here

        @Override
        public void decorate(AdminCommandContext context, Nodes parent, Node child) throws
                PropertyVetoException, TransactionFailure {
            Logger logger = LogDomains.getLogger(Node.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Node.class);
            String nodeName = child.getName();

            if (nodeName.equals("localhost-" + domain.getName())) { // can't delete localhost node
                final String msg = localStrings.getLocalString(
                        "Node.localhost",
                        "Cannot remove Node {0}. ", child.getName());

                logger.log(Level.SEVERE, msg);
                throw new TransactionFailure(msg);
            }


            List<Node> nodeList = nodes.getNode();

            // See if any servers are using this node
            List<Server> serversOnNode = servers.getServersOnNode(child);
            int n = 0;
            if (serversOnNode != null && serversOnNode.size() > 0) {
                StringBuilder sb = new StringBuilder();
                for (Server server : serversOnNode) {
                    if (n > 0)
                        sb.append(", ");
                    sb.append(server.getName());
                    n++;
                }

                final String msg = localStrings.getLocalString(
                        "Node.referencedByInstance",
                        "Node {0} referenced in server instance(s): {1}.  Remove instances before removing node.", child.getName(), sb.toString());
                logger.log(Level.SEVERE, msg);
                throw new TransactionFailure(msg);
            }
View Full Code Here

                }
            }
        } else {
            //TODO properly handle the exceptions
            LocalStringManager localStrings =
                    new LocalStringManagerImpl(configBeanClass);
            ModuleXMLConfigurationFileParser parser = new ModuleXMLConfigurationFileParser(localStrings);
            try {
                defaults = parser.parseServiceConfiguration(getConfigurationFileUrl(configBeanClass, c.baseConfigurationFileName(), runtimeType).openStream());
            } catch (XMLStreamException e) {
                LOG.log(Level.SEVERE, "Cannot parse default module configuration", e);
View Full Code Here

                }
            }
        } else {
            //TODO properly handle the exceptions
            LocalStringManager localStrings =
                    new LocalStringManagerImpl(configBeanClass);
            ModuleXMLConfigurationFileParser parser = new ModuleXMLConfigurationFileParser(localStrings);
            try {
                defaults = parser.parseServiceConfiguration(getConfigurationFileUrl(configBeanClass, c.baseConfigurationFileName(), runtimeType).openStream());
            } catch (XMLStreamException e) {
                LOG.log(Level.SEVERE, "Cannot parse default module configuration", e);
View Full Code Here

        resolverType = delete.resolver();
        try {
            // we pass false for "useAnnotations" as the @Param declarations on
      // the target type are not used for the Delete method parameters.
            model = new GenericCommandModel(targetType, false, delete.cluster(), delete.i18n(),
                    new LocalStringManagerImpl(targetType),
                    habitat.<DomDocument>getService(DomDocument.class), commandName, false,
                    delete.resolver(), delete.decorator());
            if (logger.isLoggable(level)) {
                for (String paramName : model.getParametersNames()) {
                    CommandModel.ParamModel param = model.getModelFor(paramName);
View Full Code Here

        create = getAnnotation(targetMethod, Create.class);
        resolverType = create.resolver();
        try {
            model = new GenericCommandModel(targetType, true, create.cluster(), create.i18n(),
                    new LocalStringManagerImpl(targetType),
                    habitat.<DomDocument>getService(DomDocument.class),
                    commandName, false, create.resolver(), create.decorator());
            if (logger.isLoggable(level)) {
                for (String paramName : model.getParametersNames()) {
                    CommandModel.ParamModel param = model.getModelFor(paramName);
View Full Code Here

                }
            }
        } else {
            //TODO properly handle the exceptions
            LocalStringManager localStrings =
                    new LocalStringManagerImpl(configBeanClass);
            ModuleXMLConfigurationFileParser parser = new ModuleXMLConfigurationFileParser(localStrings);
            try {
                defaults = parser.parseServiceConfiguration(getConfigurationFileUrl(configBeanClass, c.baseConfigurationFileName(), runtimeType).openStream());
            } catch (XMLStreamException e) {
                LOG.log(Level.SEVERE, "Cannot parse default module configuration", e);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.util.LocalStringManagerImpl

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.