Skip to content

Commit

Permalink
#21 CdDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 15, 2016
1 parent 6fe59c8 commit 854a708
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/main/java/io/jare/cached/CdBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
package io.jare.cached;

import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.jcabi.aspects.Cacheable;
import io.jare.model.Base;
import io.jare.model.Domain;
Expand Down Expand Up @@ -60,12 +62,18 @@ public User user(final String name) {
@Override
@Cacheable(forever = true)
public Iterator<Domain> domain(final String name) {
return this.origin.domain(name);
return Iterators.transform(
this.origin.domain(name),
CdDomain::new
);
}

@Override
@Cacheable(unit = TimeUnit.HOURS, lifetime = 1)
public Iterable<Domain> all() {
return this.origin.all();
return Iterables.transform(
this.origin.all(),
CdDomain::new
);
}
}
67 changes: 67 additions & 0 deletions src/main/java/io/jare/cached/CdDomain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 jare.io
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the above copyright notice and this
* permission notice shall be included in all copies or substantial
* portions of the Software. The software is provided "as is", without
* warranty of any kind, express or implied, including but not limited to
* the warranties of merchantability, fitness for a particular purpose
* and non-infringement. In no event shall the authors or copyright
* holders be liable for any claim, damages or other liability, whether
* in an action of contract, tort or otherwise, arising from, out of or
* in connection with the software or the use or other dealings in the
* software.
*/
package io.jare.cached;

import com.jcabi.aspects.Cacheable;
import io.jare.model.Domain;
import java.io.IOException;

/**
* Cached Domain.
*
* @author Yegor Bugayenko (yegor@teamed.io)
* @version $Id$
* @since 1.0
*/
public final class CdDomain implements Domain {

/**
* Original.
*/
private final transient Domain origin;

/**
* Ctor.
* @param domain Original
*/
public CdDomain(final Domain domain) {
this.origin = domain;
}

@Override
@Cacheable(forever = true)
public String owner() throws IOException {
return this.origin.owner();
}

@Override
@Cacheable(forever = true)
public String name() throws IOException {
return this.origin.name();
}

@Override
public void delete() throws IOException {
this.origin.delete();
}
}
4 changes: 2 additions & 2 deletions web.iml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
<orderEntry type="library" scope="RUNTIME" name="Maven: com.jcabi:jcabi-xml:0.17.2" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-immutable:1.4" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-http:1.16" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-aspects:0.22.3" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.8.9" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-http:1.16" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-log:0.17.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-dynamo:0.21.2" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.8.9" level="project" />
<orderEntry type="library" name="Maven: com.jcabi:jcabi-matchers:1.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
Expand Down

0 comments on commit 854a708

Please sign in to comment.