Blame view

src/main/java/com/huaheng/framework/redis/Exception/PrincipalInstanceException.java 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.huaheng.framework.redis.Exception;

@SuppressWarnings("serial")
public class PrincipalInstanceException extends RuntimeException
{
    private static final String MESSAGE = "We need a field to identify this Cache Object in Redis. "
            + "So you need to defined an id field which you can get unique id to identify this principal. "
            + "For example, if you use UserInfo as Principal class, the id field maybe userId, userName, email, etc. "
            + "For example, getUserId(), getUserName(), getEmail(), etc.\n"
            + "Default value is authCacheKey or id, that means your principal object has a method called \"getAuthCacheKey()\" or \"getId()\"";

    @SuppressWarnings("rawtypes")
    public PrincipalInstanceException(Class clazz, String idMethodName)
    {
        super(clazz + " must has getter for field: " + idMethodName + "\n" + MESSAGE);
    }

    @SuppressWarnings("rawtypes")
    public PrincipalInstanceException(Class clazz, String idMethodName, Exception e)
    {
        super(clazz + " must has getter for field: " + idMethodName + "\n" + MESSAGE, e);
    }
}