The Embryo Grid is a lightweight Java container for component based, distributed computing. To achieve this, it combines several techniques:
- Runtime Interface implementation
- Inversion of control
- Metadata annotations
- Binding using dependancy graph search
- A standard abstract Model for graph traversal.
The projects aims to support stateless, immutable or at least components with a clean and deterministic state. It is therefore inherently suited to grid / cloud / distributed applications.
The component paradigm can be thought of as "Inversion of Inversion of Control". IOC configures objects through method and field access. "Inverted IOC" allows the POJOs to make calls ("no, I will call you") against Interfaces which are implemented by the container. The advantages of this are:
- Reduces unnecessary configuration.
- Reduced boiler plate (only call what you need)
- "Late as possible" binding and resolution
- Clean distinction of the "concrete functional code" and "external dependencies". This encourages the component mindset and interface design.
Here are some test cases, which are working right now, that demonstrate the theory...
In this simple example, an Airline is registered with Embryo and an Aircraft is found against it...
EmbryoGrid embryo = new EmbryoGrid();
Airline airline = new Airline();
airline.addAircraft(new Aircraft("Embryo Airlines"));
embryo.addObject(airline);
Airline result = (Airline)embryo.find(Aircraft.class, "Embryo Airlines");You can also write arbitrary interfaces which Embryo will implement at runtime.
public interface Finder {
public Airline findVessel(String name);
}Airline airline = new Airline();
airline.addAircraft(new Aircraft("VH123"));
embryo.addObject(airline);
Finder finder = (Finder)embryo.implement(Finder.class);
Aircraft aircraft = finder.findVessel("VH123");This is a simple example. The real benefit comes as the model becomes increasing complex. In this example, a MaintenanceScheduler creates the Maintenance object through an indirect call to airline.getAircraft().
embryo.addObject(new MaintenanceScheduler());
Finder finder = (Finder)embryo.implement(Finder.class);
Maintenance maintenance = finder.getMaintenance("VH123");This is equivalent to..
Maintenance maintenance = MaintenanceScheduler.getMaintenanceSchedule( airline.getVessel("VH123"));Embryo Grid contains a persistence layer which connects to JDBC Datasources. It reflects schema information from the database and generates and manages SQL at a relational level. It is not an object-relational mapper in the same way as say Hibernate (in that you don't code directly against POJOs) and has less of it's complexity.
create table airline (
code CHAR(2) NOT NULL,
name VARCHAR(32) NOT NULL,
PRIMARY KEY ( code )
);embryo.addDatabase(new Database("jdbc/airline");
Finder finder = (Finder)embryo.implement(Finder.class);
Airline airline = finder.findAirline("AA");Now finally, we move on from the test cases and write our component..
public class AirlineComponent {
public Airline doAirlineShenanigans(FindAirline finder) {
Airline airline = finder.findAirline("CA");
return airline;
}
}In the example below, a Timer component fires a Date object every second. This Date is received by the Clock Face Renderer which in turn generates an Image. This is tracked and displayed on screen.
The code base contains many APIs which can be used independently of the container:
- Runtime Interface implementation
- Abstract persistence including Object, File and Reflective Database persistence.
- XML DOM to Model mapping.
- Bean reflection to Model mapping.
- 3D Object Model Visualization.
- Reflective Web Interface.
- Color Terminal Console.
- IO Stream Utilities including abstract "Stream Sources".
- Network handlers.
- Class Reflection Utilities.
- Runtime Annotations for describing programatic patterns for class methods.
- Huge persisted and special purpose Collections API.
- Imaging utilities.
- Resource mapping into class paths, file systems and custom URL implementations.
- Cluster-able communications and archiving protocol.
- Efficient HTTP Multipart (File Upload) implementation using Stream Sources.
- Various high quality utility classes such as stream, reflection, binary, math, string and build time tools.
- Single Page Overview Doclet.