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 java.io.IOException;
20 import javax.sql.DataSource;
22 import org.springframework.orm.hibernate3.HibernateTemplate;
23 import org.springframework.transaction.PlatformTransactionManager;
24 import org.wamblee.security.authorization.AuthorizationService;
25 import org.wamblee.security.authorization.hibernate.AuthorizationMappingFiles;
26 import org.wamblee.system.adapters.DefaultContainer;
27 import org.wamblee.system.adapters.ObjectConfiguration;
28 import org.wamblee.system.components.ORMappingConfig;
29 import org.wamblee.system.core.Component;
30 import org.wamblee.system.core.DefaultProvidedInterface;
31 import org.wamblee.system.core.DefaultRequiredInterface;
32 import org.wamblee.system.core.ProvidedInterface;
33 import org.wamblee.system.spring.component.HibernateComponent;
34 import org.wamblee.usermgt.UserAccessor;
41 public class AuthorizationComponent extends DefaultContainer {
42 private ProvidedInterface transactionMgr = new DefaultProvidedInterface(
43 "transactionManager", PlatformTransactionManager.class);
45 private ProvidedInterface hibernateTemplate = new DefaultProvidedInterface(
46 "hibernateTemplate", HibernateTemplate.class);
48 private ProvidedInterface authorizationService = new DefaultProvidedInterface(
49 "authorizationService", AuthorizationService.class);
52 * Creates a new AuthorizationComponent object.
56 public AuthorizationComponent(String aName, boolean aExposeInternals)
60 ObjectConfiguration authConfig = new ObjectConfiguration(
61 AuthorizationMappingFiles.class);
62 authConfig.getSetterConfig().initAllSetters();
63 addComponent("mappingFiles", new AuthorizationMappingFiles(),
66 Component<?> hibernate = new HibernateComponent("hibernate");
67 addComponent(hibernate);
69 Component<?> authorization = new AuthorizationLightComponent(
71 addComponent(authorization);
73 addRequiredInterface(new DefaultRequiredInterface("datasource",
75 addRequiredInterface(new DefaultRequiredInterface("userAccessor",
77 addRequiredInterface(new DefaultRequiredInterface("ormconfig",
78 ORMappingConfig.class));
80 if (aExposeInternals) {
81 addProvidedInterface(transactionMgr);
82 addProvidedInterface(hibernateTemplate);
85 addProvidedInterface(authorizationService);