Package org.apache.openejb.webapp.common

Examples of org.apache.openejb.webapp.common.Alerts


     * configuration, then this method will just leave the logging.properties file alone
     */
    public void installConfigFiles() {
        final File openejbCoreJar = paths.getOpenEJBCoreJar();
        final File confDir = paths.getCatalinaConfDir();
        final Alerts alerts = this.alerts;

        if (openejbCoreJar == null) {
            // the core jar contains the config files
            return;
        }
        JarFile coreJar;
        try {
            coreJar = new JarFile(openejbCoreJar);
        } catch (IOException e) {
            return;
        }

        //
        // conf/openejb.xml
        //

        File openEjbXmlFile = new File(confDir, "openejb.xml");
        if (!openEjbXmlFile.exists()) {
            // read in the openejb.xml file from the openejb core jar
            String openEjbXml = Installers.readEntry(coreJar, "default.openejb.conf", alerts);
            if (openEjbXml != null) {
                if (Installers.writeAll(openEjbXmlFile, openEjbXml, alerts)) {
                    alerts.addInfo("Copy openejb.xml to conf");
                }
            }
        }


        //
        // conf/logging.properties
        //
        String openejbLoggingProps = Installers.readEntry(coreJar, "logging.properties", alerts);
        if (openejbLoggingProps != null) {
            File loggingPropsFile = new File(confDir, "logging.properties");
            String newLoggingProps = null;
            if (!loggingPropsFile.exists()) {
                newLoggingProps = openejbLoggingProps;
            } else {
                String loggingPropsOriginal = Installers.readAll(loggingPropsFile, alerts);
                if (!loggingPropsOriginal.toLowerCase().contains("openejb")) {
                    // strip off license header
                    String[] strings = openejbLoggingProps.split("## --*", 3);
                    if (strings.length == 3) {
                        openejbLoggingProps = strings[2];
                    }
                    // append our properties
                    newLoggingProps = loggingPropsOriginal +
                            "\r\n" +
                            "############################################################\r\n" +
                            "# OpenEJB Logging Configuration.\r\n" +
                            "############################################################\r\n" +
                            openejbLoggingProps + "\r\n";
                }
            }
            if (newLoggingProps != null) {
                if (Installers.writeAll(loggingPropsFile, newLoggingProps, alerts)) {
                    alerts.addInfo("Append OpenEJB config to logging.properties");
                }
            }
        }

        //
        // conf/web.xml
        //

        JarFile openejbTomcatCommonJar;
        try {
            openejbTomcatCommonJar = new JarFile(paths.geOpenEJBTomcatCommonJar());
        } catch (IOException e) {
            return;
        }
        File webXmlFile = new File(confDir, "web.xml");
        if (webXmlFile.exists()) {
            if (!webXmlFile.delete()) {
                alerts.addError("can't replace web.xml");
            }
        }
        String webXml = Installers.readEntry(openejbTomcatCommonJar, "conf/web.xml", alerts);
        if (Installers.writeAll(webXmlFile, webXml, alerts)) {
            alerts.addInfo("Set jasper in production mode in TomEE web.xml");
        }
    }
View Full Code Here


     * configuration, then this method will just leave the logging.properties file alone
     */
    public void installConfigFiles() {
        final File openejbCoreJar = paths.getOpenEJBCoreJar();
        final File confDir = paths.getCatalinaConfDir();
        final Alerts alerts = this.alerts;

        if (openejbCoreJar == null) {
            // the core jar contains the config files
            return;
        }
        JarFile coreJar;
        try {
            coreJar = new JarFile(openejbCoreJar);
        } catch (IOException e) {
            return;
        }

        //
        // conf/openejb.xml
        //

        File openEjbXmlFile = new File(confDir, "openejb.xml");
        if (!openEjbXmlFile.exists()) {
            // read in the openejb.xml file from the openejb core jar
            String openEjbXml = Installers.readEntry(coreJar, "default.openejb.conf", alerts);
            if (openEjbXml != null) {
                if (Installers.writeAll(openEjbXmlFile, openEjbXml, alerts)) {
                    alerts.addInfo("Copy openejb.xml to conf");
                }
            }
        }


        //
        // conf/logging.properties
        //
        String openejbLoggingProps = Installers.readEntry(coreJar, "logging.properties", alerts);
        if (openejbLoggingProps != null) {
            File loggingPropsFile = new File(confDir, "logging.properties");
            String newLoggingProps = null;
            if (!loggingPropsFile.exists()) {
                newLoggingProps = openejbLoggingProps;
            } else {
                String loggingPropsOriginal = Installers.readAll(loggingPropsFile, alerts);
                if (!loggingPropsOriginal.toLowerCase().contains("openejb")) {
                    // strip off license header
                    String[] strings = openejbLoggingProps.split("## --*", 3);
                    if (strings.length == 3) {
                        openejbLoggingProps = strings[2];
                    }
                    // append our properties
                    newLoggingProps = loggingPropsOriginal +
                            "\r\n" +
                            "############################################################\r\n" +
                            "# OpenEJB Logging Configuration.\r\n" +
                            "############################################################\r\n" +
                            openejbLoggingProps + "\r\n";
                }
            }
            if (newLoggingProps != null) {
                if (Installers.writeAll(loggingPropsFile, newLoggingProps, alerts)) {
                    alerts.addInfo("Append OpenEJB config to logging.properties");
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.webapp.common.Alerts

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.