diff --git a/.gitignore b/.gitignore index 53d3192..44fae6f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .settings .gradle .maven -build \ No newline at end of file +build +/bin/ diff --git a/build.gradle b/build.gradle index 8d18dd9..d2748b1 100755 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'java' apply plugin: 'maven' -group = 'net.rubygrapefruit' -archivesBaseName = 'platform' +group = 'com.github.boukefalos' +archivesBaseName = 'jlibloader' version = '0.1' uploadArchives { diff --git a/src/main/java/net/rubygrapefruit/platform/Native.java b/src/main/java/com/github/boukefalos/jlibloader/Native.java similarity index 83% rename from src/main/java/net/rubygrapefruit/platform/Native.java rename to src/main/java/com/github/boukefalos/jlibloader/Native.java index 4bd3804..f51030c 100755 --- a/src/main/java/net/rubygrapefruit/platform/Native.java +++ b/src/main/java/com/github/boukefalos/jlibloader/Native.java @@ -14,18 +14,14 @@ * limitations under the License. */ -package net.rubygrapefruit.platform; +package com.github.boukefalos.jlibloader; import java.io.File; -import net.rubygrapefruit.platform.internal.NativeLibraryLoader; -import net.rubygrapefruit.platform.internal.NativeLibraryLocator; -import net.rubygrapefruit.platform.internal.Platform; +import com.github.boukefalos.jlibloader.internal.NativeLibraryLoader; +import com.github.boukefalos.jlibloader.internal.NativeLibraryLocator; +import com.github.boukefalos.jlibloader.internal.Platform; -/** - * Provides access to the native integrations. Use {@link #get(Class)} to load a particular integration. - */ -@ThreadSafe public class Native { private static NativeLibraryLoader loader; @@ -41,7 +37,6 @@ public class Native { * @throws NativeLibraryUnavailableException When the native library is not available on the current machine. * @throws NativeException On failure to load the native library. */ - @ThreadSafe static public void init(File extractDir) throws NativeLibraryUnavailableException, NativeException { synchronized (Native.class) { if (loader == null) { diff --git a/src/main/java/net/rubygrapefruit/platform/NativeException.java b/src/main/java/com/github/boukefalos/jlibloader/NativeException.java similarity index 83% rename from src/main/java/net/rubygrapefruit/platform/NativeException.java rename to src/main/java/com/github/boukefalos/jlibloader/NativeException.java index e5a6cee..fba325f 100644 --- a/src/main/java/net/rubygrapefruit/platform/NativeException.java +++ b/src/main/java/com/github/boukefalos/jlibloader/NativeException.java @@ -14,10 +14,12 @@ * limitations under the License. */ -package net.rubygrapefruit.platform; +package com.github.boukefalos.jlibloader; public class NativeException extends RuntimeException { - public NativeException(String message, Throwable throwable) { + private static final long serialVersionUID = 1L; + + public NativeException(String message, Throwable throwable) { super(message, throwable); } diff --git a/src/main/java/net/rubygrapefruit/platform/NativeLibraryUnavailableException.java b/src/main/java/com/github/boukefalos/jlibloader/NativeLibraryUnavailableException.java similarity index 95% rename from src/main/java/net/rubygrapefruit/platform/NativeLibraryUnavailableException.java rename to src/main/java/com/github/boukefalos/jlibloader/NativeLibraryUnavailableException.java index 266d850..d21d05f 100644 --- a/src/main/java/net/rubygrapefruit/platform/NativeLibraryUnavailableException.java +++ b/src/main/java/com/github/boukefalos/jlibloader/NativeLibraryUnavailableException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.rubygrapefruit.platform; +package com.github.boukefalos.jlibloader; /** * Thrown when a given integration is not available for the current machine. diff --git a/src/main/java/net/rubygrapefruit/platform/internal/LibraryDef.java b/src/main/java/com/github/boukefalos/jlibloader/internal/LibraryDef.java similarity index 93% rename from src/main/java/net/rubygrapefruit/platform/internal/LibraryDef.java rename to src/main/java/com/github/boukefalos/jlibloader/internal/LibraryDef.java index 6dfacd6..0805de0 100644 --- a/src/main/java/net/rubygrapefruit/platform/internal/LibraryDef.java +++ b/src/main/java/com/github/boukefalos/jlibloader/internal/LibraryDef.java @@ -1,4 +1,4 @@ -package net.rubygrapefruit.platform.internal; +package com.github.boukefalos.jlibloader.internal; public class LibraryDef { final String group; diff --git a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLoader.java b/src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLoader.java similarity index 88% rename from src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLoader.java rename to src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLoader.java index 3d421f0..984ce99 100755 --- a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLoader.java +++ b/src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLoader.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package net.rubygrapefruit.platform.internal; - -import net.rubygrapefruit.platform.NativeException; -import net.rubygrapefruit.platform.NativeLibraryUnavailableException; +package com.github.boukefalos.jlibloader.internal; import java.io.File; import java.util.HashSet; import java.util.Set; +import com.github.boukefalos.jlibloader.NativeException; +import com.github.boukefalos.jlibloader.NativeLibraryUnavailableException; + public class NativeLibraryLoader { private final Set loaded = new HashSet(); private final Platform platform; diff --git a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java b/src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLocator.java similarity index 90% rename from src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java rename to src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLocator.java index 1d5cdc7..1599640 100755 --- a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java +++ b/src/main/java/com/github/boukefalos/jlibloader/internal/NativeLibraryLocator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.rubygrapefruit.platform.internal; +package com.github.boukefalos.jlibloader.internal; import java.io.File; import java.io.FileOutputStream; @@ -24,7 +24,7 @@ import java.io.OutputStream; import java.io.RandomAccessFile; import java.net.URL; -import net.rubygrapefruit.platform.NativeException; +import com.github.boukefalos.jlibloader.NativeException; public class NativeLibraryLocator { private final File extractDir; @@ -83,7 +83,10 @@ public class NativeLibraryLocator { if (libFile.isFile()) { return libFile; } - + libFile = new File(String.format("build/binaries/mainSharedLibrary/%s/%s", libraryDef.platform.replace("-", "_"), libraryDef.name)); + if (libFile.isFile()) { + return libFile; + } return null; } diff --git a/src/main/java/net/rubygrapefruit/platform/internal/Platform.java b/src/main/java/com/github/boukefalos/jlibloader/internal/Platform.java old mode 100755 new mode 100644 similarity index 94% rename from src/main/java/net/rubygrapefruit/platform/internal/Platform.java rename to src/main/java/com/github/boukefalos/jlibloader/internal/Platform.java index 0900503..fe50658 --- a/src/main/java/net/rubygrapefruit/platform/internal/Platform.java +++ b/src/main/java/com/github/boukefalos/jlibloader/internal/Platform.java @@ -1,180 +1,180 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform.internal; - -import net.rubygrapefruit.platform.NativeLibraryUnavailableException; - -public abstract class Platform { - private static Platform platform; - - public static Platform current() { - synchronized (Platform.class) { - if (platform == null) { - String osName = getOperatingSystem().toLowerCase(); - String arch = getArchitecture(); - if (osName.contains("windows")) { - if (arch.equals("x86")) { - platform = new Window32Bit(); - } - else if (arch.equals("amd64")) { - platform = new Window64Bit(); - } - } else if (osName.contains("linux")) { - if (arch.equals("amd64") || arch.equals("x86_64")) { - platform = new Linux64Bit(); - } - else if (arch.equals("i386") || arch.equals("x86")) { - platform = new Linux32Bit(); - } - } else if (osName.contains("os x") || osName.contains("darwin")) { - if (arch.equals("i386")) { - platform = new OsX32Bit(); - } - else if (arch.equals("x86_64") || arch.equals("amd64") || arch.equals("universal")) { - platform = new OsX64Bit(); - } - } - else if (osName.contains("freebsd")) { - if (arch.equals("amd64")) { - platform = new FreeBSD64Bit(); - } - else if (arch.equals("i386") || arch.equals("x86")) { - platform = new FreeBSD32Bit(); - } - } - if (platform == null) { - platform = new Unsupported(); - } - } - return platform; - } - } - - public boolean isWindows() { - return false; - } - - @Override - public String toString() { - return String.format("%s %s", getOperatingSystem(), getArchitecture()); - } - - public String getLibraryName(String name) { - throw new NativeLibraryUnavailableException(String.format("Native library is not available for %s.", toString())); - } - - public abstract String getId(); - - private static String getOperatingSystem() { - return System.getProperty("os.name"); - } - - private static String getArchitecture() { - return System.getProperty("os.arch"); - } - - private abstract static class Windows extends Platform { - @Override - public boolean isWindows() { - return true; - } - - @Override - public String getLibraryName(String name) { - return String.format("%s.dll", name); - } - } - - private static class Window32Bit extends Windows { - @Override - public String getId() { - return "windows-i386"; - } - } - - private static class Window64Bit extends Windows { - @Override - public String getId() { - return "windows-amd64"; - } - } - - private static abstract class Posix extends Platform {} - - private abstract static class Unix extends Posix { - @Override - public String getLibraryName(String name) { - return String.format("lib%s.so", name); - } - } - - private static class Linux32Bit extends Unix { - @Override - public String getId() { - return "linux-i386"; - } - } - - private static class Linux64Bit extends Unix { - @Override - public String getId() { - return "linux-amd64"; - } - } - - private static class FreeBSD32Bit extends Unix { - @Override - public String getId() { - return "freebsd-i386"; - } - } - - private static class FreeBSD64Bit extends Unix { - @Override - public String getId() { - return "freebsd-amd64"; - } - } - - private static abstract class OsX extends Posix { - @Override - public String getLibraryName(String name) { - return String.format("lib%s.dylib", name); - } - } - - private static class OsX32Bit extends OsX { - @Override - public String getId() { - return "osx-i386"; - } - } - - private static class OsX64Bit extends OsX { - @Override - public String getId() { - return "osx-amd64"; - } - } - - private static class Unsupported extends Platform { - @Override - public String getId() { - throw new UnsupportedOperationException(); - } - } +/* + * Copyright 2012 Adam Murdoch + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.github.boukefalos.jlibloader.internal; + +import com.github.boukefalos.jlibloader.NativeLibraryUnavailableException; + +public abstract class Platform { + private static Platform platform; + + public static Platform current() { + synchronized (Platform.class) { + if (platform == null) { + String osName = getOperatingSystem().toLowerCase(); + String arch = getArchitecture(); + if (osName.contains("windows")) { + if (arch.equals("x86")) { + platform = new Window32Bit(); + } + else if (arch.equals("amd64")) { + platform = new Window64Bit(); + } + } else if (osName.contains("linux")) { + if (arch.equals("amd64") || arch.equals("x86_64")) { + platform = new Linux64Bit(); + } + else if (arch.equals("i386") || arch.equals("x86")) { + platform = new Linux32Bit(); + } + } else if (osName.contains("os x") || osName.contains("darwin")) { + if (arch.equals("i386")) { + platform = new OsX32Bit(); + } + else if (arch.equals("x86_64") || arch.equals("amd64") || arch.equals("universal")) { + platform = new OsX64Bit(); + } + } + else if (osName.contains("freebsd")) { + if (arch.equals("amd64")) { + platform = new FreeBSD64Bit(); + } + else if (arch.equals("i386") || arch.equals("x86")) { + platform = new FreeBSD32Bit(); + } + } + if (platform == null) { + platform = new Unsupported(); + } + } + return platform; + } + } + + public boolean isWindows() { + return false; + } + + @Override + public String toString() { + return String.format("%s %s", getOperatingSystem(), getArchitecture()); + } + + public String getLibraryName(String name) { + throw new NativeLibraryUnavailableException(String.format("Native library is not available for %s.", toString())); + } + + public abstract String getId(); + + private static String getOperatingSystem() { + return System.getProperty("os.name"); + } + + private static String getArchitecture() { + return System.getProperty("os.arch"); + } + + private abstract static class Windows extends Platform { + @Override + public boolean isWindows() { + return true; + } + + @Override + public String getLibraryName(String name) { + return String.format("%s.dll", name); + } + } + + private static class Window32Bit extends Windows { + @Override + public String getId() { + return "windows-i386"; + } + } + + private static class Window64Bit extends Windows { + @Override + public String getId() { + return "windows-amd64"; + } + } + + private static abstract class Posix extends Platform {} + + private abstract static class Unix extends Posix { + @Override + public String getLibraryName(String name) { + return String.format("lib%s.so", name); + } + } + + private static class Linux32Bit extends Unix { + @Override + public String getId() { + return "linux-i386"; + } + } + + private static class Linux64Bit extends Unix { + @Override + public String getId() { + return "linux-amd64"; + } + } + + private static class FreeBSD32Bit extends Unix { + @Override + public String getId() { + return "freebsd-i386"; + } + } + + private static class FreeBSD64Bit extends Unix { + @Override + public String getId() { + return "freebsd-amd64"; + } + } + + private static abstract class OsX extends Posix { + @Override + public String getLibraryName(String name) { + return String.format("lib%s.dylib", name); + } + } + + private static class OsX32Bit extends OsX { + @Override + public String getId() { + return "osx-i386"; + } + } + + private static class OsX64Bit extends OsX { + @Override + public String getId() { + return "osx-amd64"; + } + } + + private static class Unsupported extends Platform { + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + } } \ No newline at end of file diff --git a/src/main/java/net/rubygrapefruit/platform/FileSystem.java b/src/main/java/net/rubygrapefruit/platform/FileSystem.java deleted file mode 100644 index 3ba12c2..0000000 --- a/src/main/java/net/rubygrapefruit/platform/FileSystem.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.io.File; - -/** - * Information about a file system. This is a snapshot view and does not change. - */ -@ThreadSafe -public interface FileSystem { - /** - * Returns the root directory of this file system. - */ - @ThreadSafe - File getMountPoint(); - - /** - * Returns the operating system specific name for the type of this file system. - */ - @ThreadSafe - String getFileSystemType(); - - /** - * Returns true if this file system is a remote file system, or false if local. - */ - @ThreadSafe - boolean isRemote(); - - /** - * Returns true if this file system is performance case sensitive searches. - */ - @ThreadSafe - boolean isCaseSensitive(); - - /** - * Returns true if this file system preserves file name case. - */ - @ThreadSafe - boolean isCasePreserving(); - - /** - * Returns the operating system specific name for this file system. - */ - @ThreadSafe - String getDeviceName(); -} diff --git a/src/main/java/net/rubygrapefruit/platform/FileSystems.java b/src/main/java/net/rubygrapefruit/platform/FileSystems.java deleted file mode 100644 index da7d916..0000000 --- a/src/main/java/net/rubygrapefruit/platform/FileSystems.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.util.List; - -/** - * Provides access to the file systems of the current machine. - */ -@ThreadSafe -public interface FileSystems extends NativeIntegration { - /** - * Returns the set of all file systems for the current machine. - * - * @return The set of file systems. Never returns null. - * @throws NativeException On failure. - */ - @ThreadSafe - List getFileSystems() throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/MissingRegistryEntryException.java b/src/main/java/net/rubygrapefruit/platform/MissingRegistryEntryException.java deleted file mode 100644 index 4d79688..0000000 --- a/src/main/java/net/rubygrapefruit/platform/MissingRegistryEntryException.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.rubygrapefruit.platform; - -/** - * Thrown when attempting to query an unknown registry key or value. - */ -public class MissingRegistryEntryException extends NativeException { - public MissingRegistryEntryException(String message) { - super(message); - } -} diff --git a/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java b/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java deleted file mode 100644 index c7a6ff2..0000000 --- a/src/main/java/net/rubygrapefruit/platform/NativeIntegration.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * A marker interface that represents a native integration. - */ -public interface NativeIntegration { -} diff --git a/src/main/java/net/rubygrapefruit/platform/PosixFile.java b/src/main/java/net/rubygrapefruit/platform/PosixFile.java deleted file mode 100644 index 0884949..0000000 --- a/src/main/java/net/rubygrapefruit/platform/PosixFile.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * Provides some information about a file. This is a snapshot and does not change. - */ -@ThreadSafe -public interface PosixFile { - enum Type {File, Directory, Symlink, Other, Missing} - - /** - * Returns the type of this file. - */ - Type getType(); - - /** - * Returns the mode of this file. - */ - int getMode(); -} diff --git a/src/main/java/net/rubygrapefruit/platform/PosixFiles.java b/src/main/java/net/rubygrapefruit/platform/PosixFiles.java deleted file mode 100644 index 39b1db1..0000000 --- a/src/main/java/net/rubygrapefruit/platform/PosixFiles.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.io.File; - -/** - * Functions to query and modify a file's POSIX meta-data. - */ -@ThreadSafe -public interface PosixFiles extends NativeIntegration { - /** - * Sets the mode for the given file. - * - * @throws NativeException On failure. - */ - @ThreadSafe - void setMode(File path, int perms) throws NativeException; - - /** - * Gets the mode for the given file. - * - * @throws NativeException On failure. - */ - @ThreadSafe - int getMode(File path) throws NativeException; - - /** - * Creates a symbolic link with given contents. - * - * @throws NativeException On failure. - */ - @ThreadSafe - void symlink(File link, String contents) throws NativeException; - - /** - * Reads the contents of a symbolic link. - * - * @throws NativeException On failure. - */ - @ThreadSafe - String readLink(File link) throws NativeException; - - /** - * Returns basic information about the given file. - * - * @throws NativeException On failure. - */ - @ThreadSafe - PosixFile stat(File path) throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/Process.java b/src/main/java/net/rubygrapefruit/platform/Process.java deleted file mode 100755 index dbb98a7..0000000 --- a/src/main/java/net/rubygrapefruit/platform/Process.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.io.File; - -/** - * Functions to query and modify a process' state. - */ -@ThreadSafe -public interface Process extends NativeIntegration { - /** - * Returns the process identifier. - * - * @throws NativeException On failure. - */ - @ThreadSafe - int getProcessId() throws NativeException; - - /** - * Returns the process' current working directory. - * - * @throws NativeException On failure. - */ - @ThreadSafe - File getWorkingDirectory() throws NativeException; - - /** - * Sets the process' working directory. - * - * @throws NativeException On failure. - */ - @ThreadSafe - void setWorkingDirectory(File directory) throws NativeException; - - /** - * Get the value of an environment variable. - * - * @return The value or null if no such environment variable. Also returns null for an environment variable whose - * value is an empty string. - * @throws NativeException On failure. - */ - @ThreadSafe - String getEnvironmentVariable(String name) throws NativeException; - - /** - * Sets the value of an environment variable. - * - * @param value the new value. Use null or an empty string to remove the environment variable. Note that on some - * platforms it is not possible to remove the environment variable safely. On such platforms, the value is set to an - * empty string instead. - * @throws NativeException On failure. - */ - @ThreadSafe - void setEnvironmentVariable(String name, String value) throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/ProcessLauncher.java b/src/main/java/net/rubygrapefruit/platform/ProcessLauncher.java deleted file mode 100644 index 8070878..0000000 --- a/src/main/java/net/rubygrapefruit/platform/ProcessLauncher.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.lang.Process; - -/** - * Used to start processes, taking care of some platform-specific issues when launching processes concurrently or - * launching processes that will run in the background. - */ -@ThreadSafe -public interface ProcessLauncher extends NativeIntegration { - /** - * Starts a process from the given settings. - * - * @param processBuilder The process settings. - * @return the process - * @throws NativeException On failure to start the process. - */ - @ThreadSafe - Process start(ProcessBuilder processBuilder) throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/SystemInfo.java b/src/main/java/net/rubygrapefruit/platform/SystemInfo.java deleted file mode 100644 index 393ecc5..0000000 --- a/src/main/java/net/rubygrapefruit/platform/SystemInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * Provides access to some system information. This is a snapshot view and does not change. - */ -@ThreadSafe -public interface SystemInfo extends NativeIntegration { - enum Architecture { i386, amd64 } - - /** - * Returns the name of the kernel for the current operating system. - */ - @ThreadSafe - String getKernelName(); - - /** - * Returns the version of the kernel for the current operating system. - */ - @ThreadSafe - String getKernelVersion(); - - /** - * Returns the machine architecture name, as reported by the operating system. - */ - @ThreadSafe - String getArchitectureName(); - - /** - * Returns the machine architecture, as reported by the operating system. - */ - @ThreadSafe - Architecture getArchitecture(); -} diff --git a/src/main/java/net/rubygrapefruit/platform/Terminal.java b/src/main/java/net/rubygrapefruit/platform/Terminal.java deleted file mode 100644 index 66d2689..0000000 --- a/src/main/java/net/rubygrapefruit/platform/Terminal.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * Allows the terminal/console to be manipulated. - * - *

On UNIX based platforms, this provides access to the terminal. On Windows platforms, this provides access to the - * console. - *

- */ -@ThreadSafe -public interface Terminal { - /** - * Basic colors supported by a terminal. - */ - enum Color { - // Don't change the order of these. They are in ANSI order - Black, Red, Green, Yellow, Blue, Magenta, Cyan, White - } - - /** - * Returns true if this terminal supports setting text attributes, such as bold. - */ - @ThreadSafe - boolean supportsTextAttributes(); - - /** - * Returns true if this terminal supports setting output colors. - */ - @ThreadSafe - boolean supportsColor(); - - /** - * Returns true if this terminal supports moving the cursor. - */ - @ThreadSafe - boolean supportsCursorMotion(); - - /** - * Returns the size of the terminal. Supported by all terminals. - * - * @return The current terminal size. Never returns null. - * @throws NativeException On failure. - */ - @ThreadSafe - TerminalSize getTerminalSize() throws NativeException; - - /** - * Sets the terminal foreground color, if supported. Does nothing if this terminal does not support setting the - * foreground color. - * - * @throws NativeException On failure. - */ - @ThreadSafe - Terminal foreground(Color color) throws NativeException; - - /** - * Switches the terminal to bold mode, if supported. Does nothing if this terminal does not support bold mode. - * - * @throws NativeException On failure. - */ - @ThreadSafe - Terminal bold() throws NativeException; - - /** - * Switches the terminal to normal mode. Supported by all terminals. - * - * @throws NativeException On failure. - */ - @ThreadSafe - Terminal normal() throws NativeException; - - /** - * Switches the terminal to normal mode and restores default colors. Supported by all terminals. - * - * @throws NativeException On failure. - */ - @ThreadSafe - Terminal reset() throws NativeException; - - /** - * Moves the cursor the given number of characters to the left. - * - * @throws NativeException On failure, or if this terminal does not support cursor motion. - */ - @ThreadSafe - Terminal cursorLeft(int count) throws NativeException; - - /** - * Moves the cursor the given number of characters to the right. - * - * @throws NativeException On failure, or if this terminal does not support cursor motion. - */ - @ThreadSafe - Terminal cursorRight(int count) throws NativeException; - - /** - * Moves the cursor the given number of characters up. - * - * @throws NativeException On failure, or if this terminal does not support cursor motion. - */ - @ThreadSafe - Terminal cursorUp(int count) throws NativeException; - - /** - * Moves the cursor the given number of characters down. - * - * @throws NativeException On failure, or if this terminal does not support cursor motion. - */ - @ThreadSafe - Terminal cursorDown(int count) throws NativeException; - - /** - * Moves the cursor to the start of the current line. - * - * @throws NativeException On failure, or if this terminal does not support cursor motion. - */ - @ThreadSafe - Terminal cursorStartOfLine() throws NativeException; - - /** - * Clears characters from the cursor position to the end of the current line. - * - * @throws NativeException On failure, or if this terminal does not support clearing. - */ - @ThreadSafe - Terminal clearToEndOfLine() throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/TerminalSize.java b/src/main/java/net/rubygrapefruit/platform/TerminalSize.java deleted file mode 100644 index 5ed2502..0000000 --- a/src/main/java/net/rubygrapefruit/platform/TerminalSize.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * The size of a terminal. This is a snapshot view and does not change. - */ -@ThreadSafe -public interface TerminalSize { - /** - * Returns the number of character columns in the terminal. - */ - @ThreadSafe - public int getCols(); - - /** - * Returns the number of character rows in the terminal. - */ - @ThreadSafe - public int getRows(); -} diff --git a/src/main/java/net/rubygrapefruit/platform/Terminals.java b/src/main/java/net/rubygrapefruit/platform/Terminals.java deleted file mode 100644 index 609e41c..0000000 --- a/src/main/java/net/rubygrapefruit/platform/Terminals.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -/** - * Provides access to the terminal/console. - * - *

On UNIX based platforms, this provides access to the terminal. On Windows platforms, this provides access to the - * console. - *

- */ -@ThreadSafe -public interface Terminals extends NativeIntegration { - /** - * System outputs. - */ - enum Output {Stdout, Stderr} - - /** - * Returns true if the given output is attached to a terminal. - * - * @throws NativeException On failure. - */ - @ThreadSafe - boolean isTerminal(Output output) throws NativeException; - - /** - * Returns the terminal attached to the given output. - * - * @return The terminal. Never returns null. - * @throws NativeException When the output is not attached to a terminal. - */ - @ThreadSafe - Terminal getTerminal(Output output) throws NativeException; -} diff --git a/src/main/java/net/rubygrapefruit/platform/ThreadSafe.java b/src/main/java/net/rubygrapefruit/platform/ThreadSafe.java deleted file mode 100644 index c5aef91..0000000 --- a/src/main/java/net/rubygrapefruit/platform/ThreadSafe.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.rubygrapefruit.platform; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; - -/** - * Indicates that the given class or method is thread safe. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -public @interface ThreadSafe { -} diff --git a/src/main/java/net/rubygrapefruit/platform/WindowsRegistry.java b/src/main/java/net/rubygrapefruit/platform/WindowsRegistry.java deleted file mode 100644 index 13be0fd..0000000 --- a/src/main/java/net/rubygrapefruit/platform/WindowsRegistry.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.rubygrapefruit.platform; - -import java.util.List; - -@ThreadSafe -public interface WindowsRegistry extends NativeIntegration { - public enum Key { - HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER - } - - /** - * Returns a registry key value as a String. - * - * @throws NativeException On failure. - * @throws MissingRegistryEntryException When the requested key or value does not exist. - */ - String getStringValue(Key key, String subkey, String value) throws NativeException; - - /** - * Lists the subkeys of a registry key. - * - * @throws NativeException On failure. - * @throws MissingRegistryEntryException When the requested key does not exist. - */ - List getSubkeys(Key key, String subkey) throws NativeException; - - /** - * Lists the value names of a registry key. - * - * @throws NativeException On failure. - * @throws MissingRegistryEntryException When the requested key does not exist. - */ - List getValueNames(Key key, String subkey) throws NativeException; - -} diff --git a/src/main/java/net/rubygrapefruit/platform/package-info.java b/src/main/java/net/rubygrapefruit/platform/package-info.java deleted file mode 100644 index 069f368..0000000 --- a/src/main/java/net/rubygrapefruit/platform/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012 Adam Murdoch - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * The native integrations. Use {@link net.rubygrapefruit.platform.Native#get(Class)} to access a native integration. - */ -package net.rubygrapefruit.platform; \ No newline at end of file