Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties attribute at '@CacheNamespace' #841

Conversation

kazuki43zoo
Copy link
Member

@kazuki43zoo kazuki43zoo commented Nov 19, 2016

I've allowed to inject property values to a custom cache implementation using annotation driven configuration.

In this changes, we can customize a custom cache implementation as follow:

@CacheNamespace(implementation = CustomCache.class, properties = {
    @Property(name = "stringValue", value = "bar")
    ,@Property(name = "integerValue", value = "99")
    ,@Property(name = "longValue", value = "9999")
})
public interface CustomCacheMapper {
    // ...
}
public class CustomCache implements Cache {
  // ...
  private String stringValue; // inject "bar"
  private Integer integerValue; // inject 99
  private long longValue; // inject 9999

  public CustomCache(String id) {
    this.id = id;
  }

  // setter/getter and implementation methods ..

}

And we can use placeholder as follow:

<properties>
    <property name="stringProperty" value="bar"/>
    <property name="integerProperty" value="99"/>
    <property name="longProperty" value="9999"/>
</properties>
@CacheNamespace(implementation = CustomCache.class, properties = {
    @Property(name = "stringValue", value = "${stringProperty}") // inject "bar"
    ,@Property(name = "integerValue", value = "${integerProperty}") // inject 99
    ,@Property(name = "longValue", value = "${longProperty}") // inject 9999
})
public interface CustomCacheMapper {
    // ...
}

@kazuki43zoo
Copy link
Member Author

@emacarron @harawata

I've added new attribute. What do you think ? Please review this.
Thanks.

@kazuki43zoo kazuki43zoo force-pushed the support-properties-attribute-on-CacheNamespace branch from 7cfe6cd to 486fa44 Compare November 19, 2016 16:18
Allow to inject property values to a custom cache implementation using annotation driven programing
@harawata
Copy link
Member

Looks good to me. Thank you, @kazuki43zoo !

@kazuki43zoo
Copy link
Member Author

kazuki43zoo commented Nov 19, 2016

Hi @harawata, thanks for your review !!

@kazuki43zoo kazuki43zoo added the enhancement Improve a feature or add a new feature label Nov 19, 2016
@kazuki43zoo kazuki43zoo added this to the 3.4.2 milestone Nov 19, 2016
@kazuki43zoo
Copy link
Member Author

Hi @emacarron, I'll merge this PR. If you have a opinion for this improvement, please comment !!

@kazuki43zoo kazuki43zoo merged commit 5f87a8f into mybatis:master Nov 19, 2016
@kazuki43zoo kazuki43zoo deleted the support-properties-attribute-on-CacheNamespace branch November 19, 2016 18:41
@kazuki43zoo kazuki43zoo assigned kazuki43zoo and unassigned harawata Nov 19, 2016
kazuki43zoo added a commit to kazuki43zoo/mybatis-3 that referenced this pull request Nov 20, 2016
kazuki43zoo added a commit to kazuki43zoo/mybatis-3 that referenced this pull request Nov 20, 2016
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
…tribute-on-CacheNamespace

Add properties attribute at '@CacheNamespace'
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants