Package com.sun.enterprise.util

Examples of com.sun.enterprise.util.LocalStringManagerImpl


         */
        @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

        @Override
        public void decorate(AdminCommandContext context, final Server instance) throws TransactionFailure, PropertyVetoException {
            Config ourConfig = null;
            Cluster ourCluster = null;
            Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Server.class);
            Transaction tx = Transaction.getTransaction(instance);
            String configRef = instance.getConfigRef();
            Clusters clusters = domain.getClusters();

            if (tx == null) {
                throw new TransactionFailure(localStrings.getLocalString(
                        "noTransaction", "Internal Error - Cannot obtain transaction object"));
            }

/*
            if (node == null) {
                instance.setNode("localhost");  //remove?
            }
            else { */
            if (node != null){
                Node theNode = domain.getNodeNamed(node);
                if (theNode == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchNode", "Node {0} does not exist.", node));
                }

                /* 16034: see if instance creation is turned off on node */
                if (! theNode.instanceCreationAllowed()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "instanceCreationNotAllowed",
                            "Instance creation is disabled on node {0}.",
                            node));
                }
            }

            if (portBase != null) {
                PortBaseHelper pbh = new PortBaseHelper(instance, portBase, false, logger);
                pbh.verifyPortBase();
                pbh.setPorts();
            }

            // cluster instance using cluster config
            if (clusterName != null) {
                if (configRef != null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "Server.cannotSpecifyBothConfigAndCluster",
                            "A configuration name and cluster name cannot both be specified."));
                }
                boolean clusterExists = false;

                if (clusters != null) {
                    for (Cluster cluster : clusters.getCluster()) {
                        if (cluster != null && clusterName.equals(cluster.getName())) {
                            ourCluster = cluster;
                            String configName = cluster.getConfigRef();
                            instance.setConfigRef(configName);
                            clusterExists = true;
                            ourConfig = domain.getConfigNamed(configName);
                            break;
                        }
                    }
                }

                if (ourCluster == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchCluster", "Cluster {0} does not exist.", clusterName));
                }

                /*
                 * We are only setting this when the discovery uri list
                 * is set to "generate." Otherwise the user must set this
                 * properly to match the discovery uri list.
                 */
                if (ourCluster != null &&
                    ourCluster.getProperty("GMS_DISCOVERY_URI_LIST") != null &&
                    "generate".equals(
                        ourCluster.getProperty("GMS_DISCOVERY_URI_LIST").getValue())) {

                    final String propName = "GMS_LISTENER_PORT-" +
                        ourCluster.getName();

                    /*
                     * Currently all the instances will use the same port
                     * as the DAS. When/if we move to allow more than one
                     * instance/machine, the value here will need to be
                     * calculated differently.
                     */
                    Config serverConf = domain.getConfigNamed("server-config");
                    SystemProperty dasGmsPortProp =
                        serverConf.getSystemProperty(propName);
                    if (dasGmsPortProp != null) {
                        SystemProperty gmsListenerPortProp =
                            instance.createChild(SystemProperty.class);
                        gmsListenerPortProp.setName(propName);
                        gmsListenerPortProp.setValue(dasGmsPortProp.getValue());
                        instance.getSystemProperty().add(gmsListenerPortProp);
                    }
                }

                Cluster cluster = domain.getClusterNamed(clusterName);

                final String instanceName = instance.getName();
                try {
                    File configConfigDir = new File(env.getConfigDirPath(), cluster.getConfigRef());
                    new File(configConfigDir, "docroot").mkdirs();
                    new File(configConfigDir, "lib/ext").mkdirs();
                }
                catch (Exception e) {
                    // no big deal - just ignore
                }

                if (cluster != null) {
                    if (tx != null) {
                        Cluster c = tx.enroll(cluster);
                        ServerRef newServerRef = c.createChild(ServerRef.class);
                        newServerRef.setRef(instanceName);
                        if(lbEnabled != null){
                            newServerRef.setLbEnabled(lbEnabled);
                        } else {
                            //check whether all instances in cluster had lb-enabled set to false
                            List<ServerRef> serverRefs = c.getServerRef();
                            Iterator<ServerRef> serverRefIter = serverRefs.iterator();
                            boolean allLBEnabled = false;
                            while (!allLBEnabled && serverRefIter.hasNext()) {
                                ServerRef serverRef = serverRefIter.next();
                                allLBEnabled = allLBEnabled
                                        || Boolean.parseBoolean(serverRef.getLbEnabled());
                            }
                            //if there are existing instances in cluster
                            //and they all have lb-enabled to false, set it
                            //false for new instance as well
                            if (!allLBEnabled && serverRefs.size() > 0) {
                                newServerRef.setLbEnabled("false");
                            } else {
                                //check if system property exists and use that
                                String lbEnabledDefault =
                                        System.getProperty(lbEnabledSystemProperty);
                                if(lbEnabledDefault != null){
                                    newServerRef.setLbEnabled(lbEnabledDefault);
                                }
                            }
                        }
                        c.getServerRef().add(newServerRef);
                    }
                }
            }

            // instance using specified config
            if (configRef != null) {
                Config specifiedConfig = domain.getConfigs().getConfigByName(configRef);
                if (specifiedConfig == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchConfig", "Configuration {0} does not exist.", configRef));
                }
                ourConfig = specifiedConfig;
                try {
                    File configConfigDir = new File(env.getConfigDirPath(), specifiedConfig.getName());
                    new File(configConfigDir, "docroot").mkdirs();
                    new File(configConfigDir, "lib/ext").mkdirs();
                }
                catch (Exception e) {
                    // no big deal - just ignore
                }
            }

            //stand-alone instance using default-config if config not specified
            if (configRef == null && clusterName == null) {
                Config defaultConfig = domain.getConfigs().getConfigByName("default-config");

                if (defaultConfig == null) {
                    final String msg = localStrings.getLocalString(Server.class,
                            "Cluster.noDefaultConfig",
                            "Can''t find the default config (an element named \"default-config\") "
                            + "in domain.xml.  You may specify the name of an existing config element next time.");

                    logger.log(Level.SEVERE, msg);
View Full Code Here

        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

            existing = getPortInfoByPort(runtimePortInfo.getWsdlPort());
        }

        if( existing == null ) {
            if (portsInfo!=null && portsInfo.size()>0) {
                LocalStringManagerImpl localStrings =
                    new LocalStringManagerImpl(ServiceReferenceDescriptor.class);           
                DOLUtils.getDefaultLogger().warning(
                    localStrings.getLocalString("enterprise.deployment.unknownportforruntimeinfo",
                    "Runtime port info SEI {0} is not declared in standard service-ref " +
                    "deployment descriptors (under port-component-ref), is this intended ?",
                    new Object[] {runtimePortInfo.getServiceEndpointInterface()}));               
            }
            addPortInfo(runtimePortInfo);
View Full Code Here

            existing = getPortInfoByPort(runtimePortInfo.getWsdlPort());
        }

        if( existing == null ) {
            if (portsInfo!=null && portsInfo.size()>0) {
                LocalStringManagerImpl localStrings =
                    new LocalStringManagerImpl(ServiceReferenceDescriptor.class);           
                DOLUtils.getDefaultLogger().warning(
                    localStrings.getLocalString("enterprise.deployment.unknownportforruntimeinfo",
                    "Runtime port info SEI {0} is not declared in standard service-ref " +
                    "deployment descriptors (under port-component-ref), is this intended ?",
                    new Object[] {runtimePortInfo.getServiceEndpointInterface()}));               
            }
            addPortInfo(runtimePortInfo);
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,
                    AnnotationUtil.presentTransitive(ManagedJob.class, delete.decorator()),
                    delete.resolver(), delete.decorator());
            if (logger.isLoggable(level)) {
                for (String paramName : model.getParametersNames()) {
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, AnnotationUtil.presentTransitive(ManagedJob.class, create.decorator()), create.resolver(), create.decorator());
            if (logger.isLoggable(level)) {
                for (String paramName : model.getParametersNames()) {
                    CommandModel.ParamModel param = model.getModelFor(paramName);
View Full Code Here

        @Override
        public void decorate(AdminCommandContext context, final Server instance) throws TransactionFailure, PropertyVetoException {
            Config ourConfig = null;
            Cluster ourCluster = null;
            Logger logger = LogDomains.getLogger(Server.class, LogDomains.ADMIN_LOGGER);
            LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Server.class);
            Transaction tx = Transaction.getTransaction(instance);
            String configRef = instance.getConfigRef();
            Clusters clusters = domain.getClusters();

            if (tx == null) {
                throw new TransactionFailure(localStrings.getLocalString(
                        "noTransaction", "Internal Error - Cannot obtain transaction object"));
            }

            if (node != null){
                Node theNode = domain.getNodeNamed(node);
                if (theNode == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchNode", "Node {0} does not exist.", node));
                }

                /* 16034: see if instance creation is turned off on node */
                if (! theNode.instanceCreationAllowed()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "instanceCreationNotAllowed",
                            "Instance creation is disabled on node {0}.",
                            node));
                }
            }

            if (portBase != null) {
                PortBaseHelper pbh = new PortBaseHelper(instance, portBase, false, logger);
                pbh.verifyPortBase();
                pbh.setPorts();
            }

            // cluster instance using cluster config
            if (clusterName != null) {
                if (configRef != null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "Server.cannotSpecifyBothConfigAndCluster",
                            "A configuration name and cluster name cannot both be specified."));
                }
                boolean clusterExists = false;

                if (clusters != null) {
                    for (Cluster cluster : clusters.getCluster()) {
                        if (cluster != null && clusterName.equals(cluster.getName())) {
                            ourCluster = cluster;
                            String configName = cluster.getConfigRef();
                            instance.setConfigRef(configName);
                            clusterExists = true;
                            ourConfig = domain.getConfigNamed(configName);
                            break;
                        }
                    }
                }

                if (ourCluster == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchCluster", "Cluster {0} does not exist.", clusterName));
                }

                /*
                 * We are only setting this when the discovery uri list
                 * is set to "generate." Otherwise the user must set this
                 * properly to match the discovery uri list.
                 */
                if (ourCluster.getProperty("GMS_DISCOVERY_URI_LIST") != null &&
                    "generate".equals(
                        ourCluster.getProperty("GMS_DISCOVERY_URI_LIST").getValue())) {

                    final String propName = "GMS_LISTENER_PORT-" +
                        ourCluster.getName();

                    /*
                     * Currently all the instances will use the same port
                     * as the DAS. When/if we move to allow more than one
                     * instance/machine, the value here will need to be
                     * calculated differently.
                     */
                    Config serverConf = domain.getConfigNamed("server-config");
                    SystemProperty dasGmsPortProp =
                        serverConf.getSystemProperty(propName);
                    if (dasGmsPortProp != null) {
                        SystemProperty gmsListenerPortProp =
                            instance.createChild(SystemProperty.class);
                        gmsListenerPortProp.setName(propName);
                        gmsListenerPortProp.setValue(dasGmsPortProp.getValue());
                        instance.getSystemProperty().add(gmsListenerPortProp);
                    }
                }

                final String instanceName = instance.getName();
                File configConfigDir = new File(env.getConfigDirPath(), ourCluster.getConfigRef());
                File docroot = new File(configConfigDir, "docroot");
                if (!docroot.exists() && !docroot.mkdirs()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noMkdir", "Cannot create configuration specific directory {0}", "docroot"));
                }
                File lib = new File(configConfigDir, "lib/ext");
                if (!lib.exists() && !lib.mkdirs()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noMkdir", "Cannot create configuration specific directory {0}", "lib/ext"));
                }

                Cluster c = tx.enroll(ourCluster);
                ServerRef newServerRef = c.createChild(ServerRef.class);
                newServerRef.setRef(instanceName);
                if (lbEnabled != null) {
                    newServerRef.setLbEnabled(lbEnabled);
                } else {
                    //check whether all instances in cluster had lb-enabled set to false
                    List<ServerRef> serverRefs = c.getServerRef();
                    Iterator<ServerRef> serverRefIter = serverRefs.iterator();
                    boolean allLBEnabled = false;
                    while (!allLBEnabled && serverRefIter.hasNext()) {
                        ServerRef serverRef = serverRefIter.next();
                        allLBEnabled = allLBEnabled
                                || Boolean.parseBoolean(serverRef.getLbEnabled());
                    }
                    //if there are existing instances in cluster
                    //and they all have lb-enabled to false, set it
                    //false for new instance as well
                    if (!allLBEnabled && serverRefs.size() > 0) {
                        newServerRef.setLbEnabled("false");
                    } else {
                        //check if system property exists and use that
                        String lbEnabledDefault =
                                System.getProperty(lbEnabledSystemProperty);
                        if (lbEnabledDefault != null) {
                            newServerRef.setLbEnabled(lbEnabledDefault);
                        }
                    }
                }
                c.getServerRef().add(newServerRef);
            }

            // instance using specified config
            if (configRef != null) {
                Config specifiedConfig = domain.getConfigs().getConfigByName(configRef);
                if (specifiedConfig == null) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noSuchConfig", "Configuration {0} does not exist.", configRef));
                }
                ourConfig = specifiedConfig;
                File configConfigDir = new File(env.getConfigDirPath(), specifiedConfig.getName());
                File docroot = new File(configConfigDir, "docroot");
                if (!docroot.exists() && !docroot.mkdirs()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noMkdir", "Cannot create configuration specific directory {0}", "docroot"));
                }
                File lib = new File(configConfigDir, "lib/ext");
                if (!lib.exists() && !lib.mkdirs()) {
                    throw new TransactionFailure(localStrings.getLocalString(
                            "noMkdir", "Cannot create configuration specific directory {0}", "lib/ext"));
                }
             }

            //stand-alone instance using default-config if config not specified
            if (configRef == null && clusterName == null) {
                Config defaultConfig = domain.getConfigs().getConfigByName("default-config");

                if (defaultConfig == null) {
                    final String msg = localStrings.getLocalString(Server.class,
                            "Cluster.noDefaultConfig",
                            "Can''t find the default config (an element named \"default-config\") "
                            + "in domain.xml.  You may specify the name of an existing config element next time.");

                    logger.log(Level.SEVERE, 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

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.