/jboss-as-7.1.1.Final/controller/src/main/java/org/jboss/as/controller/interfaces/LoopbackInterfaceCriteria.java
Java | 42 lines | 19 code | 9 blank | 14 comment | 1 complexity | d2aebe145d6a5ead4ac08abbfa3be795 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
- /**
- *
- */
- package org.jboss.as.controller.interfaces;
- import java.io.ObjectStreamException;
- import java.net.InetAddress;
- import java.net.NetworkInterface;
- import java.net.SocketException;
- /**
- * {@link InterfaceCriteria} that tests whether a given interface is a
- * {@link NetworkInterface#isLoopback() loopback interface}
- *
- * @author Brian Stansberry
- */
- public class LoopbackInterfaceCriteria implements InterfaceCriteria {
- private static final long serialVersionUID = 1922501758657303593L;
- public static final LoopbackInterfaceCriteria INSTANCE = new LoopbackInterfaceCriteria();
- private LoopbackInterfaceCriteria() {}
- /**
- * {@inheritDoc}
- *
- * @return <code>address</code> if {@link NetworkInterface#isLoopback()} is true, null otherwise.
- */
- @Override
- public InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
- if( networkInterface.isLoopback() )
- return address;
- return null;
- }
- private Object readResolve() throws ObjectStreamException {
- return INSTANCE;
- }
- }