diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java index 7a9c159ee..092a933a9 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java @@ -37,28 +37,28 @@ */ public class ClientSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IClientSLgSessionData { - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public ClientSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster, container); + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ClientSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); - if (super.create()) { - setAppSessionIface(this, ClientSLgSession.class); - setSLgSessionState(SLgSessionState.IDLE); - } + if (super.create()) { + setAppSessionIface(this, ClientSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); } + } - /** - * @param sessionId - * @param mobicentsCluster - * @param iface - */ - public ClientSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); - } + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ClientSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java index 08e905069..046aca97d 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java @@ -37,27 +37,27 @@ */ public class ClientSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IClientSLhSessionData { - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public ClientSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster, container); + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ClientSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); - if (super.create()) { - setAppSessionIface(this, ClientSLhSession.class); - setSLhSessionState(SLhSessionState.IDLE); - } + if (super.create()) { + setAppSessionIface(this, ClientSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); } + } - /** - * @param sessionId - * @param mobicentsCluster - * @param iface - */ - public ClientSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); - } + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ClientSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java index 325eb5752..5900ae7b4 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java @@ -39,33 +39,34 @@ */ public class SLgReplicatedSessionDataFactory implements IAppSessionDataFactory { - private ReplicatedSessionDatasource replicatedSessionDataSource; - private MobicentsCluster mobicentsCluster; + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; - /** - * @param replicatedSessionDataSource - */ - public SLgReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? - super(); - this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; - this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); - } + /** + * @param replicatedSessionDataSource + */ + public SLgReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) - */ - public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { - if (clazz.equals(ClientSLgSession.class)) { - ClientSLgSessionDataReplicatedImpl data = new ClientSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); - return data; - } - else if (clazz.equals(ServerSLgSession.class)) { - ServerSLgSessionDataReplicatedImpl data = new ServerSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); - return data; - } - throw new IllegalArgumentException(); + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLgSession.class)) { + ClientSLgSessionDataReplicatedImpl data = new ClientSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } else if (clazz.equals(ServerSLgSession.class)) { + ServerSLgSessionDataReplicatedImpl data = new ServerSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; } + throw new IllegalArgumentException(); + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java index cb4af62d8..8bcd66a04 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java @@ -45,108 +45,105 @@ */ public abstract class SLgSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLgSessionData { - private static final Logger logger = LoggerFactory.getLogger(SLgSessionDataReplicatedImpl.class); + private static final Logger logger = LoggerFactory.getLogger(SLgSessionDataReplicatedImpl.class); - private static final String STATE = "STATE"; - private static final String BUFFER = "BUFFER"; - private static final String TS_TIMERID = "TS_TIMERID"; + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; - private IMessageParser messageParser; + private IMessageParser messageParser; - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public SLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster); - this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); - } + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public SLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setSLgSessionState(org.jdiameter.common.api.app.slg.SLgSessionState) - */ - public void setSLgSessionState(SLgSessionState state) { - if (exists()) { - getNode().put(STATE, state); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setSLgSessionState(org.jdiameter.common.api.app.slg.SLgSessionState) + */ + public void setSLgSessionState(SLgSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } else { + throw new IllegalStateException(); } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getSLgSessionState() - */ - public SLgSessionState getSLgSessionState() { - if (exists()) { - return (SLgSessionState) getNode().get(STATE); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getSLgSessionState() + */ + public SLgSessionState getSLgSessionState() { + if (exists()) { + return (SLgSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getTsTimerId() - */ - public Serializable getTsTimerId() { - if (exists()) { - return (Serializable) getNode().get(TS_TIMERID); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); + } + else { + throw new IllegalStateException(); } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setTsTimerId(java.io.Serializable) - */ - public void setTsTimerId(Serializable tid) { - if (exists()) { - getNode().put(TS_TIMERID, tid); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); } + else { + throw new IllegalStateException(); + } + } - public Request getBuffer() { - byte[] data = (byte[]) getNode().get(BUFFER); - if (data != null) { - try { - return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); - } - catch (AvpDataException e) { - logger.error("Unable to recreate message from buffer."); - return null; - } - } - else { - return null; - } + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } else { + return null; } + } - public void setBuffer(Request buffer) { - if (buffer != null) { - try { - byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - getNode().put(BUFFER, data); - } - catch (ParseException e) { - logger.error("Unable to encode message to buffer."); - } - } - else { - getNode().remove(BUFFER); - } + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } + else { + getNode().remove(BUFFER); } + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java index 58c5bdd62..004549561 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java @@ -39,33 +39,34 @@ */ public class SLhReplicatedSessionDataFactory implements IAppSessionDataFactory { - private ReplicatedSessionDatasource replicatedSessionDataSource; - private MobicentsCluster mobicentsCluster; + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; - /** - * @param replicatedSessionDataSource - */ - public SLhReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? - super(); - this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; - this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); - } + /** + * @param replicatedSessionDataSource + */ + public SLhReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) - */ - public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { - if (clazz.equals(ClientSLhSession.class)) { - ClientSLhSessionDataReplicatedImpl data = new ClientSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); - return data; - } - else if (clazz.equals(ServerSLhSession.class)) { - ServerSLhSessionDataReplicatedImpl data = new ServerSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); - return data; - } - throw new IllegalArgumentException(); + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLhSession.class)) { + ClientSLhSessionDataReplicatedImpl data = new ClientSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; + } else if (clazz.equals(ServerSLhSession.class)) { + ServerSLhSessionDataReplicatedImpl data = new ServerSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, + this.replicatedSessionDataSource.getContainer()); + return data; } + throw new IllegalArgumentException(); + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java index 57bee93f8..edfff1316 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java @@ -45,108 +45,105 @@ */ public abstract class SLhSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLhSessionData { - private static final Logger logger = LoggerFactory.getLogger(SLhSessionDataReplicatedImpl.class); + private static final Logger logger = LoggerFactory.getLogger(SLhSessionDataReplicatedImpl.class); - private static final String STATE = "STATE"; - private static final String BUFFER = "BUFFER"; - private static final String TS_TIMERID = "TS_TIMERID"; + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; - private IMessageParser messageParser; + private IMessageParser messageParser; - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public SLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster); - this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); - } + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public SLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setSLhSessionState(org.jdiameter.common.api.app.slh.SLhSessionState) - */ - public void setSLhSessionState(SLhSessionState state) { - if (exists()) { - getNode().put(STATE, state); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setSLhSessionState(org.jdiameter.common.api.app.slh.SLhSessionState) + */ + public void setSLhSessionState(SLhSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } + else { + throw new IllegalStateException(); } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getSLhSessionState() - */ - public SLhSessionState getSLhSessionState() { - if (exists()) { - return (SLhSessionState) getNode().get(STATE); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getSLhSessionState() + */ + public SLhSessionState getSLhSessionState() { + if (exists()) { + return (SLhSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getTsTimerId() - */ - public Serializable getTsTimerId() { - if (exists()) { - return (Serializable) getNode().get(TS_TIMERID); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); } + else { + throw new IllegalStateException(); + } + } - /* - * (non-Javadoc) - * - * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setTsTimerId(java.io.Serializable) - */ - public void setTsTimerId(Serializable tid) { - if (exists()) { - getNode().put(TS_TIMERID, tid); - } - else { - throw new IllegalStateException(); - } + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); + } + else { + throw new IllegalStateException(); } + } - public Request getBuffer() { - byte[] data = (byte[]) getNode().get(BUFFER); - if (data != null) { - try { - return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); - } - catch (AvpDataException e) { - logger.error("Unable to recreate message from buffer."); - return null; - } - } - else { - return null; - } + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } else { + return null; } + } - public void setBuffer(Request buffer) { - if (buffer != null) { - try { - byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); - getNode().put(BUFFER, data); - } - catch (ParseException e) { - logger.error("Unable to encode message to buffer."); - } - } - else { - getNode().remove(BUFFER); - } + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } else { + getNode().remove(BUFFER); } + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java index 67ecf6bfd..a0deed2f0 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java @@ -37,27 +37,27 @@ */ public class ServerSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IServerSLgSessionData { - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public ServerSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster, container); + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ServerSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); - if (super.create()) { - setAppSessionIface(this, ServerSLgSession.class); - setSLgSessionState(SLgSessionState.IDLE); - } + if (super.create()) { + setAppSessionIface(this, ServerSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); } + } - /** - * @param sessionId - * @param mobicentsCluster - * @param iface - */ - public ServerSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); - } + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ServerSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java index 3548061e5..045583294 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java @@ -37,27 +37,27 @@ */ public class ServerSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IServerSLhSessionData { - /** - * @param nodeFqn - * @param mobicentsCluster - * @param iface - */ - public ServerSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { - super(nodeFqn, mobicentsCluster, container); + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ServerSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); - if (super.create()) { - setAppSessionIface(this, ServerSLhSession.class); - setSLhSessionState(SLhSessionState.IDLE); - } + if (super.create()) { + setAppSessionIface(this, ServerSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); } + } - /** - * @param sessionId - * @param mobicentsCluster - * @param iface - */ - public ServerSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { - this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); - } + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ServerSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java index a60a73f74..7afe1767e 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/Avp.java @@ -2705,7 +2705,7 @@ public interface Avp extends Wrapper, Serializable { */ int SERVICE_AREA_IDENTITY = 1607; - // Diameter ELP Application (SLg) reused AVPs: + // Diameter ELP Application (SLg) reused AVPs: // LCS-Format-Indicator 1237 3GPP TS 32.299; // LCS-Name-String 1238 3GPP TS 2.299; // LCS-Client-Type 1241 3GPP TS 32.299 diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java index 0a7a53949..ce0733ac5 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSession.java @@ -37,28 +37,28 @@ public interface ClientSLgSession extends AppSession, StateMachine { - /** - * Send Provide-Location-Request to server - * - * @param request Provide-Location-Request event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ - void sendProvideLocationRequest(ProvideLocationRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + /** + * Send Provide-Location-Request to server + * + * @param request Provide-Location-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendProvideLocationRequest(ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - /** - * Send Location-Report-Request to server - * - * @param request Location-Report-Request event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ - void sendLocationReportRequest(LocationReportRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + /** + * Send Location-Report-Request to server + * + * @param request Location-Report-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLocationReportRequest(LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java index e95c6e5ac..467fe2dec 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ClientSLgSessionListener.java @@ -40,13 +40,13 @@ public interface ClientSLgSessionListener { - void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java index f2eea0b64..4c836233a 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSession.java @@ -37,28 +37,28 @@ public interface ServerSLgSession extends AppSession, StateMachine { - /** - * Send Provide-Location-Answer to client - * - * @param answer Provide-Location-Answer event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ - void sendProvideLocationAnswer(ProvideLocationAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + /** + * Send Provide-Location-Answer to client + * + * @param answer Provide-Location-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendProvideLocationAnswer(ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - /** - * Send Location-Report-Answer to client - * - * @param answer Location-Report-Answer event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ - void sendLocationReportAnswer(LocationReportAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + /** + * Send Location-Report-Answer to client + * + * @param answer Location-Report-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLocationReportAnswer(LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java index 651fd21f1..469400c18 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/ServerSLgSessionListener.java @@ -38,12 +38,12 @@ public interface ServerSLgSessionListener { - void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java index c136fc117..fad9c9e02 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java @@ -32,7 +32,7 @@ * As for 3GPP TS 29.172 v13.0.0, Subscriber Location Report operation is used by an MME or SGSN to provide the location of a * target UE to a GMLC, when a request for location has been implicitly issued or when a Delayed Location Reporting is triggered * after receipt of a request for location for a UE transiently not reachable. - * + * * The Location-Report-Answer (LRA) command, indicated by the Command-Code field set to 8388621 and the "R" bit cleared in the * Command Flags field, is sent by the GMLC to the MME or SGSN in response to the Location-Report-Request command (Subscriber * Location Report operation answer) @@ -40,10 +40,10 @@ public interface LocationReportAnswer extends AppAnswerEvent{ - public static final String _SHORT_NAME = "LRA"; - public static final String _LONG_NAME = "Location-Report-Answer"; + String _SHORT_NAME = "LRA"; + String _LONG_NAME = "Location-Report-Answer"; - public static final int code = 8388621; + int code = 8388621; boolean isGMLCAddressAVPPresent(); java.net.InetAddress getGMLCAddress(); diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java index e37147ebf..4ce29b0e3 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportRequest.java @@ -32,7 +32,7 @@ * As for 3GPP TS 29.172 v13.0.0, Subscriber Location Report operation is used by an MME or SGSN to provide the location of a * target UE to a GMLC, when a request for location has been implicitly issued or when a Delayed Location Reporting is triggered * after receipt of a request for location for a UE transiently not reachable. - * + * * The Location-Report-Request (LRR) command, indicated by the Command-Code field set to 8388621 and the "R" bit set in the * Command Flags field, is sent by the MME or SGSN in order to provide subscriber location data to the GMLC (Subscriber Location * Report operation request) @@ -40,10 +40,10 @@ public interface LocationReportRequest extends AppRequestEvent { - public static final String _SHORT_NAME = "LRR"; - public static final String _LONG_NAME = "Location-Report-Request"; + String _SHORT_NAME = "LRR"; + String _LONG_NAME = "Location-Report-Request"; - public static final int code = 8388621; + int code = 8388621; boolean isLocationEventAVPPresent(); int getLocationEvent(); @@ -106,7 +106,7 @@ public interface LocationReportRequest extends AppRequestEvent { int getVerticalRequested(); int getResponseTime(); - public boolean isServingNodeAvpPresent(); + boolean isServingNodeAvpPresent(); boolean isLRRFlagsAVPPresent(); long getLRRFLags(); diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java index b9ddc4515..6fe252bb4 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java @@ -35,7 +35,7 @@ * estimate of the target UE and other additional information. This operation is also used by a GMLC to request the location of * the target UE from the SGSN at any time, as part of deferred MT-LR procedure. The response contains the acknowledgment of the * receipt of the request and other additional information. - * + * * The Provide-Location-Answer (PLA) command, indicated by the Command-Code field set to 8388620 and the "R" bit cleared in the * Command Flags field, is sent by the MME or SGSN to the GMLC in response to the Provide-Location-Request command (Provide * Subscriber Location operation answer) @@ -43,10 +43,10 @@ public interface ProvideLocationAnswer extends AppAnswerEvent{ - public static final String _SHORT_NAME = "PLA"; - public static final String _LONG_NAME = "Provide-Location-Answer"; + String _SHORT_NAME = "PLA"; + String _LONG_NAME = "Provide-Location-Answer"; - public static final int code = 8388620; + int code = 8388620; boolean isLocationEstimateAvpPresent(); String getLocationEstimate(); diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java index a99892af4..0c502ef69 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationRequest.java @@ -35,7 +35,7 @@ * estimate of the target UE and other additional information. This operation is also used by a GMLC to request the location of * the target UE from the SGSN at any time, as part of deferred MT-LR procedure. The response contains the acknowledgment of the * receipt of the request and other additional information. - * + * * The Provide-Location-Request (PLR) command, indicated by the Command-Code field set to 8388620 and the "R" bit set in the * Command Flags field, is sent by the GMLC in order to request subscriber location to the MME or SGSN (Provide Subscriber * Location operation request) @@ -43,10 +43,10 @@ public interface ProvideLocationRequest extends AppRequestEvent { - public static final String _SHORT_NAME = "PLR"; - public static final String _LONG_NAME = "Provide-Location-Request"; + String _SHORT_NAME = "PLR"; + String _LONG_NAME = "Provide-Location-Request"; - public static final int code = 8388620; + int code = 8388620; boolean isSLgLocationTypeAVPPresent(); int getSLgLocationType(); diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java index ab394a06f..6907bf5c4 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSession.java @@ -36,17 +36,17 @@ public interface ClientSLhSession extends AppSession, StateMachine { - /** - * Send LCS-Routing-Info-Request to server - * - * @param request LCS-Routing-Info-Request event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ + /** + * Send LCS-Routing-Info-Request to server + * + * @param request LCS-Routing-Info-Request event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ - void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java index 4e3330d60..f0e1eabfa 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ClientSLhSessionListener.java @@ -39,10 +39,10 @@ public interface ClientSLhSessionListener { - void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doLCSRoutingInfoAnswerEvent(ClientSLhSession session, LCSRoutingInfoRequest request, LCSRoutingInfoAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doLCSRoutingInfoAnswerEvent(ClientSLhSession session, LCSRoutingInfoRequest request, LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java index 8e5bc76fd..a6b083690 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSession.java @@ -36,16 +36,16 @@ public interface ServerSLhSession extends AppSession, StateMachine { - /** - * Send LCS-Routing-Info-Answer to client - * - * @param answer LCS-Routing-Info-Answer event instance - * @throws InternalException The InternalException signals that internal error is occurred. - * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). - * @throws RouteException The NoRouteException signals that no route exist for a given realm. - * @throws OverloadException The OverloadException signals that destination host is overloaded. - */ - void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + /** + * Send LCS-Routing-Info-Answer to client + * + * @param answer LCS-Routing-Info-Answer event instance + * @throws InternalException The InternalException signals that internal error is occurred. + * @throws IllegalDiameterStateException The IllegalStateException signals that session has incorrect state (invalid). + * @throws RouteException The NoRouteException signals that no route exist for a given realm. + * @throws OverloadException The OverloadException signals that destination host is overloaded. + */ + void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java index 23203d588..f30bb7ef8 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/ServerSLhSessionListener.java @@ -37,10 +37,10 @@ public interface ServerSLhSessionListener { - void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; - void doLCSRoutingInfoRequestEvent(ServerSLhSession session, LCSRoutingInfoRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; + void doLCSRoutingInfoRequestEvent(ServerSLhSession session, LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException; } diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java index aec22b2d8..797260ed9 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoAnswer.java @@ -21,7 +21,6 @@ package org.jdiameter.api.slh.events; -import org.jdiameter.api.Avp; import org.jdiameter.api.app.AppAnswerEvent; /** @@ -34,14 +33,14 @@ * and the "R" bit cleared in the Command Flags field, is sent from HSS to GMLC. The procedure invoked by the GMLC is used for * retrieving routing information for LCS (Location Services) for a specified user from the HSS via a LCS-Routing-Info-Request * (RIR) command. - * + * */ public interface LCSRoutingInfoAnswer extends AppAnswerEvent { - public static final String _SHORT_NAME = "RIA"; - public static final String _LONG_NAME = "LCS-Routing-Info-Answer"; + String _SHORT_NAME = "RIA"; + String _LONG_NAME = "LCS-Routing-Info-Answer"; - public static final int code = 8388622; + int code = 8388622; boolean isUserNameAVPPresent(); // Mapped IE: IMSI String getUserName(); // Mapped IE: IMSI @@ -49,14 +48,14 @@ public interface LCSRoutingInfoAnswer extends AppAnswerEvent { boolean isMSISDNAVPPresent(); byte[] getMSISDN(); - public boolean isLMSIAVPPresent(); + boolean isLMSIAVPPresent(); // int getLMSIAVPValue(); byte[] getLMSI(); - public boolean isServingNodeAVPPresent(); + boolean isServingNodeAVPPresent(); // int getServingNodeAVPValue(); - public boolean isAdditionalServingNodeAVPPresent(); + boolean isAdditionalServingNodeAVPPresent(); // int getAdditionalServingNodeAVPValue(); boolean isGMLCAddressAVPPresent(); diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java index 3588c9d08..f1def06af 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slh/events/LCSRoutingInfoRequest.java @@ -21,7 +21,6 @@ package org.jdiameter.api.slh.events; -import org.jdiameter.api.Avp; import org.jdiameter.api.app.AppRequestEvent; /** @@ -33,14 +32,14 @@ * As for 3GPP TS 29.173 v13.0.0, the LCS-Routing-Info-Request (RIR) command, indicated by the Command-Code field set to 8388622 * and the "R" bit set in the Command Flags field, is sent from GMLC to HSS. The procedure invoked by the GMLC is used for * retrieving routing information for LCS (Location Services) for a specified user from the HSS. - * + * */ public interface LCSRoutingInfoRequest extends AppRequestEvent { - public static final String _SHORT_NAME = "RIR"; - public static final String _LONG_NAME = "LCS-Routing-Info-Request"; + String _SHORT_NAME = "RIR"; + String _LONG_NAME = "LCS-Routing-Info-Request"; - public static final int code = 8388622; + int code = 8388622; boolean isUserNameAVPPresent(); // Mapped IE: IMSI String getUserName(); // Mapped IE: IMSI @@ -51,6 +50,4 @@ public interface LCSRoutingInfoRequest extends AppRequestEvent { boolean isGMLCNumberAVPPresent(); byte[] getGMLCNumber(); - - } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java index 682247061..57bfb49b3 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/ClientSLgSessionDataLocalImpl.java @@ -29,6 +29,6 @@ */ public class ClientSLgSessionDataLocalImpl extends SLgLocalSessionDataImpl implements IClientSLgSessionData { - public ClientSLgSessionDataLocalImpl() { - } + public ClientSLgSessionDataLocalImpl() { + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java index 9112ecbb2..587bb4ec3 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/Event.java @@ -32,55 +32,55 @@ public class Event implements StateEvent { - enum Type { - SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLA, RECEIVE_LRA; - } + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLA, RECEIVE_LRA; + } - AppEvent request; - AppEvent answer; - Type type; + AppEvent request; + AppEvent answer; + Type type; - Event(Type type, AppEvent request, AppEvent answer) { - this.type = type; - this.answer = answer; - this.request = request; - } + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } - @SuppressWarnings("unchecked") - public E encodeType(Class eClass) { - return eClass == Type.class ? (E) type : null; - } + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } - @SuppressWarnings("rawtypes") - public Enum getType() { - return type; - } + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } - public AppEvent getRequest() { - return request; - } + public AppEvent getRequest() { + return request; + } - public AppEvent getAnswer() { - return answer; - } + public AppEvent getAnswer() { + return answer; + } - public int compareTo(Object o) { - return 0; - } + public int compareTo(Object o) { + return 0; + } - public Object getData() { - return request != null ? request : answer; - } + public Object getData() { + return request != null ? request : answer; + } - public void setData(Object data) { - try { - if (((AppEvent) data).getMessage().isRequest()) { - request = (AppEvent) data; - } else { - answer = (AppEvent) data; - } - } catch (InternalException e) { - throw new IllegalArgumentException(e); - } + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); } + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java index 35ebd5c69..2f1004878 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slg/SLgClientSessionImpl.java @@ -59,283 +59,283 @@ */ public class SLgClientSessionImpl extends SLgSession - implements ClientSLgSession, EventListener, NetworkReqListener { + implements ClientSLgSession, EventListener, NetworkReqListener { - private static final Logger logger = LoggerFactory.getLogger(SLgClientSessionImpl.class); + private static final Logger logger = LoggerFactory.getLogger(SLgClientSessionImpl.class); - private transient ClientSLgSessionListener listener; + private transient ClientSLgSessionListener listener; - protected long appId = -1; - protected IClientSLgSessionData sessionData; + protected long appId = -1; + protected IClientSLgSessionData sessionData; - public SLgClientSessionImpl(IClientSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, - ClientSLgSessionListener lst) { - super(sf, sessionData); - if (lst == null) { - throw new IllegalArgumentException("Listener can not be null"); - } - if (fct.getApplicationId() < 0) { - throw new IllegalArgumentException("ApplicationId can not be less than zero"); - } - - this.appId = fct.getApplicationId(); - this.listener = lst; - super.messageFactory = fct; - this.sessionData = sessionData; + public SLgClientSessionImpl(IClientSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, + ClientSLgSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); } - - @SuppressWarnings("unchecked") - public E getState(Class stateType) { - return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + if (fct.getApplicationId() < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); } - public Answer processRequest(Request request) { - RequestDelivery rd = new RequestDelivery(); - rd.session = this; - rd.request = request; - super.scheduler.execute(rd); - return null; + this.appId = fct.getApplicationId(); + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + public void sendProvideLocationRequest(ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void sendLocationReportRequest(LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); } - - public void sendProvideLocationRequest(ProvideLocationRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, request, null); + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); } - - public void sendLocationReportRequest(LocationReportRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, request, null); + } + + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLgSessionState state = this.sessionData.getSLgSessionState(); + SLgSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + switch (state) { + + case IDLE: + switch (eventType) { + + case SEND_MESSAGE: + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + super.session.send(((AppEvent) event.getData()).getMessage(), this); + setState(newState); // FIXME: is this ok to be here? + break; + + default: + logger.error("Invalid Event Type {} for SLg Client Session at state {}.", eventType, + sessionData.getSLgSessionState()); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLgSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLgSessionState.TERMINATED; + setState(newState); + } + break; + + case RECEIVE_PLA: + newState = SLgSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doProvideLocationAnswerEvent(this, (ProvideLocationRequest) localEvent.getRequest(), + (ProvideLocationAnswer) localEvent.getAnswer()); + break; + + case RECEIVE_LRA: + newState = SLgSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doLocationReportAnswerEvent(this, (LocationReportRequest) localEvent.getRequest(), + (LocationReportAnswer) localEvent.getAnswer()); + break; + + default: + throw new InternalException("Unexpected/Unknown message received: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLg Client FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); } + return true; + } - public void receivedSuccessMessage(Request request, Answer answer) { - AnswerDelivery rd = new AnswerDelivery(); - rd.session = this; - rd.request = request; - rd.answer = answer; - super.scheduler.execute(rd); - } + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLgSessionState newState) { + SLgSessionState oldState = this.sessionData.getSLgSessionState(); + this.sessionData.setSLgSessionState(newState); - public void timeoutExpired(Request request) { - try { - handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); - } catch (Exception e) { - logger.debug("Failed to process timeout message", e); - } + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); } - - protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { - try { - if (type != null) { - handleEvent(new Event(type, request, answer)); - } - } catch (Exception e) { - throw new InternalException(e); - } + if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); } + } - public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + public void onTimer(String timerName) { + if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); try { - sendAndStateLock.lock(); - if (!super.session.isValid()) { - // FIXME: throw new InternalException("Generic session is not valid."); - return false; - } - final SLgSessionState state = this.sessionData.getSLgSessionState(); - SLgSessionState newState = null; - Event localEvent = (Event) event; - Event.Type eventType = (Type) event.getType(); - switch (state) { - - case IDLE: - switch (eventType) { - - case SEND_MESSAGE: - newState = SLgSessionState.MESSAGE_SENT_RECEIVED; - super.session.send(((AppEvent) event.getData()).getMessage(), this); - setState(newState); // FIXME: is this ok to be here? - break; - - default: - logger.error("Invalid Event Type {} for SLg Client Session at state {}.", eventType, - sessionData.getSLgSessionState()); - break; - } - break; - - case MESSAGE_SENT_RECEIVED: - switch (eventType) { - case TIMEOUT_EXPIRES: - newState = SLgSessionState.TIMEDOUT; - setState(newState); - break; - - case SEND_MESSAGE: - try { - super.session.send(((AppEvent) event.getData()).getMessage(), this); - } finally { - newState = SLgSessionState.TERMINATED; - setState(newState); - } - break; - - case RECEIVE_PLA: - newState = SLgSessionState.TERMINATED; - setState(newState); - super.cancelMsgTimer(); - listener.doProvideLocationAnswerEvent(this, (ProvideLocationRequest) localEvent.getRequest(), - (ProvideLocationAnswer) localEvent.getAnswer()); - break; - - case RECEIVE_LRA: - newState = SLgSessionState.TERMINATED; - setState(newState); - super.cancelMsgTimer(); - listener.doLocationReportAnswerEvent(this, (LocationReportRequest) localEvent.getRequest(), - (LocationReportAnswer) localEvent.getAnswer()); - break; - - default: - throw new InternalException("Unexpected/Unknown message received: " + event.getData()); - } - break; - - case TERMINATED: - throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); - - case TIMEDOUT: - throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); - - default: - logger.error("SLg Client FSM in wrong state: {}", state); - break; - } + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); } catch (Exception e) { - throw new InternalException(e); - } finally { - sendAndStateLock.unlock(); + logger.debug("Failure handling Timeout event."); } - return true; + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void setState(SLgSessionState newState) { - SLgSessionState oldState = this.sessionData.getSLgSessionState(); - this.sessionData.setSLgSessionState(newState); - - for (StateChangeListener i : stateListeners) { - i.stateChanged(this, (Enum) oldState, (Enum) newState); - } - if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { - super.cancelMsgTimer(); - this.release(); - } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (int) (appId ^ (appId >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - public void onTimer(String timerName) { - if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { - try { - sendAndStateLock.lock(); - try { - handleEvent( - new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); - } catch (Exception e) { - logger.debug("Failure handling Timeout event."); - } - this.sessionData.setBuffer(null); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } - } + if (!super.equals(obj)) { + return false; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + (int) (appId ^ (appId >>> 32)); - return result; + if (getClass() != obj.getClass()) { + return false; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - SLgClientSessionImpl other = (SLgClientSessionImpl) obj; - if (appId != other.appId) { - return false; - } - return true; + SLgClientSessionImpl other = (SLgClientSessionImpl) obj; + if (appId != other.appId) { + return false; } - - @Override - public void release() { - if (isValid()) { - try { - sendAndStateLock.lock(); - super.release(); - } catch (Exception e) { - logger.debug("Failed to release session", e); - } finally { - sendAndStateLock.unlock(); - } - } else { - logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); - } + return true; + } + + @Override + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); } + } - private class RequestDelivery implements Runnable { - ClientSLgSession session; - Request request; - - public void run() { - try { - switch (request.getCommandCode()) { - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), null); - break; - } - } catch (Exception e) { - logger.debug("Failed to process request message", e); - } + private class RequestDelivery implements Runnable { + ClientSLgSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } } - - private class AnswerDelivery implements Runnable { - ClientSLgSession session; - Answer answer; - Request request; - - public void run() { - try { - switch (answer.getCommandCode()) { - - case ProvideLocationAnswer.code: - handleEvent(new Event(Event.Type.RECEIVE_PLA, messageFactory.createProvideLocationRequest(request), - messageFactory.createProvideLocationAnswer(answer))); - break; - - case LocationReportAnswer.code: - handleEvent(new Event(Event.Type.RECEIVE_LRA, messageFactory.createLocationReportRequest(request), - messageFactory.createLocationReportAnswer(answer))); - break; - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); - break; - } - } catch (Exception e) { - logger.debug("Failed to process success message", e); - } + } + + private class AnswerDelivery implements Runnable { + ClientSLgSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + + case ProvideLocationAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_PLA, messageFactory.createProvideLocationRequest(request), + messageFactory.createProvideLocationAnswer(answer))); + break; + + case LocationReportAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_LRA, messageFactory.createLocationReportRequest(request), + messageFactory.createLocationReportAnswer(answer))); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } } + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java index 6029910f8..2736c0c08 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/ClientSLhSessionDataLocalImpl.java @@ -29,6 +29,6 @@ */ public class ClientSLhSessionDataLocalImpl extends SLhLocalSessionDataImpl implements IClientSLhSessionData { - public ClientSLhSessionDataLocalImpl() { - } + public ClientSLhSessionDataLocalImpl() { + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java index c91422011..dab33d06b 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/Event.java @@ -29,58 +29,57 @@ * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * */ - public class Event implements StateEvent { - enum Type { - SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIA; - } + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIA; + } - AppEvent request; - AppEvent answer; - Type type; + AppEvent request; + AppEvent answer; + Type type; - Event(Type type, AppEvent request, AppEvent answer) { - this.type = type; - this.answer = answer; - this.request = request; - } + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } - @SuppressWarnings("unchecked") - public E encodeType(Class eClass) { - return eClass == Type.class ? (E) type : null; - } + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } - @SuppressWarnings("rawtypes") - public Enum getType() { - return type; - } + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } - public AppEvent getRequest() { - return request; - } + public AppEvent getRequest() { + return request; + } - public AppEvent getAnswer() { - return answer; - } + public AppEvent getAnswer() { + return answer; + } - public int compareTo(Object o) { - return 0; - } + public int compareTo(Object o) { + return 0; + } - public Object getData() { - return request != null ? request : answer; - } + public Object getData() { + return request != null ? request : answer; + } - public void setData(Object data) { - try { - if (((AppEvent) data).getMessage().isRequest()) { - request = (AppEvent) data; - } else { - answer = (AppEvent) data; - } - } catch (InternalException e) { - throw new IllegalArgumentException(e); - } + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java index 4891a9ff2..450dfeca5 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/app/slh/SLhClientSessionImpl.java @@ -50,267 +50,266 @@ * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * */ - public class SLhClientSessionImpl extends SLhSession - implements ClientSLhSession, EventListener, NetworkReqListener { - - private static final Logger logger = LoggerFactory.getLogger(SLhClientSessionImpl.class); + implements ClientSLhSession, EventListener, NetworkReqListener { - private transient ClientSLhSessionListener listener; + private static final Logger logger = LoggerFactory.getLogger(SLhClientSessionImpl.class); - protected long appId = -1; - protected IClientSLhSessionData sessionData; + private transient ClientSLhSessionListener listener; - public SLhClientSessionImpl(IClientSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, - ClientSLhSessionListener lst) { - super(sf, sessionData); - if (lst == null) { - throw new IllegalArgumentException("Listener can not be null"); - } - if (fct.getApplicationId() < 0) { - throw new IllegalArgumentException("ApplicationId can not be less than zero"); - } + protected long appId = -1; + protected IClientSLhSessionData sessionData; - this.appId = fct.getApplicationId(); - this.listener = lst; - super.messageFactory = fct; - this.sessionData = sessionData; + public SLhClientSessionImpl(IClientSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, + ClientSLhSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); } - - @SuppressWarnings("unchecked") - public E getState(Class stateType) { - return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + if (fct.getApplicationId() < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); } - public Answer processRequest(Request request) { - RequestDelivery rd = new RequestDelivery(); - rd.session = this; - rd.request = request; - super.scheduler.execute(rd); - return null; + this.appId = fct.getApplicationId(); + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + public void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, request, null); + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); } - - public void sendLCSRoutingInfoRequest(LCSRoutingInfoRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, request, null); + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); } - - public void receivedSuccessMessage(Request request, Answer answer) { - AnswerDelivery rd = new AnswerDelivery(); - rd.session = this; - rd.request = request; - rd.answer = answer; - super.scheduler.execute(rd); + } + + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLhSessionState state = this.sessionData.getSLhSessionState(); + SLhSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + switch (state) { + + case IDLE: + switch (eventType) { + + case SEND_MESSAGE: + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + super.session.send(((AppEvent) event.getData()).getMessage(), this); + setState(newState); // FIXME: is this ok to be here? + break; + + default: + logger.error("Invalid Event Type {} for SLh Client Session at state {}.", eventType, + sessionData.getSLhSessionState()); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLhSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLhSessionState.TERMINATED; + setState(newState); + } + break; + + case RECEIVE_RIA: + newState = SLhSessionState.TERMINATED; + setState(newState); + super.cancelMsgTimer(); + listener.doLCSRoutingInfoAnswerEvent(this, (LCSRoutingInfoRequest) localEvent.getRequest(), + (LCSRoutingInfoAnswer) localEvent.getAnswer()); + break; + + default: + throw new InternalException("Unexpected/Unknown message received: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLh Client FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); } + return true; + } - public void timeoutExpired(Request request) { - try { - handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); - } catch (Exception e) { - logger.debug("Failed to process timeout message", e); - } - } + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLhSessionState newState) { + SLhSessionState oldState = this.sessionData.getSLhSessionState(); + this.sessionData.setSLhSessionState(newState); - protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { - try { - if (type != null) { - handleEvent(new Event(type, request, answer)); - } - } catch (Exception e) { - throw new InternalException(e); - } + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); } + if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } - public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + public void onTimer(String timerName) { + if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); try { - sendAndStateLock.lock(); - if (!super.session.isValid()) { - // FIXME: throw new InternalException("Generic session is not valid."); - return false; - } - final SLhSessionState state = this.sessionData.getSLhSessionState(); - SLhSessionState newState = null; - Event localEvent = (Event) event; - Event.Type eventType = (Type) event.getType(); - switch (state) { - - case IDLE: - switch (eventType) { - - case SEND_MESSAGE: - newState = SLhSessionState.MESSAGE_SENT_RECEIVED; - super.session.send(((AppEvent) event.getData()).getMessage(), this); - setState(newState); // FIXME: is this ok to be here? - break; - - default: - logger.error("Invalid Event Type {} for SLh Client Session at state {}.", eventType, - sessionData.getSLhSessionState()); - break; - } - break; - - case MESSAGE_SENT_RECEIVED: - switch (eventType) { - case TIMEOUT_EXPIRES: - newState = SLhSessionState.TIMEDOUT; - setState(newState); - break; - - case SEND_MESSAGE: - try { - super.session.send(((AppEvent) event.getData()).getMessage(), this); - } finally { - newState = SLhSessionState.TERMINATED; - setState(newState); - } - break; - - case RECEIVE_RIA: - newState = SLhSessionState.TERMINATED; - setState(newState); - super.cancelMsgTimer(); - listener.doLCSRoutingInfoAnswerEvent(this, (LCSRoutingInfoRequest) localEvent.getRequest(), - (LCSRoutingInfoAnswer) localEvent.getAnswer()); - break; - - default: - throw new InternalException("Unexpected/Unknown message received: " + event.getData()); - } - break; - - case TERMINATED: - throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); - - case TIMEDOUT: - throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); - - default: - logger.error("SLh Client FSM in wrong state: {}", state); - break; - } + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); } catch (Exception e) { - throw new InternalException(e); - } finally { - sendAndStateLock.unlock(); + logger.debug("Failure handling Timeout event."); } - return true; + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void setState(SLhSessionState newState) { - SLhSessionState oldState = this.sessionData.getSLhSessionState(); - this.sessionData.setSLhSessionState(newState); - - for (StateChangeListener i : stateListeners) { - i.stateChanged(this, (Enum) oldState, (Enum) newState); - } - if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { - super.cancelMsgTimer(); - this.release(); - } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (int) (appId ^ (appId >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - public void onTimer(String timerName) { - if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { - try { - sendAndStateLock.lock(); - try { - handleEvent( - new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); - } catch (Exception e) { - logger.debug("Failure handling Timeout event."); - } - this.sessionData.setBuffer(null); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } - } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + (int) (appId ^ (appId >>> 32)); - return result; + SLhClientSessionImpl other = (SLhClientSessionImpl) obj; + if (appId != other.appId) { + return false; } + return true; + } + + @Override + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + } + } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } + private class RequestDelivery implements Runnable { + ClientSLhSession session; + Request request; - SLhClientSessionImpl other = (SLhClientSessionImpl) obj; - if (appId != other.appId) { - return false; - } - return true; - } + public void run() { + try { + switch (request.getCommandCode()) { - @Override - public void release() { - if (isValid()) { - try { - sendAndStateLock.lock(); - super.release(); - } catch (Exception e) { - logger.debug("Failed to release session", e); - } finally { - sendAndStateLock.unlock(); - } - } else { - logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } } + } - private class RequestDelivery implements Runnable { - ClientSLhSession session; - Request request; - - public void run() { - try { - switch (request.getCommandCode()) { - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), null); - break; - } - } catch (Exception e) { - logger.debug("Failed to process request message", e); - } - } - } + private class AnswerDelivery implements Runnable { + ClientSLhSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + + case LCSRoutingInfoAnswer.code: + handleEvent(new Event(Event.Type.RECEIVE_RIA, messageFactory.createLCSRoutingInfoRequest(request), + messageFactory.createLCSRoutingInfoAnswer(answer))); + break; - private class AnswerDelivery implements Runnable { - ClientSLhSession session; - Answer answer; - Request request; - - public void run() { - try { - switch (answer.getCommandCode()) { - - case LCSRoutingInfoAnswer.code: - handleEvent(new Event(Event.Type.RECEIVE_RIA, messageFactory.createLCSRoutingInfoRequest(request), - messageFactory.createLCSRoutingInfoAnswer(answer))); - break; - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); - break; - } - } catch (Exception e) { - logger.debug("Failed to process success message", e); - } + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java index bec720448..8081275fc 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgMessageFactory.java @@ -35,18 +35,18 @@ public interface ISLgMessageFactory { - ProvideLocationRequest createProvideLocationRequest(Request request); + ProvideLocationRequest createProvideLocationRequest(Request request); - ProvideLocationAnswer createProvideLocationAnswer(Answer answer); + ProvideLocationAnswer createProvideLocationAnswer(Answer answer); - LocationReportRequest createLocationReportRequest(Request request); + LocationReportRequest createLocationReportRequest(Request request); - LocationReportAnswer createLocationReportAnswer(Answer answer); + LocationReportAnswer createLocationReportAnswer(Answer answer); - /** - * Returns the Application-Id that this message factory is related to - * - * @return the Application-Id value - */ - long getApplicationId(); + /** + * Returns the Application-Id that this message factory is related to + * + * @return the Application-Id value + */ + long getApplicationId(); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java index e45d48369..e2155a479 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java @@ -30,19 +30,18 @@ * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * */ - public interface ISLgSessionData extends IAppSessionData { - public void setSLgSessionState(SLgSessionState state); + void setSLgSessionState(SLgSessionState state); - public SLgSessionState getSLgSessionState(); + SLgSessionState getSLgSessionState(); - public Serializable getTsTimerId(); + Serializable getTsTimerId(); - public void setTsTimerId(Serializable tid); + void setTsTimerId(Serializable tid); - public void setBuffer(Request buffer); + void setBuffer(Request buffer); - public Request getBuffer(); + Request getBuffer(); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java index 82680f0a6..132a03947 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionFactory.java @@ -25,7 +25,7 @@ import org.jdiameter.api.app.StateChangeListener; import org.jdiameter.api.slg.ClientSLgSessionListener; import org.jdiameter.api.slg.ServerSLgSessionListener; -import org.jdiameter.common.api.app.slg.ISLgMessageFactory; +// import org.jdiameter.common.api.app.slg.ISLgMessageFactory; /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) @@ -34,55 +34,56 @@ public interface ISLgSessionFactory { - /** - * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. - * However clustered session use this value when recreated! - * - * @return the serverSessionListener - */ - public ServerSLgSessionListener getServerSessionListener(); + /** + * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @return the serverSessionListener + */ + ServerSLgSessionListener getServerSessionListener(); - /** - * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. - * However clustered session use this value when recreated! - * - * @param serverSessionListener the serverSessionListener to set - */ - public void setServerSessionListener(ServerSLgSessionListener serverSessionListener); + /** + * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @param serverSessionListener the serverSessionListener to set + */ + void setServerSessionListener(ServerSLgSessionListener serverSessionListener); - /** - * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. - * However clustered session use this value when recreated! - * - * @return the clientSessionListener - */ - public ClientSLgSessionListener getClientSessionListener(); + /** + * Get stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @return the clientSessionListener + */ + ClientSLgSessionListener getClientSessionListener(); - /** - * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. - * However clustered session use this value when recreated! - * - * @param clientSessionListener the clientSessionListener to set - */ - public void setClientSessionListener(ClientSLgSessionListener clientSessionListener); + /** + * Set stack wide listener for sessions. In local mode it has similar effect as setting this directly in app session. + * However clustered session use this value when recreated! + * + * @param clientSessionListener the clientSessionListener to set + */ + void setClientSessionListener(ClientSLgSessionListener clientSessionListener); - /** - * @return the messageFactory - */ - public ISLgMessageFactory getMessageFactory(); + /** + * @return the messageFactory + */ + ISLgMessageFactory getMessageFactory(); - /** - * @param messageFactory the messageFactory to set - */ - public void setMessageFactory(ISLgMessageFactory messageFactory); + /** + * @param messageFactory the messageFactory to set + */ + void setMessageFactory(ISLgMessageFactory messageFactory); - /** - * @return the stateListener - */ - public StateChangeListener getStateListener(); + /** + * @return the stateListener + */ + StateChangeListener getStateListener(); + + /** + * @param stateListener the stateListener to set + */ + void setStateListener(StateChangeListener stateListener); - /** - * @param stateListener the stateListener to set - */ - public void setStateListener(StateChangeListener stateListener); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java index cde960644..a6e19d1a5 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhMessageFactory.java @@ -33,15 +33,15 @@ public interface ISLhMessageFactory { - LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request); + LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request); - LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer); + LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer); - /** - * Returns the Application-Id that this message factory is related to - * - * @return the Application-Id value - */ - long getApplicationId(); + /** + * Returns the Application-Id that this message factory is related to + * + * @return the Application-Id value + */ + long getApplicationId(); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java index 1345d9a7a..1e1090ee4 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionData.java @@ -33,16 +33,16 @@ public interface ISLhSessionData extends IAppSessionData { - public void setSLhSessionState(SLhSessionState state); + void setSLhSessionState(SLhSessionState state); - public SLhSessionState getSLhSessionState(); + SLhSessionState getSLhSessionState(); - public Serializable getTsTimerId(); + Serializable getTsTimerId(); - public void setTsTimerId(Serializable tid); + void setTsTimerId(Serializable tid); - public void setBuffer(Request buffer); + void setBuffer(Request buffer); - public Request getBuffer(); + Request getBuffer(); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java index e663e8461..db4ea4881 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slh/ISLhSessionFactory.java @@ -26,7 +26,7 @@ import org.jdiameter.api.slh.ClientSLhSessionListener; import org.jdiameter.api.slh.ServerSLhSessionListener; import org.jdiameter.common.api.app.IAppSessionFactory; -import org.jdiameter.common.api.app.slh.ISLhMessageFactory; +// import org.jdiameter.common.api.app.slh.ISLhMessageFactory; /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) @@ -34,57 +34,57 @@ */ public interface ISLhSessionFactory extends IAppSessionFactory { - - /** - * Get stack wide listener for sessions. In local mode it has similar effect - * as setting this directly in app session. However clustered session use this value when recreated! - * - * @return the serverSessionListener - */ - public ServerSLhSessionListener getServerSessionListener(); - /** - * Set stack wide listener for sessions. In local mode it has similar effect - * as setting this directly in app session. However clustered session use this value when recreated! - * - * @param serverSessionListener the serverSessionListener to set - */ - public void setServerSessionListener(ServerSLhSessionListener serverSessionListener); + /** + * Get stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @return the serverSessionListener + */ + ServerSLhSessionListener getServerSessionListener(); - /** - * Get stack wide listener for sessions. In local mode it has similar effect - * as setting this directly in app session. However clustered session use this value when recreated! - * - * @return the clientSessionListener - */ - public ClientSLhSessionListener getClientSessionListener(); + /** + * Set stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @param serverSessionListener the serverSessionListener to set + */ + void setServerSessionListener(ServerSLhSessionListener serverSessionListener); - /** - * Set stack wide listener for sessions. In local mode it has similar effect - * as setting this directly in app session. However clustered session use this value when recreated! - * - * @param clientSessionListener the clientSessionListener to set - */ - public void setClientSessionListener(ClientSLhSessionListener clientSessionListener); + /** + * Get stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @return the clientSessionListener + */ + ClientSLhSessionListener getClientSessionListener(); - /** - * @return the messageFactory - */ - public ISLhMessageFactory getMessageFactory(); + /** + * Set stack wide listener for sessions. In local mode it has similar effect + * as setting this directly in app session. However clustered session use this value when recreated! + * + * @param clientSessionListener the clientSessionListener to set + */ + void setClientSessionListener(ClientSLhSessionListener clientSessionListener); - /** - * @param messageFactory the messageFactory to set - */ - public void setMessageFactory(ISLhMessageFactory messageFactory); + /** + * @return the messageFactory + */ + ISLhMessageFactory getMessageFactory(); - /** - * @return the stateListener - */ - public StateChangeListener getStateListener(); + /** + * @param messageFactory the messageFactory to set + */ + void setMessageFactory(ISLhMessageFactory messageFactory); - /** - * @param stateListener the stateListener to set - */ - public void setStateListener(StateChangeListener stateListener); + /** + * @return the stateListener + */ + StateChangeListener getStateListener(); + + /** + * @param stateListener the stateListener to set + */ + void setStateListener(StateChangeListener stateListener); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java index c72f176d6..3c645822e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java @@ -21,7 +21,10 @@ package org.jdiameter.common.impl.app.slg; -import org.jdiameter.api.*; +import org.jdiameter.api.Avp; +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.AvpDataException; import org.jdiameter.api.slg.events.LocationReportAnswer; import org.jdiameter.common.impl.app.AppRequestEventImpl; import org.slf4j.Logger; @@ -36,14 +39,14 @@ public class LocationReportAnswerImpl extends AppRequestEventImpl implements Loc private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(LocationReportAnswerImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(LocationReportAnswerImpl.class); /** * * @param answer */ public LocationReportAnswerImpl(Answer answer) { - super(answer); + super(answer); } /** @@ -52,68 +55,68 @@ public LocationReportAnswerImpl(Answer answer) { * @param resultCode */ public LocationReportAnswerImpl(Request request, long resultCode) { - super(request.createAnswer(resultCode)); + super(request.createAnswer(resultCode)); } public Avp getResultCodeAvp() throws AvpDataException { - return null; + return null; } @Override public boolean isGMLCAddressAVPPresent(){ - return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; + return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; } @Override public java.net.InetAddress getGMLCAddress(){ Avp lcsGMLCAddressAvp = super.message.getAvps().getAvp(Avp.GMLC_ADDRESS); if (lcsGMLCAddressAvp != null) { - try { - return lcsGMLCAddressAvp.getAddress(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain GMLC Address AVP value", e); - } + try { + return lcsGMLCAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC Address AVP value", e); + } } return null; } @Override public boolean isLRAFlagsAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LRA_FLAGS) != null; + return super.message.getAvps().getAvp(Avp.LRA_FLAGS) != null; } @Override public long getLRAFLags(){ Avp lcsLRAFlagsAvp = super.message.getAvps().getAvp(Avp.LRA_FLAGS); if (lcsLRAFlagsAvp != null) { - try { - return lcsLRAFlagsAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS LRA Flags AVP value", e); - } + try { + return lcsLRAFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS LRA Flags AVP value", e); + } } return -1; } @Override public boolean isReportingPLMNListAVPPresent(){ - return super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST) != null; + return super.message.getAvps().getAvp(Avp.REPORTING_PLMN_LIST) != null; } @Override public boolean isPLMNIDListAVPPresent(){ - return super.message.getAvps().getAvp(Avp.PLMN_ID_LIST) != null; + return super.message.getAvps().getAvp(Avp.PLMN_ID_LIST) != null; } @Override public byte[] getVisitedPLMNId() { Avp lcsVisitedPLMNIdAvp = super.message.getAvps().getAvp(Avp.VISITED_PLMN_ID); if (lcsVisitedPLMNIdAvp != null) { - try { - return lcsVisitedPLMNIdAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Visited PLMN ID AVP value", e); - } + try { + return lcsVisitedPLMNIdAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Visited PLMN ID AVP value", e); + } } return null; } @@ -122,29 +125,29 @@ public byte[] getVisitedPLMNId() { public int getPeriodicLocationSupportIndicator() { Avp lcsPeriodicLocationSupportIndicatorAvp = super.message.getAvps().getAvp(Avp.PERIODIC_LOCATION_SUPPORT_INDICATOR); if (lcsPeriodicLocationSupportIndicatorAvp != null) { - try { - return lcsPeriodicLocationSupportIndicatorAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Periodic Location Support Indicator AVP value", e); - } + try { + return lcsPeriodicLocationSupportIndicatorAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Periodic Location Support Indicator AVP value", e); + } } return -1; } @Override public boolean isLCSReferenceNumberAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; + return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; } @Override public byte[] getLCSReferenceNumber(){ Avp lcsLCSReferenceNumberAvp = super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER); if (lcsLCSReferenceNumberAvp != null) { - try { - return lcsLCSReferenceNumberAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); - } + try { + return lcsLCSReferenceNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); + } } return null; } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java index d5c49227a..fd661f4e6 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportRequestImpl.java @@ -37,7 +37,7 @@ public class LocationReportRequestImpl extends AppRequestEventImpl implements Lo private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(LocationReportRequestImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(LocationReportRequestImpl.class); public LocationReportRequestImpl(Message message) { super(message); @@ -90,13 +90,13 @@ public byte[] getMSISDN() { Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); if (msisdnAvp != null) { try { - return msisdnAvp.getOctetString(); + return msisdnAvp.getOctetString(); } catch (AvpDataException e) { logger.debug("Failure trying to obtain MSISDN AVP value", e); } } return null; - } + } @Override public boolean isIMEIAVPPresent() { @@ -118,18 +118,18 @@ public String getIMEI() { @Override public boolean isLCSEPSClientNameAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME) != null; + return super.message.getAvps().getAvp(Avp.LCS_EPS_CLIENT_NAME) != null; } @Override public String getLSCNameString(){ Avp lcsEpsClientNameStringAvp = super.message.getAvps().getAvp(Avp.LCS_NAME_STRING); if (lcsEpsClientNameStringAvp != null) { - try { - return lcsEpsClientNameStringAvp.getUTF8String(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-EPS-Client-Name-String AVP value", e); - } + try { + return lcsEpsClientNameStringAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-EPS-Client-Name-String AVP value", e); + } } return null; } @@ -138,137 +138,137 @@ public String getLSCNameString(){ public int getLCSFormatIndicator(){ Avp lcsEpsClientFormatIndicatorAvp = super.message.getAvps().getAvp(Avp.LCS_FORMAT_INDICATOR); if (lcsEpsClientFormatIndicatorAvp != null) { - try { - return lcsEpsClientFormatIndicatorAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-EPS-Client-Format-Indicator AVP value", e); - } + try { + return lcsEpsClientFormatIndicatorAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-EPS-Client-Format-Indicator AVP value", e); + } } return -1; } @Override public boolean isLocationEstimateAvpPresent(){ - return super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE) != null; + return super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE) != null; } @Override public String getLocationEstimate() { Avp lcsLocationEstimateAvp = super.message.getAvps().getAvp(Avp.LOCATION_ESTIMATE); if (lcsLocationEstimateAvp != null) { - try { - return lcsLocationEstimateAvp.getUTF8String(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Location-Estimate AVP value", e); - } + try { + return lcsLocationEstimateAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Location-Estimate AVP value", e); + } } return null; } @Override public boolean isAccuracyFulfilmentIndicatorAvpPresent(){ - return super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR) != null; + return super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR) != null; } @Override public int getAccuracyFulfilmentIndicator() { Avp lcsAccuracyFulfilmentIndAvp = super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR); if (lcsAccuracyFulfilmentIndAvp != null) { - try { - return lcsAccuracyFulfilmentIndAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Accuracy fulfilment indicator AVP value", e); - } + try { + return lcsAccuracyFulfilmentIndAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Accuracy fulfilment indicator AVP value", e); + } } return -1; } @Override public boolean isAgeOfLocationEstimateAvpPresent(){ - return super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE) != null; + return super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE) != null; } @Override public long getAgeOfLocationEstimate() { Avp lcsAgeOfLocEstimateAvp = super.message.getAvps().getAvp(Avp.AGE_OF_LOCATION_ESTIMATE); if (lcsAgeOfLocEstimateAvp != null) { - try { - return lcsAgeOfLocEstimateAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Age of Location Estimate AVP value", e); - } + try { + return lcsAgeOfLocEstimateAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Age of Location Estimate AVP value", e); + } } return -1; } @Override public boolean isVelocityEstimateAvpPresent(){ - return super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE) != null; + return super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE) != null; } @Override public byte[] getVelocityEstimate() { Avp lcsVelEstimateAvp = super.message.getAvps().getAvp(Avp.VELOCITY_ESTIMATE); if (lcsVelEstimateAvp != null) { - try { - return lcsVelEstimateAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Velocity Estimate AVP value", e); - } + try { + return lcsVelEstimateAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Velocity Estimate AVP value", e); + } } return null; } @Override public boolean isEUTRANPositioningDataAvpPresent(){ - return super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA) != null; + return super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA) != null; } @Override public byte[] getEUTRANPositioningData() { Avp lcsEUTRANPosDataAvp = super.message.getAvps().getAvp(Avp.EUTRAN_POSITIONING_DATA); if (lcsEUTRANPosDataAvp != null) { - try { - return lcsEUTRANPosDataAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS E-UTRAN-Positioning-Data AVP value", e); - } + try { + return lcsEUTRANPosDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS E-UTRAN-Positioning-Data AVP value", e); + } } return null; } @Override public boolean isECGIAvpPresent(){ - return super.message.getAvps().getAvp(Avp.ECGI) != null; + return super.message.getAvps().getAvp(Avp.ECGI) != null; } @Override public byte[] getECGI(){ Avp lcsECGIAvp = super.message.getAvps().getAvp(Avp.ECGI); if (lcsECGIAvp != null) { - try { - return lcsECGIAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS ECGI AVP value", e); - } + try { + return lcsECGIAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS ECGI AVP value", e); + } } return null; } @Override public boolean isGERANPositioningInfoAvpPresent(){ - return super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO) != null; + return super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_INFO) != null; } @Override public byte[] getGERANPositioningData(){ Avp lcsGERANPositioningDataAvp = super.message.getAvps().getAvp(Avp.GERAN_POSITIONING_DATA); if (lcsGERANPositioningDataAvp != null) { - try { - return lcsGERANPositioningDataAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); - } + try { + return lcsGERANPositioningDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-Positioning-Data AVP value", e); + } } return null; } @@ -277,47 +277,47 @@ public byte[] getGERANPositioningData(){ public byte[] getGERANGANSSPositioningData(){ Avp lcsGERANGANSSPositioningDataAvp = super.message.getAvps().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA); if (lcsGERANGANSSPositioningDataAvp != null) { - try { - return lcsGERANGANSSPositioningDataAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS GERAN-GANSS-Positioning-Data AVP value", e); - } + try { + return lcsGERANGANSSPositioningDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS GERAN-GANSS-Positioning-Data AVP value", e); + } } return null; } @Override public boolean isCellGlobalIdentityAvpPresent(){ - return super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY) != null; + return super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY) != null; } @Override public byte[] getCellGlobalIdentity(){ Avp lcsCellGlobalIdAvp = super.message.getAvps().getAvp(Avp.CELL_GLOBAL_IDENTITY); if (lcsCellGlobalIdAvp != null) { - try { - return lcsCellGlobalIdAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Cell-Global-Identity AVP value", e); - } + try { + return lcsCellGlobalIdAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Global-Identity AVP value", e); + } } return null; } @Override public boolean isUTRANPositioningInfoAvpPresent(){ - return super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO) != null; + return super.message.getAvps().getAvp(Avp.UTRAN_POSITIONING_INFO) != null; } @Override public byte[] getUTRANPositioningData(){ Avp lcsUTRANPosDataAvp = super.message.getAvps().getAvp(Avp.UTRAN_ADDITIONAL_POSITIONING_DATA); if (lcsUTRANPosDataAvp != null) { - try { - return lcsUTRANPosDataAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS UTRAN-Positionin-Data AVP value", e); - } + try { + return lcsUTRANPosDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-Positionin-Data AVP value", e); + } } return null; } @@ -326,29 +326,29 @@ public byte[] getUTRANPositioningData(){ public byte[] getUTRANGANSSPositioningData(){ Avp lcsUTRANGANSSPosDataAvp = super.message.getAvps().getAvp(Avp.UTRAN_GANSS_POSITIONING_DATA); if (lcsUTRANGANSSPosDataAvp != null) { - try { - return lcsUTRANGANSSPosDataAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS UTRAN-GANSS-Positionin-Data AVP value", e); - } + try { + return lcsUTRANGANSSPosDataAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS UTRAN-GANSS-Positionin-Data AVP value", e); + } } return null; } @Override public boolean isServiceAreaIdentityAvpPresent(){ - return super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY) != null; + return super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY) != null; } @Override public byte[] getServiceAreaIdentity(){ Avp lcsServiceAreaIdentityAvp = super.message.getAvps().getAvp(Avp.SERVICE_AREA_IDENTITY); if (lcsServiceAreaIdentityAvp != null) { - try { - return lcsServiceAreaIdentityAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS SERVICE-AREA-IDENTITY AVP value", e); - } + try { + return lcsServiceAreaIdentityAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS SERVICE-AREA-IDENTITY AVP value", e); + } } return null; } @@ -362,47 +362,47 @@ public boolean isLCSServiceTypeIDAVPPresent(){ public long getLCSServiceTypeID(){ Avp lcsLCSServiceTypeIDAvp = super.message.getAvps().getAvp(Avp.LCS_SERVICE_TYPE_ID); if (lcsLCSServiceTypeIDAvp != null) { - try { - return lcsLCSServiceTypeIDAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Service Type ID AVP value", e); - } + try { + return lcsLCSServiceTypeIDAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Service Type ID AVP value", e); + } } return -1; } @Override public boolean isPseudonymIndicatorAVPPresent(){ - return super.message.getAvps().getAvp(Avp.PSEUDONYM_INDICATOR) != null; + return super.message.getAvps().getAvp(Avp.PSEUDONYM_INDICATOR) != null; } @Override public int getPseudonymIndicator(){ Avp lcsPseudonymIndicatorAvp = super.message.getAvps().getAvp(Avp.PSEUDONYM_INDICATOR); if (lcsPseudonymIndicatorAvp != null) { - try { - return lcsPseudonymIndicatorAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Pseudonym Indicator AVP value", e); - } + try { + return lcsPseudonymIndicatorAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Pseudonym Indicator AVP value", e); + } } return -1; } @Override public boolean isLCSQoSAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_QOS) != null; + return super.message.getAvps().getAvp(Avp.LCS_QOS) != null; } @Override public int getLCSQoSClass(){ Avp lcsQoSClassAvp = super.message.getAvps().getAvp(Avp.LCS_QOS_CLASS); if (lcsQoSClassAvp != null) { - try { - return lcsQoSClassAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS-Class AVP value", e); - } + try { + return lcsQoSClassAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS-Class AVP value", e); + } } return -1; } @@ -411,11 +411,11 @@ public int getLCSQoSClass(){ public long getHorizontalAccuracy(){ Avp lcsHorizontalAccuracyAvp = super.message.getAvps().getAvp(Avp.HORIZONTAL_ACCURACY); if (lcsHorizontalAccuracyAvp != null) { - try { - return lcsHorizontalAccuracyAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS Horizontal Accuracy AVP value", e); - } + try { + return lcsHorizontalAccuracyAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS Horizontal Accuracy AVP value", e); + } } return -1; } @@ -424,11 +424,11 @@ public long getHorizontalAccuracy(){ public long getVerticalAccuracy(){ Avp lcsVerticalAccuracyAvp = super.message.getAvps().getAvp(Avp.VERTICAL_ACCURACY); if (lcsVerticalAccuracyAvp != null) { - try { - return lcsVerticalAccuracyAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS Vertical Accuracy AVP value", e); - } + try { + return lcsVerticalAccuracyAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS Vertical Accuracy AVP value", e); + } } return -1; } @@ -437,11 +437,11 @@ public long getVerticalAccuracy(){ public int getVerticalRequested(){ Avp lcsVerticalAccuracyAvp = super.message.getAvps().getAvp(Avp.VERTICAL_REQUESTED); if (lcsVerticalAccuracyAvp != null) { - try { - return lcsVerticalAccuracyAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS Vertical Requested AVP value", e); - } + try { + return lcsVerticalAccuracyAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS Vertical Requested AVP value", e); + } } return -1; } @@ -450,70 +450,70 @@ public int getVerticalRequested(){ public int getResponseTime(){ Avp lcsResponseTimeAvp = super.message.getAvps().getAvp(Avp.RESPONSE_TIME); if (lcsResponseTimeAvp != null) { - try { - return lcsResponseTimeAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS Response Time AVP value", e); - } + try { + return lcsResponseTimeAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS Response Time AVP value", e); + } } return -1; } @Override public boolean isServingNodeAvpPresent() { - return super.message.getAvps().getAvp(Avp.SERVING_NODE) != null; + return super.message.getAvps().getAvp(Avp.SERVING_NODE) != null; } @Override public boolean isLRRFlagsAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LRR_FLAGS) != null; + return super.message.getAvps().getAvp(Avp.LRR_FLAGS) != null; } @Override public long getLRRFLags(){ Avp lcsLRRFlagsAvp = super.message.getAvps().getAvp(Avp.LRR_FLAGS); if (lcsLRRFlagsAvp != null) { - try { - return lcsLRRFlagsAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS LRR Flags AVP value", e); - } + try { + return lcsLRRFlagsAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS LRR Flags AVP value", e); + } } return -1; } @Override public boolean isLCSReferenceNumberAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; + return super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER) != null; } @Override public byte[] getLCSReferenceNumber(){ Avp lcsLCSReferenceNumberAvp = super.message.getAvps().getAvp(Avp.LCS_REFERENCE_NUMBER); if (lcsLCSReferenceNumberAvp != null) { - try { - return lcsLCSReferenceNumberAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); - } + try { + return lcsLCSReferenceNumberAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reference Number AVP value", e); + } } return null; } @Override public boolean isDeferredMTLRDataAVPPresent(){ - return super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA) != null; + return super.message.getAvps().getAvp(Avp.DEFERRED_MT_LR_DATA) != null; } @Override public long getDeferredLocationType(){ Avp lcsDeferredLocationTypeAvp = super.message.getAvps().getAvp(Avp.DEFERRED_LOCATION_TYPE); if (lcsDeferredLocationTypeAvp != null) { - try { - return lcsDeferredLocationTypeAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Deferred Location Type AVP value", e); - } + try { + return lcsDeferredLocationTypeAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Deferred Location Type AVP value", e); + } } return -1; } @@ -522,124 +522,124 @@ public long getDeferredLocationType(){ public long getTerminationCause(){ Avp lcsTerminationCauseAvp = super.message.getAvps().getAvp(Avp.TERMINATION_CAUSE_LCS); if (lcsTerminationCauseAvp != null) { - try { - return lcsTerminationCauseAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Termination Cause AVP value", e); - } + try { + return lcsTerminationCauseAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Termination Cause AVP value", e); + } } return -1; } @Override public boolean isGMLCAddressAVPPresent(){ - return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; + return super.message.getAvps().getAvp(Avp.GMLC_ADDRESS) != null; } @Override public java.net.InetAddress getGMLCAddress(){ Avp lcsGMLCAddressAvp = super.message.getAvps().getAvp(Avp.GMLC_ADDRESS); if (lcsGMLCAddressAvp != null) { - try { - return lcsGMLCAddressAvp.getAddress(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain GMLC Address AVP value", e); - } + try { + return lcsGMLCAddressAvp.getAddress(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain GMLC Address AVP value", e); + } } return null; } @Override public boolean isPeriodicLDRInformationAVPPresent(){ - return super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION) != null; + return super.message.getAvps().getAvp(Avp.PERIODIC_LDR_INFORMATION) != null; } @Override public boolean isReportingAmountAVPPresent(){ - return super.message.getAvps().getAvp(Avp.REPORTING_AMOUNT) != null; + return super.message.getAvps().getAvp(Avp.REPORTING_AMOUNT) != null; } @Override public long getReportingAmount(){ Avp lcsReportingAmountAvp = super.message.getAvps().getAvp(Avp.REPORTING_AMOUNT); if (lcsReportingAmountAvp != null) { - try { - return lcsReportingAmountAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); - } + try { + return lcsReportingAmountAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); + } } return -1; } @Override public boolean isESMLCCellInfoAvpPresent(){ - return super.message.getAvps().getAvp(Avp.ESMLC_CELL_INFO) != null; + return super.message.getAvps().getAvp(Avp.ESMLC_CELL_INFO) != null; } @Override public long getCellPortionId(){ Avp lcsCellPortionIdAvp = super.message.getAvps().getAvp(Avp.CELL_PORTION_ID); if (lcsCellPortionIdAvp != null) { - try { - return lcsCellPortionIdAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Cell-Portion-Id AVP value", e); - } + try { + return lcsCellPortionIdAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Cell-Portion-Id AVP value", e); + } } return -1; } @Override public boolean is1xRTTRCIDAVPPresent(){ - return super.message.getAvps().getAvp(Avp.ONEXRTT_RCID) != null; + return super.message.getAvps().getAvp(Avp.ONEXRTT_RCID) != null; } @Override public byte[] get1xRTTRCID(){ Avp lcs1xRTTRCIDAvp = super.message.getAvps().getAvp(Avp.ONEXRTT_RCID); if (lcs1xRTTRCIDAvp != null) { - try { - return lcs1xRTTRCIDAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS 1xRTT_RCID AVP value", e); - } + try { + return lcs1xRTTRCIDAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS 1xRTT_RCID AVP value", e); + } } return null; } @Override public boolean isCivicAddressAvpPresent(){ - return super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS) != null; + return super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS) != null; } @Override public String getCivicAddress(){ Avp lcsCivicAddressAvp = super.message.getAvps().getAvp(Avp.CIVIC_ADDRESS); if (lcsCivicAddressAvp != null) { - try { - return lcsCivicAddressAvp.getUTF8String(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Civic Address AVP value", e); - } + try { + return lcsCivicAddressAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Civic Address AVP value", e); + } } return null; } @Override public boolean isBarometricPressureAvpPresent(){ - return super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE) != null; + return super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE) != null; } @Override public long getBarometricPressure(){ Avp lcsBarometricPressureAvp = super.message.getAvps().getAvp(Avp.BAROMETRIC_PRESSURE); if (lcsBarometricPressureAvp != null) { - try { - return lcsBarometricPressureAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Barometric Pressure AVP value", e); - } + try { + return lcsBarometricPressureAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Barometric Pressure AVP value", e); + } } return -1; } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java index f1cc4ef69..892787216 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java @@ -21,7 +21,10 @@ package org.jdiameter.common.impl.app.slg; -import org.jdiameter.api.*; +import org.jdiameter.api.Avp; +import org.jdiameter.api.Answer; +import org.jdiameter.api.Request; +import org.jdiameter.api.AvpDataException; import org.jdiameter.api.slg.events.ProvideLocationAnswer; import org.jdiameter.common.impl.app.AppRequestEventImpl; import org.slf4j.Logger; @@ -36,7 +39,7 @@ public class ProvideLocationAnswerImpl extends AppRequestEventImpl implements Pr private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); /** * @@ -53,7 +56,7 @@ public ProvideLocationAnswerImpl(Answer answer) { */ public ProvideLocationAnswerImpl(Request request, long resultCode) { super(request.createAnswer(resultCode)); - } + } public Avp getResultCodeAvp() throws AvpDataException { return null; @@ -85,7 +88,7 @@ public boolean isAccuracyFulfilmentIndicatorAvpPresent(){ @Override public int getAccuracyFulfilmentIndicator() { Avp lcsAccuracyFulfilmentIndAvp = super.message.getAvps().getAvp(Avp.ACCURACY_FULFILMENT_INDICATOR); - if (lcsAccuracyFulfilmentIndAvp != null) { + if (lcsAccuracyFulfilmentIndAvp != null) { try { return lcsAccuracyFulfilmentIndAvp.getInteger32(); } catch (AvpDataException e) { @@ -190,7 +193,7 @@ public byte[] getGERANGANSSPositioningData(){ Avp lcsGERANGANSSPositioningDataAvp = super.message.getAvps().getAvp(Avp.GERAN_GANSS_POSITIONING_DATA); if (lcsGERANGANSSPositioningDataAvp != null) { try { - return lcsGERANGANSSPositioningDataAvp.getOctetString(); + return lcsGERANGANSSPositioningDataAvp.getOctetString(); } catch (AvpDataException e) { logger.debug("Failure trying to obtain LCS GERAN-GANSS-Positioning-Data AVP value", e); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java index 10635947f..fe77e58f3 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationRequestImpl.java @@ -37,7 +37,7 @@ public class ProvideLocationRequestImpl extends AppRequestEventImpl implements P private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(ProvideLocationRequestImpl.class); public ProvideLocationRequestImpl(Message message) { super(message); @@ -123,15 +123,15 @@ public boolean isLCSEPSClientNameAVPPresent(){ @Override public String getLSCNameString(){ - Avp lcsEpsClientNameStringAvp = super.message.getAvps().getAvp(Avp.LCS_NAME_STRING); - if (lcsEpsClientNameStringAvp != null) { - try { - return lcsEpsClientNameStringAvp.getUTF8String(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-EPS-Client-Name-String AVP value", e); - } + Avp lcsEpsClientNameStringAvp = super.message.getAvps().getAvp(Avp.LCS_NAME_STRING); + if (lcsEpsClientNameStringAvp != null) { + try { + return lcsEpsClientNameStringAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-EPS-Client-Name-String AVP value", e); } - return null; + } + return null; } @Override @@ -166,18 +166,18 @@ public int getLCSClientType(){ } @Override - public boolean isLCSRequestorNamePresent(){ - return super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME) != null; + public boolean isLCSRequestorNamePresent(){ + return super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_NAME) != null; } @Override public String getLCSRequestorIdString(){ Avp lcsRequestorIdStringAvp = super.message.getAvps().getAvp(Avp.LCS_REQUESTOR_ID_STRING); - if (lcsRequestorIdStringAvp != null) { - try { - return lcsRequestorIdStringAvp.getUTF8String(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-Requestor-Id-String AVP value", e); + if (lcsRequestorIdStringAvp != null) { + try { + return lcsRequestorIdStringAvp.getUTF8String(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-Requestor-Id-String AVP value", e); } } return null; @@ -210,8 +210,8 @@ public boolean isLCSQoSAVPPresent(){ public int getLCSQoSClass(){ Avp lcsQoSClassAvp = super.message.getAvps().getAvp(Avp.LCS_QOS_CLASS); if (lcsQoSClassAvp != null) { - try { - return lcsQoSClassAvp.getInteger32(); + try { + return lcsQoSClassAvp.getInteger32(); } catch (AvpDataException e) { logger.debug("Failure trying to obtain LCS-QoS-Class AVP value", e); } @@ -261,11 +261,11 @@ public int getVerticalRequested(){ @Override public int getResponseTime(){ Avp lcsResponseTimeAvp = super.message.getAvps().getAvp(Avp.RESPONSE_TIME); - if (lcsResponseTimeAvp != null) { - try { - return lcsResponseTimeAvp.getInteger32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS-QoS Response Time AVP value", e); + if (lcsResponseTimeAvp != null) { + try { + return lcsResponseTimeAvp.getInteger32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS-QoS Response Time AVP value", e); } } return -1; @@ -291,7 +291,7 @@ public byte[] getVelocityRequested(){ @Override public boolean isSupportedGADShapesAVPPresent(){ - return super.message.getAvps().getAvp(Avp.SUPPORTED_GAD_SHAPES) != null; + return super.message.getAvps().getAvp(Avp.SUPPORTED_GAD_SHAPES) != null; } @Override @@ -379,10 +379,10 @@ public int getLCSPrivacyCheckSession(){ return -1; } - @Override - public boolean isLCSPrivacyCheckNonSessionAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_NON_SESSION) != null; - } + @Override + public boolean isLCSPrivacyCheckNonSessionAVPPresent(){ + return super.message.getAvps().getAvp(Avp.LCS_PRIVACY_CHECK_NON_SESSION) != null; + } @Override public int getLCSPrivacyCheckNonSession(){ @@ -509,11 +509,11 @@ public boolean isPeriodicLDRInformationAVPPresent(){ public long getReportingAmount(){ Avp lcsReportingAmountAvp = super.message.getAvps().getAvp(Avp.REPORTING_AMOUNT); if (lcsReportingAmountAvp != null) { - try { - return lcsReportingAmountAvp.getUnsigned32(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); - } + try { + return lcsReportingAmountAvp.getUnsigned32(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LCS Reporting amount AVP value", e); + } } return -1; } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java index 68faaf562..789de715f 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataFactory.java @@ -36,17 +36,17 @@ public class SLgLocalSessionDataFactory implements IAppSessionDataFactory { - public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { - if (clazz.equals(ClientSLgSession.class)) { - ClientSLgSessionDataLocalImpl data = new ClientSLgSessionDataLocalImpl(); - data.setSessionId(sessionId); - return data; - } else if (clazz.equals(ServerSLgSession.class)) { - ServerSLgSessionDataLocalImpl data = new ServerSLgSessionDataLocalImpl(); - data.setSessionId(sessionId); - return data; - } else { - throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); - } + public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLgSession.class)) { + ClientSLgSessionDataLocalImpl data = new ClientSLgSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else if (clazz.equals(ServerSLgSession.class)) { + ServerSLgSessionDataLocalImpl data = new ServerSLgSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else { + throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java index d2cdc7d55..946cdc74a 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgLocalSessionDataImpl.java @@ -35,31 +35,31 @@ public class SLgLocalSessionDataImpl extends AppSessionDataLocalImpl implements ISLgSessionData { - protected SLgSessionState state = SLgSessionState.IDLE; - protected Request buffer; - protected Serializable tsTimerId; + protected SLgSessionState state = SLgSessionState.IDLE; + protected Request buffer; + protected Serializable tsTimerId; - public void setSLgSessionState(SLgSessionState state) { - this.state = state; - } + public void setSLgSessionState(SLgSessionState state) { + this.state = state; + } - public SLgSessionState getSLgSessionState() { - return this.state; - } + public SLgSessionState getSLgSessionState() { + return this.state; + } - public Serializable getTsTimerId() { - return this.tsTimerId; - } + public Serializable getTsTimerId() { + return this.tsTimerId; + } - public void setTsTimerId(Serializable tid) { - this.tsTimerId = tid; - } + public void setTsTimerId(Serializable tid) { + this.tsTimerId = tid; + } - public void setBuffer(Request buffer) { - this.buffer = buffer; - } + public void setBuffer(Request buffer) { + this.buffer = buffer; + } - public Request getBuffer() { - return this.buffer; - } + public Request getBuffer() { + return this.buffer; + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java index 9db0b5baa..973c5477e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSession.java @@ -42,93 +42,93 @@ public abstract class SLgSession extends AppSessionImpl implements NetworkReqListener, StateMachine { - public static final int _TX_TIMEOUT = 30 * 1000; + public static final int _TX_TIMEOUT = 30 * 1000; - protected Lock sendAndStateLock = new ReentrantLock(); + protected Lock sendAndStateLock = new ReentrantLock(); - @SuppressWarnings("rawtypes") - protected transient List stateListeners = new CopyOnWriteArrayList(); - protected transient ISLgMessageFactory messageFactory; + @SuppressWarnings("rawtypes") + protected transient List stateListeners = new CopyOnWriteArrayList(); + protected transient ISLgMessageFactory messageFactory; - protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; - protected ISLgSessionData sessionData; + protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; + protected ISLgSessionData sessionData; - public SLgSession(ISessionFactory sf, ISLgSessionData sessionData) { - super(sf, sessionData); - this.sessionData = sessionData; - } + public SLgSession(ISessionFactory sf, ISLgSessionData sessionData) { + super(sf, sessionData); + this.sessionData = sessionData; + } - @SuppressWarnings("rawtypes") - public void addStateChangeNotification(StateChangeListener listener) { - if (!stateListeners.contains(listener)) { - stateListeners.add(listener); - } + @SuppressWarnings("rawtypes") + public void addStateChangeNotification(StateChangeListener listener) { + if (!stateListeners.contains(listener)) { + stateListeners.add(listener); } - - @SuppressWarnings("rawtypes") - public void removeStateChangeNotification(StateChangeListener listener) { - stateListeners.remove(listener); + } + + @SuppressWarnings("rawtypes") + public void removeStateChangeNotification(StateChangeListener listener) { + stateListeners.remove(listener); + } + + public boolean isStateless() { + return true; + } + + @Override + public boolean isReplicable() { + return false; + } + + protected void startMsgTimer() { + try { + sendAndStateLock.lock(); + sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); + } finally { + sendAndStateLock.unlock(); } - - public boolean isStateless() { - return true; + } + + protected void cancelMsgTimer() { + try { + sendAndStateLock.lock(); + final Serializable timerId = this.sessionData.getTsTimerId(); + if (timerId == null) { + return; + } + super.timerFacility.cancel(timerId); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); } - - @Override - public boolean isReplicable() { - return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - protected void startMsgTimer() { - try { - sendAndStateLock.lock(); - sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); - } finally { - sendAndStateLock.unlock(); - } + if (!super.equals(obj)) { + return false; } - - protected void cancelMsgTimer() { - try { - sendAndStateLock.lock(); - final Serializable timerId = this.sessionData.getTsTimerId(); - if (timerId == null) { - return; - } - super.timerFacility.cancel(timerId); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); - return result; + if (getClass() != obj.getClass()) { + return false; } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SLgSession other = (SLgSession) obj; - if (sessionData == null) { - if (other.sessionData != null) { - return false; - } - } else if (!sessionData.equals(other.sessionData)) { - return false; - } - return true; + SLgSession other = (SLgSession) obj; + if (sessionData == null) { + if (other.sessionData != null) { + return false; + } + } else if (!sessionData.equals(other.sessionData)) { + return false; } + return true; + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java index a051fe125..a82d06c84 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java @@ -62,230 +62,230 @@ public class SLgSessionFactoryImpl implements ISLgSessionFactory, ServerSLgSessionListener, ClientSLgSessionListener, ISLgMessageFactory, StateChangeListener { - private static final Logger logger = LoggerFactory.getLogger(SLgSessionFactoryImpl.class); - - protected ISessionFactory sessionFactory; - - protected ServerSLgSessionListener serverSessionListener; - protected ClientSLgSessionListener clientSessionListener; - - protected ISLgMessageFactory messageFactory; - protected StateChangeListener stateListener; - protected ISessionDatasource iss; - protected IAppSessionDataFactory sessionDataFactory; - - public SLgSessionFactoryImpl() { - }; - - public SLgSessionFactoryImpl(SessionFactory sessionFactory) { - super(); - init(sessionFactory); + private static final Logger logger = LoggerFactory.getLogger(SLgSessionFactoryImpl.class); + + protected ISessionFactory sessionFactory; + + protected ServerSLgSessionListener serverSessionListener; + protected ClientSLgSessionListener clientSessionListener; + + protected ISLgMessageFactory messageFactory; + protected StateChangeListener stateListener; + protected ISessionDatasource iss; + protected IAppSessionDataFactory sessionDataFactory; + + public SLgSessionFactoryImpl() { + }; + + public SLgSessionFactoryImpl(SessionFactory sessionFactory) { + super(); + init(sessionFactory); + } + + public void init(SessionFactory sessionFactory) { + this.sessionFactory = (ISessionFactory) sessionFactory; + this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); + this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLgSessionData.class); + } + + /** + * @return the serverSessionListener + */ + public ServerSLgSessionListener getServerSessionListener() { + return serverSessionListener != null ? serverSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setServerSessionListener(ServerSLgSessionListener serverSessionListener) { + this.serverSessionListener = serverSessionListener; + } + + /** + * @return the serverSessionListener + */ + public ClientSLgSessionListener getClientSessionListener() { + return clientSessionListener != null ? clientSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setClientSessionListener(ClientSLgSessionListener clientSessionListener) { + this.clientSessionListener = clientSessionListener; + } + + /** + * @return the messageFactory + */ + public ISLgMessageFactory getMessageFactory() { + return messageFactory != null ? messageFactory : this; + } + + /** + * @param messageFactory the messageFactory to set + */ + public void setMessageFactory(ISLgMessageFactory messageFactory) { + this.messageFactory = messageFactory; + } + + /** + * @return the stateListener + */ + public StateChangeListener getStateListener() { + return stateListener != null ? stateListener : this; + } + + /** + * @param stateListener the stateListener to set + */ + public void setStateListener(StateChangeListener stateListener) { + this.stateListener = stateListener; + } + + public AppSession getSession(String sessionId, Class aClass) { + if (sessionId == null) { + throw new IllegalArgumentException("SessionId must not be null"); } - - public void init(SessionFactory sessionFactory) { - this.sessionFactory = (ISessionFactory) sessionFactory; - this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); - this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLgSessionData.class); + if (!this.iss.exists(sessionId)) { + return null; } - - /** - * @return the serverSessionListener - */ - public ServerSLgSessionListener getServerSessionListener() { - return serverSessionListener != null ? serverSessionListener : this; + AppSession appSession = null; + try { + if (aClass == ServerSLgSession.class) { + IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLgSession.class, sessionId); + SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLgSession.class) { + IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLgSession.class, sessionId); + SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLg Session.", e); } + return appSession; + } - /** - * @param serverSessionListener the serverSessionListener to set - */ - public void setServerSessionListener(ServerSLgSessionListener serverSessionListener) { - this.serverSessionListener = serverSessionListener; - } - - /** - * @return the serverSessionListener - */ - public ClientSLgSessionListener getClientSessionListener() { - return clientSessionListener != null ? clientSessionListener : this; - } + public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, + Object[] args) { + AppSession appSession = null; - /** - * @param serverSessionListener the serverSessionListener to set - */ - public void setClientSessionListener(ClientSLgSessionListener clientSessionListener) { - this.clientSessionListener = clientSessionListener; - } - - /** - * @return the messageFactory - */ - public ISLgMessageFactory getMessageFactory() { - return messageFactory != null ? messageFactory : this; - } - - /** - * @param messageFactory the messageFactory to set - */ - public void setMessageFactory(ISLgMessageFactory messageFactory) { - this.messageFactory = messageFactory; - } - - /** - * @return the stateListener - */ - public StateChangeListener getStateListener() { - return stateListener != null ? stateListener : this; - } - - /** - * @param stateListener the stateListener to set - */ - public void setStateListener(StateChangeListener stateListener) { - this.stateListener = stateListener; - } - - public AppSession getSession(String sessionId, Class aClass) { + try { + if (aClass == ServerSLgSession.class) { if (sessionId == null) { - throw new IllegalArgumentException("SessionId must not be null"); - } - if (!this.iss.exists(sessionId)) { - return null; - } - AppSession appSession = null; - try { - if (aClass == ServerSLgSession.class) { - IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory - .getAppSessionData(ServerSLgSession.class, sessionId); - SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getServerSessionListener()); - serverSession.getSessions().get(0).setRequestListener(serverSession); - appSession = serverSession; - } else if (aClass == ClientSLgSession.class) { - IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory - .getAppSessionData(ClientSLgSession.class, sessionId); - SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getClientSessionListener()); - clientSession.getSessions().get(0).setRequestListener(clientSession); - appSession = clientSession; - } else { - throw new IllegalArgumentException( - "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); - } - } catch (Exception e) { - logger.error("Failure to obtain new SLg Session.", e); + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } } - return appSession; - } - - public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, - Object[] args) { - AppSession appSession = null; - - try { - if (aClass == ServerSLgSession.class) { - if (sessionId == null) { - if (args != null && args.length > 0 && args[0] instanceof Request) { - Request request = (Request) args[0]; - sessionId = request.getSessionId(); - } else { - sessionId = this.sessionFactory.getSessionId(); - } - } - IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory - .getAppSessionData(ServerSLgSession.class, sessionId); - sessionData.setApplicationId(applicationId); - SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getServerSessionListener()); - - iss.addSession(serverSession); - serverSession.getSessions().get(0).setRequestListener(serverSession); - appSession = serverSession; - } else if (aClass == ClientSLgSession.class) { - if (sessionId == null) { - if (args != null && args.length > 0 && args[0] instanceof Request) { - Request request = (Request) args[0]; - sessionId = request.getSessionId(); - } else { - sessionId = this.sessionFactory.getSessionId(); - } - } - IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory - .getAppSessionData(ClientSLgSession.class, sessionId); - sessionData.setApplicationId(applicationId); - SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getClientSessionListener()); - - iss.addSession(clientSession); - clientSession.getSessions().get(0).setRequestListener(clientSession); - appSession = clientSession; - } else { - throw new IllegalArgumentException( - "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); - } - } catch (Exception e) { - logger.error("Failure to obtain new SLg Session.", e); + IServerSLgSessionData sessionData = (IServerSLgSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLgSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLgServerSessionImpl serverSession = new SLgServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + + iss.addSession(serverSession); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLgSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } } - return appSession; - } - - public void stateChanged(Enum oldState, Enum newState) { - logger.info("Diameter SLg Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); - } - - public long getApplicationId() { - return 16777255; - } - - public void stateChanged(AppSession source, Enum oldState, Enum newState) { - logger.info("Diameter SLg Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", - new Object[] { source, oldState, newState }); - } - - public ProvideLocationRequest createProvideLocationRequest(Request request) { - return new ProvideLocationRequestImpl(request); - } - - public ProvideLocationAnswer createProvideLocationAnswer(Answer answer) { - return new ProvideLocationAnswerImpl(answer); - } - - public void doProvideLocationRequestEvent(ServerSLgSession appSession, ProvideLocationRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLg Session Factory :: doProvideLocationRequestEvent :: appSession[{}], Request[{}]", appSession, - request); - } - - public void doProvideLocationAnswerEvent(ClientSLgSession appSession, ProvideLocationRequest request, - ProvideLocationAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLg Session Factory :: doProvideLocationAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", - new Object[] { appSession, request, answer }); - } - - public LocationReportRequest createLocationReportRequest(Request request) { - return new LocationReportRequestImpl(request); - } - - public LocationReportAnswer createLocationReportAnswer(Answer answer) { - return new LocationReportAnswerImpl(answer); - } - - public void doLocationReportRequestEvent(ServerSLgSession appSession, LocationReportRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLg Session Factory :: doLocationReportRequestEvent :: appSession[{}], Request[{}]", appSession, - request); - } - - public void doLocationReportAnswerEvent(ClientSLgSession appSession, LocationReportRequest request, - LocationReportAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLg Session Factory :: doLocationReportAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", - new Object[] { appSession, request, answer }); - } - - public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLg Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", - new Object[] { appSession, request, answer }); + IClientSLgSessionData sessionData = (IClientSLgSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLgSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLgClientSessionImpl clientSession = new SLgClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + + iss.addSession(clientSession); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLgSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLg Session.", e); } + return appSession; + } + + public void stateChanged(Enum oldState, Enum newState) { + logger.info("Diameter SLg Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); + } + + public long getApplicationId() { + return 16777255; + } + + public void stateChanged(AppSession source, Enum oldState, Enum newState) { + logger.info("Diameter SLg Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", + new Object[] { source, oldState, newState }); + } + + public ProvideLocationRequest createProvideLocationRequest(Request request) { + return new ProvideLocationRequestImpl(request); + } + + public ProvideLocationAnswer createProvideLocationAnswer(Answer answer) { + return new ProvideLocationAnswerImpl(answer); + } + + public void doProvideLocationRequestEvent(ServerSLgSession appSession, ProvideLocationRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doProvideLocationRequestEvent :: appSession[{}], Request[{}]", appSession, + request); + } + + public void doProvideLocationAnswerEvent(ClientSLgSession appSession, ProvideLocationRequest request, + ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doProvideLocationAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public LocationReportRequest createLocationReportRequest(Request request) { + return new LocationReportRequestImpl(request); + } + + public LocationReportAnswer createLocationReportAnswer(Answer answer) { + return new LocationReportAnswerImpl(answer); + } + + public void doLocationReportRequestEvent(ServerSLgSession appSession, LocationReportRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doLocationReportRequestEvent :: appSession[{}], Request[{}]", appSession, + request); + } + + public void doLocationReportAnswerEvent(ClientSLgSession appSession, LocationReportRequest request, + LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doLocationReportAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLg Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java index 57e342be6..bfb15867e 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java @@ -29,7 +29,7 @@ import org.jdiameter.common.impl.app.AppRequestEventImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.InetAddress; +// import java.net.InetAddress; /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) @@ -39,7 +39,7 @@ public class LCSRoutingInfoAnswerImpl extends AppRequestEventImpl implements LCS private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(LCSRoutingInfoAnswer.class); + protected static final Logger logger = LoggerFactory.getLogger(LCSRoutingInfoAnswer.class); /** * @@ -96,20 +96,20 @@ public byte[] getMSISDN() { @Override public boolean isLMSIAVPPresent() { - return super.message.getAvps().getAvp(Avp.LMSI) != null; + return super.message.getAvps().getAvp(Avp.LMSI) != null; } @Override public byte[] getLMSI() { - Avp localMobileStationIdentityAvp = super.message.getAvps().getAvp(Avp.LMSI); - if (localMobileStationIdentityAvp != null) { - try { - return localMobileStationIdentityAvp.getOctetString(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain LMSI AVP value", e); - } - } - return null; + Avp localMobileStationIdentityAvp = super.message.getAvps().getAvp(Avp.LMSI); + if (localMobileStationIdentityAvp != null) { + try { + return localMobileStationIdentityAvp.getOctetString(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain LMSI AVP value", e); + } + } + return null; } @Override @@ -149,11 +149,11 @@ public boolean isMMENameAVPPresent() { public String getMMEName(){ Avp mmeNameAvp = super.message.getAvps().getAvp(Avp.MME_NAME); if (mmeNameAvp != null) { - try { - return mmeNameAvp.getDiameterIdentity(); - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain MME-Name AVP value", e); - } + try { + return mmeNameAvp.getDiameterIdentity(); + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain MME-Name AVP value", e); + } } return null; } @@ -178,7 +178,7 @@ public byte[] getMSCNumber(){ @Override public boolean isLCSCapabilitiesSetsAVPPresent(){ - return super.message.getAvps().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; + return super.message.getAvps().getAvp(Avp.LCS_CAPABILITIES_SETS) != null; } @Override diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java index 79dfdad8d..a5c68dd6d 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoRequestImpl.java @@ -37,7 +37,7 @@ public class LCSRoutingInfoRequestImpl extends AppRequestEventImpl implements LC private static final long serialVersionUID = 1L; - protected final static Logger logger = LoggerFactory.getLogger(LCSRoutingInfoRequestImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(LCSRoutingInfoRequestImpl.class); public LCSRoutingInfoRequestImpl(Message message) { super(message); @@ -55,10 +55,10 @@ public String getUserName() { if (userNameAvp != null) { try { return userNameAvp.getUTF8String(); // IE: IMSI mapped to User-Name - } catch (AvpDataException e) { - logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); - } + } catch (AvpDataException e) { + logger.debug("Failure trying to obtain User-Name AVP value (IMSI)", e); } + } return null; } @@ -71,8 +71,8 @@ public boolean isMSISDNAVPPresent() { public byte[] getMSISDN() { Avp msisdnAvp = super.message.getAvps().getAvp(Avp.MSISDN); if (msisdnAvp != null) { - try { - return msisdnAvp.getOctetString(); + try { + return msisdnAvp.getOctetString(); } catch (AvpDataException e) { logger.debug("Failure trying to obtain MSISDN AVP value", e); } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java index cb4d67ebe..8a78018d1 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataFactory.java @@ -36,17 +36,17 @@ public class SLhLocalSessionDataFactory implements IAppSessionDataFactory { - public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { - if (clazz.equals(ClientSLhSession.class)) { - ClientSLhSessionDataLocalImpl data = new ClientSLhSessionDataLocalImpl(); - data.setSessionId(sessionId); - return data; - } else if (clazz.equals(ServerSLhSession.class)) { - ServerSLhSessionDataLocalImpl data = new ServerSLhSessionDataLocalImpl(); - data.setSessionId(sessionId); - return data; - } else { - throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); - } + public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLhSession.class)) { + ClientSLhSessionDataLocalImpl data = new ClientSLhSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else if (clazz.equals(ServerSLhSession.class)) { + ServerSLhSessionDataLocalImpl data = new ServerSLhSessionDataLocalImpl(); + data.setSessionId(sessionId); + return data; + } else { + throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java index cd5e2107f..e71fe6444 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhLocalSessionDataImpl.java @@ -35,31 +35,31 @@ public class SLhLocalSessionDataImpl extends AppSessionDataLocalImpl implements ISLhSessionData { - protected SLhSessionState state = SLhSessionState.IDLE; - protected Request buffer; - protected Serializable tsTimerId; + protected SLhSessionState state = SLhSessionState.IDLE; + protected Request buffer; + protected Serializable tsTimerId; - public void setSLhSessionState(SLhSessionState state) { - this.state = state; - } + public void setSLhSessionState(SLhSessionState state) { + this.state = state; + } - public SLhSessionState getSLhSessionState() { - return this.state; - } + public SLhSessionState getSLhSessionState() { + return this.state; + } - public Serializable getTsTimerId() { - return this.tsTimerId; - } + public Serializable getTsTimerId() { + return this.tsTimerId; + } - public void setTsTimerId(Serializable tid) { - this.tsTimerId = tid; - } + public void setTsTimerId(Serializable tid) { + this.tsTimerId = tid; + } - public void setBuffer(Request buffer) { - this.buffer = buffer; - } + public void setBuffer(Request buffer) { + this.buffer = buffer; + } - public Request getBuffer() { - return this.buffer; - } + public Request getBuffer() { + return this.buffer; + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java index 5665b7676..a1962103f 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSession.java @@ -42,93 +42,93 @@ public abstract class SLhSession extends AppSessionImpl implements NetworkReqListener, StateMachine { - public static final int _TX_TIMEOUT = 30 * 1000; + public static final int _TX_TIMEOUT = 30 * 1000; - protected Lock sendAndStateLock = new ReentrantLock(); + protected Lock sendAndStateLock = new ReentrantLock(); - @SuppressWarnings("rawtypes") - protected transient List stateListeners = new CopyOnWriteArrayList(); - protected transient ISLhMessageFactory messageFactory; + @SuppressWarnings("rawtypes") + protected transient List stateListeners = new CopyOnWriteArrayList(); + protected transient ISLhMessageFactory messageFactory; - protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; - protected ISLhSessionData sessionData; + protected static final String TIMER_NAME_MSG_TIMEOUT = "MSG_TIMEOUT"; + protected ISLhSessionData sessionData; - public SLhSession(ISessionFactory sf, ISLhSessionData sessionData) { - super(sf, sessionData); - this.sessionData = sessionData; - } + public SLhSession(ISessionFactory sf, ISLhSessionData sessionData) { + super(sf, sessionData); + this.sessionData = sessionData; + } - @SuppressWarnings("rawtypes") - public void addStateChangeNotification(StateChangeListener listener) { - if (!stateListeners.contains(listener)) { - stateListeners.add(listener); - } + @SuppressWarnings("rawtypes") + public void addStateChangeNotification(StateChangeListener listener) { + if (!stateListeners.contains(listener)) { + stateListeners.add(listener); } - - @SuppressWarnings("rawtypes") - public void removeStateChangeNotification(StateChangeListener listener) { - stateListeners.remove(listener); + } + + @SuppressWarnings("rawtypes") + public void removeStateChangeNotification(StateChangeListener listener) { + stateListeners.remove(listener); + } + + public boolean isStateless() { + return true; + } + + @Override + public boolean isReplicable() { + return false; + } + + protected void startMsgTimer() { + try { + sendAndStateLock.lock(); + sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); + } finally { + sendAndStateLock.unlock(); } - - public boolean isStateless() { - return true; + } + + protected void cancelMsgTimer() { + try { + sendAndStateLock.lock(); + final Serializable timerId = this.sessionData.getTsTimerId(); + if (timerId == null) { + return; + } + super.timerFacility.cancel(timerId); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); } - - @Override - public boolean isReplicable() { - return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - protected void startMsgTimer() { - try { - sendAndStateLock.lock(); - sessionData.setTsTimerId(super.timerFacility.schedule(getSessionId(), TIMER_NAME_MSG_TIMEOUT, _TX_TIMEOUT)); - } finally { - sendAndStateLock.unlock(); - } + if (!super.equals(obj)) { + return false; } - - protected void cancelMsgTimer() { - try { - sendAndStateLock.lock(); - final Serializable timerId = this.sessionData.getTsTimerId(); - if (timerId == null) { - return; - } - super.timerFacility.cancel(timerId); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((sessionData == null) ? 0 : sessionData.hashCode()); - return result; + if (getClass() != obj.getClass()) { + return false; } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SLhSession other = (SLhSession) obj; - if (sessionData == null) { - if (other.sessionData != null) { - return false; - } - } else if (!sessionData.equals(other.sessionData)) { - return false; - } - return true; + SLhSession other = (SLhSession) obj; + if (sessionData == null) { + if (other.sessionData != null) { + return false; + } + } else if (!sessionData.equals(other.sessionData)) { + return false; } + return true; + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java index de7929602..fe1fdf0ec 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/SLhSessionFactoryImpl.java @@ -60,210 +60,210 @@ public class SLhSessionFactoryImpl implements ISLhSessionFactory, ServerSLhSessionListener, ClientSLhSessionListener, ISLhMessageFactory, StateChangeListener { - private static final Logger logger = LoggerFactory.getLogger(SLhSessionFactoryImpl.class); - - protected ISessionFactory sessionFactory; - - protected ServerSLhSessionListener serverSessionListener; - protected ClientSLhSessionListener clientSessionListener; - - protected ISLhMessageFactory messageFactory; - protected StateChangeListener stateListener; - protected ISessionDatasource iss; - protected IAppSessionDataFactory sessionDataFactory; - - public SLhSessionFactoryImpl() { - }; - - public SLhSessionFactoryImpl(SessionFactory sessionFactory) { - super(); - init(sessionFactory); + private static final Logger logger = LoggerFactory.getLogger(SLhSessionFactoryImpl.class); + + protected ISessionFactory sessionFactory; + + protected ServerSLhSessionListener serverSessionListener; + protected ClientSLhSessionListener clientSessionListener; + + protected ISLhMessageFactory messageFactory; + protected StateChangeListener stateListener; + protected ISessionDatasource iss; + protected IAppSessionDataFactory sessionDataFactory; + + public SLhSessionFactoryImpl() { + }; + + public SLhSessionFactoryImpl(SessionFactory sessionFactory) { + super(); + init(sessionFactory); + } + + public void init(SessionFactory sessionFactory) { + this.sessionFactory = (ISessionFactory) sessionFactory; + this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); + this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLhSessionData.class); + } + + /** + * @return the serverSessionListener + */ + public ServerSLhSessionListener getServerSessionListener() { + return serverSessionListener != null ? serverSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setServerSessionListener(ServerSLhSessionListener serverSessionListener) { + this.serverSessionListener = serverSessionListener; + } + + /** + * @return the serverSessionListener + */ + public ClientSLhSessionListener getClientSessionListener() { + return clientSessionListener != null ? clientSessionListener : this; + } + + /** + * @param serverSessionListener the serverSessionListener to set + */ + public void setClientSessionListener(ClientSLhSessionListener clientSessionListener) { + this.clientSessionListener = clientSessionListener; + } + + /** + * @return the messageFactory + */ + public ISLhMessageFactory getMessageFactory() { + return messageFactory != null ? messageFactory : this; + } + + /** + * @param messageFactory the messageFactory to set + */ + public void setMessageFactory(ISLhMessageFactory messageFactory) { + this.messageFactory = messageFactory; + } + + /** + * @return the stateListener + */ + public StateChangeListener getStateListener() { + return stateListener != null ? stateListener : this; + } + + /** + * @param stateListener the stateListener to set + */ + public void setStateListener(StateChangeListener stateListener) { + this.stateListener = stateListener; + } + + public AppSession getSession(String sessionId, Class aClass) { + if (sessionId == null) { + throw new IllegalArgumentException("SessionId must not be null"); } - - public void init(SessionFactory sessionFactory) { - this.sessionFactory = (ISessionFactory) sessionFactory; - this.iss = this.sessionFactory.getContainer().getAssemblerFacility().getComponentInstance(ISessionDatasource.class); - this.sessionDataFactory = (IAppSessionDataFactory) this.iss.getDataFactory(ISLhSessionData.class); + if (!this.iss.exists(sessionId)) { + return null; } - - /** - * @return the serverSessionListener - */ - public ServerSLhSessionListener getServerSessionListener() { - return serverSessionListener != null ? serverSessionListener : this; + AppSession appSession = null; + try { + if (aClass == ServerSLhSession.class) { + IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLhSession.class, sessionId); + SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLhSession.class) { + IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLhSession.class, sessionId); + SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLh Session.", e); } + return appSession; + } - /** - * @param serverSessionListener the serverSessionListener to set - */ - public void setServerSessionListener(ServerSLhSessionListener serverSessionListener) { - this.serverSessionListener = serverSessionListener; - } + public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, + Object[] args) { + AppSession appSession = null; - /** - * @return the serverSessionListener - */ - public ClientSLhSessionListener getClientSessionListener() { - return clientSessionListener != null ? clientSessionListener : this; - } - - /** - * @param serverSessionListener the serverSessionListener to set - */ - public void setClientSessionListener(ClientSLhSessionListener clientSessionListener) { - this.clientSessionListener = clientSessionListener; - } - - /** - * @return the messageFactory - */ - public ISLhMessageFactory getMessageFactory() { - return messageFactory != null ? messageFactory : this; - } - - /** - * @param messageFactory the messageFactory to set - */ - public void setMessageFactory(ISLhMessageFactory messageFactory) { - this.messageFactory = messageFactory; - } - - /** - * @return the stateListener - */ - public StateChangeListener getStateListener() { - return stateListener != null ? stateListener : this; - } - - /** - * @param stateListener the stateListener to set - */ - public void setStateListener(StateChangeListener stateListener) { - this.stateListener = stateListener; - } - - public AppSession getSession(String sessionId, Class aClass) { + try { + if (aClass == ServerSLhSession.class) { if (sessionId == null) { - throw new IllegalArgumentException("SessionId must not be null"); - } - if (!this.iss.exists(sessionId)) { - return null; + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } } - AppSession appSession = null; - try { - if (aClass == ServerSLhSession.class) { - IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory - .getAppSessionData(ServerSLhSession.class, sessionId); - SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getServerSessionListener()); - serverSession.getSessions().get(0).setRequestListener(serverSession); - appSession = serverSession; - } else if (aClass == ClientSLhSession.class) { - IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory - .getAppSessionData(ClientSLhSession.class, sessionId); - SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getClientSessionListener()); - clientSession.getSessions().get(0).setRequestListener(clientSession); - appSession = clientSession; - } else { - throw new IllegalArgumentException( - "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); - } - } catch (Exception e) { - logger.error("Failure to obtain new SLh Session.", e); - } - return appSession; - } - - public AppSession getNewSession(String sessionId, Class aClass, ApplicationId applicationId, - Object[] args) { - AppSession appSession = null; - - try { - if (aClass == ServerSLhSession.class) { - if (sessionId == null) { - if (args != null && args.length > 0 && args[0] instanceof Request) { - Request request = (Request) args[0]; - sessionId = request.getSessionId(); - } else { - sessionId = this.sessionFactory.getSessionId(); - } - } - IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory - .getAppSessionData(ServerSLhSession.class, sessionId); - sessionData.setApplicationId(applicationId); - SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getServerSessionListener()); - - iss.addSession(serverSession); - serverSession.getSessions().get(0).setRequestListener(serverSession); - appSession = serverSession; - } else if (aClass == ClientSLhSession.class) { - if (sessionId == null) { - if (args != null && args.length > 0 && args[0] instanceof Request) { - Request request = (Request) args[0]; - sessionId = request.getSessionId(); - } else { - sessionId = this.sessionFactory.getSessionId(); - } - } - IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory - .getAppSessionData(ClientSLhSession.class, sessionId); - sessionData.setApplicationId(applicationId); - SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, - this.getClientSessionListener()); - - iss.addSession(clientSession); - clientSession.getSessions().get(0).setRequestListener(clientSession); - appSession = clientSession; - } else { - throw new IllegalArgumentException( - "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); - } - } catch (Exception e) { - logger.error("Failure to obtain new SLh Session.", e); + IServerSLhSessionData sessionData = (IServerSLhSessionData) this.sessionDataFactory + .getAppSessionData(ServerSLhSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLhServerSessionImpl serverSession = new SLhServerSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getServerSessionListener()); + + iss.addSession(serverSession); + serverSession.getSessions().get(0).setRequestListener(serverSession); + appSession = serverSession; + } else if (aClass == ClientSLhSession.class) { + if (sessionId == null) { + if (args != null && args.length > 0 && args[0] instanceof Request) { + Request request = (Request) args[0]; + sessionId = request.getSessionId(); + } else { + sessionId = this.sessionFactory.getSessionId(); + } } - return appSession; - } - - public void stateChanged(Enum oldState, Enum newState) { - logger.info("Diameter SLh Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); - } - - public long getApplicationId() { - return 16777291; - } - - public void stateChanged(AppSession source, Enum oldState, Enum newState) { - logger.info("Diameter SLh Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", - new Object[] { source, oldState, newState }); - } - - public LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer) { - return new LCSRoutingInfoAnswerImpl(answer); - } - - public LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request) { - return new LCSRoutingInfoRequestImpl(request); - } - - public void doLCSRoutingInfoRequestEvent(ServerSLhSession appSession, LCSRoutingInfoRequest request) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLh Session Factory :: doLCSRoutingInfoRequestEvent :: appSession[{}], Request[{}]", - appSession, request); - } - - public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info("Diameter SLh Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", - new Object[] { appSession, request, answer }); - } - - public void doLCSRoutingInfoAnswerEvent(ClientSLhSession appSession, LCSRoutingInfoRequest request, - LCSRoutingInfoAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - logger.info( - "Diameter SLh Session Factory :: doLCSRoutingInfoAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", - new Object[] { appSession, request, answer }); + IClientSLhSessionData sessionData = (IClientSLhSessionData) this.sessionDataFactory + .getAppSessionData(ClientSLhSession.class, sessionId); + sessionData.setApplicationId(applicationId); + SLhClientSessionImpl clientSession = new SLhClientSessionImpl(sessionData, getMessageFactory(), sessionFactory, + this.getClientSessionListener()); + + iss.addSession(clientSession); + clientSession.getSessions().get(0).setRequestListener(clientSession); + appSession = clientSession; + } else { + throw new IllegalArgumentException( + "Wrong session class: " + aClass + ". Supported[" + ServerSLhSession.class + "]"); + } + } catch (Exception e) { + logger.error("Failure to obtain new SLh Session.", e); } + return appSession; + } + + public void stateChanged(Enum oldState, Enum newState) { + logger.info("Diameter SLh Session Factory :: stateChanged :: oldState[{}], newState[{}]", oldState, newState); + } + + public long getApplicationId() { + return 16777291; + } + + public void stateChanged(AppSession source, Enum oldState, Enum newState) { + logger.info("Diameter SLh Session Factory :: stateChanged :: Session, [{}], oldState[{}], newState[{}]", + new Object[] { source, oldState, newState }); + } + + public LCSRoutingInfoAnswer createLCSRoutingInfoAnswer(Answer answer) { + return new LCSRoutingInfoAnswerImpl(answer); + } + + public LCSRoutingInfoRequest createLCSRoutingInfoRequest(Request request) { + return new LCSRoutingInfoRequestImpl(request); + } + + public void doLCSRoutingInfoRequestEvent(ServerSLhSession appSession, LCSRoutingInfoRequest request) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLh Session Factory :: doLCSRoutingInfoRequestEvent :: appSession[{}], Request[{}]", + appSession, request); + } + + public void doOtherEvent(AppSession appSession, AppRequestEvent request, AppAnswerEvent answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info("Diameter SLh Session Factory :: doOtherEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } + + public void doLCSRoutingInfoAnswerEvent(ClientSLhSession appSession, LCSRoutingInfoRequest request, + LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + logger.info( + "Diameter SLh Session Factory :: doLCSRoutingInfoAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", + new Object[] { appSession, request, answer }); + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java index 7b5bcd85e..017451023 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/data/LocalDataSource.java @@ -109,8 +109,8 @@ public LocalDataSource() { appSessionDataFactories.put(IRxSessionData.class, new RxLocalSessionDataFactory()); appSessionDataFactories.put(IS6aSessionData.class, new S6aLocalSessionDataFactory()); appSessionDataFactories.put(IS13SessionData.class, new S13LocalSessionDataFactory()); - appSessionDataFactories.put(ISLhSessionData.class, new SLhLocalSessionDataFactory()); - appSessionDataFactories.put(ISLgSessionData.class, new SLgLocalSessionDataFactory()); + appSessionDataFactories.put(ISLhSessionData.class, new SLhLocalSessionDataFactory()); + appSessionDataFactories.put(ISLgSessionData.class, new SLgLocalSessionDataFactory()); } public LocalDataSource(IContainer container) { diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java index 475f2b9f6..e315ec3f6 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/Event.java @@ -32,55 +32,55 @@ public class Event implements StateEvent { - enum Type { - SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLR, RECEIVE_LRR - } + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_PLR, RECEIVE_LRR + } - AppEvent request; - AppEvent answer; - Type type; + AppEvent request; + AppEvent answer; + Type type; - Event(Type type, AppEvent request, AppEvent answer) { - this.type = type; - this.answer = answer; - this.request = request; - } + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } - @SuppressWarnings("unchecked") - public E encodeType(Class eClass) { - return eClass == Type.class ? (E) type : null; - } + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } - @SuppressWarnings("rawtypes") - public Enum getType() { - return type; - } + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } - public AppEvent getRequest() { - return request; - } + public AppEvent getRequest() { + return request; + } - public AppEvent getAnswer() { - return answer; - } + public AppEvent getAnswer() { + return answer; + } - public int compareTo(Object o) { - return 0; - } + public int compareTo(Object o) { + return 0; + } - public Object getData() { - return request != null ? request : answer; - } + public Object getData() { + return request != null ? request : answer; + } - public void setData(Object data) { - try { - if (((AppEvent) data).getMessage().isRequest()) { - request = (AppEvent) data; - } else { - answer = (AppEvent) data; - } - } catch (InternalException e) { - throw new IllegalArgumentException(e); - } + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); } + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java index a11f4dad6..3d60857dd 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/SLgServerSessionImpl.java @@ -56,251 +56,251 @@ public class SLgServerSessionImpl extends SLgSession implements ServerSLgSession, EventListener, NetworkReqListener { - private static final Logger logger = LoggerFactory.getLogger(SLgServerSessionImpl.class); - - // Factories and Listeners - // -------------------------------------------------- - private transient ServerSLgSessionListener listener; - protected long appId = -1; - protected IServerSLgSessionData sessionData; - - public SLgServerSessionImpl(IServerSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, - ServerSLgSessionListener lst) { - super(sf, sessionData); - if (lst == null) { - throw new IllegalArgumentException("Listener can not be null"); - } - if ((this.appId = fct.getApplicationId()) < 0) { - throw new IllegalArgumentException("ApplicationId can not be less than zero"); - } - - this.listener = lst; - super.messageFactory = fct; - this.sessionData = sessionData; + private static final Logger logger = LoggerFactory.getLogger(SLgServerSessionImpl.class); + + // Factories and Listeners + // -------------------------------------------------- + private transient ServerSLgSessionListener listener; + protected long appId = -1; + protected IServerSLgSessionData sessionData; + + public SLgServerSessionImpl(IServerSLgSessionData sessionData, ISLgMessageFactory fct, ISessionFactory sf, + ServerSLgSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); } - - public void sendProvideLocationAnswer(ProvideLocationAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, null, answer); + if ((this.appId = fct.getApplicationId()) < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); } - public void sendLocationReportAnswer(LocationReportAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, null, answer); + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + public void sendProvideLocationAnswer(ProvideLocationAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + public void sendLocationReportAnswer(LocationReportAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + } + + @SuppressWarnings("unused") + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLgSessionState state = this.sessionData.getSLgSessionState(); + SLgSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + + switch (state) { + + case IDLE: + switch (eventType) { + + case RECEIVE_PLR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doProvideLocationRequestEvent(this, (ProvideLocationRequest) event.getData()); + break; + + case RECEIVE_LRR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doLocationReportRequestEvent(this, (LocationReportRequest) event.getData()); + break; + + case SEND_MESSAGE: + super.session.send(((AppEvent) event.getData()).getMessage(), this); + newState = SLgSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + break; + + default: + logger.error("Wrong action in SLg Server FSM. State: IDLE, Event Type: {}", eventType); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLgSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLgSessionState.TERMINATED; + setState(newState); + } + break; + + default: + throw new InternalException( + "Should not receive more messages after initial. Command: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLg Server FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); } - - @SuppressWarnings("unchecked") - public E getState(Class stateType) { - return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null; + return true; + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); } - - @SuppressWarnings("unused") - public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { - try { - sendAndStateLock.lock(); - if (!super.session.isValid()) { - // FIXME: throw new InternalException("Generic session is not valid."); - return false; - } - final SLgSessionState state = this.sessionData.getSLgSessionState(); - SLgSessionState newState = null; - Event localEvent = (Event) event; - Event.Type eventType = (Type) event.getType(); - - switch (state) { - - case IDLE: - switch (eventType) { - - case RECEIVE_PLR: - this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); - super.cancelMsgTimer(); - super.startMsgTimer(); - newState = SLgSessionState.MESSAGE_SENT_RECEIVED; - setState(newState); - listener.doProvideLocationRequestEvent(this, (ProvideLocationRequest) event.getData()); - break; - - case RECEIVE_LRR: - this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); - super.cancelMsgTimer(); - super.startMsgTimer(); - newState = SLgSessionState.MESSAGE_SENT_RECEIVED; - setState(newState); - listener.doLocationReportRequestEvent(this, (LocationReportRequest) event.getData()); - break; - - case SEND_MESSAGE: - super.session.send(((AppEvent) event.getData()).getMessage(), this); - newState = SLgSessionState.MESSAGE_SENT_RECEIVED; - setState(newState); - break; - - default: - logger.error("Wrong action in SLg Server FSM. State: IDLE, Event Type: {}", eventType); - break; - } - break; - - case MESSAGE_SENT_RECEIVED: - switch (eventType) { - case TIMEOUT_EXPIRES: - newState = SLgSessionState.TIMEDOUT; - setState(newState); - break; - - case SEND_MESSAGE: - try { - super.session.send(((AppEvent) event.getData()).getMessage(), this); - } finally { - newState = SLgSessionState.TERMINATED; - setState(newState); - } - break; - - default: - throw new InternalException( - "Should not receive more messages after initial. Command: " + event.getData()); - } - break; - - case TERMINATED: - throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); - - case TIMEDOUT: - throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); - - default: - logger.error("SLg Server FSM in wrong state: {}", state); - break; - } - } catch (Exception e) { - throw new InternalException(e); - } finally { - sendAndStateLock.unlock(); - } - return true; + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); } + } - public void receivedSuccessMessage(Request request, Answer answer) { - AnswerDelivery rd = new AnswerDelivery(); - rd.session = this; - rd.request = request; - rd.answer = answer; - super.scheduler.execute(rd); - } + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLgSessionState newState) { + SLgSessionState oldState = this.sessionData.getSLgSessionState(); + this.sessionData.setSLgSessionState(newState); - public void timeoutExpired(Request request) { - try { - handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); - } catch (Exception e) { - logger.debug("Failed to process timeout message", e); - } + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); } - - public Answer processRequest(Request request) { - RequestDelivery rd = new RequestDelivery(); - rd.session = this; - rd.request = request; - super.scheduler.execute(rd); - return null; + if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); } + } - protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + @Override + public void onTimer(String timerName) { + if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); try { - if (type != null) { - handleEvent(new Event(type, request, answer)); - } + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); } catch (Exception e) { - throw new InternalException(e); + logger.debug("Failure handling Timeout event."); } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void setState(SLgSessionState newState) { - SLgSessionState oldState = this.sessionData.getSLgSessionState(); - this.sessionData.setSLgSessionState(newState); - - for (StateChangeListener i : stateListeners) { - i.stateChanged(this, (Enum) oldState, (Enum) newState); - } - if (newState == SLgSessionState.TERMINATED || newState == SLgSessionState.TIMEDOUT) { - super.cancelMsgTimer(); - this.release(); - } + } + + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); } - - @Override - public void onTimer(String timerName) { - if (timerName.equals(SLgSession.TIMER_NAME_MSG_TIMEOUT)) { - try { - sendAndStateLock.lock(); - try { - handleEvent( - new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); - } catch (Exception e) { - logger.debug("Failure handling Timeout event."); - } - this.sessionData.setBuffer(null); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } + } + + private class RequestDelivery implements Runnable { + ServerSLgSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + case ProvideLocationRequest.code: + handleEvent( + new Event(Event.Type.RECEIVE_PLR, messageFactory.createProvideLocationRequest(request), null)); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } } - - public void release() { - if (isValid()) { - try { - sendAndStateLock.lock(); - super.release(); - } catch (Exception e) { - logger.debug("Failed to release session", e); - } finally { - sendAndStateLock.unlock(); - } - } else { - logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); - } - } - - private class RequestDelivery implements Runnable { - ServerSLgSession session; - Request request; - - public void run() { - try { - switch (request.getCommandCode()) { - case ProvideLocationRequest.code: - handleEvent( - new Event(Event.Type.RECEIVE_PLR, messageFactory.createProvideLocationRequest(request), null)); - break; - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), null); - break; - } - } catch (Exception e) { - logger.debug("Failed to process request message", e); - } - } - } - - private class AnswerDelivery implements Runnable { - ServerSLgSession session; - Answer answer; - Request request; - - public void run() { - try { - switch (answer.getCommandCode()) { - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); - break; - } - } catch (Exception e) { - logger.debug("Failed to process success message", e); - } + } + + private class AnswerDelivery implements Runnable { + ServerSLgSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java index ef345f9c2..05ce77b6b 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slg/ServerSLgSessionDataLocalImpl.java @@ -29,6 +29,6 @@ */ public class ServerSLgSessionDataLocalImpl extends SLgLocalSessionDataImpl implements IServerSLgSessionData { - public ServerSLgSessionDataLocalImpl() { - } + public ServerSLgSessionDataLocalImpl() { + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java index d9b786d57..1e6e1ade3 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/Event.java @@ -32,55 +32,55 @@ public class Event implements StateEvent { - enum Type { - SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIR; - } + enum Type { + SEND_MESSAGE, TIMEOUT_EXPIRES, RECEIVE_RIR; + } - AppEvent request; - AppEvent answer; - Type type; + AppEvent request; + AppEvent answer; + Type type; - Event(Type type, AppEvent request, AppEvent answer) { - this.type = type; - this.answer = answer; - this.request = request; - } + Event(Type type, AppEvent request, AppEvent answer) { + this.type = type; + this.answer = answer; + this.request = request; + } - @SuppressWarnings("unchecked") - public E encodeType(Class eClass) { - return eClass == Type.class ? (E) type : null; - } + @SuppressWarnings("unchecked") + public E encodeType(Class eClass) { + return eClass == Type.class ? (E) type : null; + } - @SuppressWarnings("rawtypes") - public Enum getType() { - return type; - } + @SuppressWarnings("rawtypes") + public Enum getType() { + return type; + } - public AppEvent getRequest() { - return request; - } + public AppEvent getRequest() { + return request; + } - public AppEvent getAnswer() { - return answer; - } + public AppEvent getAnswer() { + return answer; + } - public int compareTo(Object o) { - return 0; - } + public int compareTo(Object o) { + return 0; + } - public Object getData() { - return request != null ? request : answer; - } + public Object getData() { + return request != null ? request : answer; + } - public void setData(Object data) { - try { - if (((AppEvent) data).getMessage().isRequest()) { - request = (AppEvent) data; - } else { - answer = (AppEvent) data; - } - } catch (InternalException e) { - throw new IllegalArgumentException(e); - } + public void setData(Object data) { + try { + if (((AppEvent) data).getMessage().isRequest()) { + request = (AppEvent) data; + } else { + answer = (AppEvent) data; + } + } catch (InternalException e) { + throw new IllegalArgumentException(e); } + } } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java index 4812dcebb..3326733fb 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/SLhServerSessionImpl.java @@ -54,237 +54,237 @@ public class SLhServerSessionImpl extends SLhSession implements ServerSLhSession, EventListener, NetworkReqListener { - private static final Logger logger = LoggerFactory.getLogger(SLhServerSessionImpl.class); - - // Factories and Listeners - // -------------------------------------------------- - private transient ServerSLhSessionListener listener; - protected long appId = -1; - protected IServerSLhSessionData sessionData; - - public SLhServerSessionImpl(IServerSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, - ServerSLhSessionListener lst) { - super(sf, sessionData); - if (lst == null) { - throw new IllegalArgumentException("Listener can not be null"); - } - if ((this.appId = fct.getApplicationId()) < 0) { - throw new IllegalArgumentException("ApplicationId can not be less than zero"); - } - - this.listener = lst; - super.messageFactory = fct; - this.sessionData = sessionData; + private static final Logger logger = LoggerFactory.getLogger(SLhServerSessionImpl.class); + + // Factories and Listeners + // -------------------------------------------------- + private transient ServerSLhSessionListener listener; + protected long appId = -1; + protected IServerSLhSessionData sessionData; + + public SLhServerSessionImpl(IServerSLhSessionData sessionData, ISLhMessageFactory fct, ISessionFactory sf, + ServerSLhSessionListener lst) { + super(sf, sessionData); + if (lst == null) { + throw new IllegalArgumentException("Listener can not be null"); } - - public void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) - throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { - send(Event.Type.SEND_MESSAGE, null, answer); + if ((this.appId = fct.getApplicationId()) < 0) { + throw new IllegalArgumentException("ApplicationId can not be less than zero"); } - @SuppressWarnings("unchecked") - public E getState(Class stateType) { - return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + this.listener = lst; + super.messageFactory = fct; + this.sessionData = sessionData; + } + + public void sendLCSRoutingInfoAnswer(LCSRoutingInfoAnswer answer) + throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { + send(Event.Type.SEND_MESSAGE, null, answer); + } + + @SuppressWarnings("unchecked") + public E getState(Class stateType) { + return stateType == SLhSessionState.class ? (E) this.sessionData.getSLhSessionState() : null; + } + + @SuppressWarnings("unused") + public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { + try { + sendAndStateLock.lock(); + if (!super.session.isValid()) { + // FIXME: throw new InternalException("Generic session is not valid."); + return false; + } + final SLhSessionState state = this.sessionData.getSLhSessionState(); + SLhSessionState newState = null; + Event localEvent = (Event) event; + Event.Type eventType = (Type) event.getType(); + + switch (state) { + + case IDLE: + switch (eventType) { + + case RECEIVE_RIR: + this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); + super.cancelMsgTimer(); + super.startMsgTimer(); + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + listener.doLCSRoutingInfoRequestEvent(this, (LCSRoutingInfoRequest) event.getData()); + break; + + case SEND_MESSAGE: + super.session.send(((AppEvent) event.getData()).getMessage(), this); + newState = SLhSessionState.MESSAGE_SENT_RECEIVED; + setState(newState); + break; + + default: + logger.error("Wrong action in SLh Server FSM. State: IDLE, Event Type: {}", eventType); + break; + } + break; + + case MESSAGE_SENT_RECEIVED: + switch (eventType) { + case TIMEOUT_EXPIRES: + newState = SLhSessionState.TIMEDOUT; + setState(newState); + break; + + case SEND_MESSAGE: + try { + super.session.send(((AppEvent) event.getData()).getMessage(), this); + } finally { + newState = SLhSessionState.TERMINATED; + setState(newState); + } + break; + + default: + throw new InternalException( + "Should not receive more messages after initial. Command: " + event.getData()); + } + break; + + case TERMINATED: + throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); + + case TIMEDOUT: + throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); + + default: + logger.error("SLh Server FSM in wrong state: {}", state); + break; + } + } catch (Exception e) { + throw new InternalException(e); + } finally { + sendAndStateLock.unlock(); } - - @SuppressWarnings("unused") - public boolean handleEvent(StateEvent event) throws InternalException, OverloadException { - try { - sendAndStateLock.lock(); - if (!super.session.isValid()) { - // FIXME: throw new InternalException("Generic session is not valid."); - return false; - } - final SLhSessionState state = this.sessionData.getSLhSessionState(); - SLhSessionState newState = null; - Event localEvent = (Event) event; - Event.Type eventType = (Type) event.getType(); - - switch (state) { - - case IDLE: - switch (eventType) { - - case RECEIVE_RIR: - this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage()); - super.cancelMsgTimer(); - super.startMsgTimer(); - newState = SLhSessionState.MESSAGE_SENT_RECEIVED; - setState(newState); - listener.doLCSRoutingInfoRequestEvent(this, (LCSRoutingInfoRequest) event.getData()); - break; - - case SEND_MESSAGE: - super.session.send(((AppEvent) event.getData()).getMessage(), this); - newState = SLhSessionState.MESSAGE_SENT_RECEIVED; - setState(newState); - break; - - default: - logger.error("Wrong action in SLh Server FSM. State: IDLE, Event Type: {}", eventType); - break; - } - break; - - case MESSAGE_SENT_RECEIVED: - switch (eventType) { - case TIMEOUT_EXPIRES: - newState = SLhSessionState.TIMEDOUT; - setState(newState); - break; - - case SEND_MESSAGE: - try { - super.session.send(((AppEvent) event.getData()).getMessage(), this); - } finally { - newState = SLhSessionState.TERMINATED; - setState(newState); - } - break; - - default: - throw new InternalException( - "Should not receive more messages after initial. Command: " + event.getData()); - } - break; - - case TERMINATED: - throw new InternalException("Cant receive message in state TERMINATED. Command: " + event.getData()); - - case TIMEDOUT: - throw new InternalException("Cant receive message in state TIMEDOUT. Command: " + event.getData()); - - default: - logger.error("SLh Server FSM in wrong state: {}", state); - break; - } - } catch (Exception e) { - throw new InternalException(e); - } finally { - sendAndStateLock.unlock(); - } - return true; + return true; + } + + public void receivedSuccessMessage(Request request, Answer answer) { + AnswerDelivery rd = new AnswerDelivery(); + rd.session = this; + rd.request = request; + rd.answer = answer; + super.scheduler.execute(rd); + } + + public void timeoutExpired(Request request) { + try { + handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); + } catch (Exception e) { + logger.debug("Failed to process timeout message", e); } - - public void receivedSuccessMessage(Request request, Answer answer) { - AnswerDelivery rd = new AnswerDelivery(); - rd.session = this; - rd.request = request; - rd.answer = answer; - super.scheduler.execute(rd); + } + + public Answer processRequest(Request request) { + RequestDelivery rd = new RequestDelivery(); + rd.session = this; + rd.request = request; + super.scheduler.execute(rd); + return null; + } + + protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + try { + if (type != null) { + handleEvent(new Event(type, request, answer)); + } + } catch (Exception e) { + throw new InternalException(e); } + } - public void timeoutExpired(Request request) { - try { - handleEvent(new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(request), null)); - } catch (Exception e) { - logger.debug("Failed to process timeout message", e); - } - } + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected void setState(SLhSessionState newState) { + SLhSessionState oldState = this.sessionData.getSLhSessionState(); + this.sessionData.setSLhSessionState(newState); - public Answer processRequest(Request request) { - RequestDelivery rd = new RequestDelivery(); - rd.session = this; - rd.request = request; - super.scheduler.execute(rd); - return null; + for (StateChangeListener i : stateListeners) { + i.stateChanged(this, (Enum) oldState, (Enum) newState); } + if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { + super.cancelMsgTimer(); + this.release(); + } + } - protected void send(Event.Type type, AppEvent request, AppEvent answer) throws InternalException { + @Override + public void onTimer(String timerName) { + if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { + try { + sendAndStateLock.lock(); try { - if (type != null) { - handleEvent(new Event(type, request, answer)); - } + handleEvent( + new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); } catch (Exception e) { - throw new InternalException(e); + logger.debug("Failure handling Timeout event."); } + this.sessionData.setBuffer(null); + this.sessionData.setTsTimerId(null); + } finally { + sendAndStateLock.unlock(); + } } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void setState(SLhSessionState newState) { - SLhSessionState oldState = this.sessionData.getSLhSessionState(); - this.sessionData.setSLhSessionState(newState); - - for (StateChangeListener i : stateListeners) { - i.stateChanged(this, (Enum) oldState, (Enum) newState); - } - if (newState == SLhSessionState.TERMINATED || newState == SLhSessionState.TIMEDOUT) { - super.cancelMsgTimer(); - this.release(); - } + } + + public void release() { + if (isValid()) { + try { + sendAndStateLock.lock(); + super.release(); + } catch (Exception e) { + logger.debug("Failed to release session", e); + } finally { + sendAndStateLock.unlock(); + } + } else { + logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); } - - @Override - public void onTimer(String timerName) { - if (timerName.equals(SLhSession.TIMER_NAME_MSG_TIMEOUT)) { - try { - sendAndStateLock.lock(); - try { - handleEvent( - new Event(Event.Type.TIMEOUT_EXPIRES, new AppRequestEventImpl(this.sessionData.getBuffer()), null)); - } catch (Exception e) { - logger.debug("Failure handling Timeout event."); - } - this.sessionData.setBuffer(null); - this.sessionData.setTsTimerId(null); - } finally { - sendAndStateLock.unlock(); - } + } + + private class RequestDelivery implements Runnable { + ServerSLhSession session; + Request request; + + public void run() { + try { + switch (request.getCommandCode()) { + case LCSRoutingInfoRequest.code: + handleEvent( + new Event(Event.Type.RECEIVE_RIR, messageFactory.createLCSRoutingInfoRequest(request), null)); + break; + + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), null); + break; } + } catch (Exception e) { + logger.debug("Failed to process request message", e); + } } - - public void release() { - if (isValid()) { - try { - sendAndStateLock.lock(); - super.release(); - } catch (Exception e) { - logger.debug("Failed to release session", e); - } finally { - sendAndStateLock.unlock(); - } - } else { - logger.debug("Trying to release an already invalid session, with Session ID '{}'", getSessionId()); - } - } - - private class RequestDelivery implements Runnable { - ServerSLhSession session; - Request request; - - public void run() { - try { - switch (request.getCommandCode()) { - case LCSRoutingInfoRequest.code: - handleEvent( - new Event(Event.Type.RECEIVE_RIR, messageFactory.createLCSRoutingInfoRequest(request), null)); - break; - - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), null); - break; - } - } catch (Exception e) { - logger.debug("Failed to process request message", e); - } - } - } - - private class AnswerDelivery implements Runnable { - ServerSLhSession session; - Answer answer; - Request request; - - public void run() { - try { - switch (answer.getCommandCode()) { - default: - listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); - break; - } - } catch (Exception e) { - logger.debug("Failed to process success message", e); - } + } + + private class AnswerDelivery implements Runnable { + ServerSLhSession session; + Answer answer; + Request request; + + public void run() { + try { + switch (answer.getCommandCode()) { + default: + listener.doOtherEvent(session, new AppRequestEventImpl(request), new AppAnswerEventImpl(answer)); + break; } + } catch (Exception e) { + logger.debug("Failed to process success message", e); + } } + } } \ No newline at end of file diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java index fd97ce925..744b97e7c 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/app/slh/ServerSLhSessionDataLocalImpl.java @@ -29,6 +29,6 @@ */ public class ServerSLhSessionDataLocalImpl extends SLhLocalSessionDataImpl implements IServerSLhSessionData { - public ServerSLhSessionDataLocalImpl() { - } + public ServerSLhSessionDataLocalImpl() { + } }