Cilia/Cilia Advanced/Admin Service Usage

From Wiki Adele Team
Jump to: navigation, search

Cilia Admin Service

Besides the usage of the builder pattern, it is possible to reconfigure mediation chains using CiliaAdminService

Retrieving the CiliaAdminService

Using the BundleContext

The BundleContext in OSGi allow us to perform several functions in an OSGi platform. In this case, it is used to retrieve a service.

import fr.liglab.adele.cilia.CiliaAdminService;
...
    //Retrieve it using FrameworkUtil, iPOJO or using the BundleActivator
    BundleContext bcontext;
...
    ServiceReference refs[] = bcontext.getServiceReference(CiliaAdminService.class.getName(), null);
    //Check if is not null
...
    CiliaAdminService admin = bcontext.getService(refs[0]); //There should be only one service CiliaAdminService. Not Checked
...
    //Use the service
...
    bcontext.ungetService(refs[0]);

Using iPOJO

Using iPOJO is easier to obtain the CiliaAdminService. Using annotations we do:

//For the iPOJO annotations
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Requires;
//For the CiliaService
import fr.liglab.adele.cilia.CiliaAdminService;

@Component(name="myCiliaManager")
@Instantiate(name="my-cilia-manager-0")
@Provides(specifications={MyCiliaManager.class})
public class MyCiliaManager {

  @Requires
  CiliaAdminService cadmin;
...

}

...

Other options

You can also retrieve the CiliaAdminService using other mechanism, for example using the ServiceTracker approach, BluePrint or DeclarativeService.

Manipulating mediation chains

The CiliaAdminService allows performing the following operations in mediation chains.

Method Return Parameters Description
Chain getChain(String id); Chain: The chain model object. id: The chain ID. Get the model of a current mediation chain.
void createEmptyChain(String id); NONE. id: The new chain ID. Creates an empty chain.
void createChain(String chain); NONE. chain: The chain in XML (as the one in a dscilia file) in an String object. Create a new mediation chain without starting it.
void loadChain(String url); NONE url: The url where the chain is located. Load a dscilia file located in the specified URL.
void deleteChain(String id); NONE id: The chain id to remove. Stop and remove a mediation chain.
void startChain(String id); NONE id: The chain id to initialize. Start a mediation chain.
void stopChain(String id); NONE id: The chain id to stop. Stop a mediation chain.
void copyComponent(String chainId, String source, String destination); NONE
  • chainId: The chain.
  • source: the configured mediator.
  • destination: The new mediator to add to the chain.
Create a new mediator component using the configuration of the source component.
void replaceComponent(String chainId, String source, String destination); NONE
  • chainId: The chain.
  • source: the old mediator to be replaced.
  • destination: The new mediator to replace.
Replace the bindings of the old mediator and .

Manipulating Mediation components

The CiliaAdminService allows performing the following operations to mediation components:

Method Return Parameters Description
MediatorComponent getComponent(String chainId, String componentId); MediatorComponent: the mediator component model object.
  • chainId: The chain ID.
  • componentId: the component ID.
Get the model of a mediator or adapter component.
Mediator getMediator(String chainId, String mediatorId); Mediator: the mediator component model object.
  • chainId: The chain ID.
  • mediatorId: the mediator ID.
Get the model of a mediator component.
Adapter getAdapter(String chainId, String adapterId); Adapter: the adapter component model object.
  • chainId: The chain ID.
  • adapterId: the adapter ID.
Get the model of an adapter component.
void createMediator(String chainId, String type, String id, Map<String, Object> properties); NONE
  • chainId: The chain ID.
  • type: the mediator type.
  • id: the new mediator ID.
  • properties: properties to configure the new mediator component.
Creates a new mediator component in the specified chain.
void createAdapter(String chainId, String type, String id, Map<String, Object> properties); NONE
  • chainId: The chain ID.
  • type: the adapter type.
  • id: the new adapter ID.
  • properties: properties to configure the new adapter component.
Creates a new adapter component in the specified chain.
void updateMediator(String chainId, String id, Map<String, Object> properties); NONE
  • chainId: The chain ID.
  • id: the ID of the mediator to reconfigure.
  • properties: properties to reconfigure the mediator component.
Reconfigure an existent mediator component.
void updateAdapter(String chainId, String id, Map<String, Object> properties); NONE
  • chainId: The chain ID.
  • id: the ID of the adapter to reconfigure.
  • properties: properties to reconfigure the adapter component.
Reconfigure an existent adapter component.
void deleteMediator(String chainId, String id); NONE
  • chainId: The chain ID.
  • id: the ID of the mediator to delete.
Remove an existent mediator component.
void deleteAdapter(String chainId, String id); NONE
  • chainId: The chain ID.
  • id: the ID of the component to delete.
Remove an existent adapter component.


Manipulating bindings

The CiliaAdminService allows performing the following binding operations.

Method Return Parameters Description
void createBinding(String chainId, String from, String to, String linker, Map<String, Object> properties); NONE.
  • id: The chain ID.
  • from: the deliver component and its port in the form id:port.
  • to: the receiver component and its port in the form id:port.
  • linker: the linker to use, null to use default linker (direct).
  • properties: properties to be used by the linker (e.g. hostname, port... for JMS server)
Link two mediation components.
void deleteBinding(String chainId, String from, String to); NONE.
  • id: The chain ID.
  • from: the deliver component and its port in the form id:port.
  • to: the receiver component and its port in the form id:port.
Remove a link between two mediation components.