Revision: 42cbad9c624b
Author:   Jean Deruelle <[email protected]>
Date:     Fri Aug 10 14:28:31 2012
Log:      Update Issue 11

Refactor HA Stack to remove non HA props from it

http://code.google.com/p/jain-sip/source/detail?r=42cbad9c624b&repo=ha

Modified:
 /core/.classpath
 /core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java
 /jboss-4/.classpath
 /jboss-4/src/main/java/org/mobicents/ha/javax/sip/SipStackImplMBean.java
 /jboss-5/.classpath
 /jboss-5/src/main/java/org/mobicents/ha/javax/sip/SipStackImpl.java
 /pom.xml

=======================================
--- /core/.classpath    Mon Apr 16 05:48:37 2012
+++ /core/.classpath    Fri Aug 10 14:28:31 2012
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
        <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
- <classpathentry kind="var" path="M2_REPO/org/mobicents/javax/sip/mobicents-jain-sip-ext/1.0/mobicents-jain-sip-ext-1.0.jar"/> - <classpathentry kind="var" path="M2_REPO/org/mobicents/tools/sip-balancer-jar/1.4/sip-balancer-jar-1.4.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry combineaccessrules="false" kind="src" path="/jain-sip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/mobicents-jain-sip-ext"/> + <classpathentry combineaccessrules="false" kind="src" path="/sip-balancer-jar"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
=======================================
--- /core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java Tue Sep 13 07:18:08 2011 +++ /core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java Fri Aug 10 14:28:31 2012
@@ -48,9 +48,7 @@
 import javax.sip.SipProvider;
 import javax.sip.message.Request;

-import org.mobicents.ext.javax.sip.SipProviderFactory;
-import org.mobicents.ext.javax.sip.SipStackExtension;
-import org.mobicents.ext.javax.sip.TransactionFactory;
+import org.mobicents.ext.javax.sip.SipStackImpl;
 import org.mobicents.ha.javax.sip.cache.SipCache;
 import org.mobicents.ha.javax.sip.cache.SipCacheException;
 import org.mobicents.ha.javax.sip.cache.SipCacheFactory;
@@ -70,15 +68,12 @@
  * @author martins
  *
  */
-public abstract class ClusteredSipStackImpl extends gov.nist.javax.sip.SipStackImpl implements ClusteredSipStack, SipStackExtension { +public abstract class ClusteredSipStackImpl extends SipStackImpl implements ClusteredSipStack {

        protected SipCache sipCache = null;
protected LoadBalancerHeartBeatingService loadBalancerHeartBeatingService = null; protected ReplicationStrategy replicationStrategy = ReplicationStrategy.ConfirmedDialog;
        protected LoadBalancerElector loadBalancerElector = null;
-       protected TransactionFactory transactionFactory = null;
-       protected SipProviderFactory sipProviderFactory = null;
-       protected boolean sendTryingRightAway;
        private boolean replicateApplicationData = false;

public ClusteredSipStackImpl(Properties configurationProperties) throws PeerUnavailableException {
@@ -111,36 +106,6 @@
                        
loadBalancerElector.setService(loadBalancerHeartBeatingService);
                        }
                }
-
- // allow the stack to provide its own SIPServerTransaction/SIPClientTransaction extension instances - String transactionFactoryClassName = configurationProperties.getProperty(TRANSACTION_FACTORY_CLASS_NAME);
-               if(transactionFactoryClassName != null) {
-                       try {
- transactionFactory = (TransactionFactory) Class.forName(transactionFactoryClassName).newInstance();
-                   transactionFactory.setSipStack(this);
-               } catch (Exception e) {
-                   String errmsg = "The TransactionFactory class name: "
-                           + transactionFactoryClassName
- + " could not be instantiated. Ensure the " + TRANSACTION_FACTORY_CLASS_NAME + " property has been set correctly and that the class is on the classpath.";
-                   throw new PeerUnavailableException(errmsg, e);
-               }
-           }
-               // allow the stack to provide its own SipProviderImpl extension 
instances
- String sipProviderFactoryClassName = configurationProperties.getProperty(SIP_PROVIDER_FACTORY_CLASS_NAME);
-               if(sipProviderFactoryClassName != null) {
-                       try {
- sipProviderFactory = (SipProviderFactory) Class.forName(sipProviderFactoryClassName).newInstance();
-                   sipProviderFactory.setSipStack(this);
-               } catch (Exception e) {
-                   String errmsg = "The SipProviderFactory class name: "
-                           + sipProviderFactoryClassName
- + " could not be instantiated. Ensure the " + SIP_PROVIDER_FACTORY_CLASS_NAME + " property has been set correctly and that the class is on the classpath.";
-                   throw new PeerUnavailableException(errmsg, e);
-               }
-           }
-
-               this.sendTryingRightAway = Boolean.valueOf(
- configurationProperties.getProperty(SEND_TRYING_RIGHT_AWAY,"false")).booleanValue();

String replicationStrategyProperty = configurationProperties.getProperty(ClusteredSipStack.REPLICATION_STRATEGY_PROPERTY);
                if(replicationStrategyProperty != null) {
@@ -609,28 +574,6 @@
                }
return transactionFactory.createServerTransaction(encapsulatedMessageChannel);
        }
-
-       /**
-        * @param sendTryingRightAway the sendTryingRightAway to set
-        */
-       public void setSendTryingRightAway(boolean sendTryingRightAway) {
-               this.sendTryingRightAway = sendTryingRightAway;
-       }
-
-       /**
-        * @return the sendTryingRightAway
-        */
-       public boolean isSendTryingRightAway() {
-               return sendTryingRightAway;
-       }
-
-       public void addSipProvider(SipProviderImpl sipProvider) {
-               sipProviders.add(sipProvider);
-       }
-
-       public void removeSipProvider(SipProviderImpl sipProvider) {
-               sipProviders.remove(sipProvider);
-       }

        /**
         * @return the replicateApplicationData
=======================================
--- /jboss-4/.classpath Mon Apr 16 05:48:37 2012
+++ /jboss-4/.classpath Fri Aug 10 14:28:31 2012
@@ -20,5 +20,6 @@
<classpathentry kind="var" path="M2_REPO/trove/trove/2.1.1/trove-2.1.1.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry combineaccessrules="false" kind="src" path="/jain-sip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/mobicents-jain-sip-ext"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
=======================================
--- /jboss-4/src/main/java/org/mobicents/ha/javax/sip/SipStackImplMBean.java Thu Oct 6 11:37:38 2011 +++ /jboss-4/src/main/java/org/mobicents/ha/javax/sip/SipStackImplMBean.java Fri Aug 10 14:28:31 2012
@@ -26,8 +26,5 @@
  *
  */
 public interface SipStackImplMBean {
-       public int getNumberOfClientTransactions();
-       public int getNumberOfServerTransactions();
-       public int getNumberOfDialogs();
        public boolean isLocalMode();
 }
=======================================
--- /jboss-5/.classpath Mon Apr 16 05:48:37 2012
+++ /jboss-5/.classpath Fri Aug 10 14:28:31 2012
@@ -25,5 +25,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="M2_REPO/org/mobicents/tools/sip-balancer-jar/1.4/sip-balancer-jar-1.4.jar"/>
        <classpathentry combineaccessrules="false" kind="src" path="/jain-sip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/mobicents-jain-sip-ext"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
=======================================
--- /jboss-5/src/main/java/org/mobicents/ha/javax/sip/SipStackImpl.java Tue Apr 19 06:45:18 2011 +++ /jboss-5/src/main/java/org/mobicents/ha/javax/sip/SipStackImpl.java Fri Aug 10 14:28:31 2012
@@ -25,13 +25,9 @@
 import gov.nist.core.CommonLogger;
 import gov.nist.core.StackLogger;
 import gov.nist.javax.sip.stack.MessageProcessor;
-import gov.nist.javax.sip.stack.SIPTransaction;

 import java.util.Properties;

-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.sip.PeerUnavailableException;
@@ -47,16 +43,25 @@
  *
  */
public class SipStackImpl extends ClusteredSipStackImpl implements SipStackImplMBean, NotificationListener { - public static String JAIN_SIP_MBEAN_NAME = "org.mobicents.jain.sip:type=sip-stack,name="; + private static StackLogger logger = CommonLogger.getLogger(SipStackImpl.class); public static String LOG4J_SERVICE_MBEAN_NAME = "jboss.system:service=Logging,type=Log4jService"; - private static StackLogger logger = CommonLogger.getLogger(SipStackImpl.class);
-       ObjectName oname = null;
-       MBeanServer mbeanServer = null;
-       boolean isMBeanServerNotAvailable = false;

public SipStackImpl(Properties configurationProperties) throws PeerUnavailableException {
                super(updateConfigProperties(configurationProperties));
        }
+
+       @Override
+       public void start() throws ProviderDoesNotExistException, SipException {
+               super.start();
+               try {
+                       if(logger.isLoggingEnabled(StackLogger.TRACE_INFO)) {
+ logger.logInfo("Adding notification listener for logging mbean \"" + LOG4J_SERVICE_MBEAN_NAME + "\" to server " + getMBeanServer());
+                       }
+ getMBeanServer().addNotificationListener(new ObjectName(LOG4J_SERVICE_MBEAN_NAME), this, null, null);
+               } catch (Exception e) {
+ logger.logWarning("Could not register the stack as a Notification Listener of " + LOG4J_SERVICE_MBEAN_NAME + " runtime changes to log4j.xml won't affect SIP Stack Logging");
+               }
+       }

private static final Properties updateConfigProperties(Properties configurationProperties) { if(configurationProperties.getProperty(ClusteredSipStack.CACHE_CLASS_NAME_PROPERTY) == null) {
@@ -81,75 +86,9 @@
                return getServerTransactionTableSize();
        }

-       @Override
-       public void start() throws ProviderDoesNotExistException, SipException {
-               super.start();
-               String mBeanName=JAIN_SIP_MBEAN_NAME + stackName;
-               try {
-                       oname = new ObjectName(mBeanName);
-                       if (getMBeanServer() != null && 
!getMBeanServer().isRegistered(oname)) {
-                               getMBeanServer().registerMBean(this, oname);
-                               
if(logger.isLoggingEnabled(StackLogger.TRACE_INFO)) {
- logger.logInfo("Adding notification listener for logging mbean \"" + LOG4J_SERVICE_MBEAN_NAME + "\" to server " + getMBeanServer());
-                               }
-                       }
-               } catch (Exception e) {
- logger.logError("Could not register the stack as an MBean under the following name", e); - throw new SipException("Could not register the stack as an MBean under the following name " + mBeanName + ", cause: " + e.getMessage(), e);
-               }
-               try {
-                       if(logger.isLoggingEnabled(StackLogger.TRACE_INFO)) {
- logger.logInfo("Adding notification listener for logging mbean \"" + LOG4J_SERVICE_MBEAN_NAME + "\" to server " + getMBeanServer());
-                       }
- getMBeanServer().addNotificationListener(new ObjectName(LOG4J_SERVICE_MBEAN_NAME), this, null, null);
-               } catch (Exception e) {
- logger.logWarning("Could not register the stack as a Notification Listener of " + LOG4J_SERVICE_MBEAN_NAME + " runtime changes to log4j.xml won't affect SIP Stack Logging");
-               }
-       }
-
-       @Override
-       public void stop() {
-               String mBeanName=JAIN_SIP_MBEAN_NAME + stackName;
-               try {
- if (oname != null && getMBeanServer() != null && getMBeanServer().isRegistered(oname)) {
-                               getMBeanServer().unregisterMBean(oname);
-                       }
-               } catch (Exception e) {
- logger.logError("Could not unregister the stack as an MBean under the following name" + mBeanName);
-               }
-               super.stop();
-       }
-
-       /**
-        * Get the current MBean Server.
-        *
-        * @return
-        * @throws Exception
-        */
-       public MBeanServer getMBeanServer() throws Exception {
-               if (mbeanServer == null && !isMBeanServerNotAvailable) {
-                       try {
- mbeanServer = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
-                       } catch (Exception e) {
-                               logger.logStackTrace(StackLogger.TRACE_DEBUG);
- logger.logWarning("No Mbean Server available, so JMX statistics won't be available");
-                               isMBeanServerNotAvailable = true;
-                       }
-               }
-               return mbeanServer;
-       }
-
        public boolean isLocalMode() {
                return getSipCache().inLocalMode();
        }
-
-       /*
-        * (non-Javadoc)
- * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object)
-        */
- public void handleNotification(Notification notification, Object handback) {
-               logger.setStackProperties(super.getConfigurationProperties());
-       }

        /*
         * (non-Javadoc)
=======================================
--- /pom.xml    Mon Apr 16 05:49:39 2012
+++ /pom.xml    Fri Aug 10 14:28:31 2012
@@ -44,7 +44,7 @@
                        <dependency>
                                <groupId>org.mobicents.tools</groupId>
                                <artifactId>sip-balancer-jar</artifactId>
-                               <version>1.5.0.FINAL</version>
+                               <version>1.6.0-SNAPSHOT</version>
                                <scope>provided</scope>
                        </dependency>
                </dependencies>
@@ -62,7 +62,7 @@
                <dependency>
                        <groupId>org.mobicents.javax.sip</groupId>
                        <artifactId>mobicents-jain-sip-ext</artifactId>
-                       <version>1.1</version>
+                       <version>1.2-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
        </dependencies>

Reply via email to