private static Class getClassObject() { Class myClass = null; try { myClass = Class.forName(CLASS_NAME); } catch (ClassNotFoundException e) { String msg = "Unable to find the class: " + CLASS_NAME; JxfsCollectorLogger.getLogger().writeWarningLog(msg); } catch (Exception e) { String msg = "Unexpected exception occurred: " + CLASS_NAME; JxfsCollectorLogger.getLogger().writeWarningLog(msg); } return myClass; }
private void initialize() { Class myClass = getClassObject(); if (myClass == null) { JxfsCollectorLogger.getLogger() .writeWarningLog( "This informaton is only for NCR devices, so If other vendor Device Service is being used, please ignore this."); return; } Object reference = invokeMethod(myClass, new Object(), "getReference"); if (reference == null) { return; } Boolean libraryLoaded = (Boolean) invokeMethod(myClass, new Object(), "isLibraryLoaded"); if (libraryLoaded == null) { return; } if (!libraryLoaded.booleanValue()) { String msg = LIB_NAME + " Library is not loaded successfully, please make sure the library is available in the class path."; JxfsCollectorLogger.getLogger() .writeErrorLog(msg, new Exception("Native Library not found. " + LIB_NAME)); return; } int[] handles = (int[]) invokeMethod(myClass, reference, "JNI_UlyDevListDevices"); if (handles != null) { for (int i = 0; i < handles.length; i++) { try { Object deviceInfo = invokeMethod(myClass, reference, "JNI_UlyDevQueryDevice", handles[i]); String deviceName = (String) invokeMethod(deviceInfo.getClass(), deviceInfo, "getDeviceName"); Integer variant = (Integer) invokeMethod(deviceInfo.getClass(), deviceInfo, "getVariant"); Integer universalId = (Integer) invokeMethod(deviceInfo.getClass(), deviceInfo, "getUniversalId"); NCRVendorDependentInformation vendorDependentInfo = new NCRVendorDependentInformation(deviceName, variant, universalId); deviceInfo_.add(vendorDependentInfo); JxfsCollectorLogger.getLogger().writeInfoLog(vendorDependentInfo.toString()); } catch (Exception ex) { JxfsCollectorLogger.getLogger() .writeErrorLog("Unexpected exception occurred while invoking the methods ", ex); } } } }
private static Object invokeMethod(Class classObject, Object reference, String methodName) { try { Class noparams[] = {}; Method method = classObject.getDeclaredMethod(methodName, noparams); return method.invoke(reference, new Object[] {}); } catch (Exception ex) { String msg = "invokeMethod(): Unable to invoke the " + methodName + " method."; JxfsCollectorLogger.getLogger().writeErrorLog(msg, ex); } return null; }
public String[] getVendorInfo(String serviceName, String deviceName) { JxfsCollectorLogger.getLogger() .writeEntryLog( "NCRVendorDependentInfoProvider", "getVendorInfo(" + serviceName + "," + deviceName + ")"); String[] details = new String[0]; if ((serviceName.equals(INCRDeviceServiceClassNames.COIN_DISPENSER)) || (serviceName.equals(INCRDeviceServiceClassNames.COIN_DISPENSER_BBVA))) { details = getCoinDispenserDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.GBNA_GBRU)) { details = getCashRecyclerDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.SCPM_SCANNER) || (serviceName.equals(INCRDeviceServiceClassNames.DEPOSIT_MODULE))) { details = getSCPMDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.CASH_ACCEPTOR)) { details = getCashAcceptorDetails(); } else if ((serviceName.equals(INCRDeviceServiceClassNames.CASH_DISPENSER)) || (serviceName.equals(INCRDeviceServiceClassNames.CASH_DISPENSER_BBVA_2000))) { if (isSecondDispenser(deviceName)) { details = getSecondCashDispenserDetails(); } else { details = getCashDispenserDetails(); } } else if (serviceName.equals(INCRDeviceServiceClassNames.ENV_DEPOSITORY)) { details = getEnevelopDepositoryDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.RPTR) || (serviceName.equals(INCRDeviceServiceClassNames.USB_RPTR))) { details = getReceiptPrinterDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.JPTR) || (serviceName.equals(INCRDeviceServiceClassNames.USB_JRPTR))) { details = getJournalPrinterDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.SPTR) || (serviceName.equals(INCRDeviceServiceClassNames.USB_SPTR)) || (serviceName.equals(INCRDeviceServiceClassNames.USB_SPTR_2000))) { details = getStatementPrinterDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.OPTR)) { details = getOpenPrinterDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.PASSBOOK_PTR)) { details = getPassbookPrinterDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.MCRW_MSD) || (serviceName.equals(INCRDeviceServiceClassNames.DIP_MSD)) || (serviceName.equals(INCRDeviceServiceClassNames.SCRW_CCD)) || (serviceName.equals(INCRDeviceServiceClassNames.DASH_MSD_CCD)) || (serviceName.equals(INCRDeviceServiceClassNames.SCRW_BBVA))) { if (isSecondCardReader(deviceName)) { details = getSecondCardReaderDetails(); } else { details = getCardReaderDetails(); } } else if (serviceName.equals(INCRDeviceServiceClassNames.EKC_PIN) || (serviceName.equals(INCRDeviceServiceClassNames.BAPE_PIN)) || (serviceName.equals(INCRDeviceServiceClassNames.EPP_PIN))) { details = getPINDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.TIO)) { details = getTIODetails(); } else if ((serviceName.equals(INCRDeviceServiceClassNames.BARCODE_READER)) || (serviceName.equals(INCRDeviceServiceClassNames.BR_READER))) { details = getBarCodeReaderDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.SIU)) { details = getSIUDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.DPM)) { details = getDPMDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.CCR)) { details = getCCRDetails(); } else if (serviceName.equals(INCRDeviceServiceClassNames.S2_DISPENSER)) { details = getS2DispenserDetails(); } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < details.length; i++) { buffer.append(" " + details[i] + "\n"); } JxfsCollectorLogger.getLogger().writeInfoLog(buffer.toString()); JxfsCollectorLogger.getLogger().writeExitLog("NCRVendorDependentInfoProvider", "getVendorInfo"); return details; }