org.jboss.remoting3.spi.SpiUtils Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.remoting3.spi;
import java.io.Closeable;
import java.io.IOException;
import java.util.Arrays;
import org.jboss.remoting3.Channel;
import org.jboss.remoting3.CloseHandler;
import org.jboss.remoting3.HandleableCloseable;
import org.jboss.remoting3.OpenListener;
import org.xnio.IoUtils;
import org.jboss.logging.Logger;
/**
* Utility methods for Remoting service providers.
*/
public final class SpiUtils {
private SpiUtils() {}
private static final Logger heLog = Logger.getLogger("org.jboss.remoting.handler-errors");
/**
* Safely handle a close notification.
*
* @param handler the close handler
* @param closed the object that was closed
* @param exception the close exception, or {@code null} if the close succeeded
* @param the type of the closed resource
*/
public static void safeHandleClose(final CloseHandler super T> handler, final T closed, final IOException exception) {
try {
if (handler != null && closed != null) handler.handleClose(closed, exception);
} catch (Throwable t) {
heLog.error("Close handler threw an exception", t);
}
}
/**
* A close handler which closes another resource.
*
* @param c the resource to close
* @return the close handler
*/
public static CloseHandler
© 2015 - 2025 Weber Informatics LLC | Privacy Policy