当前位置: 首页>>代码示例>>Java>>正文


Java LastErrorException.getCause方法代码示例

本文整理汇总了Java中com.sun.jna.LastErrorException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java LastErrorException.getCause方法的具体用法?Java LastErrorException.getCause怎么用?Java LastErrorException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jna.LastErrorException的用法示例。


在下文中一共展示了LastErrorException.getCause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPlatformSocketOption

import com.sun.jna.LastErrorException; //导入方法依赖的package包/类
@Override
protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt,
    Integer optVal, int optSize) throws NativeErrorException {
  try {
    switch (optName) {
      case OPT_TCP_KEEPALIVE_THRESHOLD:
        // value required is in millis
        final IntByReference timeout = new IntByReference(optVal.intValue() * 1000);
        int result = setsockopt(sockfd, level, optName, timeout, optSize);
        if (result == 0) {
          // setting ABORT_THRESHOLD to be same as KEEPALIVE_THRESHOLD
          return setsockopt(sockfd, level, OPT_TCP_KEEPALIVE_ABORT_THRESHOLD, timeout, optSize);
        } else {
          return result;
        }
      default:
        throw new UnsupportedOperationException("unsupported option " + opt);
    }
  } catch (LastErrorException le) {
    throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause());
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:NativeCallsJNAImpl.java

示例2: setEnvironment

import com.sun.jna.LastErrorException; //导入方法依赖的package包/类
/**
 * @see NativeCalls#setEnvironment(String, String)
 */
@Override
public synchronized void setEnvironment(final String name, final String value) {
  if (name == null) {
    throw new UnsupportedOperationException("setEnvironment() for name=NULL");
  }
  int res = -1;
  Throwable cause = null;
  try {
    if (value != null) {
      res = setenv(name, value, 1);
    } else {
      res = unsetenv(name);
    }
  } catch (LastErrorException le) {
    cause = new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause());
  }
  if (res != 0) {
    throw new IllegalArgumentException(
        "setEnvironment: given name=" + name + " (value=" + value + ')', cause);
  }
  // also change in java cached map
  if (javaEnv != null) {
    if (value != null) {
      javaEnv.put(name, value);
    } else {
      javaEnv.remove(name);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:33,代码来源:NativeCallsJNAImpl.java

示例3: setEnvironment

import com.sun.jna.LastErrorException; //导入方法依赖的package包/类
/**
 * @see NativeCalls#setEnvironment(String, String)
 */
@Override
public synchronized void setEnvironment(final String name,
    final String value) {
  if (name == null) {
    throw new UnsupportedOperationException(
        "setEnvironment() for name=NULL");
  }
  int res = -1;
  Throwable cause = null;
  try {
    if (value != null) {
      res = setenv(name, value, 1);
    }
    else {
      res = unsetenv(name);
    }
  } catch (LastErrorException le) {
    cause = new NativeErrorException(le.getMessage(), le.getErrorCode(),
        le.getCause());
  }
  if (res != 0) {
    throw new IllegalArgumentException("setEnvironment: given name=" + name
        + " (value=" + value + ')', cause);
  }
  // also change in java cached map
  if (javaEnv != null) {
    if (value != null) {
      javaEnv.put(name, value);
    }
    else {
      javaEnv.remove(name);
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:38,代码来源:NativeCallsJNAImpl.java

示例4: setPlatformSocketOption

import com.sun.jna.LastErrorException; //导入方法依赖的package包/类
@Override
protected int setPlatformSocketOption(int sockfd, int level, int optName,
    TCPSocketOptions opt, Integer optVal, int optSize)
    throws NativeErrorException {
  try {
    return setsockopt(sockfd, level, optName,
        new IntByReference(optVal.intValue()), optSize);
  } catch (LastErrorException le) {
    throw new NativeErrorException(le.getMessage(), le.getErrorCode(),
        le.getCause());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:13,代码来源:NativeCallsJNAImpl.java

示例5: setSocketOptions

import com.sun.jna.LastErrorException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Map<TCPSocketOptions, Throwable> setSocketOptions(Socket sock,
    InputStream sockStream, Map<TCPSocketOptions, Object> optValueMap)
    throws UnsupportedOperationException {
  final TcpKeepAlive optValue = new TcpKeepAlive();
  final int optSize = (Integer.SIZE / Byte.SIZE) * 3;
  TCPSocketOptions errorOpt = null;
  Throwable error = null;
  for (Map.Entry<TCPSocketOptions, Object> e : optValueMap.entrySet()) {
    TCPSocketOptions opt = e.getKey();
    Object value = e.getValue();
    // all options currently require an integer argument
    if (value == null || !(value instanceof Integer)) {
      throw new IllegalArgumentException("bad argument type "
          + (value != null ? value.getClass().getName() : "NULL") + " for "
          + opt);
    }
    switch (opt) {
      case OPT_KEEPIDLE:
        optValue.enabled = 1;
        // in millis
        optValue.keepalivetime = ((Integer)value).intValue() * 1000;
        break;
      case OPT_KEEPINTVL:
        optValue.enabled = 1;
        // in millis
        optValue.keepaliveinterval = ((Integer)value).intValue() * 1000;
        break;
      case OPT_KEEPCNT:
        errorOpt = opt;
        error = new UnsupportedOperationException(
            getUnsupportedSocketOptionMessage(opt));
        break;
      default:
        throw new UnsupportedOperationException("unknown option " + opt);
    }
  }
  final int sockfd = getSocketKernelDescriptor(sock, sockStream);
  final IntByReference nBytes = new IntByReference(0);
  try {
    if (WSAIoctl(new NativeLong(sockfd), SIO_KEEPALIVE_VALS, optValue,
        optSize, null, 0, nBytes, null, null) != 0) {
      errorOpt = TCPSocketOptions.OPT_KEEPIDLE; // using some option here
      error = new SocketException(getOSType() + ": error setting options: "
          + optValueMap);
    }
  } catch (LastErrorException le) {
    // check if the error indicates that option is not supported
    errorOpt = TCPSocketOptions.OPT_KEEPIDLE; // using some option here
    if (le.getErrorCode() == WSAENOPROTOOPT) {
      error = new UnsupportedOperationException(
          getUnsupportedSocketOptionMessage(errorOpt),
          new NativeErrorException(le.getMessage(), le.getErrorCode(),
              le.getCause()));
    }
    else {
      final SocketException se = new SocketException(getOSType()
          + ": failed to set options: " + optValueMap);
      se.initCause(le);
      error = se;
    }
  }
  return errorOpt != null ? Collections.singletonMap(errorOpt, error)
      : null;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:69,代码来源:NativeCallsJNAImpl.java


注:本文中的com.sun.jna.LastErrorException.getCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。