servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r708275 - in /servicemix/sandbox/lhein/servicemix-smpp: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/servicemix/ src/main/java/org/apache/servicemix/smpp/ src/main/java/org/apache/se...
Date Mon, 27 Oct 2008 18:37:44 GMT
Author: lhein
Date: Mon Oct 27 11:37:21 2008
New Revision: 708275

URL: http://svn.apache.org/viewvc?rev=708275&view=rev
Log:
added first shot of smpp binding

Added:
    servicemix/sandbox/lhein/servicemix-smpp/
    servicemix/sandbox/lhein/servicemix-smpp/LICENSE   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/NOTICE   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/pom.xml   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/
    servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/test/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/
    servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java   (with props)
    servicemix/sandbox/lhein/servicemix-smpp/src/test/resources/

Added: servicemix/sandbox/lhein/servicemix-smpp/LICENSE
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/LICENSE?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/LICENSE (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/LICENSE Mon Oct 27 11:37:21 2008
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+

Propchange: servicemix/sandbox/lhein/servicemix-smpp/LICENSE
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/sandbox/lhein/servicemix-smpp/NOTICE
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/NOTICE?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/NOTICE (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/NOTICE Mon Oct 27 11:37:21 2008
@@ -0,0 +1,9 @@
+   =========================================================================
+   ==  NOTICE file for use with the Apache License, Version 2.0,          ==
+   ==  in this case for the Apache ServiceMix distribution.               ==
+   =========================================================================
+
+   This product contains software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+

Propchange: servicemix/sandbox/lhein/servicemix-smpp/NOTICE
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/sandbox/lhein/servicemix-smpp/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/pom.xml?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/pom.xml (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/pom.xml Mon Oct 27 11:37:21 2008
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.servicemix</groupId>
+    <artifactId>components-pom</artifactId>
+    <version>2-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.servicemix</groupId>
+  <artifactId>servicemix-smpp</artifactId>
+  <version>2008.02-SNAPSHOT</version>
+  <packaging>jbi-component</packaging>
+  
+  <name>ServiceMix :: SMPP</name>
+  <description>A SMPP component</description>
+  
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-smpp/trunk</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-smpp/trunk</developerConnection>
+    <url>http://svn.apache.org/viewcvs.cgi/servicemix/components/bindings/servicemix-smpp/trunk</url>
+  </scm>
+
+  <properties>
+    <previous.releases>3.1.2,3.2,3.2.1</previous.releases>
+    <servicemix-version>3.2.1</servicemix-version>
+    <servicemix-shared-version>2008.02-SNAPSHOT</servicemix-shared-version>
+
+    <servicemix.osgi.import>
+        org.apache.servicemix.common,
+        org.apache.servicemix.common.osgi,
+        org.apache.servicemix.executors.impl,
+        org.apache.xbean.spring.context.v2,
+        org.springframework.beans.factory.xml,
+        *
+    </servicemix.osgi.import>
+    <servicemix.osgi.export>
+        org.apache.servicemix.smpp*;version=${project.version},
+        META-INF.services.org.apache.xbean.spring.http.servicemix.apache.org.smpp
+    </servicemix.osgi.export>
+    <servicemix.osgi.bundles>
+        org.springframework.bundle.spring.core,
+        org.springframework.bundle.spring.beans,
+        org.springframework.bundle.spring.context,
+    </servicemix.osgi.bundles>
+  </properties>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-shared</artifactId>
+      <version>${servicemix-shared-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix.specs</groupId>
+      <artifactId>org.apache.servicemix.specs.jbi-api-1.0</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code</groupId>
+      <artifactId>jsmpp</artifactId>
+      <version>2.0b_05</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jta_1.1_spec</artifactId>
+    </dependency>
+    <!-- for unit/integration testing -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-core</artifactId>
+      <version>${servicemix-version}</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jmx</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <includes>
+          <include>**/*</include>
+        </includes>
+      </resource>
+      <resource>
+        <directory>target/generated</directory>
+        <includes>
+          <include>**/*</include>
+        </includes>
+      </resource>
+    </resources>
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+        <includes>
+          <include>**/*.properties</include>
+          <include>**/*.x*</include>
+          <include>**/*.wsdl</include>
+          <include>**/*.jks</include>
+          <include>**/*.zip</include>
+          <include>**/*.txt</include>
+          <include>**/*.csv</include>
+          <include>**/*.png</include>
+        </includes>
+      </testResource>
+      <testResource>
+        <directory>src/test/java</directory>
+        <includes>
+          <include>**/*.jar</include>
+          <include>**/*.zip</include>
+        </includes>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>jbi-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <type>binding-component</type>
+          <component>org.apache.servicemix.smpp.SmppComponent</component>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>maven-xbean-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>mapping</goal>
+            </goals>
+            <configuration>
+              <namespace>http://servicemix.apache.org/smpp/1.0</namespace>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>always</forkMode>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: servicemix/sandbox/lhein/servicemix-smpp/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp;
+
+import java.util.List;
+
+import org.apache.servicemix.common.DefaultComponent;
+
+/**
+ * @org.apache.xbean.XBean element="component" description="Smpp Component"
+ * 
+ * @author lhein
+ */
+public class SmppComponent extends DefaultComponent {
+    private SmppEndpointType[] endpoints;
+
+    /**
+     * @return
+     */
+    public SmppEndpointType[] getEndpoints() {
+        return endpoints;
+    }
+
+    /**
+     * @param endpoints
+     */
+    public void setEndpoints(SmppEndpointType[] endpoints) {
+        this.endpoints = endpoints;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.servicemix.common.DefaultComponent#getConfiguredEndpoints()
+     */
+    protected List getConfiguredEndpoints() {
+        return asList(getEndpoints());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.DefaultComponent#getEndpointClasses()
+     */
+    protected Class[] getEndpointClasses() {
+        return new Class[] {SmppPollerEndpoint.class, SmppSenderEndpoint.class};
+    }
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp;
+
+/**
+ * @author lhein
+ */
+public interface SmppEndpointType {
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppEndpointType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp;
+
+import ie.omk.smpp.AlreadyBoundException;
+import ie.omk.smpp.Connection;
+import ie.omk.smpp.NotBoundException;
+import ie.omk.smpp.event.ConnectionObserver;
+import ie.omk.smpp.event.ReceiverExitEvent;
+import ie.omk.smpp.event.SMPPEvent;
+import ie.omk.smpp.message.SMPPPacket;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.common.endpoints.ConsumerEndpoint;
+import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
+import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
+
+/**
+ * A polling component which bind with SMSC and receive SMPP messages and sends
+ * the SMPPs into the JBI bus as messages.
+ * 
+ * @org.apache.xbean.XBean element="poller"
+ * @author Rohit Joshi
+ */
+public class SmppPollerEndpoint extends ConsumerEndpoint implements SmppEndpointType, ConnectionObserver {
+
+    private static final transient Log LOG = LogFactory.getLog(SmppPollerEndpoint.class);
+
+    private static final int SMPP_DEFAULT_PORT = 2775;
+    private static final String DEFAULT_RESOURCE = "ServiceMix";
+    
+    private Connection connection;
+    
+    private int port = SMPP_DEFAULT_PORT;
+    
+    private long bindRetryCycle = 60000;
+    
+    private String host;
+    private String user;
+    private String password;
+    private String resource = DEFAULT_RESOURCE;
+
+    private SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.PollingEndpoint#start()
+     */
+    @Override
+    public synchronized void start() throws Exception {
+        super.start();
+
+        // connect to the smpp host
+        connect();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.PollingEndpoint#stop()
+     */
+    @Override
+    public synchronized void stop() throws Exception {
+        // disconnect
+        disconnect();
+        
+        super.stop();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.ConsumerEndpoint#validate()
+     */
+    @Override
+    public void validate() throws DeploymentException {
+        super.validate();
+
+        // check for valid port number
+        if (this.port <=0) {
+            LOG.warn("Invalid smpp port specified. Switching to default port: " + SMPP_DEFAULT_PORT);
+            this.port = SMPP_DEFAULT_PORT;
+        }
+        
+        // check for valid resource
+        if (this.resource == null || this.resource.trim().length()<=0) {
+            LOG.warn("Invalid smpp resource specified. Switching to default resource: " + DEFAULT_RESOURCE);
+            this.resource = DEFAULT_RESOURCE;
+        }
+        
+        // check for valid host
+        if (this.host == null || this.host.trim().length()<=0) {
+            throw new IllegalArgumentException("The specified host name is not valid.");
+        }
+        
+        // check for valid user
+        if (this.user == null || this.user.trim().length()<=0) {
+            throw new IllegalArgumentException("The specified user name is not valid.");
+        }
+        
+        // check for valid password
+        if (this.password == null || this.password.trim().length()<=0) {
+            throw new IllegalArgumentException("The specified password is not valid.");
+        }
+    }
+
+    /**
+     * connects to the smpp host for polling
+     */
+    private void connect() {
+        try {
+            // open the connection
+            this.connection = new Connection(this.host, this.port, true);
+
+            // register myself as an observer
+            this.connection.addObserver(this);
+        } catch (UnknownHostException uhe) {
+            LOG.error("Error connecting to host: " + this.host + ":" + this.port, uhe);
+            return;
+        }
+
+        boolean retry = true;
+
+        while (retry) {
+            try {
+                // bind
+                this.connection.bind(Connection.RECEIVER, this.user, this.password, null);
+                // bound
+                retry = false;
+            } catch (AlreadyBoundException abex) {
+                LOG.warn("Already bound.", abex);
+                retry = false;
+            } catch (Exception ioe) {
+                try {
+                    logger.warn("Bind failed. Will retry after " + this.bindRetryCycle + " ms");
+                    Thread.sleep(this.bindRetryCycle);
+                } catch (InterruptedException ie) {
+                    // ignore this exception
+                }
+            }
+        }
+    }
+
+    /**
+     * disconnects from snmp host
+     */
+    private void disconnect() {
+        
+        if (this.connection == null) {
+            // seems not to be opened at all
+            return;
+        }
+        
+        // check if bound
+        if (this.connection.isBound()) {
+            try {
+                // unbind
+                this.connection.unbind();
+            } catch (NotBoundException ex) {
+                // we were not bound
+                LOG.error("Tried to unbind while not bound.", ex);
+            } catch (IOException ex) {
+                // error while unbinding
+                LOG.error("Error while trying to unbind", ex);
+            }
+        }
+
+        try {
+            // remove me from observer list
+            this.connection.removeObserver(this);
+            // close the connection
+            this.connection.closeLink();
+        } catch (IOException ex) {
+            LOG.error("Error disconnecting from host: " + this.host + ":" + this.port, ex);
+        }
+    }
+    
+    /**
+     * does a reconnect first closing existing connection and then reestablishing
+     * the connection again
+     */
+    private void reconnect() {
+        LOG.warn("Reconnecting to host " + this.host + ":" + this.port + "...");
+        
+        // close connection
+        disconnect();
+        
+        // and reconnect
+        connect();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see ie.omk.smpp.event.ConnectionObserver#update(ie.omk.smpp.Connection,
+     * ie.omk.smpp.event.SMPPEvent)
+     */
+    public void update(Connection conn, SMPPEvent ev) {
+        if (ev.getType() == SMPPEvent.RECEIVER_EXIT && ((ReceiverExitEvent)ev).isException()) {
+            logger.debug("SMPPEvent.RECEIVER_EXIT received.");
+            // reconnect
+            reconnect();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * ie.omk.smpp.event.ConnectionObserver#packetReceived(ie.omk.smpp.Connection
+     * , ie.omk.smpp.message.SMPPPacket)
+     */
+    public void packetReceived(Connection conn, SMPPPacket pack) {
+        switch (pack.getCommandId()) {
+        case SMPPPacket.DELIVER_SM:
+            try {
+                InOnly exchange = getExchangeFactory().createInOnlyExchange();
+                NormalizedMessage in = exchange.createMessage();
+                exchange.setInMessage(in);
+                marshaler.toNMS(in, pack);
+                getChannel().send(exchange);
+            } catch (Exception e) {
+                LOG.error("Unable to send the received packet to nmr.", e);
+            }
+            break;
+
+        case SMPPPacket.BIND_TRANSCEIVER_RESP:
+            if (pack.getCommandStatus() != 0) {
+                LOG.error("Error binding: " + pack.getCommandStatus());
+                // binding failed...try to reconnect
+                reconnect();
+            } else {
+                LOG.debug("Bounded");
+            }
+            break;
+        default:  // ignore
+            LOG.debug("Received packet with unhandled command id: " + pack.getCommandId());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.servicemix.common.ExchangeProcessor#process(javax.jbi.messaging
+     * .MessageExchange)
+     */
+    public void process(MessageExchange exchange) throws Exception {
+        if (exchange.getStatus() == ExchangeStatus.DONE) {
+            // received DONE for a sent message
+            return;
+        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+            // received ERROR state for a sent message
+            return;
+        } else {
+            throw new MessagingException("Unsupported exchange received...");
+        }
+    }
+
+    /**
+     * @return Returns the connection.
+     */
+    public Connection getConnection() {
+        return this.connection;
+    }
+
+    /**
+     * @param connection The connection to set.
+     */
+    public void setConnection(Connection connection) {
+        this.connection = connection;
+    }
+
+    /**
+     * @return Returns the marshaler.
+     */
+    public SmppMarshalerSupport getMarshaler() {
+        return this.marshaler;
+    }
+
+    /**
+     * @param marshaler The marshaler to set.
+     */
+    public void setMarshaler(SmppMarshalerSupport marshaler) {
+        this.marshaler = marshaler;
+    }
+
+    /**
+     * @return Returns the port.
+     */
+    public int getPort() {
+        return this.port;
+    }
+
+    /**
+     * @param port The port to set.
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * @return Returns the bindRetryCycle.
+     */
+    public long getBindRetryCycle() {
+        return this.bindRetryCycle;
+    }
+
+    /**
+     * @param bindRetryCycle The bindRetryCycle to set.
+     */
+    public void setBindRetryCycle(long bindRetryCycle) {
+        this.bindRetryCycle = bindRetryCycle;
+    }
+
+    /**
+     * @return Returns the host.
+     */
+    public String getHost() {
+        return this.host;
+    }
+
+    /**
+     * @param host The host to set.
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * @return Returns the user.
+     */
+    public String getUser() {
+        return this.user;
+    }
+
+    /**
+     * @param user The user to set.
+     */
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * @return Returns the password.
+     */
+    public String getPassword() {
+        return this.password;
+    }
+
+    /**
+     * @param password The password to set.
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * @return Returns the resource.
+     */
+    public String getResource() {
+        return this.resource;
+    }
+
+    /**
+     * @param resource The resource to set.
+     */
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppPollerEndpoint.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,443 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp;
+
+import ie.omk.smpp.AlreadyBoundException;
+import ie.omk.smpp.Connection;
+import ie.omk.smpp.NotBoundException;
+import ie.omk.smpp.event.ConnectionObserver;
+import ie.omk.smpp.event.ReceiverExitEvent;
+import ie.omk.smpp.event.SMPPEvent;
+import ie.omk.smpp.message.SMPPPacket;
+import ie.omk.smpp.message.SubmitSM;
+import ie.omk.smpp.message.SubmitSMResp;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.common.endpoints.ProviderEndpoint;
+import org.apache.servicemix.jbi.helper.MessageUtil;
+import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
+import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
+
+/**
+ * A Provider component receives XML messae from NMR and converts into SMPP
+ * Packet and sends it to SMSC.
+ * 
+ * @org.apache.xbean.XBean element="sender"
+ * @author Rohit Joshi
+ */
+public class SmppSenderEndpoint extends ProviderEndpoint implements SmppEndpointType, ConnectionObserver {
+    private static final transient Log LOG = LogFactory.getLog(SmppSenderEndpoint.class);
+
+    private static final int SMPP_DEFAULT_PORT = 2775;
+    private static final String DEFAULT_RESOURCE = "ServiceMix";
+
+    private Connection connection;
+
+    private int port = SMPP_DEFAULT_PORT;
+
+    private long bindRetryCycle = 60000;
+
+    private String host;
+    private String user;
+    private String password;
+    private String resource = DEFAULT_RESOURCE;
+
+    private SmppMarshalerSupport marshaler = new DefaultSmppMarshaler();
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.PollingEndpoint#start()
+     */
+    @Override
+    public synchronized void start() throws Exception {
+        super.start();
+
+        // connect to the smpp host
+        connect();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.PollingEndpoint#stop()
+     */
+    @Override
+    public synchronized void stop() throws Exception {
+        // disconnect
+        disconnect();
+
+        super.stop();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.common.endpoints.ConsumerEndpoint#validate()
+     */
+    @Override
+    public void validate() throws DeploymentException {
+        super.validate();
+
+        // check for valid port number
+        if (this.port <= 0) {
+            LOG.warn("Invalid smpp port specified. Switching to default port: " + SMPP_DEFAULT_PORT);
+            this.port = SMPP_DEFAULT_PORT;
+        }
+
+        // check for valid resource
+        if (this.resource == null || this.resource.trim().length() <= 0) {
+            LOG.warn("Invalid smpp resource specified. Switching to default resource: " + DEFAULT_RESOURCE);
+            this.resource = DEFAULT_RESOURCE;
+        }
+
+        // check for valid host
+        if (this.host == null || this.host.trim().length() <= 0) {
+            throw new IllegalArgumentException("The specified host name is not valid.");
+        }
+
+        // check for valid user
+        if (this.user == null || this.user.trim().length() <= 0) {
+            throw new IllegalArgumentException("The specified user name is not valid.");
+        }
+
+        // check for valid password
+        if (this.password == null || this.password.trim().length() <= 0) {
+            throw new IllegalArgumentException("The specified password is not valid.");
+        }
+    }
+
+    /**
+     * connects to the smpp host for polling
+     */
+    private void connect() {
+        try {
+            // open the connection
+            this.connection = new Connection(this.host, this.port, true);
+
+            // register myself as an observer
+            this.connection.addObserver(this);
+        } catch (UnknownHostException uhe) {
+            LOG.error("Error connecting to host: " + this.host + ":" + this.port, uhe);
+            return;
+        }
+
+        boolean retry = true;
+
+        while (retry) {
+            try {
+                // bind
+                this.connection.bind(Connection.TRANSMITTER, this.user, this.password, null);
+                // bound
+                retry = false;
+            } catch (AlreadyBoundException abex) {
+                LOG.warn("Already bound.", abex);
+                retry = false;
+            } catch (Exception ioe) {
+                try {
+                    logger.warn("Bind failed. Will retry after " + this.bindRetryCycle + " ms");
+                    Thread.sleep(this.bindRetryCycle);
+                } catch (InterruptedException ie) {
+                    // ignore this exception
+                }
+            }
+        }
+    }
+
+    /**
+     * disconnects from snmp host
+     */
+    private void disconnect() {
+
+        if (this.connection == null) {
+            // seems not to be opened at all
+            return;
+        }
+
+        // check if bound
+        if (this.connection.isBound()) {
+            try {
+                // unbind
+                this.connection.unbind();
+            } catch (NotBoundException ex) {
+                // we were not bound
+                LOG.error("Tried to unbind while not bound.", ex);
+            } catch (IOException ex) {
+                // error while unbinding
+                LOG.error("Error while trying to unbind", ex);
+            }
+        }
+
+        try {
+            // remove me from observer list
+            this.connection.removeObserver(this);
+            // close the connection
+            this.connection.closeLink();
+        } catch (IOException ex) {
+            LOG.error("Error disconnecting from host: " + this.host + ":" + this.port, ex);
+        }
+    }
+
+    /**
+     * does a reconnect first closing existing connection and then
+     * reestablishing the connection again
+     */
+    private void reconnect() {
+        LOG.warn("Reconnecting to host " + this.host + ":" + this.port + "...");
+
+        // close connection
+        disconnect();
+
+        // and reconnect
+        connect();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.servicemix.common.endpoints.ProviderEndpoint#processInOnly
+     * (javax.jbi.messaging.MessageExchange,
+     * javax.jbi.messaging.NormalizedMessage)
+     */
+    @Override
+    protected void processInOnly(MessageExchange exchange, NormalizedMessage in) throws Exception {
+        if (exchange.getStatus() == ExchangeStatus.DONE) {
+            // Exchange is finished
+            return;
+        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+            // Exchange has been aborted with an exception
+            return;
+        } else if (exchange.getFault() != null) {
+            // Fault message
+            exchange.setStatus(ExchangeStatus.DONE);
+            getChannel().send(exchange);
+        } else {
+            // let the marshaler create a submit sm object
+            SubmitSM sm = marshaler.fromNMS(connection, exchange, in);
+            SubmitSMResp smr = (SubmitSMResp)connection.sendRequest(sm);
+
+            int code = smr.getCommandStatus();
+            if (code == 0) {
+                // message was delivered
+                done(exchange);
+            } else {
+                // message wasn't delivered
+                fail(exchange, new Exception("Unable to deliver message. Return-Code: " + code));
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.servicemix.common.endpoints.ProviderEndpoint#processInOut(
+     * javax.jbi.messaging.MessageExchange,
+     * javax.jbi.messaging.NormalizedMessage,
+     * javax.jbi.messaging.NormalizedMessage)
+     */
+    @Override
+    protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
+        throws Exception {
+
+        if (exchange.getStatus() == ExchangeStatus.DONE) {
+            // Exchange is finished
+            return;
+        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+            // Exchange has been aborted with an exception
+            return;
+        } else if (exchange.getFault() != null) {
+            // Fault message
+            exchange.setStatus(ExchangeStatus.DONE);
+            getChannel().send(exchange);
+        } else {
+            // let the marshaler create a submit sm object
+            SubmitSM sm = marshaler.fromNMS(connection, exchange, in);
+            SubmitSMResp smr = (SubmitSMResp)connection.sendRequest(sm);
+
+            int code = smr.getCommandStatus();
+            if (code == 0) {
+                // message was delivered -simply copy the in message to out
+                MessageUtil.transferInToOut(exchange, exchange);
+                // and send the exchange back to the caller
+                getChannel().send(exchange);
+            } else {
+                // message wasn't delivered
+                fail(exchange, new Exception("Unable to deliver message. Return-Code: " + code));
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see ie.omk.smpp.event.ConnectionObserver#update(ie.omk.smpp.Connection,
+     * ie.omk.smpp.event.SMPPEvent)
+     */
+    public void update(Connection conn, SMPPEvent ev) {
+        if (ev.getType() == SMPPEvent.RECEIVER_EXIT && ((ReceiverExitEvent)ev).isException()) {
+            logger.debug("SMPPEvent.RECEIVER_EXIT received.");
+            // reconnect
+            reconnect();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * ie.omk.smpp.event.ConnectionObserver#packetReceived(ie.omk.smpp.Connection
+     * , ie.omk.smpp.message.SMPPPacket)
+     */
+    public void packetReceived(Connection conn, SMPPPacket pack) {
+        LOG.debug("Received packet: " + pack);
+
+        switch (pack.getCommandId()) {
+        case SMPPPacket.SUBMIT_SM_RESP:
+            LOG.info("Packet received: SMPPPacket.SUBMIT_SM_RESP");
+            break;
+        case SMPPPacket.SUBMIT_SM:
+            LOG.info("Packet received: SMPPPacket.SUBMIT_SM");
+            break;
+        case SMPPPacket.BIND_TRANSCEIVER_RESP:
+            if (pack.getCommandStatus() != 0) {
+                LOG.error("Error binding: " + pack.getCommandStatus());
+                reconnect();
+            } else {
+                LOG.debug("Bounded");
+            }
+            break;
+        default: // ignore
+            LOG.debug("Received packet with unhandled command id: " + pack.getCommandId());
+        }
+    }
+
+    /**
+     * @return Returns the connection.
+     */
+    public Connection getConnection() {
+        return this.connection;
+    }
+
+    /**
+     * @param connection The connection to set.
+     */
+    public void setConnection(Connection connection) {
+        this.connection = connection;
+    }
+
+    /**
+     * @return Returns the port.
+     */
+    public int getPort() {
+        return this.port;
+    }
+
+    /**
+     * @param port The port to set.
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * @return Returns the bindRetryCycle.
+     */
+    public long getBindRetryCycle() {
+        return this.bindRetryCycle;
+    }
+
+    /**
+     * @param bindRetryCycle The bindRetryCycle to set.
+     */
+    public void setBindRetryCycle(long bindRetryCycle) {
+        this.bindRetryCycle = bindRetryCycle;
+    }
+
+    /**
+     * @return Returns the host.
+     */
+    public String getHost() {
+        return this.host;
+    }
+
+    /**
+     * @param host The host to set.
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * @return Returns the user.
+     */
+    public String getUser() {
+        return this.user;
+    }
+
+    /**
+     * @param user The user to set.
+     */
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * @return Returns the password.
+     */
+    public String getPassword() {
+        return this.password;
+    }
+
+    /**
+     * @param password The password to set.
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * @return Returns the resource.
+     */
+    public String getResource() {
+        return this.resource;
+    }
+
+    /**
+     * @param resource The resource to set.
+     */
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    /**
+     * @return Returns the marshaler.
+     */
+    public SmppMarshalerSupport getMarshaler() {
+        return this.marshaler;
+    }
+
+    /**
+     * @param marshaler The marshaler to set.
+     */
+    public void setMarshaler(SmppMarshalerSupport marshaler) {
+        this.marshaler = marshaler;
+    }
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/SmppSenderEndpoint.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp.marshaler;
+
+import ie.omk.smpp.Address;
+import ie.omk.smpp.Connection;
+import ie.omk.smpp.message.SMPPPacket;
+import ie.omk.smpp.message.SubmitSM;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+/**
+ * Marshals SMPP messages into and out of NMS messages
+ * 
+ * @author Rohit Joshi
+ */
+public class DefaultSmppMarshaler implements SmppMarshalerSupport {
+    
+    private static final transient Log LOG = LogFactory.getLog(DefaultSmppMarshaler.class);
+    
+    private static final String TAG_MESSAGE     = "message";
+    private static final String TAG_SOURCE      = "source";
+    private static final String TAG_DESTINATION = "destination";
+    private static final String TAG_TEXT        = "text";
+    private static final String TAG_TON         = "ton";
+    private static final String TAG_NPI         = "npi";
+    
+    private static final String TAG_MESSAGE_OPEN = "<" + TAG_MESSAGE + ">";
+    private static final String TAG_MESSAGE_CLOSE = "</" + TAG_MESSAGE + ">";
+    private static final String TAG_SOURCE_OPEN = "<" + TAG_SOURCE + ">";
+    private static final String TAG_SOURCE_CLOSE = "</" + TAG_SOURCE + ">";
+    private static final String TAG_DESTINATION_OPEN = "<" + TAG_DESTINATION + ">";
+    private static final String TAG_DESTINATION_CLOSE = "</" + TAG_DESTINATION + ">";
+    private static final String TAG_TEXT_OPEN = "<" + TAG_TEXT + ">";
+    private static final String TAG_TEXT_CLOSE = "</" + TAG_TEXT + ">";
+    private static final String TAG_TON_OPEN = "<" + TAG_TON + ">";
+    private static final String TAG_TON_CLOSE = "</" + TAG_TON + ">";
+    private static final String TAG_NPI_OPEN = "<" + TAG_NPI + ">";
+    private static final String TAG_NPI_CLOSE = "</" + TAG_NPI + ">";
+
+    private SourceTransformer transformer = new SourceTransformer();
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#toNMS(javax.jbi.messaging.NormalizedMessage, ie.omk.smpp.message.SMPPPacket)
+     */
+    public void toNMS(NormalizedMessage normalizedMessage, SMPPPacket packet) throws MessagingException {
+        
+        String text = packet.getMessageText();
+        String sourceAddr = packet.getSource().getAddress();
+        String destinationAddr = packet.getDestination().getAddress();
+        
+        int npi = packet.getSource().getNPI();
+        int ton = packet.getSource().getTON();
+        
+        if (text != null) {
+            StringBuffer data = new StringBuffer(); 
+
+            // build the message content
+            data.append(TAG_MESSAGE_OPEN);
+            
+            data.append(TAG_SOURCE_OPEN);
+            data.append(sourceAddr);
+            data.append(TAG_SOURCE_CLOSE);
+            
+            data.append(TAG_DESTINATION_OPEN);
+            data.append(destinationAddr);
+            data.append(TAG_DESTINATION_CLOSE);
+            
+            data.append(TAG_TEXT_OPEN);
+            data.append(text);
+            data.append(TAG_TEXT_CLOSE);
+            
+            data.append(TAG_NPI_OPEN);
+            data.append(npi);
+            data.append(TAG_NPI_CLOSE);
+            
+            data.append(TAG_TON_OPEN);
+            data.append(ton);
+            data.append(TAG_TON_CLOSE);
+            
+            data.append(TAG_MESSAGE_CLOSE);
+            
+            // put the content to message body
+            normalizedMessage.setContent(new StringSource(data.toString()));
+        } else {
+            LOG.debug("Received message without text content. Skipped.\nPacket: " + packet.toString());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport#fromNMS(ie.omk.smpp.Connection, javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage)
+     */
+    public SubmitSM fromNMS(Connection conn, MessageExchange exchange, NormalizedMessage normalizedMessage)
+        throws TransformerException {
+        
+        SubmitSM sm = null;
+        
+        String source = null;
+        String destination = null;
+        String text = "";
+        String ton = null;
+        String npi = null;
+
+        try {
+            // convert message content to DOM document
+            Document doc = transformer.toDOMDocument(normalizedMessage);
+
+            // normalize text representation
+            doc.getDocumentElement().normalize();
+
+            NodeList node = doc.getElementsByTagName(TAG_SOURCE);
+            
+            if (node != null && node.getLength() > 0) {
+                source = node.item(0).getChildNodes().item(0).getNodeValue();
+                LOG.debug(TAG_SOURCE + ": " + source);
+            }
+            
+            node = doc.getElementsByTagName(TAG_DESTINATION);
+            if (node != null && node.getLength() > 0) {
+                destination = node.item(0).getChildNodes().item(0).getNodeValue();
+                LOG.debug(TAG_DESTINATION + ": " + destination);
+            }
+            
+            node = doc.getElementsByTagName(TAG_TEXT);
+            if (node != null && node.getLength() > 0) {
+                text = node.item(0).getChildNodes().item(0).getNodeValue();
+                LOG.debug(TAG_TEXT + ": " + text);
+            }
+            
+            node = doc.getElementsByTagName(TAG_TON);
+            if (node != null && node.getLength() > 0) {
+                ton = node.item(0).getChildNodes().item(0).getNodeValue();
+                LOG.debug(TAG_TON + ": " + ton);
+            }
+            
+            node = doc.getElementsByTagName(TAG_NPI);
+            if (node != null && node.getLength() > 0) {
+                npi = node.item(0).getChildNodes().item(0).getNodeValue();
+                LOG.debug(TAG_NPI + ": " + npi);
+            }
+            
+            // check for mandatory attribute "destination"
+            if (destination == null) {
+                throw new TransformerException("Invalid message content. Missing tag: " + TAG_DESTINATION);
+            }
+
+            // check for mandatory attribute "ton"            
+            if (ton == null) {
+                throw new TransformerException("Invalid message content. Missing tag: " + TAG_TON);
+            }
+
+            // check for mandatory attribute "npi"            
+            if (npi == null) {
+                throw new TransformerException("Invalid message content. Missing tag: " + TAG_NPI);
+            }
+            
+            try {
+                // create the submit sm object
+                sm = (SubmitSM)conn.newInstance(SMPPPacket.SUBMIT_SM);
+                
+                // create the address
+                Address addr = new Address();
+                // configure the address
+                addr.setAddress(destination);
+                addr.setNPI(Integer.parseInt(npi));
+                addr.setTON(Integer.parseInt(ton));
+                // configure the submit sm to use the address
+                sm.setDestination(addr);
+                // set the short message text
+                sm.setMessageText(text);
+            } catch (Exception ex) {
+                throw new TransformerException(ex);
+            }
+        } catch (Exception e) {
+            throw new TransformerException(e);
+        }
+
+        return sm;
+    }
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp.marshaler;
+
+import ie.omk.smpp.Connection;
+import ie.omk.smpp.message.SMPPPacket;
+import ie.omk.smpp.message.SubmitSM;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+
+/**
+ * @author lhein
+ */
+public interface SmppMarshalerSupport {
+    
+    /**
+     * converts the received smpp packet into a normalized message
+     * 
+     * @param message   the message to fill the packet into
+     * @param packet    the received packet to convert into message
+     * @throws MessagingException       on errors
+     */
+    void toNMS(NormalizedMessage message, SMPPPacket packet) throws MessagingException;
+    
+    /**
+     * converts a normalized message from the nmr into smpp packets
+     * 
+     * @param connection        the smpp connection
+     * @param exchange          the message exchange
+     * @param message           the normalized message
+     * @return                  a submit sm object
+     * @throws TransformerException     on errors in transformation
+     */
+    SubmitSM fromNMS(Connection connection, MessageExchange exchange, NormalizedMessage message) throws TransformerException;
+}
\ No newline at end of file

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/SmppMarshalerSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml Mon Oct 27 11:37:21 2008
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The J2EE application client deployer service
+  -->
+<server>
+    <depends>org.servicemix:service=Deployer</depends>
+</server>
+

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/jbi/jboss-service.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml Mon Oct 27 11:37:21 2008
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd
+  http://www.springframework.org/schema/osgi-compendium
+  http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
+
+    <bean id="servicemix-smpp" class="org.apache.servicemix.smpp.SmppComponent">
+        <property name="executorFactory" ref="executorFactory" />
+    </bean>
+
+    <bean id="executorFactory" class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">
+        <property name="defaultConfig">
+            <bean class="org.apache.servicemix.executors.impl.ExecutorConfig">
+                <property name="corePoolSize" value="${threadPoolCorePoolSize}"/>
+                <property name="maximumPoolSize" value="${threadPoolMaximumPoolSize}"/>
+                <property name="queueSize" value="${threadPoolQueueSize}"/>
+            </bean>
+        </property>
+    </bean>
+
+    <bean id="endpoint-tracker" class="org.apache.servicemix.common.osgi.EndpointTracker">
+        <property name="component" ref="servicemix-smpp" />
+    </bean>
+
+    <osgi:list id="endpoints"
+               interface="org.apache.servicemix.common.osgi.EndpointWrapper"
+               cardinality="0..N">
+        <osgi:listener ref="endpoint-tracker" bind-method="register" unbind-method="unregister" />
+    </osgi:list>
+
+    <osgi:service ref="servicemix-smpp" interface="javax.jbi.component.Component">
+        <osgi:service-properties>
+            <entry key="NAME" value="servicemix-smpp" />
+            <entry key="TYPE" value="binding-component" />
+        </osgi:service-properties>
+    </osgi:service>
+
+    <osgix:property-placeholder persistent-id="servicemix-smpp">
+        <osgix:default-properties>
+            <prop key="threadPoolCorePoolSize">8</prop>
+            <prop key="threadPoolMaximumPoolSize">32</prop>
+            <prop key="threadPoolQueueSize">256</prop>
+        </osgix:default-properties>
+    </osgix:property-placeholder>
+
+</beans>

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/main/resources/META-INF/spring/servicemix-smpp.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java?rev=708275&view=auto
==============================================================================
--- servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java (added)
+++ servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java Mon Oct 27 11:37:21 2008
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.smpp;
+
+import ie.omk.smpp.Address;
+import ie.omk.smpp.Connection;
+import ie.omk.smpp.message.SMPPPacket;
+import ie.omk.smpp.message.SubmitSM;
+
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.TransformerException;
+
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.messaging.MessageExchangeFactoryImpl;
+import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.smpp.marshaler.DefaultSmppMarshaler;
+import org.apache.servicemix.smpp.marshaler.SmppMarshalerSupport;
+
+import junit.framework.TestCase;
+
+/**
+ * @author: lhein
+ */
+public class SmppMarshalerTest extends TestCase {
+
+    private static final String SOURCE = "0123456789";
+    private static final String DESTINATION = "9876543210";
+    private static final String TEXT = "This is a smpp test...";
+    private static final String NPI = "0";
+    private static final String TON = "1";
+    
+    private static final String MSG_VALID = "<message><source>" + SOURCE + "</source><destination>" + DESTINATION + "</destination><text>" + TEXT + "</text><npi>" + NPI + "</npi><ton>" + TON + "</ton></message>";
+    private static final String MSG_INVALID = "This will definitely break the test...";
+    private static final String MSG_INVALID_DEST = "<message><source>" + SOURCE + "</source><text>" + TEXT + "</text><npi>" + NPI + "</npi><ton>" + TON + "</ton></message>";
+    private static final String MSG_INVALID_TON = "<message><source>" + SOURCE + "</source><destination>" + DESTINATION + "</destination><text>" + TEXT + "</text><npi>" + NPI + "</npi></message>";
+    private static final String MSG_INVALID_NPI = "<message><source>" + SOURCE + "</source><destination>" + DESTINATION + "</destination><text>" + TEXT + "</text><ton>" + TON + "</ton></message>";
+        
+    private SmppMarshalerSupport marshaler;
+    private SourceTransformer st;
+    private MessageExchangeFactory factory;
+    private Connection conn;
+    
+    /*
+     * (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp() throws Exception {
+        this.marshaler = new DefaultSmppMarshaler();
+        this.st = new SourceTransformer();
+        this.factory = new MessageExchangeFactoryImpl(new IdGenerator(), new AtomicBoolean(false));
+        this.conn = new Connection("localhost", 1977, false);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception {
+        this.marshaler = null;
+        this.st = null;
+        this.factory = null;
+        this.conn.closeLink();
+        this.conn = null;
+    }
+
+    private MessageExchange prepareMessageExchange(URI pattern, String inMsgContent) {
+        MessageExchange ex = null;
+        
+        try {
+            ex = this.factory.createExchange(pattern);
+            NormalizedMessage nmsg = ex.createMessage();
+            nmsg.setContent(new StringSource(inMsgContent));
+            ex.setMessage(nmsg, "in");
+        } catch (Exception e) {
+            ex = null;
+        }        
+        
+        return ex;
+    }
+    
+    private SMPPPacket preparePacketValid() {
+        SMPPPacket packet = null;
+        
+        try {
+          packet = this.conn.newInstance(SMPPPacket.SUBMIT_SM);
+          packet.setMessageText(TEXT);
+          packet.setSource(new Address(Integer.parseInt(TON), Integer.parseInt(NPI), SOURCE));
+          packet.setDestination(new Address(Integer.parseInt(TON), Integer.parseInt(NPI), DESTINATION));
+        } catch (Exception ex) {
+          ex.printStackTrace();
+          packet = null;
+        }        
+                
+        return packet;
+    }
+    
+    private SMPPPacket preparePacketInvalid() {
+        SMPPPacket packet = null;
+        
+        try {
+          packet = this.conn.newInstance(SMPPPacket.SUBMIT_SM);
+        } catch (Exception ex) {
+          ex.printStackTrace();
+          packet = null;
+        }        
+                
+        return packet;
+    }
+    
+    
+    
+    /**
+     * ********************* HERE THE TEST METHODS **************************
+     */
+    
+    public void testFromNMSValid() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_VALID);
+        try {
+           SubmitSM sm = marshaler.fromNMS(this.conn, exch, exch.getMessage("in"));
+           
+           assertEquals("The message text is not the same. Expected: " + TEXT + ", Found: " + sm.getMessageText(), sm.getMessageText(), TEXT);
+           assertEquals("The destination is not the same. Expected: " + DESTINATION + ", Found: " + sm.getDestination().getAddress(), sm.getDestination().getAddress(), DESTINATION);
+           assertEquals("The NPI is not the same. Expected: " + NPI + ", Found: " + sm.getDestination().getNPI(), "" + sm.getDestination().getNPI(), NPI);
+           assertEquals("The TON is not the same. Expected: " + TON + ", Found: " + sm.getDestination().getTON(), "" + sm.getDestination().getTON(), TON);
+        } catch (TransformerException ex) {
+           fail(ex.getMessage());
+        }        
+    }
+    
+    public void testFromNMSNullConnection() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_VALID);
+        try {
+           marshaler.fromNMS(null, exch, exch.getMessage("in"));
+           fail("Seems we processed a message with null connection...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+    
+    public void testFromNMSNullExchange() {
+        try {
+           marshaler.fromNMS(this.conn, null, null);
+           fail("Seems we processed a message with null exchange...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+        
+    public void testFromNMSInvalid() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_INVALID);
+        try {
+           marshaler.fromNMS(this.conn, exch, exch.getMessage("in"));
+           fail("Seems that we processed a invalid message...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+    
+    public void testFromNMSInvalidDest() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_INVALID_DEST);
+        try {
+           marshaler.fromNMS(this.conn, exch, exch.getMessage("in"));
+           fail("Seems that we processed a invalid message...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+    
+    public void testFromNMSInvalidTon() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_INVALID_TON);
+        try {
+           marshaler.fromNMS(this.conn, exch, exch.getMessage("in"));
+           fail("Seems that we processed a invalid message...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+    
+    public void testFromNMSInvalidNpi() {
+        MessageExchange exch = prepareMessageExchange(MessageExchangeSupport.IN_ONLY, MSG_INVALID_NPI);
+        try {
+           marshaler.fromNMS(this.conn, exch, exch.getMessage("in"));
+           fail("Seems that we processed a invalid message...");
+        } catch (TransformerException ex) {
+           // all fine
+        }        
+    }
+    
+    public void testToNMSValid() {
+        SMPPPacket packet = preparePacketValid();
+        
+        try {
+           MessageExchange ex = this.factory.createExchange(MessageExchangeSupport.IN_ONLY);
+           NormalizedMessage nmsg = ex.createMessage();
+           ex.setMessage(nmsg, "in");
+           marshaler.toNMS(nmsg, packet);
+           assertEquals("Message not correct. Expected: " + MSG_VALID + ", Found: " + st.contentToString(nmsg), MSG_VALID, st.contentToString(nmsg));
+        } catch (Exception ex) {
+           ex.printStackTrace();
+           fail(ex.getMessage());
+        }        
+    }
+    
+    public void testToNMSInvalid() {
+        SMPPPacket packet = preparePacketInvalid();
+        
+        try {
+           MessageExchange ex = this.factory.createExchange(MessageExchangeSupport.IN_ONLY);
+           NormalizedMessage nmsg = ex.createMessage();
+           ex.setMessage(nmsg, "in");
+           marshaler.toNMS(nmsg, packet);
+           fail("Seems we processed a invalid smpp packet...");
+        } catch (Exception ex) {
+           // all fine
+        }        
+    }
+    
+    public void testToNMSNullPacket() {
+        SMPPPacket packet = null;
+        
+        try {
+           MessageExchange ex = this.factory.createExchange(MessageExchangeSupport.IN_ONLY);
+           NormalizedMessage nmsg = ex.createMessage();
+           ex.setMessage(nmsg, "in");
+           marshaler.toNMS(nmsg, packet);
+           fail("Seems we processed a null smpp packet...");
+        } catch (Exception ex) {
+           // all fine
+        }        
+    }
+    
+    public void testToNMSNullMsg() {
+        SMPPPacket packet = preparePacketInvalid();;
+        
+        try {
+           marshaler.toNMS(null, packet);
+           fail("Seems we processed a smpp packet with a null normalized message...");
+        } catch (Exception ex) {
+           // all fine
+        }        
+    }
+}

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: servicemix/sandbox/lhein/servicemix-smpp/src/test/java/org/apache/servicemix/smpp/SmppMarshalerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message