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.spring;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  import java.util.concurrent.ConcurrentHashMap;
24  import javax.persistence.ValidationMode;
25  import javax.sql.DataSource;
26  import org.apache.syncope.core.persistence.api.DomainHolder;
27  import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;
28  
29  /**
30   * Container for common configuration options among all EntityManagerFactory entities (one for each domain).
31   * Acts as a commodity place for fetching each domain's {@link DataSource}..
32   */
33  public class CommonEntityManagerFactoryConf implements DomainHolder {
34  
35      private final Map<String, DataSource> domains = new ConcurrentHashMap<>();
36  
37      private String[] packagesToScan;
38  
39      private ValidationMode validationMode;
40  
41      private PersistenceUnitPostProcessor[] postProcessors;
42  
43      private final Map<String, Object> jpaPropertyMap = new HashMap<>();
44  
45      @Override
46      public Map<String, DataSource> getDomains() {
47          return domains;
48      }
49  
50      public String[] getPackagesToScan() {
51          return packagesToScan;
52      }
53  
54      public void setPackagesToScan(final String... packagesToScan) {
55          this.packagesToScan = packagesToScan;
56      }
57  
58      public ValidationMode getValidationMode() {
59          return validationMode;
60      }
61  
62      public void setValidationMode(final ValidationMode validationMode) {
63          this.validationMode = validationMode;
64      }
65  
66      public PersistenceUnitPostProcessor[] getPersistenceUnitPostProcessors() {
67          return postProcessors;
68      }
69  
70      public void setPersistenceUnitPostProcessors(final PersistenceUnitPostProcessor... postProcessors) {
71          this.postProcessors = postProcessors;
72      }
73  
74      public Map<String, ?> getJpaPropertyMap() {
75          return jpaPropertyMap;
76      }
77  
78      public void setJpaPropertyMap(final Map<String, ?> jpaProperties) {
79          if (jpaProperties != null) {
80              this.jpaPropertyMap.putAll(jpaProperties);
81          }
82      }
83  }