Revision: b561943a759e
Author: oifa yulian <[email protected]>
Date: Wed May 2 06:29:56 2012
Log: adding m3ua files
http://code.google.com/p/jss7/source/detail?r=b561943a759e
Added:
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAChannel.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAProcess.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAProvider.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelectableChannel.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelectionKey.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelector.java
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAServerChannel.java
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAChannel.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+import org.mobicents.protocols.ss7.m3ua.message.M3UAMessage;
+
+/**
+ * A selectable channel for message connecting sockets.
+ *
+ * @author kulikov
+ */
+public interface M3UAChannel extends M3UASelectableChannel {
+
+ /**
+ * Binds the channel to a local address.
+ *
+ * @param address the SocketAddress to bind to
+ * @throws java.io.IOException
+ */
+ public void bind(SocketAddress address) throws IOException;
+
+ /**
+ * Connects this channel's.
+ *
+ * @param remote The remote address to which this channel is to be
connected
+ * @return if a connection was established, false if this channel is
in non-blocking mode and the
+ * connection operation is in progress.
+ * @throws java.io.IOException
+ */
+ public boolean connect(SocketAddress remote) throws IOException;
+
+ /**
+ * Finishes the process of connecting a channel.
+ *
+ * A non-blocking connection operation is initiated by invoking its
connect method.
+ * Once the connection is established, or the attempt has failed, the
channel will become connectable
+ * and this method may be invoked to complete the connection sequence.
If the connection operation
+ * failed then invoking this method will cause an appropriate
IOException to be thrown.
+ *
+ *
+ * @return true if, and only if, this channel is now connected
+ * @throws java.io.IOException
+ */
+ public boolean finishConnect() throws IOException;
+
+ /**
+ * Closes this channel.
+ *
+ * If the channel has already been closed then this method returns
immediately.
+ * @throws java.io.IOException
+ */
+ public void close() throws IOException;
+
+ /**
+ * Reads M3UA message from channel when channel is ready for operation
READ..
+ *
+ * @return return the received message.
+ * @throws java.io.IOException
+ */
+ public M3UAMessage receive() throws IOException;
+
+ /**
+ * Sends M3UA message when channel is ready for operation WRITE.
+ *
+ * @param message the message to send
+ * @throws java.io.IOException
+ */
+ public void send(M3UAMessage message) throws IOException;
+
+ /**
+ * Tells whether or not this channel is connected.
+ *
+ * @return true if, and only if, this channel is connected
+ */
+ public boolean isConnected() throws IOException;
+
+ /**
+ * Tells whether or not a connection operation is in progress on this
channel.
+ *
+ * @return true if, and only if, a connection operation has been
initiated on this channel but not yet
+ * completed by invoking the finishConnect method
+ */
+ public boolean isConnectionPending();
+
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAProcess.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.io.IOException;
+
+import org.mobicents.protocols.ss7.mtp.Mtp3UserPart;
+
+/**
+ * A process instance of a Signalling Gateway (SGP). It serves as an
active,
+ * backup, load-sharing, or broadcast process of a Signalling Gateway.
+ *
+ * @author amit bhayani
+ *
+ */
+public interface M3UAProcess extends Mtp3UserPart {
+
+ /**
+ * Start this Signalling Gateway Process
+ *
+ * @throws IOException
+ */
+ public void start() throws IOException;
+
+ /**
+ * Stop this Signalling Gateway Process
+ */
+ public void stop();
+
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAProvider.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.io.IOException;
+import org.mobicents.protocols.ss7.m3ua.message.MessageFactory;
+import org.mobicents.protocols.ss7.m3ua.parameter.ParameterFactory;
+
+/**
+ * Service-provider class for selectors and M3UA channels.
+ * @author kulikov
+ */
+public interface M3UAProvider {
+ /**
+ * Opens new M3UA channel.
+ *
+ * @return the new channel.
+ * @throws java.io.IOException
+ */
+ public M3UAChannel openChannel() throws IOException;
+
+ /**
+ * Opens new server channel.
+ *
+ * @return new server channel.
+ * @throws java.io.IOException
+ */
+ public M3UAServerChannel openServerChannel() throws IOException;
+
+ /**
+ * Opens new M3UA multiplexer.
+ *
+ * @return new selector.
+ * @throws java.io.IOException
+ */
+ public M3UASelector openSelector() throws IOException;
+
+ /**
+ * Provides access to the message factory implementation.
+ *
+ * @return message factory instance
+ */
+ public MessageFactory getMessageFactory();
+
+ /**
+ * Provides access to the parameter factory implementation.
+ *
+ * @return parameter factory instance
+ */
+ public ParameterFactory getParameterFactory();
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelectableChannel.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.nio.channels.ClosedChannelException;
+
+/**
+ * A channel that can be multiplexed via a M3UASelector.
+ *
+ * In order to be used with a selector, an instance of this class must
first be registered via
+ * the register method. This method returns a new M3UASelectionKey object
that represents
+ * the channel's registration with the selector.
+ *
+ * @author kulikov
+ */
+public interface M3UASelectableChannel {
+ /**
+ * Registers this channel with the given selector, returning a
selection key.
+ *
+ * @param selector The selector with which this channel is to be
registered
+ * @param ops The interest set for the resulting key
+ * @return A key representing the registration of this channel with
the given selector.
+ * @throws java.nio.channels.ClosedChannelException
+ */
+ public M3UASelectionKey register(M3UASelector selector, int ops)
throws ClosedChannelException;
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelectionKey.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+/**
+ * A token representing the registration of a M3UAChannel with a
multiplexer.
+ *
+ * A selection key is created each time a channel is registered with a
selector.
+ * A key remains valid until it is cancelled by invoking its cancel
method, by
+ * closing its channel, or by closing its selector. Cancelling a key does
not
+ * immediately remove it from its selector.
+ *
+ * A selection key is created each time a channel is registered with a
selector.
+ * A key remains valid until it is cancelled by invoking its cancel
method, by
+ * closing its channel, or by closing its selector. Cancelling a key does
not
+ * immediately remove it from its selector
+ *
+ * That a selection key's ready set indicates that its channel is ready
for some
+ * operation category is a hint, but not a guarantee, that an operation in
such
+ * a category may be performed by a thread without causing the thread to
block.
+ * A ready set is most likely to be accurate immediately after the
completion of
+ * a selection operation. It is likely to be made inaccurate by external
events
+ * and by I/O operations that are invoked upon the corresponding channel.
+ *
+ * @author amit bhayani
+ * @author kulikov
+ */
+public interface M3UASelectionKey {
+ /**
+ * Returns the channel for which this key was created. This method will
+ * continue to return the channel even after the key is cancelled.
+ *
+ * @return This key's channel.
+ */
+ public M3UASelectableChannel channel();
+
+ /**
+ * Tests whether this key's channel is ready to accept a new
connection.
+ *
+ * @return true if, and only if channel ready to accept new connection
+ */
+ public boolean isAcceptable();
+
+ /**
+ * Tests whether this key's channel is ready for reading.
+ *
+ * @return true if, and only if channel ready for reading
+ */
+ public boolean isReadable();
+
+ /**
+ * Tests whether this key's channel is ready for writting.
+ *
+ * @return true if, and only if channel ready for writting
+ */
+ public boolean isWritable();
+
+ /**
+ * Requests that the registration of this key's channel with its
selector be
+ * cancelled.
+ */
+ public void cancel();
+
+ /**
+ * Attaches the given object to this key.
+ *
+ * <p>
+ * An attached object may later be retrieved via the {@link #attachment
+ * attachment} method. Only one object may be attached at a time;
invoking
+ * this method causes any previous attachment to be discarded. The
current
+ * attachment may be discarded by attaching <tt>null</tt>.
+ * </p>
+ *
+ * @param ob
+ * The object to be attached; may be <tt>null</tt>
+ *
+ * @return The previously-attached object, if any, otherwise
<tt>null</tt>
+ */
+ public Object attach(Object ob);
+
+ /**
+ * Retrieves the current attachment.
+ * </p>
+ *
+ * @return The object currently attached to this key, or <tt>null</tt>
if
+ * there is no attachment
+ */
+ public Object attachment();
+
+ /**
+ * Tells whether or not this key is valid.
+ *
+ * <p> A key is valid upon creation and remains so until it is
cancelled,
+ * its channel is closed, or its selector is closed. </p>
+ *
+ * @return <tt>true</tt> if, and only if, this key is valid
+ */
+ public abstract boolean isValid();
+
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UASelector.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.io.IOException;
+
+import javolution.util.FastList;
+
+/**
+ * A multiplexor of M3UA channels.
+ *
+ * @author abhayani
+ * @author kulikov
+ */
+public interface M3UASelector {
+ /**
+ * Selects a set of keys whose corresponding channels are ready for
I/O operations.
+ *
+ * @return the collection keys.
+ * @throws java.io.IOException
+ */
+ public FastList<M3UASelectionKey> selectNow() throws IOException;
+
+ /**
+ * Closes this selector.
+ *
+ * @throws java.io.IOException
+ */
+ public void close() throws IOException;
+}
+
=======================================
--- /dev/null
+++
/m3ua/api/src/main/java/org/mobicents/protocols/ss7/m3ua/M3UAServerChannel.java
Wed May 2 06:29:56 2012
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.m3ua;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+
+/**
+ * A selectable channel for M3UA listening sockets.
+ *
+ * @author kulikov
+ */
+public interface M3UAServerChannel extends M3UASelectableChannel {
+ /**
+ * Accepts a connection made to this channel's socket.
+ *
+ * The channel returned by this method, if any, will be in
non-blocking mode.
+ *
+ * @return The M3UA channel for the new connection, or null if no
connection is available
+ * to be accepted
+ * @throws java.io.IOException
+ */
+ public M3UAChannel accept() throws IOException;
+
+ /**
+ * Binds the channel to a local address.
+ *
+ * @param address the SocketAddress to bind to
+ * @throws java.io.IOException
+ */
+ public void bind(SocketAddress address) throws IOException;
+
+ /**
+ * Closes this channel.
+ *
+ * If the channel has already been closed then this method returns
immediately.
+ * @throws java.io.IOException
+ */
+ public void close() throws IOException;
+
+}
+