create own data centers). What's Context and how does it correlate to
View (seems Context aims to provide the basic abstraction layer to the
whole cloud provider features).

As regards this: you're looking at a transitional phase, which unfortunately complicates things a bit ;-)

As described in the ContextBuilder Javadoc [1], there are basically two things you can work with in jclouds: a specific API, or a portable View. As explained in the Javadoc, the relationship can be one-to-many: some APIs support both blobstore as well as compute functionality, for example. But in most cases, the link is one-to-one.

When you use a context builder to get an *instance* of an API, it is wrapped in a context object that basically represents this instantiation. The "new style" is to use the ApiContext [2], but users will not often see that as the encouraged style is to use the ContextBuilder to go straight to the API object via ContextBuilder.buildApi [3]. Users can still get at the context object through ContextBuilder.build [4] if they really want to, though.

Which context a particular type of API should use is indicated by the ApiMetadata, by the way [5].

Now to Views. First, the views that a given API supports are also determined by the ApiMetadata [6, 7]. To get a view rather than an API object, users should call ContextBuilder.buildView [8], specifying the view type desired. Obviously, the system will complain if the view type is not one of the ones declared in the metadata.

Because views provide an abstraction layer, there is sometimes the need to get back to the underlying API in order to do API- or provider-specific stuff (your choice: if you know you're talking at AWS EC2 through a ComputeServiceContext, you can decide to get just the generic EC2Api, or the provider-specific AWSEC2Api). This is achieved using View.unwrapApi [9] to get the API object, or View.unwrap if you really want the context object (so View.unwrapApi and View.unwrap basically mirror ContextBuilder.buildApi vs. ContextBuilder.build).

If all this was clear already, great, and apologies for the repetition. Otherwise, hope this helps!

ap

[1] http://javadocs.jclouds.cloudbees.net/org/jclouds/ContextBuilder.html
[2] http://javadocs.jclouds.cloudbees.net/org/jclouds/rest/ApiContext.html
[3] http://javadocs.jclouds.cloudbees.net/org/jclouds/ContextBuilder.html#buildApi(java.lang.Class) [4] http://javadocs.jclouds.cloudbees.net/org/jclouds/ContextBuilder.html#build(com.google.common.reflect.TypeToken) [5] http://javadocs.jclouds.cloudbees.net/org/jclouds/apis/ApiMetadata.html#getContext() [6] http://javadocs.jclouds.cloudbees.net/org/jclouds/apis/ApiMetadata.html#getViews() [7] https://github.com/jclouds/jclouds/blob/master/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java#L87 [8] http://javadocs.jclouds.cloudbees.net/org/jclouds/ContextBuilder.html#buildView(java.lang.Class) [9] http://javadocs.jclouds.cloudbees.net/org/jclouds/View.html#unwrapApi(java.lang.Class) [10] http://javadocs.jclouds.cloudbees.net/org/jclouds/View.html#unwrap(com.google.common.reflect.TypeToken)

Reply via email to