Using Flavors

Brokers are created merging components assemblies from different layers. The layers used to create a broker are denominated a flavor. The flavor used in the creation of a broker is provided by field flavor of the configuration table passed as argument of function oil.init(config). The value of this field must be a string with the names of the different layers separated by semicolons (;), like in the example below:

broker = oil.init{
  flavor = "intercepted;cooperative;corba;base"
}

The order the layer names in the flavor string is important because layers are created from left to right. Therefore, the components of left-most layers are created first and shall not be replaced by components from other layers. Generally, more specific layers must appear first. In particular, extensions layers must come before the layer they extend. In the example above, the extension layer intercepted comes first then the extended layer corba. The same is true for extension layer typed and extended layer base. Theoretically, complementary layers can come in any order relative to one another. However, it is a good practice to put RMI layers first than the core layer because the RMI layer might extend the core layer in some way. See section Architectural Layers for the list of layers defined by OiL.

The flavor is a feature used to help the creation of brokers from combination of assemblies defined as architectural layers. For a description about the definition of layers see section Defining Layers. However, you do not have to define a new layer to can create different assemblies. Moreover, you can provide a flavor that completes a partial assembly you provide to function oil.init. As an example, consider the following code that provides RMI components and completes the broker assembly with components from layer base.

-- create assembly
broker = oil.init{
  flavor = "cooperative;base",
  OperationRequester = MyProtocolRequester(),
  ObjectReferrer     = MyProtocolReferrer(),
  RequestListener    = MyProtocolListener(),
}
-- make connections from your components
-- to components from layer 'base'
broker.OperationRequester.sockets = broker.BasicSystem.sockets
broker.RequestListener.sockets    = broker.BasicSystem.sockets

Copyright (C) 2004-2008 Tecgraf, PUC-Rio

This project is currently being maintained by Tecgraf at PUC-Rio.