001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.internal.impl; 020 021import javax.inject.Inject; 022import javax.inject.Named; 023import javax.inject.Singleton; 024 025import org.eclipse.aether.RepositorySystemSession; 026import org.eclipse.aether.repository.RepositoryKeyFunction; 027import org.eclipse.aether.spi.remoterepo.RepositoryKeyFunctionFactory; 028 029import static java.util.Objects.requireNonNull; 030 031/** 032 * Default local path prefix composer factory: it fully reuses {@link LocalPathPrefixComposerFactorySupport} class 033 * without changing anything from it. 034 * 035 * @since 1.8.1 036 */ 037@Singleton 038@Named 039public final class DefaultLocalPathPrefixComposerFactory extends LocalPathPrefixComposerFactorySupport { 040 private final RepositoryKeyFunctionFactory repositoryKeyFunctionFactory; 041 042 @Inject 043 public DefaultLocalPathPrefixComposerFactory(RepositoryKeyFunctionFactory repositoryKeyFunctionFactory) { 044 this.repositoryKeyFunctionFactory = requireNonNull(repositoryKeyFunctionFactory); 045 } 046 047 @Override 048 public LocalPathPrefixComposer createComposer(RepositorySystemSession session) { 049 return new DefaultLocalPathPrefixComposer( 050 isSplit(session), 051 getLocalPrefix(session), 052 isSplitLocal(session), 053 getRemotePrefix(session), 054 isSplitRemote(session), 055 isSplitRemoteRepository(session), 056 isSplitRemoteRepositoryLast(session), 057 getReleasesPrefix(session), 058 getSnapshotsPrefix(session), 059 repositoryKeyFunctionFactory.systemRepositoryKeyFunction(session)); 060 } 061 062 /** 063 * {@link LocalPathPrefixComposer} implementation that fully reuses {@link LocalPathPrefixComposerSupport} class. 064 */ 065 private static class DefaultLocalPathPrefixComposer extends LocalPathPrefixComposerSupport { 066 @SuppressWarnings("checkstyle:parameternumber") 067 private DefaultLocalPathPrefixComposer( 068 boolean split, 069 String localPrefix, 070 boolean splitLocal, 071 String remotePrefix, 072 boolean splitRemote, 073 boolean splitRemoteRepository, 074 boolean splitRemoteRepositoryLast, 075 String releasesPrefix, 076 String snapshotsPrefix, 077 RepositoryKeyFunction repositoryKeyFunction) { 078 super( 079 split, 080 localPrefix, 081 splitLocal, 082 remotePrefix, 083 splitRemote, 084 splitRemoteRepository, 085 splitRemoteRepositoryLast, 086 releasesPrefix, 087 snapshotsPrefix, 088 repositoryKeyFunction); 089 } 090 } 091}