Revision: 356adaf903f1
Author: Sergey Vetyutnev <[email protected]>
Date: Tue Dec 11 08:14:15 2012
Log: Adding isUp(), onServerStarted() and onServerStopped() events in a
ManagementListener
http://code.google.com/p/sctp/source/detail?r=356adaf903f1
Modified:
/sctp-api/src/main/java/org/mobicents/protocols/api/Association.java
/sctp-api/src/main/java/org/mobicents/protocols/api/ManagementEventListener.java
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/AssociationImpl.java
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java
=======================================
--- /sctp-api/src/main/java/org/mobicents/protocols/api/Association.java
Wed Aug 15 09:38:13 2012
+++ /sctp-api/src/main/java/org/mobicents/protocols/api/Association.java
Tue Dec 11 08:14:15 2012
@@ -1,23 +1,23 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
- * contributors as indicated by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.mobicents.protocols.api;
@@ -70,12 +70,19 @@
*/
public boolean isStarted();
+ /**
+ * If this association up (connection is started and established)
+ *
+ * @return
+ */
+ public boolean isConnected();
+
/**
* If this association up (connection is established)
*
* @return
*/
- public boolean isConnected();
+ public boolean isUp();
/**
* The AssociationListener set for this Association
=======================================
---
/sctp-api/src/main/java/org/mobicents/protocols/api/ManagementEventListener.java
Mon Oct 29 08:57:57 2012
+++
/sctp-api/src/main/java/org/mobicents/protocols/api/ManagementEventListener.java
Tue Dec 11 08:14:15 2012
@@ -29,6 +29,12 @@
*/
public interface ManagementEventListener {
+ public void onServiceStarted();
+
+ public void onServiceStopped();
+
+ public void onRemoveAllResources();
+
public void onServerAdded(Server server);
public void onServerRemoved(Server serverName);
@@ -37,8 +43,6 @@
public void onAssociationRemoved(Association association);
- public void onRemoveAllResources();
-
public void onAssociationStarted(Association association);
public void onAssociationStopped(Association association);
=======================================
---
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/AssociationImpl.java
Mon Oct 29 08:57:57 2012
+++
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/AssociationImpl.java
Tue Dec 11 08:14:15 2012
@@ -1,23 +1,23 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
- * contributors as indicated by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.mobicents.protocols.sctp;
@@ -223,7 +223,11 @@
}
for (ManagementEventListener lstr :
this.management.getManagementEventListeners()) {
- lstr.onAssociationStarted(this);
+ try {
+ lstr.onAssociationStarted(this);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationStarted", ee);
+ }
}
}
@@ -234,7 +238,11 @@
protected void stop() throws Exception {
this.started = false;
for (ManagementEventListener lstr :
this.management.getManagementEventListeners()) {
- lstr.onAssociationStopped(this);
+ try {
+ lstr.onAssociationStopped(this);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationStopped", ee);
+ }
}
if (this.getSocketChannel() != null && this.getSocketChannel().isOpen())
{
@@ -317,6 +325,11 @@
public boolean isConnected() {
return started && up;
}
+
+ @Override
+ public boolean isUp() {
+ return up;
+ }
protected void markAssociationUp() {
if (this.server != null) {
@@ -327,14 +340,22 @@
this.up = true;
for (ManagementEventListener lstr :
this.management.getManagementEventListeners()) {
- lstr.onAssociationUp(this);
+ try {
+ lstr.onAssociationUp(this);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationUp", ee);
+ }
}
}
protected void markAssociationDown() {
this.up = false;
for (ManagementEventListener lstr :
this.management.getManagementEventListeners()) {
- lstr.onAssociationDown(this);
+ try {
+ lstr.onAssociationDown(this);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationDown", ee);
+ }
}
if (this.server != null) {
=======================================
---
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java
Mon Oct 29 08:57:57 2012
+++
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java
Tue Dec 11 08:14:15 2012
@@ -1,23 +1,23 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
- * contributors as indicated by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.mobicents.protocols.sctp;
@@ -277,6 +277,14 @@
logger.info(String.format("Started SCTP Management=%s WorkerThreads=%d
SingleThread=%s", this.name,
(this.singleThread ? 0 :
this.workerThreads), this.singleThread));
}
+
+ for (ManagementEventListener lstr :
managementEventListeners) {
+ try {
+ lstr.onServiceStarted();
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onServiceStarted", ee);
+ }
+ }
}
}
@@ -286,6 +294,14 @@
logger.warn(String.format("management=%s is already stopped",
this.name));
return;
}
+
+ for (ManagementEventListener lstr : managementEventListeners) {
+ try {
+ lstr.onServiceStopped();
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onServiceStopped", ee);
+ }
+ }
// We store the original state first
this.store();
@@ -447,7 +463,11 @@
}
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onRemoveAllResources();
+ try {
+ lstr.onRemoveAllResources();
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onRemoveAllResources", ee);
+ }
}
}
}
@@ -505,7 +525,11 @@
this.store();
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onServerAdded(server);
+ try {
+ lstr.onServerAdded(server);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onServerAdded", ee);
+ }
}
if (logger.isInfoEnabled()) {
@@ -553,7 +577,11 @@
this.store();
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onServerRemoved(removeServer);
+ try {
+ lstr.onServerRemoved(removeServer);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onServerRemoved", ee);
+ }
}
}
}
@@ -684,7 +712,11 @@
this.store();
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onAssociationAdded(association);
+ try {
+ lstr.onAssociationAdded(association);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationAdded", ee);
+ }
}
if (logger.isInfoEnabled()) {
@@ -758,7 +790,11 @@
this.store();
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onAssociationAdded(association);
+ try {
+ lstr.onAssociationAdded(association);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationAdded", ee);
+ }
}
if (logger.isInfoEnabled()) {
@@ -875,7 +911,11 @@
this.store();
for (ManagementEventListener lstr :
managementEventListeners) {
- lstr.onAssociationRemoved(association);
+ try {
+ lstr.onAssociationRemoved(association);
+ } catch (Throwable ee) {
+ logger.error("Exception while invoking
onAssociationRemoved", ee);
+ }
}
}
}