This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.metadata.repository.file;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.configuration.ArchivaConfiguration;
023import org.apache.archiva.metadata.model.MetadataFacetFactory;
024import org.apache.archiva.metadata.repository.AbstractRepositorySessionFactory;
025import org.apache.archiva.metadata.repository.MetadataRepository;
026import org.apache.archiva.metadata.repository.MetadataRepositoryException;
027import org.apache.archiva.metadata.repository.MetadataResolver;
028import org.apache.archiva.metadata.repository.MetadataService;
029import org.apache.archiva.metadata.repository.RepositorySession;
030import org.apache.archiva.metadata.repository.RepositorySessionFactory;
031import org.apache.commons.lang3.StringUtils;
032import org.springframework.context.ApplicationContext;
033import org.springframework.stereotype.Service;
034
035import javax.inject.Inject;
036import javax.inject.Named;
037import java.util.HashMap;
038import java.util.Map;
039
040/**
041 *
042 */
043@Service( "repositorySessionFactory#file" )
044public class FileRepositorySessionFactory extends AbstractRepositorySessionFactory
045    implements RepositorySessionFactory
046{
047    @Inject
048    @Named( value = "archivaConfiguration#default" )
049    private ArchivaConfiguration configuration;
050
051    @Inject
052    private MetadataResolver metadataResolver;
053
054    @Inject
055    private ApplicationContext applicationContext;
056
057    @Inject
058    private MetadataService metadataService;
059
060    public void initialize()
061    {
062        Map<String, MetadataFacetFactory> tmpMetadataFacetFactories =
063            applicationContext.getBeansOfType( MetadataFacetFactory.class );
064    }
065
066    @Override
067    protected void shutdown() {
068        // do nothing
069    }
070
071    @Override
072    public RepositorySession createSession() throws MetadataRepositoryException
073    {
074        MetadataRepository metadataRepository = new FileMetadataRepository( metadataService, configuration );
075
076        return new RepositorySession( metadataRepository, metadataResolver );
077    }
078
079}