/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/sctp/SctpServerChannel.java

http://mobicents.googlecode.com/ · Java · 95 lines · 32 code · 12 blank · 51 comment · 0 complexity · ce9ef09e22f972cf2908074e45934460 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.ss7.m3ua.impl.sctp;
  23. import java.io.IOException;
  24. import java.net.SocketAddress;
  25. import java.nio.channels.spi.AbstractSelectableChannel;
  26. import org.mobicents.protocols.ss7.m3ua.M3UAChannel;
  27. import org.mobicents.protocols.ss7.m3ua.impl.M3UAServerChannelImpl;
  28. /**
  29. * @author amit bhayani
  30. *
  31. */
  32. public class SctpServerChannel extends M3UAServerChannelImpl {
  33. private SctpProvider provider;
  34. /**
  35. * @param channel
  36. * @throws IOException
  37. */
  38. public SctpServerChannel(SctpProvider provider,
  39. AbstractSelectableChannel channel) throws IOException {
  40. super(channel);
  41. this.provider = provider;
  42. }
  43. /**
  44. * Opens new M3UA channel.
  45. *
  46. * @return the new M3UA channel
  47. * @throws java.io.IOException
  48. */
  49. public static SctpServerChannel open(SctpProvider provider)
  50. throws IOException {
  51. return new SctpServerChannel(provider,
  52. com.sun.nio.sctp.SctpServerChannel.open());
  53. }
  54. /*
  55. * (non-Javadoc)
  56. *
  57. * @see org.mobicents.protocols.ss7.m3ua.M3UAServerChannel#accept()
  58. */
  59. @Override
  60. public M3UAChannel accept() throws IOException {
  61. return new SctpChannel(provider,
  62. ((com.sun.nio.sctp.SctpServerChannel) channel).accept());
  63. }
  64. /*
  65. * (non-Javadoc)
  66. *
  67. * @see org.mobicents.protocols.ss7.m3ua.M3UAServerChannel#bind(java.net.
  68. * SocketAddress)
  69. */
  70. @Override
  71. public void bind(SocketAddress address) throws IOException {
  72. ((com.sun.nio.sctp.SctpServerChannel) channel).bind(address);
  73. }
  74. /*
  75. * (non-Javadoc)
  76. *
  77. * @see org.mobicents.protocols.ss7.m3ua.M3UAServerChannel#close()
  78. */
  79. @Override
  80. public void close() throws IOException {
  81. ((com.sun.nio.sctp.SctpServerChannel) channel).close();
  82. }
  83. }