Skip to content

Commit f2296ee

Browse files
authored
Revert "Use GxProperties for properties and pass context to invoked objects (…"
This reverts commit e4cd483.
1 parent e4cd483 commit f2296ee

File tree

3 files changed

+58
-31
lines changed

3 files changed

+58
-31
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.genexus.gxdynamiccall;
2+
3+
public class GXDynCallProperties {
4+
private String externalName;
5+
private String packageName;
6+
7+
public String getExternalName() {
8+
return externalName;
9+
}
10+
public void setExternalName(String name) {
11+
externalName = name;
12+
}
13+
public String getPackageName() {
14+
return packageName;
15+
}
16+
public void setPackageName(String packageN) {
17+
packageName = packageN;
18+
}
19+
20+
21+
22+
23+
}

gxdynamiccall/src/main/java/com/genexus/gxdynamiccall/GXDynamicCall.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,36 @@
77

88
import com.genexus.CommonUtil;
99
import com.genexus.GXBaseCollection;
10-
import com.genexus.ModelContext;
1110
import com.genexus.SdtMessages_Message;
12-
import com.genexus.util.GXProperties;
11+
import com.genexus.common.interfaces.SpecificImplementation;
1312

1413
public class GXDynamicCall {
1514

16-
private GXProperties properties;
15+
private GXDynCallProperties properties;
1716
private Object instanceObject;
18-
private String externalName;
19-
private int remoteHandle;
20-
private ModelContext context;
17+
private String objectName;
2118

22-
public GXDynamicCall(int remoteHandle, ModelContext context){
23-
this.remoteHandle = remoteHandle;
24-
this.context = context;
25-
this.properties = new GXProperties();
19+
public GXDynamicCall(){
20+
properties = new GXDynCallProperties();
21+
properties.setPackageName(SpecificImplementation.Application.getPACKAGE());
2622
}
2723

28-
public GXProperties getProperties() {
24+
public GXDynCallProperties getProperties() {
2925
return properties;
3026
}
3127

32-
public void setProperties(GXProperties properties) {
28+
public void setProperties(GXDynCallProperties properties) {
3329
this.properties = properties;
3430
}
3531

36-
public String getExternalName(){
37-
return externalName;
32+
public String getObjectName(){
33+
return objectName;
34+
3835
}
3936

40-
public void setExternalName(String name){
41-
externalName=name;
37+
public void setObjectName(String name){
38+
objectName=name;
39+
properties.setExternalName(name);
4240
}
4341

4442
public void execute(Vector<Object> parameters, Vector<SdtMessages_Message> errorsArray) {
@@ -75,7 +73,7 @@ public Object execute(Vector<Object> parameters, GXDynCallMethodConf methodConfi
7573
{
7674
Class<?> auxClass=null;
7775
try {
78-
auxClass = loadClass(this.externalName, properties.get("PackageName"));
76+
auxClass = loadClass(properties.getExternalName(),properties.getPackageName());
7977
} catch (ClassNotFoundException e) {
8078
CommonUtil.ErrorToMessages("Load class Error", e.getMessage(), errors);
8179
errorsArray.addAll(errors.getStruct());
@@ -90,10 +88,12 @@ public Object execute(Vector<Object> parameters, GXDynCallMethodConf methodConfi
9088

9189
public void create(Vector<Object> constructParameters, Vector<SdtMessages_Message> errors) {
9290
GXBaseCollection<SdtMessages_Message> error =new GXBaseCollection<SdtMessages_Message>();
91+
String objectNameToInvoke;
9392
Constructor<?> constructor=null;
94-
if (!this.externalName.isEmpty()) {
93+
objectNameToInvoke = constructParameters==null?objectName:properties.getExternalName();
94+
if (!objectNameToInvoke.isEmpty()) {
9595
try {
96-
Class<?> objClass = loadClass(this.externalName, properties.get("PackageName"));
96+
Class<?> objClass = loadClass(objectNameToInvoke, properties.getPackageName());
9797
Object[] auxConstParameters;
9898
Class<?>[] auxConstructorTypes;
9999
if (constructParameters != null && constructParameters.size() > 0) {
@@ -104,9 +104,9 @@ public void create(Vector<Object> constructParameters, Vector<SdtMessages_Messag
104104
auxConstructorTypes[i] = obj.getClass();
105105
i++;
106106
}
107-
} else {
108-
auxConstParameters = new Object[] {this.remoteHandle, this.context};
109-
auxConstructorTypes = new Class[] {int.class, ModelContext.class};
107+
} else {
108+
auxConstParameters = new Object[] {Integer.valueOf(-1)};
109+
auxConstructorTypes = new Class[] {int.class};
110110
}
111111
try{
112112
constructor = objClass.getConstructor(auxConstructorTypes);
@@ -258,7 +258,7 @@ private static void updateParams(Vector<Object> originalParameter, Object[] call
258258

259259
private Class<?> loadClass(String className, String sPackage) throws ClassNotFoundException {
260260
String classPackage="";
261-
if(sPackage != null && !sPackage.isEmpty())
261+
if(sPackage != null)
262262
classPackage+= sPackage + ".";
263263
classPackage+= className;
264264
Class<?> c = Class.forName(classPackage);;

gxdynamiccall/src/test/java/com/genexus/gxdynamiccall/test/GxDynamicCallTest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.genexus.gxdynamiccall.test;
22
import com.genexus.Application;
3-
import com.genexus.ModelContext;
3+
import com.genexus.GXBaseCollection;
4+
import com.genexus.GXSimpleCollection;
45
import com.genexus.SdtMessages_Message;
56
import com.genexus.gxdynamiccall.GXDynCallMethodConf;
6-
7+
import com.genexus.gxdynamiccall.GXDynCallProperties;
78
import com.genexus.gxdynamiccall.GXDynamicCall;
9+
import com.genexus.specific.java.Connect;
810

911
import org.junit.Assert;
1012
import org.junit.Test;
@@ -16,8 +18,8 @@ public class GxDynamicCallTest {
1618
@Test
1719
public void callGxNativeObject(){
1820
Application.init(com.genexus.gxdynamiccall.test.GXcfg.class);
19-
GXDynamicCall call = new GXDynamicCall(-1, new ModelContext(GxDynamicCallTest.class));
20-
call.setExternalName("com.genexus.gxdynamiccall.test.DynamicCallTestProcedure");
21+
GXDynamicCall call = new GXDynamicCall();
22+
call.setObjectName("DynamicCallTestProcedure");
2123
Vector<Object> paramArray = new Vector<>();
2224
paramArray.add(Double.parseDouble("3"));
2325
paramArray.add((short)4);
@@ -32,9 +34,10 @@ public void callGxNativeObject(){
3234
@Test
3335
public void callExternalClass(){
3436
Application.init(com.genexus.gxdynamiccall.test.GXcfg.class);
35-
GXDynamicCall call = new GXDynamicCall(-1, new ModelContext(GxDynamicCallTest.class));
37+
GXDynamicCall call = new GXDynamicCall();
3638
Vector<SdtMessages_Message> errorsArray= new Vector<>();
37-
call.setExternalName("com.genexus.gxdynamiccall.test.DynamicCallExternalTestProcedure");
39+
call.getProperties().setExternalName("DynamicCallExternalTestProcedure");
40+
call.getProperties().setPackageName("com.genexus.gxdynamiccall.test");
3841
//Constructor
3942
Vector<Object> constructParamArray = new Vector<>();
4043
constructParamArray.add((int)3);
@@ -61,8 +64,9 @@ public void callExternalClass(){
6164
@Test
6265
public void callExternalClassWithStaticMethod(){
6366
Application.init(com.genexus.gxdynamiccall.test.GXcfg.class);
64-
GXDynamicCall call = new GXDynamicCall(-1, new ModelContext(GxDynamicCallTest.class));
65-
call.setExternalName("com.genexus.gxdynamiccall.test.DynamicCallExternalTestProcedure");
67+
GXDynamicCall call = new GXDynamicCall();
68+
call.getProperties().setExternalName("DynamicCallExternalTestProcedure");
69+
call.getProperties().setPackageName("com.genexus.gxdynamiccall.test");
6670
Vector<SdtMessages_Message> errorsArray= new Vector<>();
6771
//Parameters
6872
Vector<Object> paramArray = new Vector<>();

0 commit comments

Comments
 (0)