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


Java UnknownServiceException类代码示例

本文整理汇总了Java中java.net.UnknownServiceException的典型用法代码示例。如果您正苦于以下问题:Java UnknownServiceException类的具体用法?Java UnknownServiceException怎么用?Java UnknownServiceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: cleartextCallsFailWhenCleartextIsDisabled

import java.net.UnknownServiceException; //导入依赖的package包/类
@Test public void cleartextCallsFailWhenCleartextIsDisabled() throws Exception {
  // Configure the client with only TLS configurations. No cleartext!
  client = client.newBuilder()
      .connectionSpecs(Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS))
      .build();

  server.enqueue(new MockResponse());

  Request request = new Request.Builder().url(server.url("/")).build();
  try {
    client.newCall(request).execute();
    fail();
  } catch (UnknownServiceException expected) {
    assertEquals("CLEARTEXT communication not enabled for client", expected.getMessage());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:CallTest.java

示例2: getInputStream

import java.net.UnknownServiceException; //导入依赖的package包/类
public InputStream getInputStream() throws IOException, UnknownServiceException {
    connect();

    if (iStream == null) {
        try {
            if (fo.isFolder()) {
                iStream = new FIS(fo);
            } else {
                iStream = fo.getInputStream();
            }
        } catch (FileNotFoundException e) {
            ExternalUtil.exception(e);
            throw e;
        }
    }

    return iStream;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FileURL.java

示例3: convert

import java.net.UnknownServiceException; //导入依赖的package包/类
@Override
public T convert(@NonNull ResponseBody value) throws IOException {
    if (adapter != null && gson != null) {
        JsonReader jsonReader = gson.newJsonReader(value.charStream());
        try {
            T data = adapter.read(jsonReader);
            if (data == null) throw new UnknownServiceException("server back data is null");
            if (data instanceof ApiResult) {
                ApiResult apiResult = (ApiResult) data;
                if (!ResponseHelper.isSuccess(apiResult)) {
                    throw new UnknownServiceException(apiResult.getMsg() == null ? "unknow error" : apiResult.getMsg());
                }
            }
            return data;
        } finally {
            value.close();
        }
    } else {
        return null;
    }
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:22,代码来源:GsonResponseBodyConverter.java

示例4: convert

import java.net.UnknownServiceException; //导入依赖的package包/类
@Override
public T convert(ResponseBody value) throws IOException {
    if (adapter != null && gson != null) {
        JsonReader jsonReader = gson.newJsonReader(value.charStream());
        try {
            T data = adapter.read(jsonReader);
            if (data == null) throw new UnknownServiceException("server back data is null");
            if (data instanceof ApiResult) {
                ApiResult apiResult = (ApiResult) data;
                if (!ApiException.isSuccess(apiResult)) {
                    throw new UnknownServiceException(apiResult.getMsg() == null ? "unknow error" : apiResult.getMsg());
                }
            }
            return data;
        } finally {
            value.close();
        }
    } else {
        return null;
    }
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:22,代码来源:GsonResponseBodyConverter.java

示例5: configureSecureSocket

import java.net.UnknownServiceException; //导入依赖的package包/类
public ConnectionSpec configureSecureSocket(SSLSocket sslSocket) throws IOException {
    ConnectionSpec tlsConfiguration = null;
    int size = this.connectionSpecs.size();
    for (int i = this.nextModeIndex; i < size; i++) {
        ConnectionSpec connectionSpec = (ConnectionSpec) this.connectionSpecs.get(i);
        if (connectionSpec.isCompatible(sslSocket)) {
            tlsConfiguration = connectionSpec;
            this.nextModeIndex = i + 1;
            break;
        }
    }
    if (tlsConfiguration == null) {
        throw new UnknownServiceException("Unable to find acceptable protocols. isFallback="
                + this.isFallback + ", modes=" + this.connectionSpecs + ", supported " +
                "protocols=" + Arrays.toString(sslSocket.getEnabledProtocols()));
    }
    this.isFallbackPossible = isFallbackPossible(sslSocket);
    Internal.instance.apply(tlsConfiguration, sslSocket, this.isFallback);
    return tlsConfiguration;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:ConnectionSpecSelector.java

示例6: cleartextCallsFailWhenCleartextIsDisabled

import java.net.UnknownServiceException; //导入依赖的package包/类
@Test public void cleartextCallsFailWhenCleartextIsDisabled() throws Exception {
  // Configure the client with only TLS configurations. No cleartext!
  client = client.newBuilder()
      .connectionSpecs(Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS))
      .build();

  server.enqueue(new MockResponse());

  Request request = new Request.Builder().url(server.url("/")).build();
  try {
    client.newCall(request).execute();
    fail();
  } catch (UnknownServiceException expected) {
    assertTrue(expected.getMessage().contains("CLEARTEXT communication not supported"));
  }
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:17,代码来源:CallTest.java

示例7: onFailure

import java.net.UnknownServiceException; //导入依赖的package包/类
@Override
public void onFailure(@NonNull Call<MediathekAnswer> call, @NonNull Throwable t) {
	adapter.setLoading(false);
	swipeRefreshLayout.setRefreshing(false);

	if (!call.isCanceled()) {
		// ignore canceled calls, because it most likely was canceled by app code
		Timber.e(t);

		if (t instanceof SSLHandshakeException || t instanceof UnknownServiceException) {
			showError(R.string.error_mediathek_ssl_error);
		} else {
			showError(R.string.error_mediathek_info_not_available);
		}
	}
}
 
开发者ID:cemrich,项目名称:zapp,代码行数:17,代码来源:MediathekListFragment.java

示例8: setSupportedMethods

import java.net.UnknownServiceException; //导入依赖的package包/类
/**
 * Sets the supported RTSP method by the server
 * 
 * @throws IOException
 */
protected void setSupportedMethods() throws IOException {
	options();
	if (isSuccessfullResponse()) {
		String pub = responses.findValue("Public");
		if (pub != null) {
			StringTokenizer st = new StringTokenizer(pub, ",");
			if (st.countTokens() > 0) {
				List<String> l = new ArrayList<String>();
				l.add(OPTIONS);
				String s;
				while (st.hasMoreTokens()) {
					s = st.nextToken().trim();
					if (Arrays.binarySearch(getPlatformPossibleMethods(), s) >= 0) {
						Debug.println(" ADD SRV METHOD " + s);
						l.add(s);
					}
				}
				this.supportedMethods = l.toArray(new String[l.size()]);
				return;
			}
		}
	}
	throw new UnknownServiceException("Cannot retreive server supported rtsp methods.");
}
 
开发者ID:tyazid,项目名称:RTSP-Java-UrlConnection,代码行数:30,代码来源:RtspURLConnection.java

示例9: getService

import java.net.UnknownServiceException; //导入依赖的package包/类
/**
 * Returns an authorized Bitbucket API service.
 * @param authorizationCode authorization code received by the redirection
 * endpoint
 * @return authorized Bitbucket API service
 * @throws IOException if an I/O exception has occurred
 * @throws NullPointerException if this object has no client credentials
 * @since 5.0
 */
public Service getService(String authorizationCode)
        throws IOException {
    AuthorizationCodeFlow flow = getAuthorizationCodeFlow(true);
    AuthorizationCodeTokenRequest request
            = flow.newTokenRequest(authorizationCode);
    if (redirectionEndpointUri != null) {
        request.setRedirectUri(redirectionEndpointUri);
    }

    TokenResponse tokenResponse = request.execute();
    String tokenType = tokenResponse.getTokenType();
    if (!tokenType.equals(BEARER_TOKEN_TYPE)) {
        throw new UnknownServiceException("Unsupported token type");
    }
    return new RestService(
            flow.createAndStoreCredential(tokenResponse, getUser()));
}
 
开发者ID:kazssym,项目名称:bitbucket-api-client-java,代码行数:27,代码来源:OAuthClient.java

示例10: getConnection

import java.net.UnknownServiceException; //导入依赖的package包/类
/**
 * @throws NoRouteToHostException if the process is terminated.
 * @throws UnknownServiceException if the process has no known monitor address.
 */
@Nonnull
public QApiConnection getConnection() throws IOException {
    if (monitor == null)
        throw new UnknownServiceException("No monitor address known.");

    try {
        // If this succeeds, then we have exited.
        int exitValue = process.exitValue();
        connection = null;
        throw new NoRouteToHostException("Process terminated with exit code " + exitValue);
    } catch (IllegalThreadStateException e) {
    }

    synchronized (lock) {
        if (connection != null)
            return connection;
        connection = new QApiConnection(monitor);
        return connection;
    }
}
 
开发者ID:shevek,项目名称:qemu-java,代码行数:25,代码来源:QEmuProcess.java

示例11: getInputStream

import java.net.UnknownServiceException; //导入依赖的package包/类
public InputStream getInputStream() throws IOException
{
    if (this.connected == false)
        connect();

    if (node instanceof VStreamReadable)
    {
        return ((VStreamReadable) node).createInputStream();
    }
    else if (node instanceof VDir)
    {
        // Directories do not have stream read methods.
        // possibly the 'index.html' file is meant, but
        // here we don't know what the caller wants.
        throw new UnknownServiceException("VRS: Location is a directory:" + node);
    }
    else
    {
        throw new UnknownServiceException("VRS: Location is not streamreadable:" + node);
    }
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:22,代码来源:VRLConnection.java

示例12: getOutputStream

import java.net.UnknownServiceException; //导入依赖的package包/类
public OutputStream getOutputStream() throws IOException
{
    if (this.connected == false)
        connect();

    if (node instanceof VStreamReadable)
    {
        return ((VStreamWritable) node).createOutputStream();
    }
    else if (node instanceof VDir)
    {
        // Directories do not have stream read methods.
        // possibly the 'index.html' file is meant, but
        // here we don't know what the caller wants.
        throw new UnknownServiceException("VRS: Location is a directory:" + node);
    }
    else
    {
        throw new UnknownServiceException("VRS: location is not streamwritable:" + node);
    }
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:22,代码来源:VRLConnection.java

示例13: configureSecureSocket

import java.net.UnknownServiceException; //导入依赖的package包/类
/**
 * Configures the supplied {@link SSLSocket} to connect to the specified host using an appropriate
 * {@link ConnectionSpec}. Returns the chosen {@link ConnectionSpec}, never {@code null}.
 *
 * @throws IOException if the socket does not support any of the TLS modes available
 */
public ConnectionSpec configureSecureSocket(SSLSocket sslSocket) throws IOException {
  ConnectionSpec tlsConfiguration = null;
  for (int i = nextModeIndex, size = connectionSpecs.size(); i < size; i++) {
    ConnectionSpec connectionSpec = connectionSpecs.get(i);
    if (connectionSpec.isCompatible(sslSocket)) {
      tlsConfiguration = connectionSpec;
      nextModeIndex = i + 1;
      break;
    }
  }

  if (tlsConfiguration == null) {
    // This may be the first time a connection has been attempted and the socket does not support
    // any the required protocols, or it may be a retry (but this socket supports fewer
    // protocols than was suggested by a prior socket).
    throw new UnknownServiceException(
        "Unable to find acceptable protocols. isFallback=" + isFallback
            + ", modes=" + connectionSpecs
            + ", supported protocols=" + Arrays.toString(sslSocket.getEnabledProtocols()));
  }

  isFallbackPossible = isFallbackPossible(sslSocket);

  Internal.instance.apply(tlsConfiguration, sslSocket, isFallback);

  return tlsConfiguration;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:ConnectionSpecSelector.java

示例14: connect

import java.net.UnknownServiceException; //导入依赖的package包/类
public void connect() throws IOException {
    if (f == null) {
        f = NbinstURLMapper.decodeURL(url);
        if (f == null) {
            throw new FileNotFoundException("Cannot find: " + url); // NOI18N
        }
    }
    if (!f.isFile()) {
        throw new UnknownServiceException();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:NbinstURLStreamHandler.java

示例15: getOutputStream

import java.net.UnknownServiceException; //导入依赖的package包/类
public OutputStream getOutputStream() throws IOException, UnknownServiceException {
    connect();

    if (fo.isFolder()) {
        throw new UnknownServiceException();
    }

    if (oStream == null) {
        FileLock flock = fo.lock();
        oStream = new LockOS(fo.getOutputStream(flock), flock);
    }

    return oStream;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FileURL.java


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