Skip to content

Commit

Permalink
#40 #4 Drop SLF4J/Logback dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
harawata committed Jan 26, 2021
1 parent 36a7a99 commit a0618b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 35 deletions.
21 changes: 5 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,17 @@
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/net/harawata/appdirs/AppDirsFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,26 @@

package net.harawata.appdirs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.harawata.appdirs.impl.MacOSXAppDirs;
import net.harawata.appdirs.impl.ShellFolderResolver;
import net.harawata.appdirs.impl.UnixAppDirs;
import net.harawata.appdirs.impl.WindowsAppDirs;
import net.harawata.appdirs.impl.WindowsFolderResolver;

public class AppDirsFactory {
private static final Logger logger = LoggerFactory
.getLogger(AppDirsFactory.class);

private AppDirsFactory() {
super();
}

public static AppDirs getInstance() {
String os = System.getProperty("os.name").toLowerCase();
if (os.startsWith("mac os x")) {
logger.debug("os.name {} is resolved to Mac OS X", os);
return new MacOSXAppDirs();
} else if (os.startsWith("windows")) {
logger.debug("os.name {} is resolved to Windows", os);
WindowsFolderResolver folderResolver = new ShellFolderResolver();
return new WindowsAppDirs(folderResolver);
} else {
// Assume other *nix.
logger.debug("os.name {} is resolved to *nix", os);
return new UnixAppDirs();
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/harawata/appdirs/impl/ShellFolderResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

package net.harawata.appdirs.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.KnownFolders;
import com.sun.jna.platform.win32.Shell32Util;
Expand All @@ -27,26 +24,19 @@
import net.harawata.appdirs.impl.WindowsAppDirs.FolderId;

public class ShellFolderResolver implements WindowsFolderResolver {
private static final Logger logger = LoggerFactory
.getLogger(ShellFolderResolver.class);

public String resolveFolder(FolderId folderId) {
try {
logger.debug("Invoking SHGetKnownFolderPath");
return Shell32Util.getKnownFolderPath(convertFolderIdToGuid(folderId));
} catch (Win32Exception e) {
logger.error("SHGetKnownFolderPath returns an error: {}",
e.getErrorCode());
throw new AppDirsException(
"SHGetKnownFolderPath returns an error: " + e.getErrorCode());
} catch (UnsatisfiedLinkError e) {
// Fallback for pre-vista OSes. #5
try {
logger.debug("SHGetKnownFolderPath failed. Trying SHGetFolderPath.");
int folder = convertFolderIdToCsidl(folderId);
return Shell32Util.getFolderPath(folder);
} catch (Win32Exception e2) {
logger.error("SHGetFolderPath returns an error: {}", e2);
throw new AppDirsException(
"SHGetFolderPath returns an error: " + e2.getErrorCode());
}
Expand Down

0 comments on commit a0618b3

Please sign in to comment.