public static void main(String[] args) { System.out.println(Settings.LIBRARY_INFO); System.out.println(Settings.LIBRARY_COPYRIGHT); System.out.println(Settings.LIBRARY_LICENSE); System.out.println("SMSLib Version: " + Settings.LIBRARY_VERSION); System.out.println("OS Version: " + System.getProperty("os.name") + " / " + System.getProperty("os.arch") + " / " + System.getProperty("os.version")); System.out.println("JAVA Version: " + System.getProperty("java.version")); System.out.println("JAVA Runtime Version: " + System.getProperty("java.runtime.version")); System.out.println("JAVA Vendor: " + System.getProperty("java.vm.vendor")); System.out.println("JAVA Class Path: " + System.getProperty("java.class.path")); try { getInstance().terminate(); System.out.println(); System.out.println("Running port autodetection / diagnostics..."); System.out.println(); testCommPorts(); } catch (Exception e) { e.printStackTrace(); } } }
private void setStatus(Status status) { Status oldStatus = this.status; this.status = status; Status newStatus = this.status; Service.getInstance().getCallbackManager().registerGatewayStatusEvent(this, oldStatus, newStatus); }
private int getNoOfStartedGateways() { try { int count = 0; for (String gatewayId : Service.getInstance().getGatewayIDs()) { if (Service.getInstance().getGatewayById(gatewayId).getStatus() == Status.Started) count++; } return count; } catch (Exception e) { logger.warn("Gateway list modified, re-testing...", e); return getNoOfStartedGateways(); } } }
@Override public void run() { while (running) { try { Thread.sleep(delay); int count = counter.incrementAndGet(); if (failOperation()) throw new IOException("Dummy Failure!"); InboundMessage message = new InboundMessage("Mock Originator", "Dummy Text! " + count, new Date(), getClass().getName(), count); message.setGatewayId(getGatewayId()); Service.getInstance().getCallbackManager().registerInboundMessageEvent(message); break; } catch (Exception e) { logger.warn("Error!", e); //running = false; } } } });
private void processMessage(InboundMessage message) { String messageSignature = message.getSignature(); if (!this.modem.getReadMessagesSet().contains(messageSignature)) { this.modem.getStatistics().increaseTotalReceived(); if (message instanceof DeliveryReportMessage) Service.getInstance().getCallbackManager().registerDeliveryReportEvent((DeliveryReportMessage) message); else Service.getInstance().getCallbackManager().registerInboundMessageEvent(message); this.modem.getReadMessagesSet().add(messageSignature); } } }
public OutboundEncryptedMessage(MsIsdn recipientAddress, byte[] data) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException, NoSuchAlgorithmException { super(recipientAddress, data); setPayload(new Payload(Service.getInstance().getKeyManager().encrypt(recipientAddress, data))); }
Matcher m = this.rxCallerId.matcher(line); if (m.find()) callerId = m.group(1).replaceAll("\"", ""); Service.getInstance().getCallbackManager().registerInboundCallEvent(new MsIsdn(callerId), this.modem.getGatewayId()); Common.countSheeps(Integer.valueOf(getModemSettings("wait_unit"))); continue;
public byte[] getDecryptedData() throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException, NoSuchAlgorithmException { if (Service.getInstance().getKeyManager().getKey(getOriginatorAddress()) != null) return (Service.getInstance().getKeyManager().decrypt(getOriginatorAddress(), getPayload().getBytes())); return new byte[0]; } }
p.println("<tr><td>Status</td><td>Uptime</td><td>Callback Queue</td><td>Message Queue</td><td>Received</td><td>Sent</td><td>Failed</td><td>Failures</td><td>Sending Rate</td></tr>"); p.println("<tbody>"); p.println(String.format("<tr><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%f m/s</td></tr>", formatStatus(Service.getInstance().getStatus()), formatUpTime(Service.getInstance().getStatistics().getStartTime()), Service.getInstance().getCallbackManager().getQueueLoad(), Service.getInstance().getAllQueueLoad(), Service.getInstance().getStatistics().getTotalReceived(), Service.getInstance().getStatistics().getTotalSent(), Service.getInstance().getStatistics().getTotalFailed(), Service.getInstance().getStatistics().getTotalFailures(), getSendingRate(Service.getInstance().getStatistics().getStartTime(), Service.getInstance().getStatistics().getTotalSent()))); p.println("</table>"); p.println("<h3>Gateway information</h3>"); p.println("<tr><td>Gateway ID</td><td>Description</td><td>Class</td><td>Status</td><td>Uptime</td><td>Message Queue</td><td>Received</td><td>Sent</td><td>Failed</td><td>Failures</td><td>Sending Rate</td></tr>"); p.println("<tbody>"); for (String gId : Service.getInstance().getGatewayIDs()) AbstractGateway g = Service.getInstance().getGatewayById(gId); p.println(String.format("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%f m/s</td>", gId, g.getDescription(), g.getClass(), formatStatus(g.getStatus()), (g.getStatus() == AbstractGateway.Status.Started ? formatUpTime(g.getStatistics().getStartTime()) : "N/A"), g.getQueueLoad(), g.getStatistics().getTotalReceived(), g.getStatistics().getTotalSent(), g.getStatistics().getTotalFailed(), g.getStatistics().getTotalFailures(), getSendingRate(g.getStatistics().getStartTime(), g.getStatistics().getTotalSent()))); p.println("</tr>");
if (message != null) Collection<AbstractGateway> routes = Service.getInstance().routeMessage(message); if (routes.isEmpty()) Service.getInstance().getCallbackManager().registerMessageSentEvent(message);
Service.getInstance().getCallbackManager().registerMessageSentEvent(message); Service.getInstance().queue(message); Service.getInstance().getCallbackManager().registerMessageSentEvent(message);
if (Service.getInstance().getKeyManager().getKey(msg.getOriginatorAddress()) != null) msg = new InboundEncryptedMessage((SmsDeliveryPdu) pdu, memLocation, memIndex);
if (consumed && Settings.deleteMessagesAfterCallback) Service.getInstance().delete(((InboundMessageCallbackEvent) ev).getMessage()); if (consumed && Settings.deleteMessagesAfterCallback) Service.getInstance().delete(((DeliveryReportCallbackEvent) ev).getMessage());
Service.getInstance().getStatistics().increaseTotalSent(); Service.getInstance().getStatistics().increaseTotalFailed(); Service.getInstance().getStatistics().increaseTotalFailures(); throw e;
Service.getInstance().queue(message);