⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractjettymojo.java

📁 jetty SERVER連接資料庫用的軟體
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            this.systemProperties = new SystemProperties();                for (Enumeration keys = properties.keys(); keys.hasMoreElements();  )        {            String key = (String)keys.nextElement();            if ( ! systemProperties.containsSystemProperty(key) )            {                SystemProperty prop = new SystemProperty();                prop.setKey(key);                prop.setValue(properties.getProperty(key));                                this.systemProperties.setSystemProperty(prop);            }        }            }        public void setSystemProperties(SystemProperties systemProperties)    {        if (this.systemProperties == null)            this.systemProperties = systemProperties;        else        {            Iterator itor = systemProperties.getSystemProperties().iterator();            while (itor.hasNext())            {                SystemProperty prop = (SystemProperty)itor.next();                this.systemProperties.setSystemProperty(prop);            }           }    }    public File getJettyXmlFile ()    {        return this.jettyConfig;    }    public JettyPluginServer getServer ()    {        return this.server;    }    public void setServer (JettyPluginServer server)    {        this.server = server;    }    public void setScanList (ArrayList list)    {        this.scanList = new ArrayList(list);    }    public ArrayList getScanList ()    {        return this.scanList;    }    public void setScannerListeners (ArrayList listeners)    {        this.scannerListeners = new ArrayList(listeners);    }    public ArrayList getScannerListeners ()    {        return this.scannerListeners;    }    public Scanner getScanner ()    {        return scanner;    }    public void execute() throws MojoExecutionException, MojoFailureException    {        getLog().info("Configuring Jetty for project: " + getProject().getName());        PluginLog.setLog(getLog());        checkPomConfiguration();        startJetty();    }    public void startJetty () throws MojoExecutionException    {        try        {            getLog().debug("Starting Jetty Server ...");            printSystemProperties();            setServer(createServer());            //apply any config from a jetty.xml file first which is able to            //be overwritten by config in the pom.xml            applyJettyXml ();            JettyPluginServer plugin=getServer();            // if the user hasn't configured their project's pom to use a            // different set of connectors,            // use the default            Object[] configuredConnectors = getConfiguredConnectors();            plugin.setConnectors(configuredConnectors);            Object[] connectors = plugin.getConnectors();            if (connectors == null|| connectors.length == 0)            {                //if a SystemProperty -Djetty.port=<portnum> has been supplied, use that as the default port                configuredConnectors = new Object[] { plugin.createDefaultConnector(System.getProperty(PORT_SYSPROPERTY, null)) };                plugin.setConnectors(configuredConnectors);            }            //set up a RequestLog if one is provided            if (getConfiguredRequestLog() != null)                getServer().setRequestLog(getConfiguredRequestLog());            //set up the webapp and any context provided            getServer().configureHandlers();            configureWebApplication();            getServer().addWebApplication(webAppConfig);            // set up security realms            Object[] configuredRealms = getConfiguredUserRealms();            for (int i = 0; (configuredRealms != null) && i < configuredRealms.length; i++)                getLog().debug(configuredRealms[i].getClass().getName() + ": "+ configuredRealms[i].toString());            plugin.setUserRealms(configuredRealms);            //do any other configuration required by the            //particular Jetty version            finishConfigurationBeforeStart();            // start Jetty            server.start();            getLog().info("Started Jetty Server");                        if(stopPort>0 && stopKey!=null)            {                org.mortbay.jetty.plugin.util.Monitor monitor = new org.mortbay.jetty.plugin.util.Monitor(stopPort, stopKey, new Server[]{(Server)server.getProxiedObject()}, !daemon);                monitor.start();            }                        // start the scanner thread (if necessary) on the main webapp            configureScanner ();            startScanner();                        // start the new line scanner thread if necessary            startConsoleScanner();            // keep the thread going if not in daemon mode            if (!daemon)            {                server.join();            }        }        catch (Exception e)        {            throw new MojoExecutionException("Failure", e);        }        finally        {            if (!daemon)            {                getLog().info("Jetty server exiting.");            }                    }            }            public abstract void restartWebApp(boolean reconfigureScanner) throws Exception;    /**     * Subclasses should invoke this to setup basic info     * on the webapp     *      * @throws MojoExecutionException     */    public void configureWebApplication () throws Exception    {        //use EITHER a <webAppConfig> element or the now deprecated <contextPath>, <tmpDirectory>, <webDefaultXml>, <overrideWebXml>        //way of doing things        if (webAppConfig == null)        {            webAppConfig = new Jetty6PluginWebAppContext();            webAppConfig.setContextPath((getContextPath().startsWith("/") ? getContextPath() : "/"+ getContextPath()));            if (getTmpDirectory() != null)                webAppConfig.setTempDirectory(getTmpDirectory());            if (getWebDefaultXml() != null)                webAppConfig.setDefaultsDescriptor(getWebDefaultXml().getCanonicalPath());            if (getOverrideWebXml() != null)                webAppConfig.setOverrideDescriptor(getOverrideWebXml().getCanonicalPath());        }        getLog().info("Context path = " + webAppConfig.getContextPath());        getLog().info("Tmp directory = "+ " determined at runtime");        getLog().info("Web defaults = "+(webAppConfig.getDefaultsDescriptor()==null?" jetty default":webAppConfig.getDefaultsDescriptor()));        getLog().info("Web overrides = "+(webAppConfig.getOverrideDescriptor()==null?" none":webAppConfig.getOverrideDescriptor()));    }    /**     * Run a scanner thread on the given list of files and directories, calling     * stop/start on the given list of LifeCycle objects if any of the watched     * files change.     *     */    private void startScanner()    {        // check if scanning is enabled        if (getScanIntervalSeconds() <= 0) return;        // check if reload is manual. It disables file scanning        if ( "manual".equalsIgnoreCase( reload ) )        {            // issue a warning if both scanIntervalSeconds and reload            // are enabled            getLog().warn("scanIntervalSeconds is set to " + scanIntervalSeconds + " but will be IGNORED due to manual reloading");            return;        }        scanner = new Scanner();        scanner.setReportExistingFilesOnStartup(false);        scanner.setScanInterval(getScanIntervalSeconds());        scanner.setScanDirs(getScanList());        scanner.setRecursive(true);        List listeners = getScannerListeners();        Iterator itor = (listeners==null?null:listeners.iterator());        while (itor!=null && itor.hasNext())            scanner.addListener((Scanner.Listener)itor.next());        getLog().info("Starting scanner at interval of " + getScanIntervalSeconds()+ " seconds.");        scanner.start();    }        /**     * Run a thread that monitors the console input to detect ENTER hits.     */    protected void startConsoleScanner()     {        if ( "manual".equalsIgnoreCase( reload ) )        {            getLog().info("Console reloading is ENABLED. Hit ENTER on the console to restart the context.");            consoleScanner = new ConsoleScanner(this);            consoleScanner.start();        }            }    private void printSystemProperties ()    {        // print out which system properties were set up        if (getLog().isDebugEnabled())        {            if (systemProperties != null)            {                Iterator itor = systemProperties.getSystemProperties().iterator();                while (itor.hasNext())                {                    SystemProperty prop = (SystemProperty)itor.next();                    getLog().debug("Property "+prop.getName()+"="+prop.getValue()+" was "+ (prop.isSet() ? "set" : "skipped"));                }            }        }    }    /**     * Try and find a jetty-web.xml file, using some     * historical naming conventions if necessary.     * @param webInfDir     * @return     */    public File findJettyWebXmlFile (File webInfDir)    {        if (webInfDir == null)            return null;        if (!webInfDir.exists())            return null;        File f = new File (webInfDir, "jetty-web.xml");        if (f.exists())            return f;        //try some historical alternatives        f = new File (webInfDir, "web-jetty.xml");        if (f.exists())            return f;        f = new File (webInfDir, "jetty6-web.xml");        if (f.exists())            return f;                return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -