source code formatting.
[utils] / security / src / main / java / org / wamblee / usermgt / hibernate / AuthorizationComponent.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.security.authorization.AuthorizationService;
25 import org.wamblee.security.authorization.hibernate.AuthorizationMappingFiles;
26
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;
36
37 import org.wamblee.usermgt.UserAccessor;
38 import org.wamblee.usermgt.UserAdministration;
39 import org.wamblee.usermgt.UserGroupRepositoryComponent;
40
41 import java.io.IOException;
42
43 import javax.sql.DataSource;
44
45
46 /**
47  * DOCUMENT ME!
48  *
49  * @author $author$
50  * @version $Revision$
51  */
52 public class AuthorizationComponent extends DefaultContainer {
53     /**
54      * DOCUMENT ME!
55      */
56     private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface("transactionManager",
57             PlatformTransactionManager.class);
58
59     /**
60      * DOCUMENT ME!
61      */
62     private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface("hibernateTemplate",
63             HibernateTemplate.class);
64
65     /**
66      * DOCUMENT ME!
67      */
68     private ProvidedInterface AUTHORIZATION_SERVICE = new DefaultProvidedInterface("authorizationService",
69             AuthorizationService.class);
70
71 /**
72      * Creates a new AuthorizationComponent object.
73      *
74      * @param aName DOCUMENT ME!
75      * @param aExposeInternals DOCUMENT ME!
76      *
77      * @throws IOException DOCUMENT ME!
78      */
79     public AuthorizationComponent(String aName, boolean aExposeInternals)
80         throws IOException {
81         super(aName);
82
83         ObjectConfiguration authConfig = new ObjectConfiguration(AuthorizationMappingFiles.class);
84         authConfig.getSetterConfig().initAllSetters();
85         addComponent("mappingFiles", new AuthorizationMappingFiles(), authConfig);
86
87         Component<?> hibernate = new HibernateComponent("hibernate");
88         addComponent(hibernate);
89
90         Component<?> authorization = new AuthorizationLightComponent(
91                 "authorization");
92         addComponent(authorization);
93
94         addRequiredInterface(new DefaultRequiredInterface("datasource",
95                 DataSource.class));
96         addRequiredInterface(new DefaultRequiredInterface("userAccessor",
97                 UserAccessor.class));
98         addRequiredInterface(new DefaultRequiredInterface("ormconfig",
99                 ORMappingConfig.class));
100
101         if (aExposeInternals) {
102             addProvidedInterface(TRANSACTION_MGR);
103             addProvidedInterface(HIBERNATE_TEMPLATE);
104         }
105
106         addProvidedInterface(AUTHORIZATION_SERVICE);
107     }
108 }