Sfoglia il codice sorgente

Fix Error on Remote EJB Call

anthony.moreno 7 anni fa
parent
commit
a0044e52f0

+ 0 - 3
GabonTelMobicashMobileAppHelper/.checkstyle

@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false"/>

+ 42 - 2
GabonTelMobicashMobileAppHelper/pom.xml

@@ -17,13 +17,53 @@
 	<build>
         <finalName>Test_210_GabonTelMobicashMobileAppHelper</finalName>
     </build>
+	<dependencyManagement>
+	   <dependencies>
+	      <dependency>
+	         <groupId>org.wildfly</groupId>
+	         <artifactId>wildfly-ejb-client-bom</artifactId>
+	         <version>12.0.0.Final</version>
+	         <type>pom</type>
+	         <scope>import</scope>
+	      </dependency>
+	   </dependencies>
+	</dependencyManagement>
 	<dependencies>
-	    <dependency>
+        <dependency>
             <groupId>org.wildfly</groupId>
             <artifactId>wildfly-ejb-client-bom</artifactId>
             <type>pom</type>
-            <scope>compile</scope>
+	         <scope>provided</scope>
         </dependency>
+		<dependency>
+		    <groupId>org.wildfly.wildfly-http-client</groupId>
+		    <artifactId>wildfly-http-ejb-client</artifactId>
+		    <version>1.0.11.Final</version>
+	        <scope>provided</scope>
+		</dependency>
+		<dependency>
+		    <groupId>org.wildfly.wildfly-http-client</groupId>
+		    <artifactId>wildfly-http-naming-client</artifactId>
+		    <version>1.0.11.Final</version>
+	        <scope>provided</scope>
+		</dependency>
+		<dependency>
+		    <groupId>org.wildfly.wildfly-http-client</groupId>
+		    <artifactId>wildfly-http-client-common</artifactId>
+		    <version>1.0.11.Final</version>
+	        <scope>provided</scope>
+		</dependency>
+		<dependency>
+		    <groupId>org.jboss.remoting</groupId>
+		    <artifactId>jboss-remoting</artifactId>
+		    <version>5.0.8.Final</version>
+	         <scope>compile</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.jboss.logging</groupId>
+		    <artifactId>jboss-logging</artifactId>
+		    <scope>provided</scope>
+		</dependency>
 		<dependency>
 			<groupId>com.psi.common</groupId>
 			<artifactId>transactions</artifactId>

+ 5 - 3
GabonTelMobicashMobileAppHelper/src/main/java/com/psi/gabontel/mobileapp/thirdparty/helper/InitializerBean.java

@@ -24,6 +24,7 @@ import com.psi.ussd.interfaces.UssdReceiverFunction;
 public class InitializerBean {
     private static final Logger log = Logger.getLogger(InitializerBean.class);
     private static final Hashtable<String,String> ussdgwmenuejb = new Hashtable<String,String>();
+    private static final Hashtable<String, String> jndiProperties = new Hashtable<>();
     private static Context context;
     @PostConstruct
     public void initialize() {
@@ -45,11 +46,11 @@ public class InitializerBean {
         String extra = row.getString("PARAMS");
         Map<String, String> extraparam = StringUtil.json2Map(extra);
         
-        final Hashtable<String, String> jndiProperties = new Hashtable<>();
         //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
         jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
         jndiProperties.put(Context.PROVIDER_URL, url);
         try {
+            log.info("url: " + url);
             context = new InitialContext(jndiProperties);
         } catch (NamingException e) {
             log.error(e,e);
@@ -64,10 +65,11 @@ public class InitializerBean {
     }
     public static UssdReceiverFunction getInterface(String jndi) {
         try {
+            final Context context = new InitialContext(jndiProperties);
             UssdReceiverFunction ussdplugin = (UssdReceiverFunction) context.lookup(jndi);
             return ussdplugin;
-        } catch (NamingException e) {
-            log.error(e,e);
+        } catch (Exception e) {
+            log.error(jndi,e);
         }
         return null;
     }

+ 4 - 5
GabonTelMobicashMobileAppHelper/src/main/java/com/psi/gabontel/mobileapp/thirdparty/helper/MobileAppThirdPartyHelper.java

@@ -47,14 +47,13 @@ public class MobileAppThirdPartyHelper  implements AppManagerFunction {
 			if(method.equals("postpaidinvoices")){
 				
 				String arisreturn = clazz.requestFunc(listarr);
-				
+				log.info(arisreturn);
 			    clazz = InitializerBean.getInterface(InitializerBean.getUssdgwmenuejb("displayinvoices"));
 				
 				listarr =  Arrays.asList(arisreturn);
-				clazz.requestFunc(listarr);
-				
-				return new Message(0,0,new JsonResponse(0,clazz.requestFunc(listarr)).toString());
-					
+				String resp = clazz.requestFunc(listarr);
+				log.info(resp);
+				return new Message(0,0,new JsonResponse(0,resp).toString());	
 			}
 			
 			return new Message(0,0,new JsonResponse(0,clazz.requestFunc(listarr)).toString());

+ 40 - 14
GabonTelMobicashMobileAppHelper/src/main/java/com/psi/gabontel/mobileapp/thirdparty/helper/Test.java

@@ -1,29 +1,55 @@
 package com.psi.gabontel.mobileapp.thirdparty.helper;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Hashtable;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
 
+import com.psi.applicationmanager.AppManagerFunction;
 import com.psi.ussd.interfaces.UssdReceiverFunction;
 
 public class Test {
-
     public static void main(String[] args) {
-//        final Hashtable<String, String> jndiProperties = new Hashtable<>();
-//        //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
-//        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
-//        jndiProperties.put(Context.PROVIDER_URL, "http://localhost:8280/wildfly-services");
-//        String jndi = "java:jboss/exported/Test_110_GabonTelUssdMfsInfo/GetMfsTypeBean!com.psi.ussd.interfaces.UssdReceiverFunction";
-//        try {
-//            final Context context = new InitialContext(jndiProperties);
-//            UssdReceiverFunction reference = (UssdReceiverFunction) context.lookup(jndi.replace("java:jboss/exported", "ejb:") );
-//            System.out.println(reference.requestFunc(Arrays.asList("moov","241060000")));
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
+        if(1==1)
+            appman(args);
+        else
+            ussd(args);
+    }
+    public static void appman(String[] args) {
+        final Hashtable<String, String> jndiProperties = new Hashtable<>();
+        //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
+        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
+        jndiProperties.put(Context.PROVIDER_URL, "http://127.0.0.1:8180/wildfly-services");
+        String jndi = "java:jboss/exported/Test_210_GabonTelMobicashMobileAppHelper/MobileAppThirdPartyHelper!com.psi.applicationmanager.AppManagerFunction";
+        try {
+            final Context context = new InitialContext(jndiProperties);
+            AppManagerFunction reference = (AppManagerFunction) context.lookup(jndi.replace("java:jboss/exported", "ejb:") );
+            HashMap<String,String> map = new HashMap<String,String>();
+            map.put("key", "MNFO1");
+            map.put("method", "postpaidinvoices");
+            map.put("param", "01765853");
+            map.put("language", "F");
+            System.out.println(reference.processTransaction("320180805000101", "24106394167", "MNFO1 postpaidinvoices 01765853", map));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        System.exit(0);
+    }
+    public static void ussd(String[] args) {
+        final Hashtable<String, String> jndiProperties = new Hashtable<>();
+        //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
+        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
+        jndiProperties.put(Context.PROVIDER_URL, "http://127.0.0.1:8280/wildfly-services");
+        String jndi = "java:jboss/exported/Test_110_GabonTelUssdPostpaidInfo/GetListOfInvoicesBean!com.psi.ussd.interfaces.UssdReceiverFunction";
+        try {
+            final Context context = new InitialContext(jndiProperties);
+            UssdReceiverFunction reference = (UssdReceiverFunction) context.lookup(jndi.replace("java:jboss/exported", "ejb:") );
+            System.out.println(reference.requestFunc(Arrays.asList(new String[] {"01765853"})));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         System.exit(0);
     }
-
 }