You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by tmf <th...@gmx.de> on 2008/03/05 00:01:06 UTC

ServiceMix File component

Hello,

I have a conceptual question.
After reading the examples and additional guides I am wondering whether the
following scenario would work.

The filereader monitors a folder. Every time a new file is inserted (maybe
with ending .xml) an own written java application is started. This
application needs a string as input which has to be the path of the file to
do some transformations. After the transformation it returns an .txt-file
which has to be transfered to an other folder.

Now my questions
1. Is is possible to insert an own written java application in servicemix?
2. Is it possible that the java application only gets the string of the path
of the file (or the file itself) as input to make tranformations?
--> something like that
       public void doSomethig (String inputPath){
      //make some transformations
       }

At the moment the application is written for local use. So there is no
problem to make the transformations only with the string of the path.

best regards
tmf
-- 
View this message in context: http://www.nabble.com/ServiceMix-File-component-tp15839219s12049p15839219.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix File component

Posted by lhein <lh...@apache.org>.

tmf wrote:
> 
> Now my questions
> 1. Is is possible to insert an own written java application in servicemix?
> 

--> Yes, you may write a bean su for this purpose. Look at servicemix-bean
component for details. 



tmf wrote:
> 
> 2. Is it possible that the java application only gets the string of the
> path of the file (or the file itself) as input to make tranformations?
> --> something like that
>        public void doSomethig (String inputPath){
>       //make some transformations
>        }
> 

--> You can write your own FileMarshaler class passing only the path of the
file. Look at the servicemix-file component for how to do this.

If you got further questions just ask here.

Regards,
Lars

-- 
View this message in context: http://www.nabble.com/ServiceMix-File-component-tp15839219s12049p15844750.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix File component

Posted by tmf <th...@gmx.de>.
Thanks for the quick and useful answers.

I'll work it out.


best regards
tmf
-- 
View this message in context: http://www.nabble.com/ServiceMix-File-component-tp15839219s12049p15869341.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix File component

Posted by Lars Heinemann <la...@compart.net>.
Nico74,

I am not sure if I understood you correctly.

Via the file marshaler you can do almost everything what is needed.

Lets have a look at an example:

public class MyFileMarshaler extends MarshalerSupport implements FileMarshaler 
{ 
    private void fillContent(NormalizedMessage message, String path) throws 
IOException, JBIException, ParserConfigurationException
        {
        // HERE YOU CONVERT THE FILE INTO A JBI MESSAGE
        // FILL THE JBI MESSAGE AS YOU LIKE...IT'S UP TO YOU
        }

    public String getOutputName(MessageExchange exchange, NormalizedMessage 
message) throws MessagingException
        {
        // HERE YOU GENERATE THE FILE NAME FOR WRITING TO FS (PROVIDER 
ENDPOINT)
        }

    /**
     * 
     */
    public void readMessage(MessageExchange exchange, NormalizedMessage 
message, InputStream in, String path)
            throws IOException, JBIException
        {
        try
            {
            // HERE YOU CALL THE FILL CONTENT METHOD FROM ABOVE
            fillContent(message, path);
            }
        catch (ParserConfigurationException pcEx)
            {
            throw new JBIException("MyFileMarshaler.readMessage(): Error 
building JBI message for " + path, pcEx);
            }
        }

    /**
     * 
     */
    public void writeMessage(MessageExchange exchange, NormalizedMessage 
message, OutputStream out, String path)
            throws IOException, JBIException
        {
	// HERE YOU CONVERT FROM THE JBI MESSAGE INTO A FILE
        }
}

Hopefully this clarifies a bit.

Regards,
Lars


Am Mittwoch, 5. März 2008 14:25:21 schrieb Nico74:
> Hum,
>
> you are right but I think that the base information that the file component
> treat is the canonical path of the file. In specific case you may have to
> have different strategy and targets to apply in function of owner, size ...
> (etl) and it's very convenient to have all thoses informations from the
> file pool component.
>
> lhe77 wrote:
> > Nico74,
> >
> > what you said is not correct. It makes no sense to rewrite a new file
> > component. The file component is only the bridge between the file system
> > and the jbi bus. This file component is very customizable via the
> > marshaler
> > logic. To achieve the wanted behaviour it is simply enough to write your
> > own
> > file marshaler. Thats it.
> >
> > Regards,
> > Lars
> >
> > Am Mittwoch, 5. März 2008 14:03:46 schrieb Nico74:
> >> You need to create a binding component like servicemix-file (watch
> >> source code to have an idea).  Yours new component just send message
> >> with file path to the NMR.



Re: ServiceMix File component

Posted by Nico74 <nb...@nbconseil.com>.
Hum,

you are right but I think that the base information that the file component
treat is the canonical path of the file. In specific case you may have to
have different strategy and targets to apply in function of owner, size ...
(etl) and it's very convenient to have all thoses informations from the file
pool component. 



lhe77 wrote:
> 
> Nico74,
> 
> what you said is not correct. It makes no sense to rewrite a new file 
> component. The file component is only the bridge between the file system
> and the jbi bus. This file component is very customizable via the
> marshaler 
> logic. To achieve the wanted behaviour it is simply enough to write your
> own 
> file marshaler. Thats it.
> 
> Regards,
> Lars
> 
> 
> Am Mittwoch, 5. März 2008 14:03:46 schrieb Nico74:
>> You need to create a binding component like servicemix-file (watch source
>> code to have an idea).  Yours new component just send message with file
>> path to the NMR.
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-File-component-tp15839219s12049p15849932.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix File component

Posted by Lars Heinemann <la...@compart.net>.
Nico74,

what you said is not correct. It makes no sense to rewrite a new file 
component. The file component is only the bridge between the file system
and the jbi bus. This file component is very customizable via the marshaler 
logic. To achieve the wanted behaviour it is simply enough to write your own 
file marshaler. Thats it.

Regards,
Lars


Am Mittwoch, 5. März 2008 14:03:46 schrieb Nico74:
> You need to create a binding component like servicemix-file (watch source
> code to have an idea).  Yours new component just send message with file
> path to the NMR.



Re: ServiceMix File component

Posted by Nico74 <nb...@nbconseil.com>.
You need to create a binding component like servicemix-file (watch source
code to have an idea).  Yours new component just send message with file path
to the NMR.
-- 
View this message in context: http://www.nabble.com/ServiceMix-File-component-tp15839219s12049p15849509.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.