Advise on @Annotation & Reflection !!

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Advise on @Annotation & Reflection !!

Charles Moulliard
Hi,

I'm currently working on a small prototype to bind CSV data to POJOs using annotation. Camel through its component file:/// and dataformat will provide me the infrastructure that I need to parse the file content, extract each CSV record and return an array of String for each record found in a file.

Remark : A string contains the list of CSV values separated by a comma.

In order to bind the CSV values to my POJOs, I have created two annotations :

@Retention(RetentionPolicy.RUNTIME)
public @interface CSVRecord {
       
        String name(); --> root name of the class handling the content of a CSV record
        String separator(); --> separator used to separate CSV data

}

@Retention(RetentionPolicy.RUNTIME)
public @interface CSVField {
       
        int pos(); --> key indicating the position of the CSV data in the CSV record
        String name(); --> key assigned to the column name of a CSV field
       
}

Here is an example of a POJO (= Model) using these annotations :

@CSVRecord(separator =",", name = "OrderModel")
public class OrderModel {
       
        @CSVField(name = "Number", pos = 0)
        String orderNr;
       
        @CSVField(name = "Client Number", pos = 1)
        String clientNr;
       
        @CSVField(name = "ISIN", pos = 2)
        String ISIN_Code;
       
        @CSVField(name = "Name", pos = 3)
        String Instrument_Name;
       
        @CSVField(name = "Quantity", pos = 4)
        String Quantity;
       
        @CSVField(name = "Cur", pos = 5)
        String Currency;
       


Here is my question ?

Using reflection (or project ASM in an next step), I'm able at the launch of the application to discover all the fields annotated and their parameters. With this information, I'm able to set the field value with the CSV data using the following syntax :


String[] result = record.split(csv.retrieveSeparator()); --> to retrieve the separator assigned to my CSVRecord
....
field.set(order, result[csvField.pos()]);

A CSV record can contain one or several classes like :
- Order (with reference to a client, instrument, billing, ...),
- Client,
- Instrument,
- Billing
where annotations have been defined for the fields corresponding to what we have in CSV record.

Remark : In this first prototype implementation, I will only support mapping 1-1 between objects

Questions :

1) What is the best to strategy to recursively find all the annotated fields defined within the different classes ?

2) Should we have to create a kind of java tree objects to store the annotated Fields with existing relation between the different classes (= model) ?

ex : RootNode = Order, value = list of annotatedFields, childNode = Client, childNode = Instrument, ...

3) Is there performant java algorythm to read the Java Tree in order to find the annotated field corresponding to a key no matter if the field is defined in the parent node or any its children ?

Regards,


Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2008/12/23 cmoulliard <[hidden email]>:

>
> Hi,
>
> I'm currently working on a small prototype to bind CSV data to POJOs using
> annotation. Camel through its component file:/// and dataformat will provide
> me the infrastructure that I need to parse the file content, extract each
> CSV record and return an array of String for each record found in a file.
>
> Remark : A string contains the list of CSV values separated by a comma.
>
> In order to bind the CSV values to my POJOs, I have created two annotations
> :
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVRecord {
>
>        String name(); --> root name of the class handling the content of a CSV
> record
>        String separator(); --> separator used to separate CSV data
>
> }
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVField {
>
>        int pos(); --> key indicating the position of the CSV data in the CSV
> record
>        String name(); --> key assigned to the column name of a CSV field
>
> }
>
> Here is an example of a POJO (= Model) using these annotations :
>
> @CSVRecord(separator =",", name = "OrderModel")
> public class OrderModel {
>
>        @CSVField(name = "Number", pos = 0)
>        String orderNr;
>
>        @CSVField(name = "Client Number", pos = 1)
>        String clientNr;
>
>        @CSVField(name = "ISIN", pos = 2)
>        String ISIN_Code;
>
>        @CSVField(name = "Name", pos = 3)
>        String Instrument_Name;
>
>        @CSVField(name = "Quantity", pos = 4)
>        String Quantity;
>
>        @CSVField(name = "Cur", pos = 5)
>        String Currency;

Minor point - but you could use more defaults in that if you like.
e.g. default "," if its not specified and maybe default the name to be
the name of the field if its not specified (maybe even default the
position?)


> Here is my question ?
>
> Using reflection (or project ASM in an next step), I'm able at the launch of
> the application to discover all the fields annotated and their parameters.
> With this information, I'm able to set the field value with the CSV data
> using the following syntax :
>
>
> String[] result = record.split(csv.retrieveSeparator()); --> to retrieve the
> separator assigned to my CSVRecord
> ....
> field.set(order, result[csvField.pos()]);
>
> A CSV record can contain one or several classes like :
> - Order (with reference to a client, instrument, billing, ...),
> - Client,
> - Instrument,
> - Billing
> where annotations have been defined for the fields corresponding to what we
> have in CSV record.
>
> Remark : In this first prototype implementation, I will only support mapping
> 1-1 between objects
>
> Questions :
>
> 1) What is the best to strategy to recursively find all the annotated fields
> defined within the different classes ?

Probably keeping a cache of class -> metadata rather like we do with
the annotation metadata for bean binding (see BeanInfo /
MethodInfoCache in the org.apache.camel.component.bean package).


> 2) Should we have to create a kind of java tree objects to store the
> annotated Fields with existing relation between the different classes (=
> model) ?
>
> ex : RootNode = Order, value = list of annotatedFields, childNode = Client,
> childNode = Instrument, ...
>
> 3) Is there performant java algorythm to read the Java Tree in order to find
> the annotated field corresponding to a key no matter if the field is defined
> in the parent node or any its children ?

Not totally sure I follow this last bit. Are you talking about nested
CSVs? Or is it you flatten a master/detail type record into a single
row of the csv? The internals of JPA providers or JAXB could be useful
maybe (though possibly too complex :).

Given the flat nature of a CSV its gonna be hard walking an arbitrary
object graph and mapping it to a row; but I guess for 1-1
relationships you could bind nested fields (e.g. fields of Currency in
your example) as optional columns in the parent object's row. In this
special case though, just walking the field types (for non-primitive
types) would do the trick I think? You'd probably only be able to walk
one or two levels deep - and just keep track of types you've already
walked maybe?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard

James.Strachan wrote
2008/12/23 cmoulliard <cmoulliard@gmail.com>:
>
> Hi,
>
> I'm currently working on a small prototype to bind CSV data to POJOs using
> annotation. Camel through its component file:/// and dataformat will provide
> me the infrastructure that I need to parse the file content, extract each
> CSV record and return an array of String for each record found in a file.
>
> Remark : A string contains the list of CSV values separated by a comma.
>
> In order to bind the CSV values to my POJOs, I have created two annotations
> :
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVRecord {
>
>        String name(); --> root name of the class handling the content of a CSV
> record
>        String separator(); --> separator used to separate CSV data
>
> }
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVField {
>
>        int pos(); --> key indicating the position of the CSV data in the CSV
> record
>        String name(); --> key assigned to the column name of a CSV field
>
> }
>
> Here is an example of a POJO (= Model) using these annotations :
>
> @CSVRecord(separator =",", name = "OrderModel")
> public class OrderModel {
>
>        @CSVField(name = "Number", pos = 0)
>        String orderNr;
>
>        @CSVField(name = "Client Number", pos = 1)
>        String clientNr;
>
>        @CSVField(name = "ISIN", pos = 2)
>        String ISIN_Code;
>
>        @CSVField(name = "Name", pos = 3)
>        String Instrument_Name;
>
>        @CSVField(name = "Quantity", pos = 4)
>        String Quantity;
>
>        @CSVField(name = "Cur", pos = 5)
>        String Currency;

Minor point - but you could use more defaults in that if you like.
e.g. default "," if its not specified and maybe default the name to be
the name of the field if its not specified (maybe even default the
position?)

>> OK. I will check that.


> Here is my question ?
>
> Using reflection (or project ASM in an next step), I'm able at the launch of
> the application to discover all the fields annotated and their parameters.
> With this information, I'm able to set the field value with the CSV data
> using the following syntax :
>
>
> String[] result = record.split(csv.retrieveSeparator()); --> to retrieve the
> separator assigned to my CSVRecord
> ....
> field.set(order, result[csvField.pos()]);
>
> A CSV record can contain one or several classes like :
> - Order (with reference to a client, instrument, billing, ...),
> - Client,
> - Instrument,
> - Billing
> where annotations have been defined for the fields corresponding to what we
> have in CSV record.
>
> Remark : In this first prototype implementation, I will only support mapping
> 1-1 between objects
>
> Questions :
>
> 1) What is the best to strategy to recursively find all the annotated fields
> defined within the different classes ?

Probably keeping a cache of class -> metadata rather like we do with
the annotation metadata for bean binding (see BeanInfo /
MethodInfoCache in the org.apache.camel.component.bean package).

>> OK. I will check Camel code.


> 2) Should we have to create a kind of java tree objects to store the
> annotated Fields with existing relation between the different classes (=
> model) ?
>
> ex : RootNode = Order, value = list of annotatedFields, childNode = Client,
> childNode = Instrument, ...
>
> 3) Is there performant java algorythm to read the Java Tree in order to find
> the annotated field corresponding to a key no matter if the field is defined
> in the parent node or any its children ?

Not totally sure I follow this last bit. Are you talking about nested
CSVs? Or is it you flatten a master/detail type record into a single
row of the csv?

>> Yes except that we only have a relation 1-1 between the parent class and all these children.

The internals of JPA providers or JAXB could be useful
maybe (though possibly too complex :).

>> For sure. I hope that in the future a JCP project will be created to handle binding of non XML data (JAnXB) ;-)

Given the flat nature of a CSV its gonna be hard walking an arbitrary
object graph and mapping it to a row; but I guess for 1-1
relationships you could bind nested fields (e.g. fields of Currency in
your example) as optional columns in the parent object's row. In this
special case though, just walking the field types (for non-primitive
types) would do the trick I think? You'd probably only be able to walk
one or two levels deep - and just keep track of types you've already
walked maybe?

>> What do you mean by optional columns in the parent object ? Can you provide me an example James ?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2008/12/23 cmoulliard <[hidden email]>:

>
>
>
> James.Strachan wrote:
>>
>> 2008/12/23 cmoulliard <[hidden email]>:
>>>
>>> Hi,
>>>
>>> I'm currently working on a small prototype to bind CSV data to POJOs
>>> using
>>> annotation. Camel through its component file:/// and dataformat will
>>> provide
>>> me the infrastructure that I need to parse the file content, extract each
>>> CSV record and return an array of String for each record found in a file.
>>>
>>> Remark : A string contains the list of CSV values separated by a comma.
>>>
>>> In order to bind the CSV values to my POJOs, I have created two
>>> annotations
>>> :
>>>
>>> @Retention(RetentionPolicy.RUNTIME)
>>> public @interface CSVRecord {
>>>
>>>        String name(); --> root name of the class handling the content of
>>> a CSV
>>> record
>>>        String separator(); --> separator used to separate CSV data
>>>
>>> }
>>>
>>> @Retention(RetentionPolicy.RUNTIME)
>>> public @interface CSVField {
>>>
>>>        int pos(); --> key indicating the position of the CSV data in the
>>> CSV
>>> record
>>>        String name(); --> key assigned to the column name of a CSV field
>>>
>>> }
>>>
>>> Here is an example of a POJO (= Model) using these annotations :
>>>
>>> @CSVRecord(separator =",", name = "OrderModel")
>>> public class OrderModel {
>>>
>>>        @CSVField(name = "Number", pos = 0)
>>>        String orderNr;
>>>
>>>        @CSVField(name = "Client Number", pos = 1)
>>>        String clientNr;
>>>
>>>        @CSVField(name = "ISIN", pos = 2)
>>>        String ISIN_Code;
>>>
>>>        @CSVField(name = "Name", pos = 3)
>>>        String Instrument_Name;
>>>
>>>        @CSVField(name = "Quantity", pos = 4)
>>>        String Quantity;
>>>
>>>        @CSVField(name = "Cur", pos = 5)
>>>        String Currency;
>>
>> Minor point - but you could use more defaults in that if you like.
>> e.g. default "," if its not specified and maybe default the name to be
>> the name of the field if its not specified (maybe even default the
>> position?)
>>
>>>> OK. I will check that.
>>
>>
>>> Here is my question ?
>>>
>>> Using reflection (or project ASM in an next step), I'm able at the launch
>>> of
>>> the application to discover all the fields annotated and their
>>> parameters.
>>> With this information, I'm able to set the field value with the CSV data
>>> using the following syntax :
>>>
>>>
>>> String[] result = record.split(csv.retrieveSeparator()); --> to retrieve
>>> the
>>> separator assigned to my CSVRecord
>>> ....
>>> field.set(order, result[csvField.pos()]);
>>>
>>> A CSV record can contain one or several classes like :
>>> - Order (with reference to a client, instrument, billing, ...),
>>> - Client,
>>> - Instrument,
>>> - Billing
>>> where annotations have been defined for the fields corresponding to what
>>> we
>>> have in CSV record.
>>>
>>> Remark : In this first prototype implementation, I will only support
>>> mapping
>>> 1-1 between objects
>>>
>>> Questions :
>>>
>>> 1) What is the best to strategy to recursively find all the annotated
>>> fields
>>> defined within the different classes ?
>>
>> Probably keeping a cache of class -> metadata rather like we do with
>> the annotation metadata for bean binding (see BeanInfo /
>> MethodInfoCache in the org.apache.camel.component.bean package).
>>
>>>> OK. I will check Camel code.
>>
>>
>>> 2) Should we have to create a kind of java tree objects to store the
>>> annotated Fields with existing relation between the different classes (=
>>> model) ?
>>>
>>> ex : RootNode = Order, value = list of annotatedFields, childNode =
>>> Client,
>>> childNode = Instrument, ...
>>>
>>> 3) Is there performant java algorythm to read the Java Tree in order to
>>> find
>>> the annotated field corresponding to a key no matter if the field is
>>> defined
>>> in the parent node or any its children ?
>>
>> Not totally sure I follow this last bit. Are you talking about nested
>> CSVs? Or is it you flatten a master/detail type record into a single
>> row of the csv?
>>
>>>> Yes except that we only have a relation 1-1 between the parent class and
>>>> all these children.
>>
>> The internals of JPA providers or JAXB could be useful
>> maybe (though possibly too complex :).
>>
>>>> For sure. I hope that in the future a JCP project will be created to
>>>> handle binding of non XML data (JAnXB) ;-)
>>
>> Given the flat nature of a CSV its gonna be hard walking an arbitrary
>> object graph and mapping it to a row; but I guess for 1-1
>> relationships you could bind nested fields (e.g. fields of Currency in
>> your example) as optional columns in the parent object's row. In this
>> special case though, just walking the field types (for non-primitive
>> types) would do the trick I think? You'd probably only be able to walk
>> one or two levels deep - and just keep track of types you've already
>> walked maybe?
>>
>>>> What do you mean by optional columns in the parent object ? Can you
>>>> provide me an example James ?

By optional I just meant its hard to know how deep a user may/must go.
But since each field (however deeply nested) is gonna have a single
column index, I guess the whole idea of optional columns is bogus :)

I guess we just need to sort things correctly in a kinda priority
order. e.g. if we've class A which has a field of type B which has a
field of type C we'd put the primitive fields of A first, then
primitive types of B then primitive types of C etc.

BTW fixing the column index on an annotation is a good thing (its like
the thing which makes Protocol Buffers from google so cool) - allowing
you to refactor your code and still be able to read CSVs.

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
In reply to this post by jstrachan
I have started to understand how the BeanInfo and MethodInfoCache classes works.

I see that the ProxyHelper will call MethodInfoCache

    public static <T> T createProxy(Endpoint endpoint, ClassLoader cl, Class<T>... interfaceClasses) throws Exception {
        return (T) createProxy(endpoint, cl, interfaceClasses, createMethodInfoCache(endpoint));
    }

in order to create the cache for the method and class but I don't see how/who is calling the ProxyHelper class and How the classes (to be scanned) are passed ?

Regards,

charles

James.Strachan wrote
2008/12/23 cmoulliard <cmoulliard@gmail.com>:
>
> Hi,
>
> I'm currently working on a small prototype to bind CSV data to POJOs using
> annotation. Camel through its component file:/// and dataformat will provide
> me the infrastructure that I need to parse the file content, extract each
> CSV record and return an array of String for each record found in a file.
>
> Remark : A string contains the list of CSV values separated by a comma.
>
> In order to bind the CSV values to my POJOs, I have created two annotations
> :
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVRecord {
>
>        String name(); --> root name of the class handling the content of a CSV
> record
>        String separator(); --> separator used to separate CSV data
>
> }
>
> @Retention(RetentionPolicy.RUNTIME)
> public @interface CSVField {
>
>        int pos(); --> key indicating the position of the CSV data in the CSV
> record
>        String name(); --> key assigned to the column name of a CSV field
>
> }
>
> Here is an example of a POJO (= Model) using these annotations :
>
> @CSVRecord(separator =",", name = "OrderModel")
> public class OrderModel {
>
>        @CSVField(name = "Number", pos = 0)
>        String orderNr;
>
>        @CSVField(name = "Client Number", pos = 1)
>        String clientNr;
>
>        @CSVField(name = "ISIN", pos = 2)
>        String ISIN_Code;
>
>        @CSVField(name = "Name", pos = 3)
>        String Instrument_Name;
>
>        @CSVField(name = "Quantity", pos = 4)
>        String Quantity;
>
>        @CSVField(name = "Cur", pos = 5)
>        String Currency;

Minor point - but you could use more defaults in that if you like.
e.g. default "," if its not specified and maybe default the name to be
the name of the field if its not specified (maybe even default the
position?)


> Here is my question ?
>
> Using reflection (or project ASM in an next step), I'm able at the launch of
> the application to discover all the fields annotated and their parameters.
> With this information, I'm able to set the field value with the CSV data
> using the following syntax :
>
>
> String[] result = record.split(csv.retrieveSeparator()); --> to retrieve the
> separator assigned to my CSVRecord
> ....
> field.set(order, result[csvField.pos()]);
>
> A CSV record can contain one or several classes like :
> - Order (with reference to a client, instrument, billing, ...),
> - Client,
> - Instrument,
> - Billing
> where annotations have been defined for the fields corresponding to what we
> have in CSV record.
>
> Remark : In this first prototype implementation, I will only support mapping
> 1-1 between objects
>
> Questions :
>
> 1) What is the best to strategy to recursively find all the annotated fields
> defined within the different classes ?

Probably keeping a cache of class -> metadata rather like we do with
the annotation metadata for bean binding (see BeanInfo /
MethodInfoCache in the org.apache.camel.component.bean package).


> 2) Should we have to create a kind of java tree objects to store the
> annotated Fields with existing relation between the different classes (=
> model) ?
>
> ex : RootNode = Order, value = list of annotatedFields, childNode = Client,
> childNode = Instrument, ...
>
> 3) Is there performant java algorythm to read the Java Tree in order to find
> the annotated field corresponding to a key no matter if the field is defined
> in the parent node or any its children ?

Not totally sure I follow this last bit. Are you talking about nested
CSVs? Or is it you flatten a master/detail type record into a single
row of the csv? The internals of JPA providers or JAXB could be useful
maybe (though possibly too complex :).

Given the flat nature of a CSV its gonna be hard walking an arbitrary
object graph and mapping it to a row; but I guess for 1-1
relationships you could bind nested fields (e.g. fields of Currency in
your example) as optional columns in the parent object's row. In this
special case though, just walking the field types (for non-primitive
types) would do the trick I think? You'd probably only be able to walk
one or two levels deep - and just keep track of types you've already
walked maybe?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2008/12/23 cmoulliard <[hidden email]>:

>
> I have started to understand how the BeanInfo and MethodInfoCache classes
> works.
>
> I see that the ProxyHelper will call MethodInfoCache
>
>    public static <T> T createProxy(Endpoint endpoint, ClassLoader cl,
> Class<T>... interfaceClasses) throws Exception {
>        return (T) createProxy(endpoint, cl, interfaceClasses,
> createMethodInfoCache(endpoint));
>    }
>
> in order to create the cache for the method and class but I don't see
> how/who is calling the ProxyHelper class and How the classes (to be scanned)
> are passed ?

There are a few different entry points for this code based on use case
(using proxies / spring remoting versus invoking a bean in the DSL or
via annotations etc).

In your case, I'd add the hooks to scan packages/classes for
annotations to your custom DataFormat? Rather like with JAXB or
XStream you can configure a list of classes/packages, you'd be doing
something similar right?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
I will answer to your question tomorrow morning but I see that it should be interesting to add a @TODO annotation in order to follow/keep track of the TODO remarks of the code ;-)

http://rskommu.wordpress.com/2007/12/28/introducing-annotation-processing-tool-apt-in-jdk15-beta2/


James.Strachan wrote
2008/12/23 cmoulliard <cmoulliard@gmail.com>:
>
> I have started to understand how the BeanInfo and MethodInfoCache classes
> works.
>
> I see that the ProxyHelper will call MethodInfoCache
>
>    public static <T> T createProxy(Endpoint endpoint, ClassLoader cl,
> Class<T>... interfaceClasses) throws Exception {
>        return (T) createProxy(endpoint, cl, interfaceClasses,
> createMethodInfoCache(endpoint));
>    }
>
> in order to create the cache for the method and class but I don't see
> how/who is calling the ProxyHelper class and How the classes (to be scanned)
> are passed ?

There are a few different entry points for this code based on use case
(using proxies / spring remoting versus invoking a bean in the DSL or
via annotations etc).

In your case, I'd add the hooks to scan packages/classes for
annotations to your custom DataFormat? Rather like with JAXB or
XStream you can configure a list of classes/packages, you'd be doing
something similar right?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
In reply to this post by jstrachan
"In your case, I'd add the hooks to scan packages/classes for
annotations to your custom DataFormat? Rather like with JAXB or
XStream you can configure a list of classes/packages, you'd be doing
something similar right?"

This is exactly what I have done. The name of the package is provided as parameter to the DataFormat class. Next, using reflection/introspection the classes of the model are retrieved. I have implemented something simple but we can bind one or several classes to a CSV record.

ex :

public class Client {

        @DataField(name = "ClientNumber", pos = 1, formatType = "java.lang.String")
        public String clientNr;
       
        @DataField(name = "firstName", pos = 2, formatType = "java.lang.String")
        public String FirstName;
       
        @DataField(name = "lastName", pos = 3, formatType = "java.lang.String")
        public String LastName;

@Record(separator =",", name = "Order")
public class Order {
       
        @DataField(name = "Number", pos = 0, formatType = "java.lang.Integer")
        public int orderNr;
       
        @LinkField( from = "com.xpectis.csv.model.Order", to = "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
        public Client client;
       
        @DataField(name = "ISIN", pos = 4, formatType = "java.lang.String")
        public String ISIN_Code;
       
        @DataField(name = "Name", pos = 5, formatType = "java.lang.String")
        public String Instrument_Name;
       
        @DataField(name = "Quantity", pos = 6, formatType = "java.lang.String")
        public String Quantity;
       
        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
        public String Currency;

Remark : It is also possible to link class together (but only One to One relation is supported) using the annotation @LinkField and makes sense because I don't want to support nested CSV.

Charles

James.Strachan wrote
2008/12/23 cmoulliard <cmoulliard@gmail.com>:
>
> I have started to understand how the BeanInfo and MethodInfoCache classes
> works.
>
> I see that the ProxyHelper will call MethodInfoCache
>
>    public static <T> T createProxy(Endpoint endpoint, ClassLoader cl,
> Class<T>... interfaceClasses) throws Exception {
>        return (T) createProxy(endpoint, cl, interfaceClasses,
> createMethodInfoCache(endpoint));
>    }
>
> in order to create the cache for the method and class but I don't see
> how/who is calling the ProxyHelper class and How the classes (to be scanned)
> are passed ?

There are a few different entry points for this code based on use case
(using proxies / spring remoting versus invoking a bean in the DSL or
via annotations etc).

In your case, I'd add the hooks to scan packages/classes for
annotations to your custom DataFormat? Rather like with JAXB or
XStream you can configure a list of classes/packages, you'd be doing
something similar right?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2009/1/6 cmoulliard <[hidden email]>:

>
> "In your case, I'd add the hooks to scan packages/classes for
> annotations to your custom DataFormat? Rather like with JAXB or
> XStream you can configure a list of classes/packages, you'd be doing
> something similar right?"
>
> This is exactly what I have done. The name of the package is provided as
> parameter to the DataFormat class. Next, using reflection/introspection the
> classes of the model are retrieved. I have implemented something simple but
> we can bind one or several classes to a CSV record.
>
> ex :
>
> public class Client {
>
>        @DataField(name = "ClientNumber", pos = 1, formatType = "java.lang.String")
>        public String clientNr;
>
>        @DataField(name = "firstName", pos = 2, formatType = "java.lang.String")
>        public String FirstName;
>
>        @DataField(name = "lastName", pos = 3, formatType = "java.lang.String")
>        public String LastName;
>
> @Record(separator =",", name = "Order")
> public class Order {
>
>        @DataField(name = "Number", pos = 0, formatType = "java.lang.Integer")
>        public int orderNr;
>
>        @LinkField( from = "com.xpectis.csv.model.Order", to =
> "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
>        public Client client;
>
>        @DataField(name = "ISIN", pos = 4, formatType = "java.lang.String")
>        public String ISIN_Code;
>
>        @DataField(name = "Name", pos = 5, formatType = "java.lang.String")
>        public String Instrument_Name;
>
>        @DataField(name = "Quantity", pos = 6, formatType = "java.lang.String")
>        public String Quantity;
>
>        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
>        public String Currency;
>
> Remark : It is also possible to link class together (but only One to One
> relation is supported) using the annotation @LinkField and makes sense
> because I don't want to support nested CSV.

Great stuff!

BTW could the pos & formatType be inferred from the reflection/introspection?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
What do you mean ?

James.Strachan wrote
2009/1/6 cmoulliard <cmoulliard@gmail.com>:
>
> "In your case, I'd add the hooks to scan packages/classes for
> annotations to your custom DataFormat? Rather like with JAXB or
> XStream you can configure a list of classes/packages, you'd be doing
> something similar right?"
>
> This is exactly what I have done. The name of the package is provided as
> parameter to the DataFormat class. Next, using reflection/introspection the
> classes of the model are retrieved. I have implemented something simple but
> we can bind one or several classes to a CSV record.
>
> ex :
>
> public class Client {
>
>        @DataField(name = "ClientNumber", pos = 1, formatType = "java.lang.String")
>        public String clientNr;
>
>        @DataField(name = "firstName", pos = 2, formatType = "java.lang.String")
>        public String FirstName;
>
>        @DataField(name = "lastName", pos = 3, formatType = "java.lang.String")
>        public String LastName;
>
> @Record(separator =",", name = "Order")
> public class Order {
>
>        @DataField(name = "Number", pos = 0, formatType = "java.lang.Integer")
>        public int orderNr;
>
>        @LinkField( from = "com.xpectis.csv.model.Order", to =
> "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
>        public Client client;
>
>        @DataField(name = "ISIN", pos = 4, formatType = "java.lang.String")
>        public String ISIN_Code;
>
>        @DataField(name = "Name", pos = 5, formatType = "java.lang.String")
>        public String Instrument_Name;
>
>        @DataField(name = "Quantity", pos = 6, formatType = "java.lang.String")
>        public String Quantity;
>
>        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
>        public String Currency;
>
> Remark : It is also possible to link class together (but only One to One
> relation is supported) using the annotation @LinkField and makes sense
> because I don't want to support nested CSV.

Great stuff!

BTW could the pos & formatType be inferred from the reflection/introspection?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2009/1/6 cmoulliard <[hidden email]>:
>
> What do you mean ?

That you don't have to specify the position / formatType parameters on
the annotation - and your reflection/introspection code could figure
those out from the types of the fields/properties and their position
in the class definition

>
>
> James.Strachan wrote:
>>
>> 2009/1/6 cmoulliard <[hidden email]>:
>>>
>>> "In your case, I'd add the hooks to scan packages/classes for
>>> annotations to your custom DataFormat? Rather like with JAXB or
>>> XStream you can configure a list of classes/packages, you'd be doing
>>> something similar right?"
>>>
>>> This is exactly what I have done. The name of the package is provided as
>>> parameter to the DataFormat class. Next, using reflection/introspection
>>> the
>>> classes of the model are retrieved. I have implemented something simple
>>> but
>>> we can bind one or several classes to a CSV record.
>>>
>>> ex :
>>>
>>> public class Client {
>>>
>>>        @DataField(name = "ClientNumber", pos = 1, formatType =
>>> "java.lang.String")
>>>        public String clientNr;
>>>
>>>        @DataField(name = "firstName", pos = 2, formatType =
>>> "java.lang.String")
>>>        public String FirstName;
>>>
>>>        @DataField(name = "lastName", pos = 3, formatType =
>>> "java.lang.String")
>>>        public String LastName;
>>>
>>> @Record(separator =",", name = "Order")
>>> public class Order {
>>>
>>>        @DataField(name = "Number", pos = 0, formatType =
>>> "java.lang.Integer")
>>>        public int orderNr;
>>>
>>>        @LinkField( from = "com.xpectis.csv.model.Order", to =
>>> "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
>>>        public Client client;
>>>
>>>        @DataField(name = "ISIN", pos = 4, formatType =
>>> "java.lang.String")
>>>        public String ISIN_Code;
>>>
>>>        @DataField(name = "Name", pos = 5, formatType =
>>> "java.lang.String")
>>>        public String Instrument_Name;
>>>
>>>        @DataField(name = "Quantity", pos = 6, formatType =
>>> "java.lang.String")
>>>        public String Quantity;
>>>
>>>        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
>>>        public String Currency;
>>>
>>> Remark : It is also possible to link class together (but only One to One
>>> relation is supported) using the annotation @LinkField and makes sense
>>> because I don't want to support nested CSV.
>>
>> Great stuff!
>>
>> BTW could the pos & formatType be inferred from the
>> reflection/introspection?
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/Advise-on-%40Annotation---Reflection-%21%21-tp21141422s22882p21311190.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
- Concerning the formatType, this parameter could be optional. If not provided, the type of the field will be used to format the data.

- For the position, this could be possible but only for the case where we would like to map the content of a CSV record to one class and not to several classes. The advantage to define the position in the annotations of the class is that we can use them to generate the Model documentation between CSV file & classes ;-)

James.Strachan wrote
2009/1/6 cmoulliard <cmoulliard@gmail.com>:
>
> What do you mean ?

That you don't have to specify the position / formatType parameters on
the annotation - and your reflection/introspection code could figure
those out from the types of the fields/properties and their position
in the class definition

>
>
> James.Strachan wrote:
>>
>> 2009/1/6 cmoulliard <cmoulliard@gmail.com>:
>>>
>>> "In your case, I'd add the hooks to scan packages/classes for
>>> annotations to your custom DataFormat? Rather like with JAXB or
>>> XStream you can configure a list of classes/packages, you'd be doing
>>> something similar right?"
>>>
>>> This is exactly what I have done. The name of the package is provided as
>>> parameter to the DataFormat class. Next, using reflection/introspection
>>> the
>>> classes of the model are retrieved. I have implemented something simple
>>> but
>>> we can bind one or several classes to a CSV record.
>>>
>>> ex :
>>>
>>> public class Client {
>>>
>>>        @DataField(name = "ClientNumber", pos = 1, formatType =
>>> "java.lang.String")
>>>        public String clientNr;
>>>
>>>        @DataField(name = "firstName", pos = 2, formatType =
>>> "java.lang.String")
>>>        public String FirstName;
>>>
>>>        @DataField(name = "lastName", pos = 3, formatType =
>>> "java.lang.String")
>>>        public String LastName;
>>>
>>> @Record(separator =",", name = "Order")
>>> public class Order {
>>>
>>>        @DataField(name = "Number", pos = 0, formatType =
>>> "java.lang.Integer")
>>>        public int orderNr;
>>>
>>>        @LinkField( from = "com.xpectis.csv.model.Order", to =
>>> "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
>>>        public Client client;
>>>
>>>        @DataField(name = "ISIN", pos = 4, formatType =
>>> "java.lang.String")
>>>        public String ISIN_Code;
>>>
>>>        @DataField(name = "Name", pos = 5, formatType =
>>> "java.lang.String")
>>>        public String Instrument_Name;
>>>
>>>        @DataField(name = "Quantity", pos = 6, formatType =
>>> "java.lang.String")
>>>        public String Quantity;
>>>
>>>        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
>>>        public String Currency;
>>>
>>> Remark : It is also possible to link class together (but only One to One
>>> relation is supported) using the annotation @LinkField and makes sense
>>> because I don't want to support nested CSV.
>>
>> Great stuff!
>>
>> BTW could the pos & formatType be inferred from the
>> reflection/introspection?
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/Advise-on-%40Annotation---Reflection-%21%21-tp21141422s22882p21311190.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
I have adapted the code and now the type to be used is the type defined for the Bean property (String, Double, ....)

I plan to finalize a first version of my code next week.

Question :

1) Is Camel project interested to 'host' this code ?
2) If the answer is yes, can you provide guidelines about packaging, where this code must be submitted in svn, How it will be integrated with Camel, .... ?

Regards,

Charles

cmoulliard wrote
- Concerning the formatType, this parameter could be optional. If not provided, the type of the field will be used to format the data.

- For the position, this could be possible but only for the case where we would like to map the content of a CSV record to one class and not to several classes. The advantage to define the position in the annotations of the class is that we can use them to generate the Model documentation between CSV file & classes ;-)

James.Strachan wrote
2009/1/6 cmoulliard <cmoulliard@gmail.com>:
>
> What do you mean ?

That you don't have to specify the position / formatType parameters on
the annotation - and your reflection/introspection code could figure
those out from the types of the fields/properties and their position
in the class definition

>
>
> James.Strachan wrote:
>>
>> 2009/1/6 cmoulliard <cmoulliard@gmail.com>:
>>>
>>> "In your case, I'd add the hooks to scan packages/classes for
>>> annotations to your custom DataFormat? Rather like with JAXB or
>>> XStream you can configure a list of classes/packages, you'd be doing
>>> something similar right?"
>>>
>>> This is exactly what I have done. The name of the package is provided as
>>> parameter to the DataFormat class. Next, using reflection/introspection
>>> the
>>> classes of the model are retrieved. I have implemented something simple
>>> but
>>> we can bind one or several classes to a CSV record.
>>>
>>> ex :
>>>
>>> public class Client {
>>>
>>>        @DataField(name = "ClientNumber", pos = 1, formatType =
>>> "java.lang.String")
>>>        public String clientNr;
>>>
>>>        @DataField(name = "firstName", pos = 2, formatType =
>>> "java.lang.String")
>>>        public String FirstName;
>>>
>>>        @DataField(name = "lastName", pos = 3, formatType =
>>> "java.lang.String")
>>>        public String LastName;
>>>
>>> @Record(separator =",", name = "Order")
>>> public class Order {
>>>
>>>        @DataField(name = "Number", pos = 0, formatType =
>>> "java.lang.Integer")
>>>        public int orderNr;
>>>
>>>        @LinkField( from = "com.xpectis.csv.model.Order", to =
>>> "com.xpectis.csv.model.Client", linkType = LinkType.OneToOne)
>>>        public Client client;
>>>
>>>        @DataField(name = "ISIN", pos = 4, formatType =
>>> "java.lang.String")
>>>        public String ISIN_Code;
>>>
>>>        @DataField(name = "Name", pos = 5, formatType =
>>> "java.lang.String")
>>>        public String Instrument_Name;
>>>
>>>        @DataField(name = "Quantity", pos = 6, formatType =
>>> "java.lang.String")
>>>        public String Quantity;
>>>
>>>        @DataField(name = "Cur", pos = 7, formatType = "java.lang.String")
>>>        public String Currency;
>>>
>>> Remark : It is also possible to link class together (but only One to One
>>> relation is supported) using the annotation @LinkField and makes sense
>>> because I don't want to support nested CSV.
>>
>> Great stuff!
>>
>> BTW could the pos & formatType be inferred from the
>> reflection/introspection?
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/Advise-on-%40Annotation---Reflection-%21%21-tp21141422s22882p21311190.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2009/1/7 cmoulliard <[hidden email]>:
>
> I have adapted the code and now the type to be used is the type defined for
> the Bean property (String, Double, ....)
>
> I plan to finalize a first version of my code next week.
>
> Question :
>
> 1) Is Camel project interested to 'host' this code ?

Definitely! :)

> 2) If the answer is yes, can you provide guidelines about packaging, where
> this code must be submitted in svn, How it will be integrated with Camel,
> .... ?

There's a guide here on
http://activemq.apache.org/camel/contributing.html

I guess the best thing to do is create a separate maven module for this?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Claus Ibsen-2
Awesome Charles. Looking forward to the contribution. This is great
for the community.

On Wed, Jan 7, 2009 at 5:11 PM, James Strachan <[hidden email]> wrote:

> 2009/1/7 cmoulliard <[hidden email]>:
>>
>> I have adapted the code and now the type to be used is the type defined for
>> the Bean property (String, Double, ....)
>>
>> I plan to finalize a first version of my code next week.
>>
>> Question :
>>
>> 1) Is Camel project interested to 'host' this code ?
>
> Definitely! :)
>
>> 2) If the answer is yes, can you provide guidelines about packaging, where
>> this code must be submitted in svn, How it will be integrated with Camel,
>> .... ?
>
> There's a guide here on
> http://activemq.apache.org/camel/contributing.html
>
> I guess the best thing to do is create a separate maven module for this?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>



--

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
Thanks but I need more info about packaging, ... (see my previous question).

Claus Ibsen-2 wrote
Awesome Charles. Looking forward to the contribution. This is great
for the community.

On Wed, Jan 7, 2009 at 5:11 PM, James Strachan <james.strachan@gmail.com> wrote:
> 2009/1/7 cmoulliard <cmoulliard@gmail.com>:
>>
>> I have adapted the code and now the type to be used is the type defined for
>> the Bean property (String, Double, ....)
>>
>> I plan to finalize a first version of my code next week.
>>
>> Question :
>>
>> 1) Is Camel project interested to 'host' this code ?
>
> Definitely! :)
>
>> 2) If the answer is yes, can you provide guidelines about packaging, where
>> this code must be submitted in svn, How it will be integrated with Camel,
>> .... ?
>
> There's a guide here on
> http://activemq.apache.org/camel/contributing.html
>
> I guess the best thing to do is create a separate maven module for this?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>



--

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
For new code (rather than patches) its easiest to just attach a
tarball/zip to a JIRA (remember to click the grant to the ASF
checkbox) as described in the "Submitting patches" section
http://activemq.apache.org/camel/contributing.html

2009/1/7 cmoulliard <[hidden email]>:

>
> Thanks but I need more info about packaging, ... (see my previous question).
>
>
> Claus Ibsen-2 wrote:
>>
>> Awesome Charles. Looking forward to the contribution. This is great
>> for the community.
>>
>> On Wed, Jan 7, 2009 at 5:11 PM, James Strachan <[hidden email]>
>> wrote:
>>> 2009/1/7 cmoulliard <[hidden email]>:
>>>>
>>>> I have adapted the code and now the type to be used is the type defined
>>>> for
>>>> the Bean property (String, Double, ....)
>>>>
>>>> I plan to finalize a first version of my code next week.
>>>>
>>>> Question :
>>>>
>>>> 1) Is Camel project interested to 'host' this code ?
>>>
>>> Definitely! :)
>>>
>>>> 2) If the answer is yes, can you provide guidelines about packaging,
>>>> where
>>>> this code must be submitted in svn, How it will be integrated with
>>>> Camel,
>>>> .... ?
>>>
>>> There's a guide here on
>>> http://activemq.apache.org/camel/contributing.html
>>>
>>> I guess the best thing to do is create a separate maven module for this?
>>>
>>> --
>>> James
>>> -------
>>> http://macstrac.blogspot.com/
>>>
>>> Open Source Integration
>>> http://fusesource.com/
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/Advise-on-%40Annotation---Reflection-%21%21-tp21141422s22882p21335684.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
Question

- Are we going to create a new module (under components folder) for this framework ?
- If this is the case, which name (project and package name) are we going to use regarding to the fact that this framework can parse/format CSV, fixedLength format where the binding is defined through annotations ? Suggestion : JAnXB - Java Api for non XML binding ?

Regards,

Charles

James.Strachan wrote
For new code (rather than patches) its easiest to just attach a
tarball/zip to a JIRA (remember to click the grant to the ASF
checkbox) as described in the "Submitting patches" section
http://activemq.apache.org/camel/contributing.html

2009/1/7 cmoulliard <cmoulliard@gmail.com>:
>
> Thanks but I need more info about packaging, ... (see my previous question).
>
>
> Claus Ibsen-2 wrote:
>>
>> Awesome Charles. Looking forward to the contribution. This is great
>> for the community.
>>
>> On Wed, Jan 7, 2009 at 5:11 PM, James Strachan <james.strachan@gmail.com>
>> wrote:
>>> 2009/1/7 cmoulliard <cmoulliard@gmail.com>:
>>>>
>>>> I have adapted the code and now the type to be used is the type defined
>>>> for
>>>> the Bean property (String, Double, ....)
>>>>
>>>> I plan to finalize a first version of my code next week.
>>>>
>>>> Question :
>>>>
>>>> 1) Is Camel project interested to 'host' this code ?
>>>
>>> Definitely! :)
>>>
>>>> 2) If the answer is yes, can you provide guidelines about packaging,
>>>> where
>>>> this code must be submitted in svn, How it will be integrated with
>>>> Camel,
>>>> .... ?
>>>
>>> There's a guide here on
>>> http://activemq.apache.org/camel/contributing.html
>>>
>>> I guess the best thing to do is create a separate maven module for this?
>>>
>>> --
>>> James
>>> -------
>>> http://macstrac.blogspot.com/
>>>
>>> Open Source Integration
>>> http://fusesource.com/
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/Advise-on-%40Annotation---Reflection-%21%21-tp21141422s22882p21335684.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

jstrachan
2009/1/8 cmoulliard <[hidden email]>:
>
> Question
>
> - Are we going to create a new module (under components folder) for this
> framework ?

Yeah I think so

> - If this is the case, which name (project and package name) are we going to
> use regarding to the fact that this framework can parse/format CSV,
> fixedLength format where the binding is defined through annotations ?
> Suggestion : JAnXB - Java Api for non XML binding ?

Naming is probably the trickiest bit of software development :). I
confess to really not being sure - after a few days; here's the best I
could come up with (though note I'm not too hot at naming things :)

name: CsvBinding
module:  camel-csv-binding
package: org.apache.camel.binding.csv

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Advise on @Annotation & Reflection !!

Charles Moulliard
After a few days of reflection (and a good week-end), I'm coming back also with some ideas and a name

I think that the name of the project / package will be simply : "bindy" Why, the idea behind this framework is to bind data to Java Bean using annotations. The framework in this first release allows a user to bind a CSV record to more than one POJOs and to convert the data according to the type of the java property. The objects created can be link together in an one to one relation. In the next step, it will be possible to bind also fixed length content (including header and footer). From the java objects, it is possible to generate the data content (ex : csv, fixedlength, ...).

Concerning the package I propose to use :

org.apache.camel.bindy.annotation (where annotations have been defined and can be used for csv, fixed length, ...
org.apache.camel.bindy.csv (for CSV)
org.apache.camel.bindy.fixed (for fixed length)
org.apache.camel.bindy.format
org.apache.camel.bindy.format.impl (to transform string to java type or java types to String)

I'm not so long from your proposal ;-)

Charles



James.Strachan wrote
2009/1/8 cmoulliard <cmoulliard@gmail.com>:
>
> Question
>
> - Are we going to create a new module (under components folder) for this
> framework ?

Yeah I think so

> - If this is the case, which name (project and package name) are we going to
> use regarding to the fact that this framework can parse/format CSV,
> fixedLength format where the binding is defined through annotations ?
> Suggestion : JAnXB - Java Api for non XML binding ?

Naming is probably the trickiest bit of software development :). I
confess to really not being sure - after a few days; here's the best I
could come up with (though note I'm not too hot at naming things :)

name: CsvBinding
module:  camel-csv-binding
package: org.apache.camel.binding.csv

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
12