1package org.apache.archiva.metadata.repository;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24import org.springframework.beans.factory.config.AbstractFactoryBean;
2526import java.util.Properties;
2728/**29 * @author Olivier Lamy30 * @since 2.0.231 */32publicclassRepositorySessionFactoryBean33extends AbstractFactoryBean<RepositorySessionFactory>
34 {
3536private Logger logger = LoggerFactory.getLogger( getClass() );
3738privatestaticfinal String BEAN_ID_SYS_PROPS = "archiva.repositorySessionFactory.id";
3940private Properties properties;
4142private String id;
4344publicRepositorySessionFactoryBean( Properties properties )
45 {
46this.properties = properties;
47// we can override with system props48 String value = System.getProperty( BEAN_ID_SYS_PROPS );
49if ( value != null )
50 {
51this.properties.put( BEAN_ID_SYS_PROPS, value );
52 }
53 id = properties.getProperty( BEAN_ID_SYS_PROPS );
54 }
5556 @Override
57public Class<RepositorySessionFactory> getObjectType()
58 {
59return RepositorySessionFactory.class;
60 }
6162 @Override
63protectedRepositorySessionFactory createInstance()
64throws Exception
65 {
66RepositorySessionFactory repositorySessionFactory =
67 getBeanFactory().getBean( "repositorySessionFactory#" + id, RepositorySessionFactory.class );
68 logger.info( "create RepositorySessionFactory with id {} instance of {}", //69 id, //70 repositorySessionFactory.getClass().getName() );
71return repositorySessionFactory;
72 }
7374public String getId()
75 {
76return id;
77 }
7879publicvoid setId( String id )
80 {
81this.id = id;
82 }
8384public Properties getProperties()
85 {
86return properties;
87 }
8889publicvoid setProperties( Properties properties )
90 {
91this.properties = properties;
92 }
93 }