Home Docs Changes To-do End Users FAQs Getting Started Developers JCL RI Sample Code JavaDOC References |  |
jpos.config/loader (JCL) - Sample Code
This section will describe the sample JCL-enabled JavaPOS service and sample application that should constitute a better verification test for the JCL installed and be a stating point for service writers. Setting up, configuration and running Sample Virtual LineDisplay service Compiling sources Setting up, configuration and running To setup the JCL sample code, you need to make sure that the jcl_sample.jar file is in your CLASSPATH. See the Getting Started on how to setup the JCL JAR files. Sources: s extract the jcl_sample_src.jar file in the "sample" directory to get the source to the sample JCL test application. Use the following command with the jar utility found in Java 2 (issued in the "sample" directory): >jar xvf jcl_sample_src.jar Once the jcl_sample.jar file is in your CLASSPATH you need to setup your jpos.properties file correctly (i.e. populator file pointing to the <jcl-dir>\res\jpos.cfg or using the XML populator <jcl-dir>\res\sample.xml) Run the TestApp by issuing the following command: >java com.xyz.TestApp Once you launch the application you will see the following screen: Type in the logical name (use "LineDisplay0" if using the XML populator or "com.xyz.MyLD" if not) then Click on "Open" then "Claim" then check "DeviceEnabled" box. You should see the "virtual" 2x20 line display frame. Display text in it by typing the text and clicking on the "displayText" button. It should look something like this: PS: turn tracing ON to see any errors that might occur while loading the app and while the JCL looks for the entries file or for any errors that could happen. Do this by defining the property jpos.util.tracing to ON ( i.e. jpos.util.tracing = ON in the jpos.properties file) Sample Virtual LineDisplay service The key points to understand about the com.xyz.jpos.LineDisplay service in the sample code are: The com.xyz.jpos.LineDisplayservice class extends the com.xyz.jpos.DeviceService class The com.xyz.jpos.DeviceService super class implements jpos.services.BaseService and implemented all the common methods The com.xyz.jpos.DeviceService class also implements the jpos.loader.JposServiceInstance interface. This is important since the factory class will need to cast the service object that it creates from the com.xyz.jpos.LineDisplay class to this interface The com.xyz.jpos.DeviceService has a public setJposEntry( JposEntry ) method that the factory calls and pass the JposEntry object that was used to configure this service. The service should use the JposEntry passed for further initialization (if required) The com.xyz.jpos.DeviceService (or the com.xyz.jpos.LineDisplay) implements the deleteInstance() method that is called when the service is disconnected form its control object. The service typically would use this to do some clean-up code (e.g. releasing resources) Compiling sources Compile the sample sources by issuing following command in the "sample" directory: >javac com/xyz/*.java >javac com/xyz/jpos/*.java
Last modified by EMM on 03/07/2001 12:33 AM