2 * Copyright 2008 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.usermgt.hibernate;
18 import org.springframework.orm.hibernate3.HibernateTemplate;
20 import org.springframework.transaction.PlatformTransactionManager;
22 import org.wamblee.cache.EhCache;
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;
34 import org.wamblee.usermgt.UserAdministration;
35 import org.wamblee.usermgt.UserGroupRepositoryComponent;
37 import java.io.IOException;
39 import javax.sql.DataSource;
46 public class UserAdministrationComponent extends DefaultContainer {
47 private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface(
48 "transactionManager", PlatformTransactionManager.class);
50 private ProvidedInterface USER_CACHE = new DefaultProvidedInterface(
51 "userCache", EhCache.class);
53 private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface(
54 "hibernateTemplate", HibernateTemplate.class);
56 private ProvidedInterface USER_MGT = new DefaultProvidedInterface(
57 "usermgt", UserAdministration.class);
60 * Creates a new UserAdministrationComponent object.
64 public UserAdministrationComponent(String aName, boolean aExposeInternals)
68 ObjectConfiguration mappingFilesConfig = new ObjectConfiguration(
69 UsermgtHibernateMappingFiles.class);
70 mappingFilesConfig.getSetterConfig().initAllSetters();
71 addComponent("mappingFiles", new UsermgtHibernateMappingFiles(),
74 Component<?> hibernate = new HibernateComponent("hibernate");
75 addComponent(hibernate);
77 Component<?> repository = new UserGroupRepositoryComponent(
79 addComponent(repository);
81 Component<?> usermgt = new UserAdministrationLightComponent(
83 addComponent(usermgt);
85 addRequiredInterface(new DefaultRequiredInterface("datasource",
87 addRequiredInterface(new DefaultRequiredInterface("ormconfig",
88 ORMappingConfig.class));
90 if (aExposeInternals) {
91 addProvidedInterface(TRANSACTION_MGR);
92 addProvidedInterface(USER_CACHE);
93 addProvidedInterface(HIBERNATE_TEMPLATE);
96 addProvidedInterface(USER_MGT);