當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。