Skip to content

Instantly share code, notes, and snippets.

View sizovs's full-sized avatar
🌴
Mentoring software developers @ principal.dev

Eduards Sizovs sizovs

🌴
Mentoring software developers @ principal.dev
View GitHub Profile
Method method = PersonController.class.getMethod("show", Long.class);
Link link = linkTo(method, 2L).withSelfRel();
assertThat(link.getHref(), is("/people/2")));
package fm.ask.infrastructure.caching;
import org.springframework.cache.CacheManager;
public abstract class CacheManagerFactory {
protected abstract CacheManager createInstance() ;
}
package fm.ask.infrastructure.caching;
import com.google.common.base.Supplier;
import com.google.common.base.Ticker;
import com.google.common.cache.CacheBuilder;
import com.rubylight.conf.IConfListener;
import com.rubylight.conf.IConfProperty;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.guava.GuavaCacheManager;
package fm.ask.infrastructure.caching;
import com.google.common.base.Function;
import com.google.common.base.Ticker;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.support.CompositeCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@DegradesWithDefaultValue
@Override
public Collection<AnswerNotification> list(AuthorId authorId, Pageable page) {
String key = allNotificationsKey(authorId);
IRedisCacheDAO dao = shardedNotificationsDAOFactory.getDAOByUserId(authorId.asLong());
Set<Tuple> notifications = dao.zrevrangeWithScoresBinary(key, page.getFrom(), page.getTo() + 1);
return transform(notifications, new FromTuple());
}
@Produces("illegal_action")
public class MaxNumberOfFolloweesReachedException extends FollowRelationshipAddingException {
@Repository
class DefaultDailyQuestionTemplateRepository implements DailyQuestionTemplateRepository {
private static final String DAILY_QUESTION_TEMPLATE_CACHE = "dailyQuestionTemplate";
private final DailyQuestionTemplateDAO dailyQuestionTemplateDAO;
@Cacheable(DAILY_QUESTION_TEMPLATE_CACHE)
@Override
public DailyQuestionTemplate get(DailyQuestionTemplateId dailyQuestionTemplateId) {
private static final String DAILY_QUESTION_TEMPLATE_CACHE = "dailyQuestionTemplate";
private final DailyQuestionTemplateDAO dailyQuestionTemplateDAO;
@Cacheable(DAILY_QUESTION_TEMPLATE_CACHE)
@Override
public DailyQuestionTemplate get(DailyQuestionTemplateId dailyQuestionTemplateId) {
DailyQuestionTemplate dailyQuestionTemplate = dailyQuestionTemplateDAO.getById(dailyQuestionTemplateId);
if (dailyQuestionTemplate == null) {
throw new EntityDoesNotExistException(dailyQuestionTemplateId);
@Autowired
@ConfigurableMap(value = "map")
private IConfProperty<Map<Long, Long>> map
@Autowired
@ConfigurableProperties(value = "props")
private IConfProperty<Properties> props
@Autowired
@ConfigurableList(value = "list")
@Autowired
@ConfigurableMap(value = "map", keyType = Long, valueType = Long)
private IConfProperty<Map<Long, Long>> map
@Autowired
@ConfigurableProperties(value = "props")
private IConfProperty<Properties> props
@Autowired
@ConfigurableList(value = "list", itemType = Long)