How to implement a java code (JMC) in Axway B2Bi?

60 Views Asked by At

I made a java code focusing on converting xsl files to csv or xml, using apache poi and axway xib libs. I had a problem regarding the implementation in b2bi.

I have tried to implement, but i couldn't even add the file, so I think the problem might has relation with versioning and compatibility

1

There are 1 best solutions below

2
Andrey Kumi On

Here's how I do this. You should have 2 classes:

import com.axway.xib.Activity;
import com.axway.xib.Component;
import com.axway.xib.Context;
import com.axway.xib.Creator;
import com.axway.xib.ProcessingMessage;


public class B2BiTest
extends Component
implements Creator
{
    public void process(Context context, final ProcessingMessage message, final Activity[] nextActivities)
    {
        //Main Code Here
    }
    
}

And another class for bean:

import java.beans.BeanDescriptor;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;

    /**
     * Simple test component bean info.
     */
    public class B2BiTestBeanInfo extends SimpleBeanInfo
    {

        /** Bean descriptor */
        private BeanDescriptor beanDescriptor;

        /** Property descriptors */
        private PropertyDescriptor[] propertyDescriptors;

        /**
         * Returns the bean descriptor.
         * @return the bean descriptor
         */
        public BeanDescriptor getBeanDescriptor()
        {
            if (beanDescriptor == null)
            {
                beanDescriptor = new BeanDescriptor(B2BiTest.class);
                beanDescriptor.setName("B2BiTest");
                beanDescriptor.setShortDescription("B2BiTest Description");
            }
            return beanDescriptor;
        }

        /**
         * Returns the properties descriptors.
         * @return the descriptor list
         */
        public PropertyDescriptor[] getPropertyDescriptors()
        {
            try
            {
                if (propertyDescriptors == null)
                {
                    PropertyDescriptor name = new PropertyDescriptor("name", B2BiTest.class);
                    name.setShortDescription("Name");
                    propertyDescriptors = new PropertyDescriptor[] { name };
                }
                return propertyDescriptors;
            }
            catch (IntrospectionException e)
            {
                throw new RuntimeException(e);
            }
        }
    }

Export and paste your jar inside <B2Bi_shared_directory>/local/java/component.

Below are some important points.

You should import the following libraries into the project before proceeding:

  • integrator-javamodules-developmentkit-api-x.x.x-x.jar
  • integrator-javamodules-developmentkit-runtime-x.x.x-x.jar
  • Commons-beanutils-x.x.x.jar
  • Commons-collections-x.x.jar
  • Commons-lang-x.x.jar
  • Commons-logging-x.x.x.jar

You should name your BeanInfo class correctly. Otherwise it won't compile. Example:

  • Main class name: MyClassName
  • BeanInfo class name should be: MyClassName + BeanInfo (MyClassNameBeanInfo)

Important notice: we also had issues while not knowing this when in our early development stages. Your manifest should be like this:

Manifest-Version: 1.0
Main-Class: com.example.mainclassname
Container-Version: 3.7
Component-Version: 1.0

You should add an empty line at the end of the manifest. I don't know exactly what the reason is. but it's not working without an empty line in the end.

Let us know if there are any issues.