2 * Copyright 2005-2010 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.security.authorization.AuthorizationService;
25 import org.wamblee.security.authorization.hibernate.AuthorizationMappingFiles;
27 import org.wamblee.system.adapters.DefaultContainer;
28 import org.wamblee.system.adapters.ObjectConfiguration;
29 import org.wamblee.system.components.ORMappingConfig;
30 import org.wamblee.system.core.Component;
31 import org.wamblee.system.core.DefaultProvidedInterface;
32 import org.wamblee.system.core.DefaultRequiredInterface;
33 import org.wamblee.system.core.ProvidedInterface;
34 import org.wamblee.system.core.Scope;
35 import org.wamblee.system.spring.component.HibernateComponent;
37 import org.wamblee.usermgt.UserAccessor;
38 import org.wamblee.usermgt.UserAdministration;
39 import org.wamblee.usermgt.UserGroupRepositoryComponent;
41 import java.io.IOException;
43 import javax.sql.DataSource;
50 public class AuthorizationComponent extends DefaultContainer {
51 private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface(
52 "transactionManager", PlatformTransactionManager.class);
54 private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface(
55 "hibernateTemplate", HibernateTemplate.class);
57 private ProvidedInterface AUTHORIZATION_SERVICE = new DefaultProvidedInterface(
58 "authorizationService", AuthorizationService.class);
61 * Creates a new AuthorizationComponent object.
65 public AuthorizationComponent(String aName, boolean aExposeInternals)
69 ObjectConfiguration authConfig = new ObjectConfiguration(
70 AuthorizationMappingFiles.class);
71 authConfig.getSetterConfig().initAllSetters();
72 addComponent("mappingFiles", new AuthorizationMappingFiles(),
75 Component<?> hibernate = new HibernateComponent("hibernate");
76 addComponent(hibernate);
78 Component<?> authorization = new AuthorizationLightComponent(
80 addComponent(authorization);
82 addRequiredInterface(new DefaultRequiredInterface("datasource",
84 addRequiredInterface(new DefaultRequiredInterface("userAccessor",
86 addRequiredInterface(new DefaultRequiredInterface("ormconfig",
87 ORMappingConfig.class));
89 if (aExposeInternals) {
90 addProvidedInterface(TRANSACTION_MGR);
91 addProvidedInterface(HIBERNATE_TEMPLATE);
94 addProvidedInterface(AUTHORIZATION_SERVICE);