When you need to introduce a custom repository type, you should implement the Repository interface. The following example extends the HostedRepository class and adds a repository type with the path prefix "sample".
Example 18.7. Creating a Custom Repository Type Interface
package org.sample.plugin;
import org.sonatype.nexus.plugins.RepositoryType;
import org.sonatype.nexus.proxy.repository.HostedRepository;
@RepositoryType( pathPrefix="sample" )
public interface SampleRepository
extends HostedRepository
{
String boo();
}
If you want to implement a custom repository type, you should reference the nexus-proxy module as dependency which contains the AbstractRepository class which is a useful superclass for repository implementations. To implement the SampleRepository interface, you can then extend the AbstractRepository as shown in the following example.
Example 18.8. Creating a Custom Repository Type Implementation
package org.sample.plugin;
public class DefaultSampleRepository
extends AbstractRepository
implements SampleRepository
{
.... implement it
}
Your newly introduced repository type will appear under http://localhost:8081/nexus/content/sample/.