tuscany-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Sebastien Delfino <jsdelf...@apache.org>
Subject Re: Porting Tuscany C++ to C++11 and some code cleanup
Date Sun, 30 Dec 2012 02:20:48 GMT
Hi all,


I had a few more offline Q&A exchanges with Thomas, and thought it'd be
useful to share a summary here:


Q: In the C++ trunk, is DataObject now replaced by tuscany::value
and tuscany::list?


A: Yes


Q: Why are most files in kernel/ C++ header files?


A: They’re C++ templates that you can just include, similar to what other
C++ frameworks like boost do for example.



Q: In M3 a C++ component implementation looked like this:

virtual commonj::sdo::DataObjectPtr /*AccountReport*/
getAccountReport(const string customerID) {

  ...

}


What does a C++ component implementation look like with the code in trunk?


A: With trunk, a C++ component implementation must contain this function:

const value apply(const list<value>& params) {

  // implement your own dispatch code here, for example

  // if first element of params is “getAccountReport” then

  //   call your own getAccountReport function, which could look like

  //   const value getAccountReport(const value customerID)

}


The apply() function is a component invocation dispatch mechanism. It
shouldn’t be too difficult to provide a tool to generate the body of
apply() from a WSDL+XSD to lift the programming model to a level of
abstraction close to M3.


I was initially planning to do that but then found that writing apply() by
hand was good enough for me. I'm not sure about the value of requiring an
app developer to write a WSDL+XSD, use a tool to generate code, link with
that code, understand the additional moving parts and data conversion etc,
just to avoid having to write that apply() function... but if somebody
wants to do it, I can try to help integrate that support.


Q: Is the runtime implemented as Apache HTTPD modules?


A: Yes, the runtime plugs into Apache HTTPD as a set of HTTPD modules but
it should be possible to integrate with other servers too.


Q: Are C++ component implementations packaged as dynamic libraries?


A: Yes, the runtime also supports other component implementation
technologies and languages incl. Python, OpenCL C99 (for GPU programming),
Java (experimental) and a subset of MIT Scheme (useful for self-contained
testing).


Q: Which communication protocols are supported?


A: REST Web services using XML, ATOM, RSS or JSON over HTTP, and JSON-RPC.
Communication with SOAP services is supported using a configurable SCA
component wrapping Axis2/C in components/webservice/.



Q: Which versions of SCA are implemented?


M3 implements a subset of the OSOA (pre-OASIS) SCA assembly spec and a
subset of the corresponding SCA C++ component implementation spec.


Trunk implements a subset of the OASIS SCA assembly spec. The C++ component
implementation model is different from the spec, but like I said above it
shouldn't be too difficult to generate C++ implementations as per the spec
on top of the current dispatch mechanism.



Hope that helps.


- Jean-Sebastien

On Wed, Dec 19, 2012 at 1:00 PM, Thomas Gentsch <tg@e-tge.de> wrote:

>
> Hi JS,
>
> I'm still looking through the docs, code, etc. I can find.
>
> One thing I discovered: it does not look to me as if SDO support has
> been removed from Java SCA, at least I found some related activity in
> 2011:
>
> http://www.mail-archive.com/user@tuscany.apache.org/msg03435.html
>
> http://www.mail-archive.com/dev@tuscany.apache.org/msg17116.html
>
> (the latter is quite funny because I actually submitted this against C++
> but seems as if the same problem occurred with Java? :-)
>
> More later ... :-)
> Rgds,
>   tge
>
> On Thu, 2012-12-06 at 01:04 -0800, Jean-Sebastien Delfino wrote:
> > On Fri, Nov 30, 2012 at 9:43 AM, Thomas Gentsch <tg@e-tge.de> wrote:
> >
> >         OK, many thx for this info!
> >
> >         Regarding SDO - yes, I noticed that there was not a lot of
> >         activity
> >         during the last years.
> >         Hello out there: Is there anybody else still using this?
> >
> >         Rgd SDO as SCA-internal data-flow mechanism - what is being
> >         used now?
> >         I know about libxml2 (actually its being used in SCA/SDO :-),
> >         nothing
> >         yet about JSON, will read.
> >
> >
> > Hi Thomas,
> >
> >
> > Here's a short overview of what's used now.
> >
> >
> > Data read/write functions are provided for XML (using Libxml2 [1]),
> > JSON (using Mozilla SpiderMonkey but I've started to migrate to
> > Jansson [2]), and Lisp/Scheme S-expressions [3].
> >
> >
> > Here's how to read XML in a C++ component:
> > <customer
> > age="21"><name>johndoe</name><phone>(650)123-4567</phone><phone>
> (415)765-4321</phone></customer>
> >
> >
> > // A list of strings containing the above XML doc, obtained from an
> > input stream for example
> > const list<string> ls = ...;
> >
> >
> > // Read the XML doc (the failable<...> result type helps encapsulate
> > error handling)
> > // See below for a description of the 'value' data type
> > const failable<value> fe = xml::readElements(ls);
> >
> >
> > // Assuming no failure, get and print the result
> > const value e = content(fe);
> > cout << e << endl;
> >
> >
> > The result is a list like follows (using the S-expression syntax here
> > for conciseness: element, customer, attribute, age are symbols, 21 is
> > a number, "johndoe" is a string, (x y) is a list of x, y):
> > ((element customer (attribute age "21") (element name "johndoe")
> > (element phone "(650)123-4567") (element phone "(415)765-4321")))
> >
> >
> > The runtime is schema-less. You do not need an XML schema to
> > read/write any XML.
> >
> >
> > If you don't care about the XML element vs attribute representation
> > you can strip it like this:
> > const value v = elementsToValues(e);
> > to get this:
> > ((customer (@age "21") (name "johndoe") (phone ("(650)123-4567"
> > "(415)765-4321"))))
> >
> >
> > Note the @age attribute name, which follows the Badgerfish [4]
> > convention often used to name XML attributes in JSON documents for
> > example.
> >
> > The same data can be constructed and represented in the various
> > programming languages supported by the runtime, as follows:
> >
> >
> > C++:
> > list<value>(list<value>("customer", list<value>("@age", 21),
> > list<value>("name", string("johndoe")), list<value>("phone",
> > list<value>("(650)123-4567", "(415)765-4321"))));
> > using the following C++ types:
> > - string, similar to std::string but lighter and faster for small
> > strings, with builtin conversions from/to native char*;
> > - list<T>, a lightweight list/lazy-list type with useful
> > Lisp/Scheme-like [5] functions incl. cons, car, cdr, map, filter,
> > reduce, assoc, etc;
> > - lambda<R(P...)>, a function type similar to std::function but
> > lighter and faster;
> > - value, a dynamic value type (type can be number, boolean, symbol,
> > string, list<value>, lambda<value(list<value>)>, value*) with
builtin
> > conversions from/to native double, bool, char*, C++ lambdas and
> > pointers.
> >
> >
> > Python:
> > ((customer, ("'@age" 21), ("'name", "johndoe") (phone,
> > ("(650)123-4567" "(415)765-4321"))),)
> > using Python tuples [6] and native Python data types for strings,
> > numbers and booleans.
> >
> >
> > JavaScript / JSON:
> >
> {"customer":{"@age":"21","name":"johndoe","phone":["(650)123-4567","(415)765-4321"]}}
> > using JSON arrays and native Javascript types.
> >
> >
> > Scheme:
> > ((customer (@age "21") (name "johndoe") (phone ("(650)123-4567"
> > "(415)765-4321"))))
> > just an S-expression.
> >
> >
> > Java (there's experimental support for running Java components on the
> > C++ runtime):
> > list(list("'customer", list("'@age", 21), list("'name", "johndoe"),
> > list("'phone", list("(650)123-4567", "(415)765-4321"))));
> > using java.lang.Iterable [7] for lists and native Java data types for
> > strings, numbers and booleans (the list(...) function is a static
> > 'builder' function returning a java.lang.Iterable<?>.)
> >
> >
> > To summarize: fast and schemaless support for XML, JSON and
> > S-expressions, with lightweight representation using lists and simple
> > types in the supported programming languages.
> >
> >
> > Hope that helps.
> >
> >
> > [1] http://www.xmlsoft.org
> > [2] http://www.digip.org/jansson/
> > [3] http://en.wikipedia.org/wiki/S-expression
> > [4] http://badgerfish.ning.com
> > [5]
> http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Lists.html#Lists
> > [6]
> http://docs.python.org/2/tutorial/datastructures.html#tuples-and-sequences
> > [7] http://docs.oracle.com/javase/6/docs/api/java/lang/Iterable.html
> >
> >
> > - Jean-Sebastien
>
>
>

Mime
View raw message