/** * Create a JMS MapMessage for the given Map. * @param map the Map to convert * @param session current JMS session * @return the resulting message * @throws JMSException if thrown by JMS methods * @see javax.jms.Session#createMapMessage */ protected MapMessage createMessageForMap(Map<?, ?> map, Session session) throws JMSException { MapMessage message = session.createMapMessage(); for (Map.Entry<?, ?> entry : map.entrySet()) { Object key = entry.getKey(); if (!(key instanceof String)) { throw new MessageConversionException("Cannot convert non-String key of type [" + ObjectUtils.nullSafeClassName(key) + "] to JMS MapMessage entry"); } message.setObject((String) key, entry.getValue()); } return message; }
private static <T> Object doGetTimestamp(Object timestamp, Class<T> targetType) { if (ClassUtils.isAssignableValue(targetType, timestamp)) { return timestamp; } if (timestamp instanceof Instant) { return new BsonTimestamp((int) ((Instant) timestamp).getEpochSecond(), 0); } if (timestamp instanceof BsonTimestamp) { return Instant.ofEpochSecond(((BsonTimestamp) timestamp).getTime()); } throw new IllegalArgumentException( "o_O that should actually not happen. The timestamp should be an Instant or a BsonTimestamp but was " + ObjectUtils.nullSafeClassName(timestamp)); }
ObjectUtils.nullSafeClassName(object) + "] to JMS message. Supported message " + "payloads are: String, byte array, Map<String,?>, Serializable object.");
mbd.getResourceDescription(), beanName, new InjectionPoint(methodParam), "Could not convert argument value of type [" + ObjectUtils.nullSafeClassName(valueHolder.getValue()) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
throw new UnsatisfiedDependencyException( mbd.getResourceDescription(), beanName, new InjectionPoint(methodParam), "Could not convert argument value of type [" + ObjectUtils.nullSafeClassName(argValue) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
mbd.getResourceDescription(), beanName, new InjectionPoint(methodParam), "Could not convert argument value of type [" + ObjectUtils.nullSafeClassName(valueHolder.getValue()) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
throw new UnsatisfiedDependencyException( mbd.getResourceDescription(), beanName, new InjectionPoint(methodParam), "Could not convert argument value of type [" + ObjectUtils.nullSafeClassName(argValue) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
mbd.getResourceDescription(), beanName, argIndex, paramType, "Could not convert " + methodType + " argument value of type [" + ObjectUtils.nullSafeClassName(argValue) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
mbd.getResourceDescription(), beanName, paramIndex, paramType, "Could not convert " + methodType + " argument value of type [" + ObjectUtils.nullSafeClassName(valueHolder.getValue()) + "] to required type [" + paramType.getName() + "]: " + ex.getMessage());
/** * Sets a reference to the configured Spring {@link BeanFactory}. * * @param beanFactory configured Spring {@link BeanFactory}. * @throws IllegalArgumentException if the given {@link BeanFactory} is not an instance of * {@link ConfigurableListableBeanFactory}. * @see org.springframework.beans.factory.BeanFactoryAware * @see org.springframework.beans.factory.BeanFactory */ @Override @SuppressWarnings("all") public final void setBeanFactory(BeanFactory beanFactory) throws BeansException { Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory, String.format("BeanFactory [%1$s] must be an instance of %2$s", ObjectUtils.nullSafeClassName(beanFactory), ConfigurableListableBeanFactory.class.getSimpleName())); this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; }
/** * Sets a reference to the configured Spring {@link BeanFactory}. * * @param beanFactory configured Spring {@link BeanFactory}. * @throws IllegalArgumentException if the given {@link BeanFactory} is not an instance of * {@link ConfigurableListableBeanFactory}. * @see org.springframework.beans.factory.BeanFactoryAware * @see org.springframework.beans.factory.BeanFactory */ @Override @SuppressWarnings("all") public final void setBeanFactory(BeanFactory beanFactory) throws BeansException { Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory, String.format("BeanFactory [%1$s] must be an instance of %2$s", ObjectUtils.nullSafeClassName(beanFactory), ConfigurableListableBeanFactory.class.getSimpleName())); this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; }
private String toRegionMethodSignature(JoinPoint joinPoint) { return Optional.ofNullable(joinPoint) .map(JoinPoint::getSignature) .map(signature -> String.format("%1$s.%2$s", ObjectUtils.nullSafeClassName(joinPoint.getTarget()), signature.getName())) .orElse(""); } }
private String toRegionMethodSignature(JoinPoint joinPoint) { return Optional.ofNullable(joinPoint) .map(JoinPoint::getSignature) .map(signature -> String.format("%1$s.%2$s", ObjectUtils.nullSafeClassName(joinPoint.getTarget()), signature.getName())) .orElse(""); } }
/** * {@inheritDoc} */ @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (log.isDebugEnabled()) { log.debug(String.format("Processing Bean [%1$s] of Type [%2$s] with Name [%3$s] before initialization%n", bean, ObjectUtils.nullSafeClassName(bean), beanName)); } if (bean instanceof DiskDir) { createIfNotExists((DiskDir) bean); } return bean; }
/** * Factory method used to construct an instance of {@link PdxInstanceMethodInterceptor} initialized with * the given {@link Object source}. * * @param source {@link Object} serving as the source to back the proxy in method invocations. * Source must be an instance of {@link PdxInstance}. * @return a new instance of {@link PdxInstanceMethodInterceptor} initialized with the given {@link Object source}. * @throws IllegalArgumentException if {@link Object source} is not an instance of {@link PdxInstance}. * @see #newPdxInstanceMethodInterceptor(PdxInstance) */ public static PdxInstanceMethodInterceptor newPdxInstanceMethodInterceptor(Object source) { Assert.isInstanceOf(PdxInstance.class, source, () -> String.format("Source [%1$s] is not an instance of [%2$s]", ObjectUtils.nullSafeClassName(source), PdxInstance.class.getName())); return newPdxInstanceMethodInterceptor((PdxInstance) source); }
/** * {@inheritDoc} */ @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (log.isDebugEnabled()) { log.debug(String.format("Processing Bean [%1$s] of Type [%2$s] with Name [%3$s] before initialization%n", bean, ObjectUtils.nullSafeClassName(bean), beanName)); } if (bean instanceof DiskDir) { createIfNotExists((DiskDir) bean); } return bean; }
/** * Factory method used to construct an instance of {@link PdxInstanceMethodInterceptor} initialized with * the given {@link Object source}. * * @param source {@link Object} serving as the source to back the proxy in method invocations. * Source must be an instance of {@link PdxInstance}. * @return a new instance of {@link PdxInstanceMethodInterceptor} initialized with the given {@link Object source}. * @throws IllegalArgumentException if {@link Object source} is not an instance of {@link PdxInstance}. * @see #newPdxInstanceMethodInterceptor(PdxInstance) */ public static PdxInstanceMethodInterceptor newPdxInstanceMethodInterceptor(Object source) { Assert.isInstanceOf(PdxInstance.class, source, () -> String.format("Source [%1$s] is not an instance of [%2$s]", ObjectUtils.nullSafeClassName(source), PdxInstance.class.getName())); return newPdxInstanceMethodInterceptor((PdxInstance) source); }
/** * Returns a reference to the Spring container {@link ConfigurableBeanFactory}. * * @return a reference to the Spring container {@link ConfigurableBeanFactory}. * @see org.springframework.beans.factory.config.ConfigurableBeanFactory * @see #getApplicationContext() */ protected ConfigurableBeanFactory getBeanFactory() { ApplicationContext applicationContext = getApplicationContext(); return Optional.ofNullable(applicationContext) .filter(ConfigurableApplicationContext.class::isInstance) .map(ConfigurableApplicationContext.class::cast) .map(ConfigurableApplicationContext::getBeanFactory) .orElseThrow(() -> newIllegalStateException("Unable to resolve a reference to a [%1$s] from a [%2$s]", ConfigurableBeanFactory.class.getName(), ObjectUtils.nullSafeClassName(applicationContext))); }
@Override public Message toMessage(final Object object, final Session session) throws JMSException, MessageConversionException { final Message message = converter.toMessage(object, session); if (object instanceof Event) { final Event event = (Event) object; addProperties(event, message); } else { logger.warn("Converting object of type [" + ObjectUtils.nullSafeClassName(object) + "] to JMS message. Only Event objects are supoorted."); } return message; }
@Override public <R> R read(Class<R> type, Object row) { if (row instanceof Row) { return readRow(type, (Row) row); } throw new MappingException(String.format("Unknown row object [%s]", ObjectUtils.nullSafeClassName(row))); }