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.attrvalue.validation.PlainAttrValidationManager;
22  import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
23  import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
24  import org.apache.syncope.core.persistence.api.dao.AuditConfDAO;
25  import org.apache.syncope.core.persistence.api.dao.DynRealmDAO;
26  import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
27  import org.apache.syncope.core.persistence.api.dao.GroupDAO;
28  import org.apache.syncope.core.persistence.api.dao.JPAJSONAnyDAO;
29  import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
30  import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
31  import org.apache.syncope.core.persistence.api.dao.RealmDAO;
32  import org.apache.syncope.core.persistence.api.dao.UserDAO;
33  import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
34  import org.apache.syncope.core.persistence.api.entity.EntityFactory;
35  import org.apache.syncope.core.persistence.jpa.dao.MyJPAJSONAnyDAO;
36  import org.apache.syncope.core.persistence.jpa.dao.MyJPAJSONAnySearchDAO;
37  import org.apache.syncope.core.persistence.jpa.dao.MyJPAJSONAuditConfDAO;
38  import org.apache.syncope.core.persistence.jpa.dao.MyJPAJSONPlainSchemaDAO;
39  import org.apache.syncope.core.persistence.jpa.entity.MyJPAJSONEntityFactory;
40  import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
41  import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
42  import org.springframework.context.annotation.Bean;
43  import org.springframework.context.annotation.Lazy;
44  
45  @ConditionalOnExpression("#{'${provisioning.quartz.sql}' matches '.*mysql.*'}")
46  public class MyJPAJSONPersistenceContext extends JPAJSONPersistenceContext {
47  
48      @ConditionalOnMissingBean(name = "myJPAJSONEntityFactory")
49      @Bean
50      public EntityFactory entityFactory() {
51          return new MyJPAJSONEntityFactory();
52      }
53  
54      @ConditionalOnMissingBean(name = "myJPAJSONAnyDAO")
55      @Bean
56      public JPAJSONAnyDAO anyDAO(final @Lazy PlainSchemaDAO plainSchemaDAO) {
57          return new MyJPAJSONAnyDAO(plainSchemaDAO);
58      }
59  
60      @ConditionalOnMissingBean(name = "myJPAJSONAnySearchDAO")
61      @Bean
62      public AnySearchDAO anySearchDAO(
63              final @Lazy RealmDAO realmDAO,
64              final @Lazy DynRealmDAO dynRealmDAO,
65              final @Lazy UserDAO userDAO,
66              final @Lazy GroupDAO groupDAO,
67              final @Lazy AnyObjectDAO anyObjectDAO,
68              final @Lazy PlainSchemaDAO schemaDAO,
69              final @Lazy EntityFactory entityFactory,
70              final AnyUtilsFactory anyUtilsFactory,
71              final PlainAttrValidationManager validator) {
72  
73          return new MyJPAJSONAnySearchDAO(
74                  realmDAO,
75                  dynRealmDAO,
76                  userDAO,
77                  groupDAO,
78                  anyObjectDAO,
79                  schemaDAO,
80                  entityFactory,
81                  anyUtilsFactory,
82                  validator);
83      }
84  
85      @ConditionalOnMissingBean(name = "myJPAJSONAuditConfDAO")
86      @Bean
87      public AuditConfDAO auditConfDAO() {
88          return new MyJPAJSONAuditConfDAO();
89      }
90  
91      @ConditionalOnMissingBean(name = "myJPAJSONPlainSchemaDAO")
92      @Bean
93      public PlainSchemaDAO plainSchemaDAO(
94              final AnyUtilsFactory anyUtilsFactory,
95              final @Lazy PlainAttrDAO plainAttrDAO,
96              final @Lazy ExternalResourceDAO resourceDAO) {
97  
98          return new MyJPAJSONPlainSchemaDAO(anyUtilsFactory, plainAttrDAO, resourceDAO);
99      }
100 }