The marshaler must be set as a property on the FilePoller component.
See http://servicemix.goopen.org/site/file.html

Cheers,
Guillaume Nodet

On 5/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

[EMAIL PROTECTED]
05/25/2006 09:11 AM
Please respond to
[email protected]


To
[email protected]
cc

Subject
Re: Help in reading text files using the file-Binding example








Thanks Bruce. Please find the java class attached.


import java.io.BufferedReader;
import java.io.FileReader;

import java.io.FileWriter ;
import com.unidex.xflat.XmlConvert ;
import com.unidex.xflat.XflatException ;


import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;

import org.servicemix.MessageExchangeListener;
import org.servicemix.components.util.PojoSupport;
import org.servicemix.jbi.jaxp.StringSource;
import org.servicemix.components.util.DefaultFileMarshaler;

public class FFConverter extends   DefaultFileMarshaler  {

FFConverter()
{
super();
}

private         String schema_file;
private         String flat_file;
private         String xml_file ;

public void setSchema_file(String sfile)
{
schema_file=sfile;
}

public void setFlat_file(String sfile)
{
flat_file=sfile;
}

public void setXml_file(String sfile)
{
xml_file=sfile;
}

public String getSchema_file()
{
return schema_file;
}

public String getFlat_file()
{
return flat_file;

}

public String getXml_file()
{
return xml_file;

}



        public void readMessage(javax.jbi.messaging.MessageExchange
exchange, javax.jbi.messaging.NormalizedMessage message,
java.io.InputStream in, java.lang.String path) throws MessagingException {
          //   NormalizedMessage message = exchange.createMessage();
                  // exchange.setMessage(message, "out");



        }

public void writeMessage(javax.jbi.messaging.MessageExchange exchange,
javax.jbi.messaging.NormalizedMessage message, java.io.InputStream in,
java.lang.String path) throws MessagingException {
        //     NormalizedMessage message = exchange.createMessage();
        //         exchange.setMessage(message, "out");



        }


        private void ConvertFile() {

                final boolean suppress_startup_message = true ;

                try {
                        // Create an XmlConvert instance.
                        XmlConvert xml_convert =
                                new XmlConvert( new FileReader(
getSchema_file() ),
                                                suppress_startup_message )
;

                        // Use the flatToXml method of the XmlConvert
object
                        // to convert the flat file into XML.
                        xml_convert.flatToXml(  new FileReader(
getFlat_file() ),
                                                new FileWriter(
getXml_file() ) ) ;
                } catch( Exception e ) {
                        if ( e instanceof XflatException ) {
                                System.err.println( e.getMessage() ) ;
                        } else {
                                System.err.println( e.toString() ) ;
                        }
                        System.exit( 1 ) ; // Error.
                }
                System.exit( 0 ) ; // Success.
        }
}



"Bruce Snyder" <[EMAIL PROTECTED]>
05/24/2006 04:52 PM

Please respond to
[email protected]


To
[email protected]
cc

Subject
Re: Help in reading text files using the file-Binding example








On 5/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi Bruce,
>
> I tried implementing the DefaultFileMarshaller. The file compiles well.
> When I try to integrate that to servicemix.xml using the following
> configration. It throws an error.
>
> <!--Flat File converter components-->
>
> <sm:activationSpec componentName="flatfileConverter"
> service="foo:flatFile">
>
>    <sm:component>
>               <bean class="FFConverter">
>                 <property name="schema_file" value="rbc.rfl" />
>                 <property name="flat_file" value="rbc_push_small" />
>                 <property name="xml_file" value="output.xml" />
>               </bean>
>     </sm:component>
>
> </sm:activationSpec>
>
> <!--Flat File converter Component -->
>
>
> Error
>
> orkManager]; root of BeanFactory hierarchy}
> Caught: org.springframework.beans.factory.BeanCreationException: Error
> creating
> bean with name 'jbi' defined in file
> [C:\servicemix-2.0.2\examples\file-binding\
> servicemix.xml]: Initialization of bean failed; nested exception is
> java.lang.Il
> legalArgumentException: Component name: flatfileConverter is bound to an
> object
> which is not a JBI component, it is of type: FFConverter

Based on the error, it would appear that an interface was not
implemented or some requirement of JBI components has not been met.
Please post the Java class so that I can fully understand what is
happening.

Bruce
--
perl -e 'print
unpack("u30","D0G)[EMAIL PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache Geronimo - http://geronimo.apache.org/
Apache ActiveMQ - http://incubator.apache.org/activemq/
Apache ServiceMix - http://incubator.apache.org/servicemix/
Castor - http://castor.org/





--
Cheers,
Guillaume Nodet

Reply via email to