In the series Hacking Infor Grid application development, today I will illustrate how to add a JAR file to an Infor Grid application and a JAR file to a dynamic web application in that Grid application (which is trivial).
JAR for Grid application
First, create a simple Java library:
package net.company.your.library1; public class HelloWorldLibrary1 { public static String getMessage() { return "Hello World sample library for my Grid application"; } }
Then, compile it with:
javac net\company\your\library1\HelloWorldLibrary1.java
Then, add it to a JAR file with:
jar cvf HelloWorldLibrary1.jar net\company\your\library\HelloWorldLibrary1.class
Then, call that library from the Grid application with:
[...] import net.company.your.library1.*; public class HelloWorld implements ApplicationEntryPointEx { public boolean startModule(ModuleContext paramModuleContext) { System.out.println(HelloWorldLibrary1.getMessage()); return true; } [...] }
Then, recompile that Grid application as usual with:
javac -cp grid-core-1.11.27.jar;. net\company\your\HelloWorld.java
Here’s the result in the command prompt:
Then, create a jars folder in the Grid application and add the JAR file to it:
The default folder for JAR files is jars. It seems other Infor Grid applications use folder lib instead. We can change the classpath in the Grid application’s properties, for instance the application M3UIAdapter has JAR files in a folder lib:
Then, replace the Grid application:
Then, restart the Module in the Grid Management Pages:
We can see the result in the logs:
JAR for dynamic web application
Now let’s create a second Java library for the dynamic web application of the Grid application; this is classic J2EE and trivial:
package net.company.your.library2; public class HelloWorldLibrary2 { public static String getMessage() { return "Hello World sample library for my dynamic web application"; } }
Then, compile it and add it to a JAR file as shown above.
Then, let’s use that library from the servlet (or from a JSP):
[...] import net.company.your.library2.*; public class HelloWorldServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { [...] out.println(HelloWorldLibrary2.getMessage()); } }
Then, recompile the servlet as usual.
Here’s the result in the command prompt:
Then, create a lib folder in the WEB-INF folder of the dynamic web application:
Then, replace the servlet (or JSP):
And refresh the servlet (or JSP) to see the result:
Summary
That was how to add a JAR file to an Infor Grid application and a JAR file to a dynamic web application in that Grid application (which was trivial). Next time I will find out how to add a WAR file.
Also, remember this is a hack that currently has limitations due to our lack of knowledge of how to develop good applications for the Infor Grid, as discussed in part 1 of this series.
Also, remember to join the campaign and sign the petition to Infor Product Development for making their source code available.
That’s it! If you like this, please click the Like button, leave a comment below, subscribe to this blog, share around you, and write about your own ideas here. Thank you.
UPDATE: You can add lib to the classpath of the application deployment descriptor.
LikeLike