A small example model to describe components of an application and which services this components provides, only example stuff not a good model anyway.
Here a model instance with plain EMF Java code:
ComponentFactory factory = ComponentFactory.eINSTANCE;
Interface orderServiceInterface = factory.createInterface();
orderServiceInterface.setName("dsl.OrderService");
Port orderServicePort = factory.createPort();
orderServicePort.setProvides(orderServiceInterface);
Component order = factory.createComponent();
order.setName("order");
order.getPorts().add(orderServicePort);
Interface loggerServiceInterface = factory.createInterface();
loggerServiceInterface.setName("dsl.LoggerService");
Port loggerServicePort = factory.createPort();
loggerServicePort.setProvides(loggerServiceInterface);
Component logger = factory.createComponent();
logger.setName("logger");
logger.getPorts().add(loggerServicePort);
Application shop = factory.createApplication();
shop.setName("shop");
shop.getComponents().add(order);
shop.getComponents().add(logger);
And here the same model instance created with a Java internal DSL (Gof Builder Pattern):
Application shop = ApplicationBuilder.create("shop", new Components() {{
component("order", new Ports() {{
provides( OrderService.class );
}});
component("logger", new Ports() {{
provides( LoggerService.class );
}});
}});
Links:
In one of my next posts I will show the results of a Eclipse xText generated text DSL for the example model.
