org.jboss.remoting3.spi.SpiUtils Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including
all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and
JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
The newest version!
/*
* 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