10.12.2. Using connection schemes to regulate accessibility

If you need more control about the way generated artifacts can interact with other generated artifacts we need to use connection schemes in combination with artifact classes.

// main file components.arc
class Layered
{
    interface Service, Controller, DataAccess, Model, Util
    connector Service, Controller, DataAccess, Model, Util
}

connection-scheme C2C : Layered to Layered
{
    connect Service to target.Service, target.Controller, target.Model, target.Util
    connect Controller to target.Controller, target.Model, target.Util
    connect DataAccess to target.DataAccess, target.Model, target.Util
    connect Model to target.Model, target.Util
    connect Util to target.Util
}

template Components : Layered
{
    include "**/com/hello2morrow/(*)/**"
    exclude "**/com/hello2morrow/framework/**"

    artifact capitalize($1)+"Component"
    {
        apply "layering"
    }
    connect all using C2C
}
// ...
        

Now you have total control about the way components access each other. The connection scheme determines for each of the layers which layers can be used in the target artifact. The "connect all" statement declares the connection scheme to be used. The scheme has to connect an artifact class to itself ("Layered" to "Layered" in this example) and prototype artifact must be of the matching class. In our example that happens implicitly by using the class on the template.