PageRenderTime 57ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. /**
  2. *
  3. */
  4. package org.jboss.as.controller.interfaces;
  5. import java.io.ObjectStreamException;
  6. import java.net.InetAddress;
  7. import java.net.NetworkInterface;
  8. import java.net.SocketException;
  9. /**
  10. * {@link InterfaceCriteria} that tests whether a given interface is a
  11. * {@link NetworkInterface#isLoopback() loopback interface}
  12. *
  13. * @author Brian Stansberry
  14. */
  15. public class LoopbackInterfaceCriteria implements InterfaceCriteria {
  16. private static final long serialVersionUID = 1922501758657303593L;
  17. public static final LoopbackInterfaceCriteria INSTANCE = new LoopbackInterfaceCriteria();
  18. private LoopbackInterfaceCriteria() {}
  19. /**
  20. * {@inheritDoc}
  21. *
  22. * @return <code>address</code> if {@link NetworkInterface#isLoopback()} is true, null otherwise.
  23. */
  24. @Override
  25. public InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
  26. if( networkInterface.isLoopback() )
  27. return address;
  28. return null;
  29. }
  30. private Object readResolve() throws ObjectStreamException {
  31. return INSTANCE;
  32. }
  33. }