View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.persistence.jpa;
20  
21  import org.apache.syncope.core.persistence.api.dao.AccessTokenDAO;
22  import org.apache.syncope.core.persistence.api.dao.AnyMatchDAO;
23  import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
24  import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
25  import org.apache.syncope.core.persistence.api.dao.DelegationDAO;
26  import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
27  import org.apache.syncope.core.persistence.api.dao.DynRealmDAO;
28  import org.apache.syncope.core.persistence.api.dao.FIQLQueryDAO;
29  import org.apache.syncope.core.persistence.api.dao.GroupDAO;
30  import org.apache.syncope.core.persistence.api.dao.JPAJSONAnyDAO;
31  import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
32  import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
33  import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
34  import org.apache.syncope.core.persistence.api.dao.RoleDAO;
35  import org.apache.syncope.core.persistence.api.dao.UserDAO;
36  import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
37  import org.apache.syncope.core.persistence.api.search.SearchCondVisitor;
38  import org.apache.syncope.core.persistence.jpa.dao.JPAJSONAnyObjectDAO;
39  import org.apache.syncope.core.persistence.jpa.dao.JPAJSONGroupDAO;
40  import org.apache.syncope.core.persistence.jpa.dao.JPAJSONPlainAttrDAO;
41  import org.apache.syncope.core.persistence.jpa.dao.JPAJSONPlainAttrValueDAO;
42  import org.apache.syncope.core.persistence.jpa.dao.JPAJSONUserDAO;
43  import org.apache.syncope.core.spring.security.SecurityProperties;
44  import org.springframework.beans.factory.annotation.Autowired;
45  import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
46  import org.springframework.context.ApplicationEventPublisher;
47  import org.springframework.context.annotation.Bean;
48  import org.springframework.context.annotation.Configuration;
49  import org.springframework.context.annotation.Lazy;
50  
51  @Configuration(proxyBeanMethods = false)
52  public abstract class JPAJSONPersistenceContext {
53  
54      @Autowired
55      protected SecurityProperties securityProperties;
56  
57      @ConditionalOnMissingBean(name = "jpaJSONAnyObjectDAO")
58      @Bean
59      public AnyObjectDAO anyObjectDAO(
60              final AnyUtilsFactory anyUtilsFactory,
61              final @Lazy PlainSchemaDAO plainSchemaDAO,
62              final @Lazy DerSchemaDAO derSchemaDAO,
63              final @Lazy DynRealmDAO dynRealmDAO,
64              final @Lazy UserDAO userDAO,
65              final @Lazy GroupDAO groupDAO,
66              final @Lazy JPAJSONAnyDAO anyDAO) {
67  
68          return new JPAJSONAnyObjectDAO(
69                  anyUtilsFactory,
70                  plainSchemaDAO,
71                  derSchemaDAO,
72                  dynRealmDAO,
73                  userDAO,
74                  groupDAO,
75                  anyDAO);
76      }
77  
78      @ConditionalOnMissingBean(name = "jpaJSONGroupDAO")
79      @Bean
80      public GroupDAO groupDAO(
81              final AnyUtilsFactory anyUtilsFactory,
82              final ApplicationEventPublisher publisher,
83              final @Lazy PlainSchemaDAO plainSchemaDAO,
84              final @Lazy DerSchemaDAO derSchemaDAO,
85              final @Lazy DynRealmDAO dynRealmDAO,
86              final @Lazy AnyMatchDAO anyMatchDAO,
87              final @Lazy PlainAttrDAO plainAttrDAO,
88              final @Lazy UserDAO userDAO,
89              final @Lazy AnyObjectDAO anyObjectDAO,
90              final @Lazy AnySearchDAO anySearchDAO,
91              final SearchCondVisitor searchCondVisitor,
92              final @Lazy JPAJSONAnyDAO anyDAO) {
93  
94          return new JPAJSONGroupDAO(
95                  anyUtilsFactory,
96                  publisher,
97                  plainSchemaDAO,
98                  derSchemaDAO,
99                  dynRealmDAO,
100                 anyMatchDAO,
101                 plainAttrDAO,
102                 userDAO,
103                 anyObjectDAO,
104                 anySearchDAO,
105                 searchCondVisitor,
106                 anyDAO);
107     }
108 
109     @ConditionalOnMissingBean(name = "jpaJSONPlainAttrDAO")
110     @Bean
111     public PlainAttrDAO plainAttrDAO() {
112         return new JPAJSONPlainAttrDAO();
113     }
114 
115     @ConditionalOnMissingBean(name = "jpaJSONPlainAttrValueDAO")
116     @Bean
117     public PlainAttrValueDAO plainAttrValueDAO() {
118         return new JPAJSONPlainAttrValueDAO();
119     }
120 
121     @ConditionalOnMissingBean(name = "jpaJSONUserDAO")
122     @Bean
123     public UserDAO userDAO(
124             final AnyUtilsFactory anyUtilsFactory,
125             final @Lazy PlainSchemaDAO plainSchemaDAO,
126             final @Lazy DerSchemaDAO derSchemaDAO,
127             final @Lazy DynRealmDAO dynRealmDAO,
128             final @Lazy RoleDAO roleDAO,
129             final @Lazy AccessTokenDAO accessTokenDAO,
130             final @Lazy GroupDAO groupDAO,
131             final @Lazy DelegationDAO delegationDAO,
132             final @Lazy FIQLQueryDAO fiqlQueryDAO,
133             final @Lazy JPAJSONAnyDAO anyDAO) {
134 
135         return new JPAJSONUserDAO(
136                 anyUtilsFactory,
137                 plainSchemaDAO,
138                 derSchemaDAO,
139                 dynRealmDAO,
140                 roleDAO,
141                 accessTokenDAO,
142                 groupDAO,
143                 delegationDAO,
144                 fiqlQueryDAO,
145                 securityProperties,
146                 anyDAO);
147     }
148 }