source code formatting.
[utils] / security / src / main / java / org / wamblee / usermgt / hibernate / UserAdministrationComponent.java
1 /*
2  * Copyright 2008 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.usermgt.hibernate;
17
18 import org.springframework.orm.hibernate3.HibernateTemplate;
19
20 import org.springframework.transaction.PlatformTransactionManager;
21
22 import org.wamblee.cache.EhCache;
23
24 import org.wamblee.system.adapters.DefaultContainer;
25 import org.wamblee.system.adapters.ObjectConfiguration;
26 import org.wamblee.system.components.ORMappingConfig;
27 import org.wamblee.system.core.Component;
28 import org.wamblee.system.core.DefaultProvidedInterface;
29 import org.wamblee.system.core.DefaultRequiredInterface;
30 import org.wamblee.system.core.ProvidedInterface;
31 import org.wamblee.system.core.Scope;
32 import org.wamblee.system.spring.component.HibernateComponent;
33
34 import org.wamblee.usermgt.UserAdministration;
35 import org.wamblee.usermgt.UserGroupRepositoryComponent;
36
37 import java.io.IOException;
38
39 import javax.sql.DataSource;
40
41
42 /**
43  * DOCUMENT ME!
44  *
45  * @author $author$
46  * @version $Revision$
47  */
48 public class UserAdministrationComponent extends DefaultContainer {
49     /**
50      * DOCUMENT ME!
51      */
52     private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface("transactionManager",
53             PlatformTransactionManager.class);
54
55     /**
56      * DOCUMENT ME!
57      */
58     private ProvidedInterface USER_CACHE = new DefaultProvidedInterface("userCache",
59             EhCache.class);
60
61     /**
62      * DOCUMENT ME!
63      */
64     private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface("hibernateTemplate",
65             HibernateTemplate.class);
66
67     /**
68      * DOCUMENT ME!
69      */
70     private ProvidedInterface USER_MGT = new DefaultProvidedInterface("usermgt",
71             UserAdministration.class);
72
73 /**
74      * Creates a new UserAdministrationComponent object.
75      *
76      * @param aName DOCUMENT ME!
77      * @param aExposeInternals DOCUMENT ME!
78      *
79      * @throws IOException DOCUMENT ME!
80      */
81     public UserAdministrationComponent(String aName, boolean aExposeInternals)
82         throws IOException {
83         super(aName);
84
85         ObjectConfiguration mappingFilesConfig = new ObjectConfiguration(UsermgtHibernateMappingFiles.class);
86         mappingFilesConfig.getSetterConfig().initAllSetters();
87         addComponent("mappingFiles", new UsermgtHibernateMappingFiles(),
88             mappingFilesConfig);
89
90         Component<?> hibernate = new HibernateComponent("hibernate");
91         addComponent(hibernate);
92
93         Component<?> repository = new UserGroupRepositoryComponent(
94                 "usersgroups");
95         addComponent(repository);
96
97         Component<?> usermgt = new UserAdministrationLightComponent(
98                 "usermgtlight");
99         addComponent(usermgt);
100
101         addRequiredInterface(new DefaultRequiredInterface("datasource",
102                 DataSource.class));
103         addRequiredInterface(new DefaultRequiredInterface("ormconfig",
104                 ORMappingConfig.class));
105
106         if (aExposeInternals) {
107             addProvidedInterface(TRANSACTION_MGR);
108             addProvidedInterface(USER_CACHE);
109             addProvidedInterface(HIBERNATE_TEMPLATE);
110         }
111
112         addProvidedInterface(USER_MGT);
113     }
114 }