Jetty9 - Removed code duplication for calculating the jetty version.

This commit is contained in:
Simone Bordet 2012-09-06 09:16:34 +02:00
parent d74d7a7a09
commit 1c306ad89c
2 changed files with 21 additions and 31 deletions

View File

@ -26,7 +26,6 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
@ -41,6 +40,7 @@ import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.URIUtil;
@ -69,17 +69,6 @@ public class Server extends HandlerWrapper implements Attributes
{
private static final Logger LOG = Log.getLogger(Server.class);
private static final String __version;
static
{
if (Server.class.getPackage()!=null &&
"Eclipse.org - Jetty".equals(Server.class.getPackage().getImplementationVendor()) &&
Server.class.getPackage().getImplementationVersion()!=null)
__version=Server.class.getPackage().getImplementationVersion();
else
__version=System.getProperty("jetty.version","9.x.y.z-SNAPSHOT");
}
private final Container _container;
private final AttributesMap _attributes = new AttributesMap();
private final ThreadPool _threadPool;
@ -144,7 +133,7 @@ public class Server extends HandlerWrapper implements Attributes
@ManagedAttribute("version of this server")
public static String getVersion()
{
return __version;
return Jetty.VERSION;
}
/* ------------------------------------------------------------ */
@ -289,8 +278,8 @@ public class Server extends HandlerWrapper implements Attributes
if (getStopAtShutdown())
ShutdownThread.register(this);
LOG.info("jetty-"+__version);
HttpGenerator.setServerVersion(__version);
LOG.info("jetty-"+getVersion());
HttpGenerator.setServerVersion(getVersion());
MultiException mex=new MultiException();
try
@ -359,10 +348,6 @@ public class Server extends HandlerWrapper implements Attributes
if (!future.isDone())
future.get(Math.max(1L,stop_by-System.currentTimeMillis()),TimeUnit.MILLISECONDS);
}
catch (ExecutionException e)
{
mex.add(e.getCause());
}
catch (Exception e)
{
mex.add(e.getCause());

View File

@ -1,15 +1,20 @@
//========================================================================
//Copyright 2012-2012 Mort Bay Consulting Pty. Ltd.
//------------------------------------------------------------------------
//All rights reserved. This program and the accompanying materials
//are made available under the terms of the Eclipse Public License v1.0
//and Apache License v2.0 which accompanies this distribution.
//The Eclipse Public License is available at
//http://www.eclipse.org/legal/epl-v10.html
//The Apache License v2.0 is available at
//http://www.opensource.org/licenses/apache2.0.php
//You may elect to redistribute this code under either of these licenses.
//========================================================================
//
// ========================================================================
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util;