You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ni...@apache.org on 2014/04/15 04:05:06 UTC

svn commit: r1587384 - in /servicemix/smx4/bundles/trunk: ./ jsmpp-2.1.0/ jsmpp-2.1.0/src/main/java/ jsmpp-2.1.0/src/main/java/org/ jsmpp-2.1.0/src/main/java/org/jsmpp/ jsmpp-2.1.0/src/main/java/org/jsmpp/session/

Author: ningjiang
Date: Tue Apr 15 02:05:06 2014
New Revision: 1587384

URL: http://svn.apache.org/r1587384
Log:
SMX4-1748 Fixed the concurrent modification exception in SMPP bundle

Added:
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/AbstractSessionContext.java
Modified:
    servicemix/smx4/bundles/trunk/jsmpp-2.1.0/pom.xml
    servicemix/smx4/bundles/trunk/pom.xml

Modified: servicemix/smx4/bundles/trunk/jsmpp-2.1.0/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/bundles/trunk/jsmpp-2.1.0/pom.xml?rev=1587384&r1=1587383&r2=1587384&view=diff
==============================================================================
--- servicemix/smx4/bundles/trunk/jsmpp-2.1.0/pom.xml (original)
+++ servicemix/smx4/bundles/trunk/jsmpp-2.1.0/pom.xml Tue Apr 15 02:05:06 2014
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.servicemix.bundles</groupId>
         <artifactId>bundles-pom</artifactId>
-        <version>9-SNAPSHOT</version>
+        <version>11</version>
         <relativePath>../bundles-pom/pom.xml</relativePath>
     </parent>
 
@@ -67,6 +67,14 @@
             <classifier>sources</classifier>
             <optional>true</optional>
         </dependency>
+        
+        <!-- slf4j dependency to compile the patched file -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.6.1</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <repositories>

Added: servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/AbstractSessionContext.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/AbstractSessionContext.java?rev=1587384&view=auto
==============================================================================
--- servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/AbstractSessionContext.java (added)
+++ servicemix/smx4/bundles/trunk/jsmpp-2.1.0/src/main/java/org/jsmpp/session/AbstractSessionContext.java Tue Apr 15 02:05:06 2014
@@ -0,0 +1,97 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.jsmpp.session;
+
+import java.util.List;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.jsmpp.bean.BindType;
+import org.jsmpp.extra.SessionState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author uudashr
+ *
+ */
+public abstract class AbstractSessionContext implements SessionContext {
+    private static final Logger logger = LoggerFactory.getLogger(AbstractSessionContext.class);
+    private long lastActivityTimestamp;
+    private List<SessionStateListener> sessionStateListeners = new CopyOnWriteArrayList<SessionStateListener>();
+    
+    public AbstractSessionContext() {
+    }
+    
+    public AbstractSessionContext(SessionStateListener sessionStateListener) {
+        sessionStateListeners.add(sessionStateListener);
+    }
+    
+    public synchronized void open() {
+        changeState(SessionState.OPEN);
+    }
+    
+    public synchronized void bound(BindType bindType) {
+        if (bindType.equals(BindType.BIND_TX)) {
+            changeState(SessionState.BOUND_TX);
+        } else if (bindType.equals(BindType.BIND_RX)) {
+            changeState(SessionState.BOUND_RX);
+        } else if (bindType.equals(BindType.BIND_TRX)) {
+            changeState(SessionState.BOUND_TRX);
+        } else {
+            throw new IllegalArgumentException("Bind type " + bindType + " not supported");
+        }
+    }
+    
+    public synchronized void unbound() {
+        changeState(SessionState.UNBOUND);
+    }
+    
+    public synchronized void close() {
+        changeState(SessionState.CLOSED);
+    }
+    
+    public void addSessionStateListener(
+            SessionStateListener l) {
+        sessionStateListeners.add(l);
+    }
+    
+    public void removeSessionStateListener(SessionStateListener l) {
+        sessionStateListeners.remove(l);
+    }
+
+    protected void fireStateChanged(SessionState newState,
+                                    SessionState oldState, Session source) {
+
+        for (SessionStateListener l : sessionStateListeners) {
+            try {
+                l.onStateChange(newState, oldState, source);
+            } catch (Exception e) {
+                logger.error("Invalid runtime exception thrown when calling onStateChange for " + source, e);
+            }
+        }
+
+    }
+    
+    public void notifyActivity() {
+        lastActivityTimestamp = System.currentTimeMillis();
+    }
+    
+    public long getLastActivityTimestamp() {
+        return lastActivityTimestamp;
+    }
+    
+    protected abstract void changeState(SessionState newState);
+}
+

Modified: servicemix/smx4/bundles/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/bundles/trunk/pom.xml?rev=1587384&r1=1587383&r2=1587384&view=diff
==============================================================================
--- servicemix/smx4/bundles/trunk/pom.xml (original)
+++ servicemix/smx4/bundles/trunk/pom.xml Tue Apr 15 02:05:06 2014
@@ -43,6 +43,7 @@
 
     <modules>
         <!-- add modules for all bundles to released in the next batch here -->
+        <module>jsmpp-2.1.0</module>
     </modules>
 
 </project>