1package org.apache.archiva.metadata.repository.file;
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.apache.archiva.metadata.model.MetadataFacetFactory;
23import org.apache.archiva.metadata.repository.MetadataRepository;
24import org.apache.archiva.metadata.repository.MetadataResolver;
25import org.apache.archiva.metadata.repository.RepositorySession;
26import org.apache.archiva.metadata.repository.RepositorySessionFactory;
27import org.apache.commons.lang.StringUtils;
28import org.apache.archiva.configuration.ArchivaConfiguration;
29import org.springframework.context.ApplicationContext;
30import org.springframework.stereotype.Service;
3132import javax.annotation.PostConstruct;
33import javax.inject.Inject;
34import javax.inject.Named;
35import java.util.HashMap;
36import java.util.Map;
3738/**39 *40 */41 @Service( "repositorySessionFactory#file" )
42publicclassFileRepositorySessionFactory43implementsRepositorySessionFactory44 {
45/**46 *47 */48private Map<String, MetadataFacetFactory> metadataFacetFactories;
4950/**51 *52 */53 @Inject
54 @Named( value = "archivaConfiguration#default" )
55privateArchivaConfiguration configuration;
5657/**58 *59 */60 @Inject
61privateMetadataResolver metadataResolver;
6263 @Inject
64private ApplicationContext applicationContext;
6566 @PostConstruct
67publicvoid initialize()
68 {
69 Map<String, MetadataFacetFactory> tmpMetadataFacetFactories =
70 applicationContext.getBeansOfType( MetadataFacetFactory.class );
71// olamy with spring the "id" is now "metadataFacetFactory#hint"72// whereas was only hint with plexus so let remove metadataFacetFactory#73 metadataFacetFactories = new HashMap<>( tmpMetadataFacetFactories.size() );
7475for ( Map.Entry<String, MetadataFacetFactory> entry : tmpMetadataFacetFactories.entrySet() )
76 {
77 metadataFacetFactories.put( StringUtils.substringAfterLast( entry.getKey(), "#" ), entry.getValue() );
78 }
798081 }
8283 @Override
84publicRepositorySession createSession()
85 {
86MetadataRepository metadataRepository = newFileMetadataRepository( metadataFacetFactories, configuration );
8788returnnewRepositorySession( metadataRepository, metadataResolver );
89 }
90 }