tdiesler / fabric8poc

POC for the new Fabric8 API
Apache License 2.0
2 stars 5 forks source link

Define an entry level api for clients and internal use #9

Closed iocanel closed 10 years ago

iocanel commented 10 years ago

Currently we have things like the ProfileManager the ContainerManager etc, but I think that we should have an entry level api for clients and internal use.

The entry point can directly make use of ProfileManager and ContainerManager etc.

Obtaining the entry point

Internally can be done by service lookup.

Excternallyl it could look like:

FabricConnection fabric = new FabricConnection(url, username, password);

Playing with containers

List

fabric.container().list();

Create:

fabric.container().newContainer(ChildContainerProvider.class)
                           .id("mycontainer")
                           .parent("root")
                           .version("1.1")
                           .profile("myprofile")
                           .create();

Stop / Destroy a container

fabric.container().find("mycontainer").stop();
fabric.container().find("mycontainer").destroy();

Operate on multiple containers using Predicates (as used in guava and java8) :

fabric.container().find(new Predicate<Container>(){ 
    Boolean apply(Container cnt) {
        return cnt.getIdentity().startsWith("broker");
    }
}).stop();

Playing with Versions

List

fabric.version().list();

Create

fabric.version().newVersion().id("1.1.0").create()

Delete

fabric.version().find("1.1.0").delete()

List Profiles

fabric.version().find("1.1.0").profiles().list()

Playing with Profiles

Create

fabric.version().find("1.1.0").newProfile().id("myprofile")
        .addParent("profileA")
        .addConfigItem("my.pid", map)
        .create()
tdiesler commented 10 years ago

When used in container (where our 1st Level API is available) it would not add functionality - it may provide convenience for the expense of duplicating large parts of the API.

For remote access we currently work with Open MBeans, which indeed are not very convenient to work with. To work with a container, we currently can do

        ContainerManagement cntManagement = ManagementUtils.getMBeanProxy(mbeanServer, ContainerManagement.OBJECT_NAME, ContainerManagement.class);
        CompositeData cdata = cntManagement.getContainer(idA.getCanonicalForm());
        Container cntB = ContainerOpenType.getContainer(cdata);
        Assert.assertEquals(idA, cntB.getIdentity());
        Assert.assertEquals(cntA.getAttributes(), cntB.getAttributes());

I suggest to keep this proposal in mind and perhaps get it started as an additional project one day. In the foreseeable future I suggest to focus on 1st Level API, and a comprehensive set of MBeans that would need to be available to get something like this implemented anyway.

tdiesler commented 10 years ago

Deferred