Skip to content
John Casey edited this page Feb 13, 2014 · 2 revisions

Autoprox allows you to point to a remove Maven repository manager or other site hosting multiple Maven repositories, and automatically create Repository entries to those remote repositories on demand, using a template configuration that specifies content expiration, connection options, etc.

Configuration

First, to enable autoprox, add the following to your /etc/aprox/conf.d directory:

/etc/aprox/conf.d/autoprox.conf:
--------------------------------

[autoprox]
enabled=true
deployEnabled=true

This simply turns on autoprox support. You still need to configure the templates for the new Repository and Group instances it will create. To do this, edit /etc/aprox/autoprox.json:

/etc/aprox/autoprox.json:
-------------------------

{
  "repo": {
      "url":"http://aprox.remote-site.com/aprox/api/1.0/repository/${name}/",
      "timeout_seconds":30,
      "proxy_host":"localhost",
      "proxy_port":3128,
      "is_passthrough":false,
      "cache_timeout_seconds":7200,
      "name":"${name}",
      "key":"repository:${name}"
    },
    "deploy": {
      "allow_snapshots":true,
      "allow_releases":true,
      "snapshotTimeoutSeconds":86400,
      "name":"${name}",
      "key":"deploy_point:${name}"
    },
    "group": {
      "constituents":[
        "${deploy}",
        "${repository}"
      ],
      "name":"${name}",
      "key":"group:${name}"
    }
}

You'll note that the remote repository URL pattern is in the Repository part of the template, using the ${name} expression as a placeholder. Actually, ${name} is sprinkled liberally throughout the template, since it's the main variable autoprox has to work with.

Second, notice that we've included a template section for a DeployPoint (and enabled its use above via deployEnabled=true in the autoprox.conf file). That will be used when Autoprox creates a new Group definition on demand.

Finally, notice the constituents field of the Group template section. This contains an ordered list of other stores that will become members of the new Group. Currently, we have placeholder expressions for the Repository and DeployPoint instances which will be created on-demand. However, in principle, we could include any other pre-existing store (Group, Repository, or DeployPoint) we have in the system as well.

Interactions with Other Add-Ons

If you use DotMaven in conjunction with Autoprox, accessing the settings.xml for a repository, group, or deploy-point that doesn't exist yet will cause it to be created on the fly by Autoprox.

Implementation Notes

In terms of implmentation, Autoprox is a JEE @Decorator around the StoreDataManager class. When getRepository or getGroup is called, Autoprox intercepts the result. If the result is null (missing), Autoprox will issue a HEAD request to the configured remote server looking to see whether it contains a repository by that name. If it does, Autoprox creates a proxy instance using its template configuration and passes the resulting Repository or Group back to the caller.

If the request is for a Group, Autoprox's template support allows creation of accompanying DeployPoint (for deploying back to that group) and insertion of other pre-existing Repositories or Groups into the new Group's membership.

Clone this wiki locally