http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/SyncContextFactory.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/SyncContextFactory.java b/aether-impl/src/main/java/org/eclipse/aether/impl/SyncContextFactory.java deleted file mode 100644 index 95086d1..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/SyncContextFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.SyncContext; - -/** - * A factory to create synchronization contexts. A synchronization context is used to coordinate concurrent access to - * artifacts or metadata. - * - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public interface SyncContextFactory -{ - - /** - * Creates a new synchronization context. - * - * @param session The repository session during which the context will be used, must not be {@code null}. - * @param shared A flag indicating whether access to the artifacts/metadata associated with the new context can be - * shared among concurrent readers or whether access needs to be exclusive to the calling thread. - * @return The synchronization context, never {@code null}. - * @see RepositorySystem#newSyncContext(RepositorySystemSession, boolean) - */ - SyncContext newInstance( RepositorySystemSession session, boolean shared ); - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java b/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java deleted file mode 100644 index b77d2bc..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheck.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.eclipse.aether.RepositoryException; -import org.eclipse.aether.repository.RemoteRepository; - -/** - * A request to check if an update of an artifact/metadata from a remote repository is needed. - * - * @param <T> - * @param <E> - * @see UpdateCheckManager - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public final class UpdateCheck<T, E extends RepositoryException> -{ - - private long localLastUpdated; - - private T item; - - private File file; - - private boolean fileValid = true; - - private String policy; - - private RemoteRepository repository; - - private RemoteRepository authoritativeRepository; - - private boolean required; - - private E exception; - - /** - * Creates an uninitialized update check request. - */ - public UpdateCheck() - { - } - - /** - * Gets the last-modified timestamp of the corresponding item produced by a local installation. If non-zero, a - * remote update will be surpressed if the local item is up-to-date, even if the remote item has not been cached - * locally. - * - * @return The last-modified timestamp of the corresponding item produced by a local installation or {@code 0} to - * ignore any local item. - */ - public long getLocalLastUpdated() - { - return localLastUpdated; - } - - /** - * Sets the last-modified timestamp of the corresponding item produced by a local installation. If non-zero, a - * remote update will be surpressed if the local item is up-to-date, even if the remote item has not been cached - * locally. - * - * @param localLastUpdated The last-modified timestamp of the corresponding item produced by a local installation or - * {@code 0} to ignore any local item. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setLocalLastUpdated( long localLastUpdated ) - { - this.localLastUpdated = localLastUpdated; - return this; - } - - /** - * Gets the item of the check. - * - * @return The item of the check, never {@code null}. - */ - public T getItem() - { - return item; - } - - /** - * Sets the item of the check. - * - * @param item The item of the check, must not be {@code null}. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setItem( T item ) - { - this.item = item; - return this; - } - - /** - * Returns the local file of the item. - * - * @return The local file of the item. - */ - public File getFile() - { - return file; - } - - /** - * Sets the local file of the item. - * - * @param file The file of the item, never {@code null} . - * @return This object for chaining. - */ - public UpdateCheck<T, E> setFile( File file ) - { - this.file = file; - return this; - } - - /** - * Indicates whether the local file given by {@link #getFile()}, if existent, should be considered valid or not. An - * invalid file is equivalent to a physically missing file. - * - * @return {@code true} if the file should be considered valid if existent, {@code false} if the file should be - * treated as if it was missing. - */ - public boolean isFileValid() - { - return fileValid; - } - - /** - * Controls whether the local file given by {@link #getFile()}, if existent, should be considered valid or not. An - * invalid file is equivalent to a physically missing file. - * - * @param fileValid {@code true} if the file should be considered valid if existent, {@code false} if the file - * should be treated as if it was missing. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setFileValid( boolean fileValid ) - { - this.fileValid = fileValid; - return this; - } - - /** - * Gets the policy to use for the check. - * - * @return The policy to use for the check. - * @see org.eclipse.aether.repository.RepositoryPolicy - */ - public String getPolicy() - { - return policy; - } - - /** - * Sets the policy to use for the check. - * - * @param policy The policy to use for the check, may be {@code null}. - * @return This object for chaining. - * @see org.eclipse.aether.repository.RepositoryPolicy - */ - public UpdateCheck<T, E> setPolicy( String policy ) - { - this.policy = policy; - return this; - } - - /** - * Gets the repository from which a potential update/download will performed. - * - * @return The repository to use for the check. - */ - public RemoteRepository getRepository() - { - return repository; - } - - /** - * Sets the repository from which a potential update/download will performed. - * - * @param repository The repository to use for the check, must not be {@code null}. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setRepository( RemoteRepository repository ) - { - this.repository = repository; - return this; - } - - /** - * Gets the repository which ultimately hosts the metadata to update. This will be different from the repository - * given by {@link #getRepository()} in case the latter denotes a repository manager. - * - * @return The actual repository hosting the authoritative copy of the metadata to update, never {@code null} for a - * metadata update check. - */ - public RemoteRepository getAuthoritativeRepository() - { - return authoritativeRepository != null ? authoritativeRepository : repository; - } - - /** - * Sets the repository which ultimately hosts the metadata to update. This will be different from the repository - * given by {@link #getRepository()} in case the latter denotes a repository manager. - * - * @param authoritativeRepository The actual repository hosting the authoritative copy of the metadata to update, - * must not be {@code null} for a metadata update check. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setAuthoritativeRepository( RemoteRepository authoritativeRepository ) - { - this.authoritativeRepository = authoritativeRepository; - return this; - } - - /** - * Gets the result of a check, denoting whether the remote repository should be checked for updates. - * - * @return The result of a check. - */ - public boolean isRequired() - { - return required; - } - - /** - * Sets the result of an update check. - * - * @param required The result of an update check. In case of {@code false} and the local file given by - * {@link #getFile()} does actually not exist, {@link #setException(RepositoryException)} should be used - * to provide the previous/cached failure that explains the absence of the file. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setRequired( boolean required ) - { - this.required = required; - return this; - } - - /** - * Gets the exception that occurred during the update check. - * - * @return The occurred exception or {@code null} if the update check was successful. - */ - public E getException() - { - return exception; - } - - /** - * Sets the exception for this update check. - * - * @param exception The exception for this update check, may be {@code null} if the check was successful. - * @return This object for chaining. - */ - public UpdateCheck<T, E> setException( E exception ) - { - this.exception = exception; - return this; - } - - @Override - public String toString() - { - return getPolicy() + ": " + getFile() + " < " + getRepository(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheckManager.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheckManager.java b/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheckManager.java deleted file mode 100644 index cd35df0..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdateCheckManager.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.transfer.ArtifactTransferException; -import org.eclipse.aether.transfer.MetadataTransferException; - -/** - * Determines if updates of artifacts and metadata from remote repositories are needed. - * - * @noimplement This interface is not intended to be implemented by clients. - * @noextend This interface is not intended to be extended by clients. - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public interface UpdateCheckManager -{ - - /** - * Checks whether an artifact has to be updated from a remote repository. - * - * @param session The repository system session during which the request is made, must not be {@code null}. - * @param check The update check request, must not be {@code null}. - */ - void checkArtifact( RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check ); - - /** - * Updates the timestamp for the artifact contained in the update check. - * - * @param session The repository system session during which the request is made, must not be {@code null}. - * @param check The update check request, must not be {@code null}. - */ - void touchArtifact( RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check ); - - /** - * Checks whether metadata has to be updated from a remote repository. - * - * @param session The repository system session during which the request is made, must not be {@code null}. - * @param check The update check request, must not be {@code null}. - */ - void checkMetadata( RepositorySystemSession session, UpdateCheck<Metadata, MetadataTransferException> check ); - - /** - * Updates the timestamp for the metadata contained in the update check. - * - * @param session The repository system session during which the request is made, must not be {@code null}. - * @param check The update check request, must not be {@code null}. - */ - void touchMetadata( RepositorySystemSession session, UpdateCheck<Metadata, MetadataTransferException> check ); - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/UpdatePolicyAnalyzer.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdatePolicyAnalyzer.java b/aether-impl/src/main/java/org/eclipse/aether/impl/UpdatePolicyAnalyzer.java deleted file mode 100644 index ce8018a..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/UpdatePolicyAnalyzer.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.RepositorySystemSession; - -/** - * Evaluates update policies. - * - * @noimplement This interface is not intended to be implemented by clients. - * @noextend This interface is not intended to be extended by clients. - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public interface UpdatePolicyAnalyzer -{ - - /** - * Returns the policy with the shorter update interval. - * - * @param session The repository system session during which the request is made, must not be {@code null}. - * @param policy1 A policy to compare, may be {@code null}. - * @param policy2 A policy to compare, may be {@code null}. - * @return The policy with the shorter update interval. - */ - String getEffectiveUpdatePolicy( RepositorySystemSession session, String policy1, String policy2 ); - - /** - * Determines whether the specified modification timestamp satisfies the freshness constraint expressed by the given - * update policy. - * - * @param session The repository system session during which the check is made, must not be {@code null}. - * @param lastModified The timestamp to check against the update policy. - * @param policy The update policy, may be {@code null}. - * @return {@code true} if the specified timestamp is older than acceptable by the update policy, {@code false} - * otherwise. - */ - boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy ); - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/VersionRangeResolver.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/VersionRangeResolver.java b/aether-impl/src/main/java/org/eclipse/aether/impl/VersionRangeResolver.java deleted file mode 100644 index 89bf706..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/VersionRangeResolver.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.resolution.VersionRangeRequest; -import org.eclipse.aether.resolution.VersionRangeResolutionException; -import org.eclipse.aether.resolution.VersionRangeResult; - -/** - * Parses and evaluates version ranges encountered in dependency declarations. - * - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public interface VersionRangeResolver -{ - - /** - * Expands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to - * "3.8", "3.8.1", "3.8.2". The returned list of versions is only dependent on the configured repositories and their - * contents, the list is not processed by the {@link RepositorySystemSession#getVersionFilter() session's version - * filter}. - * <p> - * The supplied request may also refer to a single concrete version rather than a version range. In this case - * though, the result contains simply the (parsed) input version, regardless of the repositories and their contents. - * - * @param session The repository session, must not be {@code null}. - * @param request The version range request, must not be {@code null}. - * @return The version range result, never {@code null}. - * @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does - * not raise an exception. - * @see RepositorySystem#resolveVersionRange(RepositorySystemSession, VersionRangeRequest) - */ - VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request ) - throws VersionRangeResolutionException; - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/VersionResolver.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/VersionResolver.java b/aether-impl/src/main/java/org/eclipse/aether/impl/VersionResolver.java deleted file mode 100644 index e6a8a10..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/VersionResolver.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.resolution.VersionRequest; -import org.eclipse.aether.resolution.VersionResolutionException; -import org.eclipse.aether.resolution.VersionResult; - -/** - * Evaluates artifact meta/pseudo versions. - * - * @provisional This type is provisional and can be changed, moved or removed without prior notice. - */ -public interface VersionResolver -{ - - /** - * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to - * "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0". - * - * @param session The repository session, must not be {@code null}. - * @param request The version request, must not be {@code null} - * @return The version result, never {@code null}. - * @throws VersionResolutionException If the metaversion could not be resolved. - * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest) - */ - VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException; - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java b/aether-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java deleted file mode 100644 index f775fb1..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.eclipse.aether.impl.guice; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.eclipse.aether.RepositoryListener; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.impl.ArtifactResolver; -import org.eclipse.aether.impl.DependencyCollector; -import org.eclipse.aether.impl.Deployer; -import org.eclipse.aether.impl.Installer; -import org.eclipse.aether.impl.LocalRepositoryProvider; -import org.eclipse.aether.impl.MetadataResolver; -import org.eclipse.aether.impl.OfflineController; -import org.eclipse.aether.impl.RemoteRepositoryManager; -import org.eclipse.aether.impl.RepositoryConnectorProvider; -import org.eclipse.aether.impl.RepositoryEventDispatcher; -import org.eclipse.aether.impl.SyncContextFactory; -import org.eclipse.aether.impl.UpdateCheckManager; -import org.eclipse.aether.impl.UpdatePolicyAnalyzer; -import org.eclipse.aether.internal.impl.DefaultArtifactResolver; -import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider; -import org.eclipse.aether.internal.impl.DefaultDependencyCollector; -import org.eclipse.aether.internal.impl.DefaultDeployer; -import org.eclipse.aether.internal.impl.DefaultFileProcessor; -import org.eclipse.aether.internal.impl.DefaultInstaller; -import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider; -import org.eclipse.aether.internal.impl.DefaultMetadataResolver; -import org.eclipse.aether.internal.impl.DefaultOfflineController; -import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager; -import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider; -import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher; -import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider; -import org.eclipse.aether.internal.impl.DefaultRepositorySystem; -import org.eclipse.aether.internal.impl.DefaultSyncContextFactory; -import org.eclipse.aether.internal.impl.DefaultTransporterProvider; -import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager; -import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer; -import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory; -import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory; -import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider; -import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory; -import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider; -import org.eclipse.aether.spi.connector.transport.TransporterProvider; -import org.eclipse.aether.spi.io.FileProcessor; -import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; -import org.slf4j.ILoggerFactory; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.name.Names; - -/** - * A ready-made <a href="http://code.google.com/p/google-guice/" target="_blank">Guice</a> module that sets up bindings - * for all components from this library. To acquire a complete repository system, clients need to bind an artifact - * descriptor reader, a version resolver, a version range resolver, zero or more metadata generator factories, some - * repository connector and transporter factories to access remote repositories. - * - * @noextend This class must not be extended by clients and will eventually be marked {@code final} without prior - * notice. - */ -public class AetherModule - extends AbstractModule -{ - - /** - * Creates a new instance of this Guice module, typically for invoking - * {@link com.google.inject.Binder#install(com.google.inject.Module)}. - */ - public AetherModule() - { - } - - /** - * Configures Guice with bindings for Aether components provided by this library. - */ - @Override - protected void configure() - { - bind( RepositorySystem.class ) // - .to( DefaultRepositorySystem.class ).in( Singleton.class ); - bind( ArtifactResolver.class ) // - .to( DefaultArtifactResolver.class ).in( Singleton.class ); - bind( DependencyCollector.class ) // - .to( DefaultDependencyCollector.class ).in( Singleton.class ); - bind( Deployer.class ) // - .to( DefaultDeployer.class ).in( Singleton.class ); - bind( Installer.class ) // - .to( DefaultInstaller.class ).in( Singleton.class ); - bind( MetadataResolver.class ) // - .to( DefaultMetadataResolver.class ).in( Singleton.class ); - bind( RepositoryLayoutProvider.class ) // - .to( DefaultRepositoryLayoutProvider.class ).in( Singleton.class ); - bind( RepositoryLayoutFactory.class ).annotatedWith( Names.named( "maven2" ) ) // - .to( Maven2RepositoryLayoutFactory.class ).in( Singleton.class ); - bind( TransporterProvider.class ) // - .to( DefaultTransporterProvider.class ).in( Singleton.class ); - bind( ChecksumPolicyProvider.class ) // - .to( DefaultChecksumPolicyProvider.class ).in( Singleton.class ); - bind( RepositoryConnectorProvider.class ) // - .to( DefaultRepositoryConnectorProvider.class ).in( Singleton.class ); - bind( RemoteRepositoryManager.class ) // - .to( DefaultRemoteRepositoryManager.class ).in( Singleton.class ); - bind( UpdateCheckManager.class ) // - .to( DefaultUpdateCheckManager.class ).in( Singleton.class ); - bind( UpdatePolicyAnalyzer.class ) // - .to( DefaultUpdatePolicyAnalyzer.class ).in( Singleton.class ); - bind( FileProcessor.class ) // - .to( DefaultFileProcessor.class ).in( Singleton.class ); - bind( SyncContextFactory.class ) // - .to( DefaultSyncContextFactory.class ).in( Singleton.class ); - bind( RepositoryEventDispatcher.class ) // - .to( DefaultRepositoryEventDispatcher.class ).in( Singleton.class ); - bind( OfflineController.class ) // - .to( DefaultOfflineController.class ).in( Singleton.class ); - bind( LocalRepositoryProvider.class ) // - .to( DefaultLocalRepositoryProvider.class ).in( Singleton.class ); - bind( LocalRepositoryManagerFactory.class ).annotatedWith( Names.named( "simple" ) ) // - .to( SimpleLocalRepositoryManagerFactory.class ).in( Singleton.class ); - bind( LocalRepositoryManagerFactory.class ).annotatedWith( Names.named( "enhanced" ) ) // - .to( EnhancedLocalRepositoryManagerFactory.class ).in( Singleton.class ); - if ( Slf4jLoggerFactory.isSlf4jAvailable() ) - { - bindSlf4j(); - } - else - { - bind( LoggerFactory.class ) // - .toInstance( NullLoggerFactory.INSTANCE ); - } - - } - - private void bindSlf4j() - { - install( new Slf4jModule() ); - } - - @Provides - @Singleton - Set<LocalRepositoryManagerFactory> provideLocalRepositoryManagerFactories( @Named( "simple" ) LocalRepositoryManagerFactory simple, - @Named( "enhanced" ) LocalRepositoryManagerFactory enhanced ) - { - Set<LocalRepositoryManagerFactory> factories = new HashSet<LocalRepositoryManagerFactory>(); - factories.add( simple ); - factories.add( enhanced ); - return Collections.unmodifiableSet( factories ); - } - - @Provides - @Singleton - Set<RepositoryLayoutFactory> provideRepositoryLayoutFactories( @Named( "maven2" ) RepositoryLayoutFactory maven2 ) - { - Set<RepositoryLayoutFactory> factories = new HashSet<RepositoryLayoutFactory>(); - factories.add( maven2 ); - return Collections.unmodifiableSet( factories ); - } - - @Provides - @Singleton - Set<RepositoryListener> providesRepositoryListeners() - { - return Collections.emptySet(); - } - - private static class Slf4jModule - extends AbstractModule - { - - @Override - protected void configure() - { - bind( LoggerFactory.class ) // - .to( Slf4jLoggerFactory.class ); - } - - @Provides - @Singleton - ILoggerFactory getLoggerFactory() - { - return org.slf4j.LoggerFactory.getILoggerFactory(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java b/aether-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java deleted file mode 100644 index e3f8fd3..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/guice/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/** - * The integration with the dependency injection framework <a href="http://code.google.com/p/google-guice/" target="_blank">Google Guice</a>. - */ -package org.eclipse.aether.impl.guice; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/impl/package-info.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/impl/package-info.java b/aether-impl/src/main/java/org/eclipse/aether/impl/package-info.java deleted file mode 100644 index 959a431..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/impl/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/** - * The provisional interfaces defining the various sub components that implement the repository system. Aether Core - * provides stock implementations for most of these components but not all. To obtain a complete/runnable repository - * system, the application needs to provide implementations of the following component contracts: - * {@link org.eclipse.aether.impl.ArtifactDescriptorReader}, {@link org.eclipse.aether.impl.VersionResolver}, - * {@link org.eclipse.aether.impl.VersionRangeResolver} and potentially - * {@link org.eclipse.aether.impl.MetadataGeneratorFactory}. Said components basically define the file format of the - * metadata that is used to reason about an artifact's dependencies and available versions. - */ -package org.eclipse.aether.impl; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/AbstractChecksumPolicy.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/AbstractChecksumPolicy.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/AbstractChecksumPolicy.java deleted file mode 100644 index 368e31b..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/AbstractChecksumPolicy.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.eclipse.aether.spi.connector.checksum.ChecksumPolicy; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; -import org.eclipse.aether.transfer.ChecksumFailureException; -import org.eclipse.aether.transfer.TransferResource; - -abstract class AbstractChecksumPolicy - implements ChecksumPolicy - -{ - - protected final Logger logger; - - protected final TransferResource resource; - - protected AbstractChecksumPolicy( LoggerFactory loggerFactory, TransferResource resource ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() ); - this.resource = resource; - } - - public boolean onChecksumMatch( String algorithm, int kind ) - { - return true; - } - - public void onChecksumMismatch( String algorithm, int kind, ChecksumFailureException exception ) - throws ChecksumFailureException - { - if ( ( kind & KIND_UNOFFICIAL ) == 0 ) - { - throw exception; - } - } - - public void onChecksumError( String algorithm, int kind, ChecksumFailureException exception ) - throws ChecksumFailureException - { - logger.debug( "Could not validate " + algorithm + " checksum for " + resource.getResourceName(), exception ); - } - - public void onNoMoreChecksums() - throws ChecksumFailureException - { - throw new ChecksumFailureException( "Checksum validation failed, no checksums available" ); - } - - public void onTransferRetry() - { - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ArtifactRequestBuilder.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ArtifactRequestBuilder.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ArtifactRequestBuilder.java deleted file mode 100644 index f9773dc..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ArtifactRequestBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.aether.RequestTrace; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; -import org.eclipse.aether.resolution.ArtifactRequest; - -/** - */ -class ArtifactRequestBuilder - implements DependencyVisitor -{ - - private final RequestTrace trace; - - private List<ArtifactRequest> requests; - - public ArtifactRequestBuilder( RequestTrace trace ) - { - this.trace = trace; - this.requests = new ArrayList<ArtifactRequest>(); - } - - public List<ArtifactRequest> getRequests() - { - return requests; - } - - public boolean visitEnter( DependencyNode node ) - { - if ( node.getDependency() != null ) - { - ArtifactRequest request = new ArtifactRequest( node ); - request.setTrace( trace ); - requests.add( request ); - } - - return true; - } - - public boolean visitLeave( DependencyNode node ) - { - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java deleted file mode 100644 index d7e8f01..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CacheUtils.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.ArtifactRepository; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.repository.RepositoryPolicy; -import org.eclipse.aether.repository.WorkspaceReader; -import org.eclipse.aether.repository.WorkspaceRepository; - -/** - * @deprecated To be deleted without replacement. - */ -@Deprecated -public final class CacheUtils -{ - - public static <T> boolean eq( T s1, T s2 ) - { - return s1 != null ? s1.equals( s2 ) : s2 == null; - } - - public static int hash( Object obj ) - { - return obj != null ? obj.hashCode() : 0; - } - - public static int repositoriesHashCode( List<RemoteRepository> repositories ) - { - int result = 17; - for ( RemoteRepository repository : repositories ) - { - result = 31 * result + repositoryHashCode( repository ); - } - return result; - } - - private static int repositoryHashCode( RemoteRepository repository ) - { - int result = 17; - result = 31 * result + hash( repository.getUrl() ); - return result; - } - - private static boolean repositoryEquals( RemoteRepository r1, RemoteRepository r2 ) - { - if ( r1 == r2 ) - { - return true; - } - - return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() ) - && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) ) - && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) ); - } - - private static boolean policyEquals( RepositoryPolicy p1, RepositoryPolicy p2 ) - { - if ( p1 == p2 ) - { - return true; - } - // update policy doesn't affect contents - return p1.isEnabled() == p2.isEnabled() && eq( p1.getChecksumPolicy(), p2.getChecksumPolicy() ); - } - - public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 ) - { - if ( r1.size() != r2.size() ) - { - return false; - } - - for ( Iterator<RemoteRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); ) - { - if ( !repositoryEquals( it1.next(), it2.next() ) ) - { - return false; - } - } - - return true; - } - - public static WorkspaceRepository getWorkspace( RepositorySystemSession session ) - { - WorkspaceReader reader = session.getWorkspaceReader(); - return ( reader != null ) ? reader.getRepository() : null; - } - - public static ArtifactRepository getRepository( RepositorySystemSession session, - List<RemoteRepository> repositories, Class<?> repoClass, - String repoId ) - { - if ( repoClass != null ) - { - if ( WorkspaceRepository.class.isAssignableFrom( repoClass ) ) - { - return session.getWorkspaceReader().getRepository(); - } - else if ( LocalRepository.class.isAssignableFrom( repoClass ) ) - { - return session.getLocalRepository(); - } - else - { - for ( RemoteRepository repository : repositories ) - { - if ( repoId.equals( repository.getId() ) ) - { - return repository; - } - } - } - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CachingArtifactTypeRegistry.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CachingArtifactTypeRegistry.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CachingArtifactTypeRegistry.java deleted file mode 100644 index bde4103..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/CachingArtifactTypeRegistry.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.ArtifactType; -import org.eclipse.aether.artifact.ArtifactTypeRegistry; - -/** - * A short-lived artifact type registry that caches results from a presumedly slower type registry. - */ -class CachingArtifactTypeRegistry - implements ArtifactTypeRegistry -{ - - private final ArtifactTypeRegistry delegate; - - private final Map<String, ArtifactType> types; - - public static ArtifactTypeRegistry newInstance( RepositorySystemSession session ) - { - return newInstance( session.getArtifactTypeRegistry() ); - } - - public static ArtifactTypeRegistry newInstance( ArtifactTypeRegistry delegate ) - { - return ( delegate != null ) ? new CachingArtifactTypeRegistry( delegate ) : null; - } - - private CachingArtifactTypeRegistry( ArtifactTypeRegistry delegate ) - { - this.delegate = delegate; - types = new HashMap<String, ArtifactType>(); - } - - public ArtifactType get( String typeId ) - { - ArtifactType type = types.get( typeId ); - - if ( type == null ) - { - type = delegate.get( typeId ); - types.put( typeId, type ); - } - - return type; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DataPool.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DataPool.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DataPool.java deleted file mode 100644 index fdf9ce5..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DataPool.java +++ /dev/null @@ -1,439 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; - -import org.eclipse.aether.RepositoryCache; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.collection.DependencyManager; -import org.eclipse.aether.collection.DependencySelector; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.collection.VersionFilter; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.repository.ArtifactRepository; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactDescriptorException; -import org.eclipse.aether.resolution.ArtifactDescriptorRequest; -import org.eclipse.aether.resolution.ArtifactDescriptorResult; -import org.eclipse.aether.resolution.VersionRangeRequest; -import org.eclipse.aether.resolution.VersionRangeResult; -import org.eclipse.aether.version.Version; -import org.eclipse.aether.version.VersionConstraint; - -/** - */ -final class DataPool -{ - - private static final String ARTIFACT_POOL = DataPool.class.getName() + "$Artifact"; - - private static final String DEPENDENCY_POOL = DataPool.class.getName() + "$Dependency"; - - private static final String DESCRIPTORS = DataPool.class.getName() + "$Descriptors"; - - public static final ArtifactDescriptorResult NO_DESCRIPTOR = - new ArtifactDescriptorResult( new ArtifactDescriptorRequest() ); - - private ObjectPool<Artifact> artifacts; - - private ObjectPool<Dependency> dependencies; - - private Map<Object, Descriptor> descriptors; - - private Map<Object, Constraint> constraints = new HashMap<Object, Constraint>(); - - private Map<Object, List<DependencyNode>> nodes = new HashMap<Object, List<DependencyNode>>( 256 ); - - @SuppressWarnings( "unchecked" ) - public DataPool( RepositorySystemSession session ) - { - RepositoryCache cache = session.getCache(); - - if ( cache != null ) - { - artifacts = (ObjectPool<Artifact>) cache.get( session, ARTIFACT_POOL ); - dependencies = (ObjectPool<Dependency>) cache.get( session, DEPENDENCY_POOL ); - descriptors = (Map<Object, Descriptor>) cache.get( session, DESCRIPTORS ); - } - - if ( artifacts == null ) - { - artifacts = new ObjectPool<Artifact>(); - if ( cache != null ) - { - cache.put( session, ARTIFACT_POOL, artifacts ); - } - } - - if ( dependencies == null ) - { - dependencies = new ObjectPool<Dependency>(); - if ( cache != null ) - { - cache.put( session, DEPENDENCY_POOL, dependencies ); - } - } - - if ( descriptors == null ) - { - descriptors = Collections.synchronizedMap( new WeakHashMap<Object, Descriptor>( 256 ) ); - if ( cache != null ) - { - cache.put( session, DESCRIPTORS, descriptors ); - } - } - } - - public Artifact intern( Artifact artifact ) - { - return artifacts.intern( artifact ); - } - - public Dependency intern( Dependency dependency ) - { - return dependencies.intern( dependency ); - } - - public Object toKey( ArtifactDescriptorRequest request ) - { - return request.getArtifact(); - } - - public ArtifactDescriptorResult getDescriptor( Object key, ArtifactDescriptorRequest request ) - { - Descriptor descriptor = descriptors.get( key ); - if ( descriptor != null ) - { - return descriptor.toResult( request ); - } - return null; - } - - public void putDescriptor( Object key, ArtifactDescriptorResult result ) - { - descriptors.put( key, new GoodDescriptor( result ) ); - } - - public void putDescriptor( Object key, ArtifactDescriptorException e ) - { - descriptors.put( key, BadDescriptor.INSTANCE ); - } - - public Object toKey( VersionRangeRequest request ) - { - return new ConstraintKey( request ); - } - - public VersionRangeResult getConstraint( Object key, VersionRangeRequest request ) - { - Constraint constraint = constraints.get( key ); - if ( constraint != null ) - { - return constraint.toResult( request ); - } - return null; - } - - public void putConstraint( Object key, VersionRangeResult result ) - { - constraints.put( key, new Constraint( result ) ); - } - - public Object toKey( Artifact artifact, List<RemoteRepository> repositories, DependencySelector selector, - DependencyManager manager, DependencyTraverser traverser, VersionFilter filter ) - { - return new GraphKey( artifact, repositories, selector, manager, traverser, filter ); - } - - public List<DependencyNode> getChildren( Object key ) - { - return nodes.get( key ); - } - - public void putChildren( Object key, List<DependencyNode> children ) - { - nodes.put( key, children ); - } - - abstract static class Descriptor - { - - public abstract ArtifactDescriptorResult toResult( ArtifactDescriptorRequest request ); - - } - - static final class GoodDescriptor - extends Descriptor - { - - final Artifact artifact; - - final List<Artifact> relocations; - - final Collection<Artifact> aliases; - - final List<RemoteRepository> repositories; - - final List<Dependency> dependencies; - - final List<Dependency> managedDependencies; - - public GoodDescriptor( ArtifactDescriptorResult result ) - { - artifact = result.getArtifact(); - relocations = result.getRelocations(); - aliases = result.getAliases(); - dependencies = result.getDependencies(); - managedDependencies = result.getManagedDependencies(); - repositories = result.getRepositories(); - } - - public ArtifactDescriptorResult toResult( ArtifactDescriptorRequest request ) - { - ArtifactDescriptorResult result = new ArtifactDescriptorResult( request ); - result.setArtifact( artifact ); - result.setRelocations( relocations ); - result.setAliases( aliases ); - result.setDependencies( dependencies ); - result.setManagedDependencies( managedDependencies ); - result.setRepositories( repositories ); - return result; - } - - } - - static final class BadDescriptor - extends Descriptor - { - - static final BadDescriptor INSTANCE = new BadDescriptor(); - - public ArtifactDescriptorResult toResult( ArtifactDescriptorRequest request ) - { - return NO_DESCRIPTOR; - } - - } - - static final class Constraint - { - - final VersionRepo[] repositories; - - final VersionConstraint versionConstraint; - - public Constraint( VersionRangeResult result ) - { - versionConstraint = result.getVersionConstraint(); - List<Version> versions = result.getVersions(); - repositories = new VersionRepo[versions.size()]; - int i = 0; - for ( Version version : versions ) - { - repositories[i++] = new VersionRepo( version, result.getRepository( version ) ); - } - } - - public VersionRangeResult toResult( VersionRangeRequest request ) - { - VersionRangeResult result = new VersionRangeResult( request ); - for ( VersionRepo vr : repositories ) - { - result.addVersion( vr.version ); - result.setRepository( vr.version, vr.repo ); - } - result.setVersionConstraint( versionConstraint ); - return result; - } - - static final class VersionRepo - { - - final Version version; - - final ArtifactRepository repo; - - VersionRepo( Version version, ArtifactRepository repo ) - { - this.version = version; - this.repo = repo; - } - - } - - } - - static final class ConstraintKey - { - - private final Artifact artifact; - - private final List<RemoteRepository> repositories; - - private final int hashCode; - - public ConstraintKey( VersionRangeRequest request ) - { - artifact = request.getArtifact(); - repositories = request.getRepositories(); - hashCode = artifact.hashCode(); - } - - @Override - public boolean equals( Object obj ) - { - if ( obj == this ) - { - return true; - } - else if ( !( obj instanceof ConstraintKey ) ) - { - return false; - } - ConstraintKey that = (ConstraintKey) obj; - return artifact.equals( that.artifact ) && equals( repositories, that.repositories ); - } - - private static boolean equals( List<RemoteRepository> repos1, List<RemoteRepository> repos2 ) - { - if ( repos1.size() != repos2.size() ) - { - return false; - } - for ( int i = 0, n = repos1.size(); i < n; i++ ) - { - RemoteRepository repo1 = repos1.get( i ); - RemoteRepository repo2 = repos2.get( i ); - if ( repo1.isRepositoryManager() != repo2.isRepositoryManager() ) - { - return false; - } - if ( repo1.isRepositoryManager() ) - { - if ( !equals( repo1.getMirroredRepositories(), repo2.getMirroredRepositories() ) ) - { - return false; - } - } - else if ( !repo1.getUrl().equals( repo2.getUrl() ) ) - { - return false; - } - else if ( repo1.getPolicy( true ).isEnabled() != repo2.getPolicy( true ).isEnabled() ) - { - return false; - } - else if ( repo1.getPolicy( false ).isEnabled() != repo2.getPolicy( false ).isEnabled() ) - { - return false; - } - } - return true; - } - - @Override - public int hashCode() - { - return hashCode; - } - - } - - static final class GraphKey - { - - private final Artifact artifact; - - private final List<RemoteRepository> repositories; - - private final DependencySelector selector; - - private final DependencyManager manager; - - private final DependencyTraverser traverser; - - private final VersionFilter filter; - - private final int hashCode; - - public GraphKey( Artifact artifact, List<RemoteRepository> repositories, DependencySelector selector, - DependencyManager manager, DependencyTraverser traverser, VersionFilter filter ) - { - this.artifact = artifact; - this.repositories = repositories; - this.selector = selector; - this.manager = manager; - this.traverser = traverser; - this.filter = filter; - - int hash = 17; - hash = hash * 31 + artifact.hashCode(); - hash = hash * 31 + repositories.hashCode(); - hash = hash * 31 + hash( selector ); - hash = hash * 31 + hash( manager ); - hash = hash * 31 + hash( traverser ); - hash = hash * 31 + hash( filter ); - hashCode = hash; - } - - @Override - public boolean equals( Object obj ) - { - if ( obj == this ) - { - return true; - } - else if ( !( obj instanceof GraphKey ) ) - { - return false; - } - GraphKey that = (GraphKey) obj; - return artifact.equals( that.artifact ) && repositories.equals( that.repositories ) - && eq( selector, that.selector ) && eq( manager, that.manager ) && eq( traverser, that.traverser ) - && eq( filter, that.filter ); - } - - @Override - public int hashCode() - { - return hashCode; - } - - private static <T> boolean eq( T o1, T o2 ) - { - return ( o1 != null ) ? o1.equals( o2 ) : o2 == null; - } - - private static int hash( Object o ) - { - return ( o != null ) ? o.hashCode() : 0; - } - - } - -}