Created
January 10, 2014 10:00
-
-
Save izerui/8349365 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserDao extends BasicHibernateDao<User, String> { | |
public User getUserByUsername(String username) { | |
return findUniqueByProperty("username", username); | |
} | |
@CacheEvict(value="shiroAuthorizationCache",allEntries=true) | |
public void saveUser(User entity) { | |
save(entity); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
public class ResourceDao extends BasicHibernateDao<Resource, String> { | |
@CacheEvict(value="shiroAuthorizationCache",allEntries=true) | |
public void saveResource(Resource entity) { | |
save(entity); | |
} | |
@CacheEvict(value="shiroAuthorizationCache",allEntries=true) | |
public void deleteResource(Resource entity) { | |
delete(entity); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
当userDao或者reaourceDao调用了相应带有缓存注解的方法,都会将AuthorizingRealm类中的缓存去掉。那么就意味着 shiro在用户访问链接时要重新授权一次。 | |
整个apache shiro的使用在basic-curd项目有例子。可以参考showcase/basic-curd项目中的例子去理解。。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment