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


Java Exceptions类代码示例

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


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

示例1: startElement

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, final Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    Map.Entry[] attributeMap = new Map.Entry[attributes.getLength()];
    for (int i = 0; i < attributeMap.length; i++) {
        attributeMap[i] =
                new AbstractMap.SimpleEntry<String, String>(
                        attributes.getLocalName(i),
                        attributes.getValue(i)
                );
    }
    try {
        EventedValue esv = createValue(localName, attributeMap);
        if (esv != null)
            getInstance().getValues().add(esv);
    } catch (Exception ex) {
        // Don't exit, just log a warning
        log.warning("Error reading event XML, ignoring value: " + Exceptions.unwrap(ex));
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:LastChangeParser.java

示例2: received

import org.seamless.util.Exceptions; //导入依赖的package包/类
/**
 * Obtains the asynchronous protocol {@code Executor} and runs the protocol created
 * by the {@link org.fourthline.cling.protocol.ProtocolFactory} for the given message.
 * <p>
 * If the factory doesn't create a protocol, the message is dropped immediately without
 * creating another thread or consuming further resources. This means we can filter the
 * datagrams in the protocol factory and e.g. completely disable discovery or only
 * allow notification message from some known services we'd like to work with.
 * </p>
 *
 * @param msg The received datagram message.
 */
public void received(IncomingDatagramMessage msg) {
    if (!enabled) {
        log.fine("Router disabled, ignoring incoming message: " + msg);
        return;
    }
    try {
        ReceivingAsync protocol = getProtocolFactory().createReceivingAsync(msg);
        if (protocol == null) {
            if (log.isLoggable(Level.FINEST))
                log.finest("No protocol, ignoring received message: " + msg);
            return;
        }
        if (log.isLoggable(Level.FINE))
            log.fine("Received asynchronous message: " + msg);
        getConfiguration().getAsyncProtocolExecutor().execute(protocol);
    } catch (ProtocolCreationException ex) {
        log.warning("Handling received datagram failed - " + Exceptions.unwrap(ex).toString());
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:32,代码来源:RouterImpl.java

示例3: afterExecute

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
protected void afterExecute(Runnable runnable, Throwable throwable) {
    super.afterExecute(runnable, throwable);
    if (throwable != null) {
        Throwable cause = Exceptions.unwrap(throwable);
        if (cause instanceof InterruptedException) {
            // Ignore this, might happen when we shutdownNow() the executor. We can't
            // log at this point as the logging system might be stopped already (e.g.
            // if it's a CDI component).
            return;
        }
        // Log only
        log.warning("Thread terminated " + runnable + " abruptly with exception: " + throwable);
        log.warning("Root cause: " + cause);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:17,代码来源:DefaultUpnpServiceConfiguration.java

示例4: createCallable

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
protected Callable<StreamResponseMessage> createCallable(final StreamRequestMessage requestMessage,
                                                         final HttpContentExchange exchange) {
    return new Callable<StreamResponseMessage>() {
        public StreamResponseMessage call() throws Exception {

            if (log.isLoggable(Level.FINE))
                log.fine("Sending HTTP request: " + requestMessage);

            client.send(exchange);
            int exchangeState = exchange.waitForDone();

            if (exchangeState == HttpExchange.STATUS_COMPLETED) {
                try {
                    return exchange.createResponse();
                } catch (Throwable t) {
                    log.log(Level.WARNING, "Error reading response: " + requestMessage, Exceptions.unwrap(t));
                    return null;
                }
            } else if (exchangeState == HttpExchange.STATUS_CANCELLED) {
                // That's ok, happens when we abort the exchange after timeout
                return null;
            } else if (exchangeState == HttpExchange.STATUS_EXCEPTED) {
                // The warnings of the "excepted" condition are logged in HttpContentExchange
                return null;
            } else {
                log.warning("Unhandled HTTP exchange status: " + exchangeState);
                return null;
            }
        }
    };
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:33,代码来源:ArchosStreamClientImpl.java

示例5: run

import org.seamless.util.Exceptions; //导入依赖的package包/类
public void run() {
    try {
        execute();
    } catch (Exception ex) {
        Throwable cause = Exceptions.unwrap(ex);
        if (cause instanceof InterruptedException) {
            log.log(Level.INFO, "Interrupted protocol '" + getClass().getSimpleName() + "': " + ex, cause);
        } else {
            throw new RuntimeException(
                "Fatal error while executing protocol '" + getClass().getSimpleName() + "': " + ex, ex
            );
        }
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:15,代码来源:SendingAsync.java

示例6: handleResponse

import org.seamless.util.Exceptions; //导入依赖的package包/类
protected void handleResponse(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response for outgoing call, reading SOAP response body: " + responseMsg);
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response message. " + ex.getMessage(),
                false
            );
        }
    }
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:16,代码来源:SendingAction.java

示例7: handleResponseFailure

import org.seamless.util.Exceptions; //导入依赖的package包/类
protected void handleResponseFailure(IncomingActionResponseMessage responseMsg) throws ActionException {

        try {
            log.fine("Received response with Internal Server Error, reading SOAP failure message");
            getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation);
        } catch (UnsupportedDataException ex) {
            log.fine("Error reading SOAP body: " + ex);
            log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex));
            throw new ActionException(
                ErrorCode.ACTION_FAILED,
                "Error reading SOAP response failure message. " + ex.getMessage(),
                false
            );
        }
    }
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:16,代码来源:SendingAction.java

示例8: end

import org.seamless.util.Exceptions; //导入依赖的package包/类
/**
 * Removes a property change listener on the {@link org.fourthline.cling.model.ServiceManager}.
 */
synchronized public void end(CancelReason reason) {
    try {
        getService().getManager().getPropertyChangeSupport().removePropertyChangeListener(this);
    } catch (Exception ex) {
        log.warning("Removal of local service property change listener failed: " + Exceptions.unwrap(ex));
    }
    ended(reason);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:12,代码来源:LocalGENASubscription.java

示例9: propertyChange

import org.seamless.util.Exceptions; //导入依赖的package包/类
public void propertyChange(PropertyChangeEvent e) {
    log.finer("Property change event on local service: " + e.getPropertyName());

    // Prevent recursion
    if (e.getPropertyName().equals(EVENTED_STATE_VARIABLES)) return;

    String[] variableNames = ModelUtil.fromCommaSeparatedList(e.getPropertyName());
    log.fine("Changed variable names: " + Arrays.toString(variableNames));

    try {
        Collection<StateVariableValue> currentValues = getCurrentState(variableNames);

        if (!currentValues.isEmpty()) {
            getPropertyChangeSupport().firePropertyChange(
                EVENTED_STATE_VARIABLES,
                null,
                currentValues
            );
        }

    } catch (Exception ex) {
        // TODO: Is it OK to only log this error? It means we keep running although we couldn't send events?
        log.log(
            Level.SEVERE,
            "Error reading state of service after state variable update event: " + Exceptions.unwrap(ex),
            ex
        );
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:30,代码来源:DefaultServiceManager.java

示例10: valueOf

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
protected URI valueOf(String s) throws InvalidValueException {
    try {
        // These URIs are really defined as 'string' datatype in AVTransport1.0.pdf, but we can try
        // to parse whatever devices give us, like the Roku which sends "unknown url".
        return super.valueOf(s);
    } catch (InvalidValueException ex) {
        log.info("Ignoring invalid URI in evented value '" + s +"': " + Exceptions.unwrap(ex));
        return null;
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:12,代码来源:EventedValueURI.java

示例11: handleStartFailure

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
public void handleStartFailure(InitializationException ex) throws InitializationException {
    if (ex instanceof NoNetworkException) {
        log.info("Unable to initialize network router, no network found.");
    } else {
        log.severe("Unable to initialize network router: " + ex);
        log.severe("Cause: " + Exceptions.unwrap(ex));
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:10,代码来源:RouterImpl.java

示例12: process

import org.seamless.util.Exceptions; //导入依赖的package包/类
/**
 * Selects a UPnP protocol, runs it within the calling thread, returns the response.
 * <p>
 * This method will return <code>null</code> if the UPnP protocol returned <code>null</code>.
 * The HTTP response in this case is always <em>404 NOT FOUND</em>. Any other (HTTP) error
 * condition will be encapsulated in the returned response message and has to be
 * passed to the HTTP client as it is.
 * </p>
 * @param requestMsg The TCP (HTTP) stream request message.
 * @return The TCP (HTTP) stream response message, or <code>null</code> if a 404 should be send to the client.
 */
public StreamResponseMessage process(StreamRequestMessage requestMsg) {
    log.fine("Processing stream request message: " + requestMsg);

    try {
        // Try to get a protocol implementation that matches the request message
        syncProtocol = getProtocolFactory().createReceivingSync(requestMsg);
    } catch (ProtocolCreationException ex) {
        log.warning("Processing stream request failed - " + Exceptions.unwrap(ex).toString());
        return new StreamResponseMessage(UpnpResponse.Status.NOT_IMPLEMENTED);
    }

    // Run it
    log.fine("Running protocol for synchronous message processing: " + syncProtocol);
    syncProtocol.run();

    // ... then grab the response
    StreamResponseMessage responseMsg = syncProtocol.getOutputMessage();

    if (responseMsg == null) {
        // That's ok, the caller is supposed to handle this properly (e.g. convert it to HTTP 404)
        log.finer("Protocol did not return any response message");
        return null;
    }
    log.finer("Protocol returned response: " + responseMsg);
    return responseMsg;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:38,代码来源:UpnpStream.java

示例13: run

import org.seamless.util.Exceptions; //导入依赖的package包/类
@Override
public void run() {
    try {
        StreamRequestMessage requestMessage = readRequestMessage();
        if (log.isLoggable(Level.FINER))
            log.finer("Processing new request message: " + requestMessage);

        responseMessage = process(requestMessage);

        if (responseMessage != null) {
            if (log.isLoggable(Level.FINER))
                log.finer("Preparing HTTP response message: " + responseMessage);
            writeResponseMessage(responseMessage);
        } else {
            // If it's null, it's 404
            if (log.isLoggable(Level.FINER))
                log.finer("Sending HTTP response status: " + HttpURLConnection.HTTP_NOT_FOUND);
            getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND);
        }

    } catch (Throwable t) {
        log.info("Exception occurred during UPnP stream processing: " + t);
        if (log.isLoggable(Level.FINER)) {
            log.log(Level.FINER, "Cause: " + Exceptions.unwrap(t), Exceptions.unwrap(t));
        }
        if (!getResponse().isCommitted()) {
            log.finer("Response hasn't been committed, returning INTERNAL SERVER ERROR to client");
            getResponse().setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        } else {
            log.info("Could not return INTERNAL SERVER ERROR to client, response was already committed");
        }
        responseException(t);
    } finally {
        complete();
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:37,代码来源:AsyncServletUpnpStream.java

示例14: handleRouterExceptionOnNetworkTypeChange

import org.seamless.util.Exceptions; //导入依赖的package包/类
protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex) {
    Throwable cause = Exceptions.unwrap(ex);
    if (cause instanceof InterruptedException) {
        log.log(Level.INFO, "Router was interrupted: " + ex, cause);
    } else {
        throw new RuntimeException("Router error on network change: " + ex, ex);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:9,代码来源:AndroidRouter.java

示例15: shutdownRouter

import org.seamless.util.Exceptions; //导入依赖的package包/类
protected void shutdownRouter() {
    try {
        getRouter().shutdown();
    } catch (RouterException ex) {
        Throwable cause = Exceptions.unwrap(ex);
        if (cause instanceof InterruptedException) {
            log.log(Level.INFO, "Router shutdown was interrupted: " + ex, cause);
        } else {
            throw new RuntimeException("Router error on shutdown: " + ex, ex);
        }
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:13,代码来源:UpnpServiceImpl.java


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