-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nfs41: add possibility to specify server implementation details
Motivation: The EXCHANGE_ID operation allows server to expose his implementation information. However this information in nfs4j is hardcoded and can't be used by implementers. Modification: Update NFSServerV41#Builder to allow custom server implementations. Result: a possibility to specify server implementation details. Acked-by: Paul Millar Target: master
- Loading branch information
Showing
9 changed files
with
215 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2009 - 2023 Deutsches Elektronen-Synchroton, | ||
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY | ||
* | ||
* This library is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Library General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public | ||
* License along with this program (see the file COPYING.LIB for more | ||
* details); if not, write to the Free Software Foundation, Inc., | ||
* 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
package org.dcache.nfs.util; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.security.CodeSource; | ||
import java.security.ProtectionDomain; | ||
import java.time.Instant; | ||
import java.time.format.DateTimeParseException; | ||
import java.util.Optional; | ||
import java.util.jar.Attributes; | ||
import java.util.jar.JarInputStream; | ||
import java.util.jar.Manifest; | ||
|
||
public class Misc { | ||
|
||
private Misc() {} | ||
|
||
/** | ||
* Get package build time. This method uses {@code Build-Time} attribute in the | ||
* jar Manifest file. | ||
* @return optional instant of package build time. | ||
*/ | ||
public static Optional<Instant> getBuildTime() { | ||
|
||
try { | ||
|
||
ProtectionDomain pd = Misc.class.getProtectionDomain(); | ||
CodeSource cs = pd.getCodeSource(); | ||
URL u = cs.getLocation(); | ||
|
||
InputStream is = u.openStream(); | ||
JarInputStream jis = new JarInputStream(is); | ||
Manifest m = jis.getManifest(); | ||
|
||
if (m != null) { | ||
Attributes as = m.getMainAttributes(); | ||
String buildTime = as.getValue("Build-Time"); | ||
if (buildTime != null) { | ||
return Optional.of(Instant.parse(buildTime)); | ||
} | ||
} | ||
|
||
} catch (IOException | DateTimeParseException e) { | ||
// bad luck | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.