actframework / act-aaa-plugin

Use OSGL aaa library to mange Authentication/Authorization/Accounting for ActFramework Application
Apache License 2.0
6 stars 2 forks source link

Cannot instantiate beetlsql mapper interface when inject #11

Closed leeaee closed 7 years ago

leeaee commented 7 years ago
  1. Implement a SecurityService extends from ActAAAService.Base.
  2. Inject a beetsql mapper into SecurityService
  3. ACT start failed with exception:
    2017-08-03 17:10:12,262 WARN  [jobs-thread-1] [act.job._Job] - error executing job register-singleton-instances
    org.osgl.inject.InjectException: Cannot instantiate interface cc.bable.data.mapper.AdminMapper(mapper)
    at org.osgl.inject.Genie.findProvider(Genie.java:657)
    at org.osgl.inject.Genie.fieldInjector(Genie.java:797)
    at org.osgl.inject.Genie.fieldInjectors(Genie.java:784)
    at org.osgl.inject.Genie.buildFieldMethodInjector(Genie.java:725)
    at org.osgl.inject.Genie.buildProvider(Genie.java:705)

    Code: AdminMapper.java

    public interface AdminMapper extends BaseMapper<Admin> {
    Admin findByName(@Param(value = "loginName") String loginName);
    } 
    public class SecurityService extends ActAAAService.Base<Admin> {
    private static final String USER_KEY = "loginName";
    @Inject
    private AdminMapper mapper;
    @Override
    protected String userKey() {
        return USER_KEY;
    }
    ...
    }
greenlaw110 commented 7 years ago

It can now overwrite the following two methods in your SecurityService to allow act-aaa to work with act-beetlsql:


        protected USER_TYPE findUser(String username) {
            return userDao.findOneBy(_userKey(), username);
        }

        protected void initUserDao(Class<USER_TYPE> userType) {
            this.userDao = Act.app().dbServiceManager().dao(userType);
        }