jnr.posix.POSIX.setenv()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中jnr.posix.POSIX.setenv()方法的一些代码示例,展示了POSIX.setenv()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.setenv()方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:setenv

POSIX.setenv介绍

暂无

代码示例

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
  3. }

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. return posix().setenv(envName, envValue, overwrite);
  3. }

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
  3. }

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
  3. }

代码示例来源:origin: com.github.jnr/jnr-posix

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. return posix().setenv(envName, envValue, overwrite);
  3. }

代码示例来源:origin: com.github.jnr/jnr-posix

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
  3. }

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. return posix().setenv(envName, envValue, overwrite);
  3. }

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

  1. public int setenv(String envName, String envValue, int overwrite) {
  2. return posix().setenv(envName, envValue, overwrite);
  3. }

代码示例来源:origin: jerlang/jerlang

  1. /**
  2. * Sets a new Value for the environment variable VarName.
  3. *
  4. * http://www.erlang.org/doc/man/os.html#putenv-2
  5. */
  6. public static Term putenv_2(Str varName, Str value) {
  7. posix.setenv(varName.string(), value.string(), 1);
  8. return Boolean.am_true;
  9. }

代码示例来源:origin: org.jruby/jruby-complete

  1. private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  2. if (!isStringLike(key)) {
  3. throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  4. }
  5. RubyString keyAsStr = key.convertToString();
  6. if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  7. if (value == context.nil) {
  8. return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  9. }
  10. if (!isStringLike(value)) {
  11. throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  12. }
  13. RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  14. if (updateRealENV) {
  15. final POSIX posix = context.runtime.getPosix();
  16. final String keyAsJava = keyAsStr.asJavaString();
  17. // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
  18. if (valueAsStr == context.nil) {
  19. synchronized (Object.class) { posix.unsetenv(keyAsJava); }
  20. } else {
  21. final String valueAsJava = valueAsStr.asJavaString();
  22. synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
  23. }
  24. }
  25. return super.op_aset(context, keyAsStr, valueAsStr);
  26. }

代码示例来源:origin: org.jruby/jruby-core

  1. private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  2. if (!isStringLike(key)) {
  3. throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  4. }
  5. RubyString keyAsStr = key.convertToString();
  6. if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  7. if (value == context.nil) {
  8. return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  9. }
  10. if (!isStringLike(value)) {
  11. throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  12. }
  13. RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  14. if (updateRealENV) {
  15. final POSIX posix = context.runtime.getPosix();
  16. final String keyAsJava = keyAsStr.asJavaString();
  17. // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
  18. if (valueAsStr == context.nil) {
  19. synchronized (Object.class) { posix.unsetenv(keyAsJava); }
  20. } else {
  21. final String valueAsJava = valueAsStr.asJavaString();
  22. synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
  23. }
  24. }
  25. return super.op_aset(context, keyAsStr, valueAsStr);
  26. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  2. if (!key.respondsTo("to_str")) {
  3. throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  4. }
  5. if (!value.respondsTo("to_str") && !value.isNil()) {
  6. throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  7. }
  8. if (! caseSensitive) {
  9. key = getCorrectKey(key, context);
  10. }
  11. if (value.isNil()) {
  12. return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  13. }
  14. IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  15. IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
  16. normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  17. if (updateRealENV) {
  18. POSIX posix = getRuntime().getPosix();
  19. String keyAsJava = keyAsStr.asJavaString();
  20. // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
  21. if (valueAsStr == getRuntime().getNil()) {
  22. synchronized (Object.class) { posix.unsetenv(keyAsJava); }
  23. } else {
  24. synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
  25. }
  26. }
  27. return super.op_aset(context, keyAsStr, valueAsStr);
  28. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  2. if (!key.respondsTo("to_str")) {
  3. throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  4. }
  5. if (!value.respondsTo("to_str") && !value.isNil()) {
  6. throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  7. }
  8. if (! caseSensitive) {
  9. key = getCorrectKey(key, context);
  10. }
  11. if (value.isNil()) {
  12. return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  13. }
  14. IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  15. IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
  16. normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  17. if (updateRealENV) {
  18. POSIX posix = getRuntime().getPosix();
  19. String keyAsJava = keyAsStr.asJavaString();
  20. // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
  21. if (valueAsStr == getRuntime().getNil()) {
  22. synchronized (Object.class) { posix.unsetenv(keyAsJava); }
  23. } else {
  24. synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
  25. }
  26. }
  27. return super.op_aset(context, keyAsStr, valueAsStr);
  28. }

相关文章

POSIX类方法