public void Set(String interface_name, String property_name, Variant new_value) throws Exception { Type t = new_value.getType(); Object s = new_value.getValue(); ((Class)t).cast(s); System.out.println("Object cast to "+s.getClass().getName()); }
@Override public void onSuccess() { logger.debug("Sent '{}' message to '{}' devices", variant.getType().getTypeName(), tokenSize); }
@Override public void onSuccess() { logger.debug("Sent '{}' message to '{}' devices", variant.getType().getTypeName(), tokenSize); }
@Override public void onError(final String reason) { logger.warn("Error on '{}' delivery: {}", variant.getType().getTypeName(), reason); pushMessageMetricsService.appendError(pushMessageInformation, variant, reason); } }
@Override public void onError(final String reason) { logger.warn("Error on '{}' delivery: {}", variant.getType().getTypeName(), reason); pushMessageMetricsService.appendError(pushMessageInformation, variant, reason); } }
@Override public boolean isValid(Installation installation, ConstraintValidatorContext context) { final String deviceToken = installation.getDeviceToken(); if (installation.getVariant() == null || installation.getVariant().getType() == null || deviceToken == null) { return false; } final VariantType type = installation.getVariant().getType(); return isValidDeviceTokenForVariant(deviceToken, type); }
@Override public boolean isValid(Installation installation, ConstraintValidatorContext context) { final String deviceToken = installation.getDeviceToken(); if (installation.getVariant() == null || installation.getVariant().getType() == null || deviceToken == null) { return false; } final VariantType type = installation.getVariant().getType(); return isValidDeviceTokenForVariant(deviceToken, type); }
public void queueMessageVariantForProcessing(@Observes @DispatchToQueue MessageHolderWithTokens msg) { final VariantType variantType = msg.getVariant().getType(); logger.trace("dispatching payload for {} variant type", variantType); final String deduplicationId = String.format("%s-%s", msg.getPushMessageInformation().getId(), msg.getSerialId()); jmsClient.send(msg).withDuplicateDetectionId(deduplicationId).to(selectQueue(variantType)); }
public void queueMessageVariantForProcessing(@Observes @DispatchToQueue MessageHolderWithTokens msg) { final VariantType variantType = msg.getVariant().getType(); logger.trace("dispatching payload for {} variant type", variantType); final String deduplicationId = String.format("%s-%s", msg.getPushMessageInformation().getId(), msg.getSerialId()); jmsClient.send(msg).withDuplicateDetectionId(deduplicationId).to(selectQueue(variantType)); }
private void storeInstallationAndSetReferences(Variant variant, Installation entity) { // ensure lower case for iOS if (variant.getType() == VariantType.IOS) { entity.setDeviceToken(entity.getDeviceToken().toLowerCase()); } // set reference entity.setVariant(variant); // update attached categories mergeCategories(entity, entity.getCategories()); // store Installation entity installationDao.create(entity); } }
/** * Receives a {@link UnifiedPushMessage} and list of device tokens that the message should be sent to, selects appropriate sender implementation that * the push notifications are submitted to. * * @param msg object containing details about the payload and the related device tokens */ public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("Received UnifiedPushMessage from JMS queue, will now trigger the Push Notification delivery for the %s variant ({})", variant.getType().getTypeName(), variant.getVariantID()); senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }
/** * Receives a {@link UnifiedPushMessage} and list of device tokens that the message should be sent to, selects appropriate sender implementation that * the push notifications are submitted to. * * @param msg object containing details about the payload and the related device tokens */ public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("Received UnifiedPushMessage from JMS queue, will now trigger the Push Notification delivery for the %s variant ({})", variant.getType().getTypeName(), variant.getVariantID()); senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }
logger.info(String.format("Loaded batch #%s, containing %d tokens, for %s variant (%s)", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID())); } else { logger.debug(String.format("Failing token loading transaction for batch token #%s for %s variant (%s), since queue is full, will retry...", serialId, variant.getType().getTypeName(), variant.getVariantID())); context.setRollbackOnly(); return; logger.info("Loaded batch #{}, containing {} tokens, for {} variant ({})", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID()); logger.debug(String.format("Ending token loading transaction for %s variant (%s)", variant.getType().getTypeName(), variant.getVariantID())); nextBatchEvent.fire(new MessageHolderWithVariants(msg.getPushMessageInformation(), message, msg.getVariantType(), variants, serialId, lastTokenInBatch)); } else { logger.debug("All batches for {} variant were loaded ({})", variant.getType().getTypeName(), variant.getVariantID());
@Override @Asynchronous public void addInstallation(Variant variant, Installation entity) { // does it already exist ? Installation installation = this.findInstallationForVariantByDeviceToken(variant.getVariantID(), entity.getDeviceToken()); // Needed for the Admin UI Only. Help for setting up Routes entity.setPlatform(variant.getType().getTypeName()); // new device/client ? if (installation == null) { logger.trace("Performing new device/client registration"); // store the installation: storeInstallationAndSetReferences(variant, entity); } else { // We only update the metadata, if the device is enabled: if (installation.isEnabled()) { logger.trace("Updating received metadata for an 'enabled' installation"); // fix variant property of installation object installation.setVariant(variant); // update the entity: this.updateInstallation(installation, entity); } } }
logger.info(String.format("Loaded batch #%s, containing %d tokens, for %s variant (%s)", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID())); } else { logger.debug(String.format("Failing token loading transaction for batch token #%s for %s variant (%s), since queue is full, will retry...", serialId, variant.getType().getTypeName(), variant.getVariantID())); context.setRollbackOnly(); return; logger.info("Loaded batch #{}, containing {} tokens, for {} variant ({})", serialId, tokens.size() ,variant.getType().getTypeName(), variant.getVariantID()); logger.debug(String.format("Ending token loading transaction for %s variant (%s)", variant.getType().getTypeName(), variant.getVariantID())); nextBatchEvent.fire(new MessageHolderWithVariants(msg.getPushMessageInformation(), message, msg.getVariantType(), variants, serialId, lastTokenInBatch)); } else { logger.debug("All batches for {} variant were loaded ({})", variant.getType().getTypeName(), variant.getVariantID());
@Override public void updateInstallation(Installation installationToUpdate, Installation postedInstallation) { // copy the "updateable" values: mergeCategories(installationToUpdate, postedInstallation.getCategories()); installationToUpdate.setDeviceToken(postedInstallation.getDeviceToken()); installationToUpdate.setAlias(postedInstallation.getAlias()); installationToUpdate.setDeviceType(postedInstallation.getDeviceType()); installationToUpdate.setOperatingSystem(postedInstallation .getOperatingSystem()); installationToUpdate.setOsVersion(postedInstallation.getOsVersion()); installationToUpdate.setEnabled(postedInstallation.isEnabled()); installationToUpdate.setPlatform(postedInstallation.getPlatform()); // update it: updateInstallation(installationToUpdate); // unsubscribe Android devices from topics that device should no longer be subscribed to if (installationToUpdate.getVariant().getType() == VariantType.ANDROID) { unsubscribeOldTopics(installationToUpdate); } }