/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param entityClass * @param propertyName * @param value * @return * @throws DaoException <br> */ @SuppressWarnings("unchecked") @Override public <T> List<T> findByProperty(Class<T> entityClass, String propertyName, Object value) throws DaoException { Assert.notEmpty(propertyName, ErrorCodeDef.DAO_PROPERTY_IS_EMPTY); return (List<T>) createCriteria(entityClass, Restrictions.eq(propertyName, value)).list(); }
/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param entityClass * @param propertyName * @param value * @return * @throws DaoException <br> */ @SuppressWarnings("unchecked") @Override public <T> T findUniqueByProperty(Class<T> entityClass, String propertyName, Object value) throws DaoException { Assert.notEmpty(propertyName, ErrorCodeDef.DAO_PROPERTY_IS_EMPTY); return (T) createCriteria(entityClass, Restrictions.eq(propertyName, value)).uniqueResult(); }
private static Address[] getAddresses() { String address = PropertyHolder.getProperty(REDIS_ADDRESS); Assert.notEmpty(address, ErrorCodeDef.REDIS_ADDRESS_NOT_SET, REDIS_ADDRESS); return ProtocolUtil.parseAddress(address); }
protected Address[] getAddresses() { String address = PropertyHolder.getProperty(REDIS_ADDRESS); Assert.notEmpty(address, ErrorCodeDef.REDIS_ADDRESS_NOT_SET, REDIS_ADDRESS); return ProtocolUtil.parseAddress(address); }
/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param ids * @throws DaoException <br> */ @Override public <T> void deleteAllEntitiesByIds(Class<T> entityName, Collection<String> ids) throws DaoException { Assert.notEmpty(ids, ErrorCodeDef.ID_IS_NULL); for (String id : ids) { getSession().delete(get(entityName, id)); } getSession().flush(); }
public static MessagePublisher createMessagePublisher() { if (messagePublisher == null) { String messageModel = PropertyHolder.getProperty("message.model"); Assert.notEmpty(messageModel, ErrorCodeDef.MESSAGE_MODEL_NOT_SET); ServiceLoader<MessagePublisher> serviceLoader = ServiceLoader.load(MessagePublisher.class); for (MessagePublisher c : serviceLoader) { if (messageModel.equals(c.getName())) { messagePublisher = c; break; } } if (messagePublisher == null) { throw new InitializationException(ErrorCodeDef.MESSAGE_MIDDLE_NOT_FOUND); } } return messagePublisher; }
public static ICache getCache() { if (cache == null) { String cacheModel = PropertyHolder.getProperty("cache.model"); Assert.notEmpty(cacheModel, ErrorCodeDef.CACHE_MODEL_NOT_SET); ServiceLoader<ICache> serviceLoader = ServiceLoader.load(ICache.class); for (ICache c : serviceLoader) { if (cacheModel.equals(c.getName())) { cache = c; break; } } if (cache == null) { throw new InitializationException(ErrorCodeDef.CACHE_NOT_FOUND); } } return cache; }
public static MessageSubcriberFactory createMessageSubcriberFactory() { if (messageSubcriberFactory == null) { String messageModel = PropertyHolder.getProperty("message.model"); Assert.notEmpty(messageModel, ErrorCodeDef.MESSAGE_MODEL_NOT_SET); ServiceLoader<MessageSubcriberFactory> serviceLoader = ServiceLoader.load(MessageSubcriberFactory.class); for (MessageSubcriberFactory c : serviceLoader) { if (messageModel.equals(c.getName())) { messageSubcriberFactory = c; break; } } if (messageSubcriberFactory == null) { throw new InitializationException(ErrorCodeDef.MESSAGE_MIDDLE_NOT_FOUND); } } return messageSubcriberFactory; } }
public DbParam(String prefix) { this.url = PropertyHolder.getProperty(prefix + ".db.url"); Assert.notEmpty(this.url, ErrorCodeDef.DB_URL_NOT_SET); this.username = PropertyHolder.getProperty(prefix + ".db.username"); // Assert.notEmpty(this.username, ErrorCodeDef.DB_USERNAME_NOT_SET, prefix); String password = PropertyHolder.getProperty(prefix + ".db.password"); // Assert.notEmpty(password, ErrorCodeDef.DB_PASSWORD_NOT_SET, prefix); setPassword(password); init(prefix); }