This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.mock;
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.metadata.repository.AbstractMetadataRepository;
023import org.apache.archiva.metadata.repository.AbstractRepositorySessionFactory;
024import org.apache.archiva.metadata.repository.MetadataRepository;
025import org.apache.archiva.metadata.repository.MetadataRepositoryException;
026import org.apache.archiva.metadata.repository.MetadataResolver;
027import org.apache.archiva.metadata.repository.MetadataSessionException;
028import org.apache.archiva.metadata.repository.RepositorySession;
029import org.apache.archiva.metadata.repository.RepositorySessionFactory;
030import org.springframework.stereotype.Service;
031
032/**
033 * @author Olivier Lamy
034 */
035@Service( "repositorySessionFactory#mock" )
036public class MockRepositorySessionFactory extends AbstractRepositorySessionFactory
037    implements RepositorySessionFactory
038{
039    private MetadataRepository repository = new AbstractMetadataRepository()
040    {
041    };
042
043    private MetadataResolver resolver;
044
045    public void setRepository( MetadataRepository repository )
046    {
047        this.repository = repository;
048    }
049
050    public void setResolver( MetadataResolver resolver )
051    {
052        this.resolver = resolver;
053    }
054
055    @Override
056    public RepositorySession createSession() throws MetadataRepositoryException
057    {
058        return new RepositorySession( repository, resolver )
059        {
060            @Override
061            public void close()
062            {
063                return;
064            }
065
066            @Override
067            public void save() throws MetadataSessionException
068            {
069                // no op
070            }
071
072            @Override
073            public MetadataRepository getRepository()
074            {
075                return repository;
076            }
077        };
078    }
079
080    @Override
081    protected void initialize() {
082        // noop
083    }
084
085    @Override
086    protected void shutdown() {
087        // noop
088    }
089
090
091}