I Need help please to create/insert NetBeans BPEL activities

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

I Need help please to create/insert NetBeans BPEL activities

ztarek77
This post has NOT been accepted by the mailing list yet.
Hi sir,
I followed the posts between "Nam" and "sam-wang2" few years ago in this forum, i learned a lot and resolved a lot of problems while manipulating BPEL processes. It was really a very useful post for me, till i'm used to use Eclipse, and now i'm using Netbeans.
here is the link of the post:

http://netbeans-org.1045718.n5.nabble.com/still-about-how-to-generate-BPEL-process-without-GUI-designer-td3014718.html

I followed your suggestions that "Nam" gave to "sam", i just copied the classes of DomAccess and DomAccessProvider which extends the "ReadOnlyAccess" class from the post, then i created a file named : org.netbeans.modules.xml.xam.spi.ModelAccessProvider in a folder i created manually under the root of my project /META-INF/services/ as "Nam" mentioned. I added this line inside the file: org.netbeans.modules.xml.xam.spi.DomAccessProvier

1- The DomAccess class:
********************************************************************************************
package org.netbeans.modules.xml.xam.dom;


import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel;
import org.netbeans.modules.xml.xam.dom.DocumentModelAccess;
import org.netbeans.modules.xml.xam.dom.ReadOnlyAccess;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class DomAccess extends ReadOnlyAccess {
     
        AbstractDocumentModel model;
     
    public DomAccess(AbstractDocumentModel model) {
                super(model);
                // TODO Auto-generated constructor stub
        }
 
        private boolean noMutations() {
        return model.inSync() && ! model.startedFiringEvents() || model.inUndoRedo();
    }
     
    public void setAttribute(Element element, String name, String value, NodeUpdater updater) {
         if (noMutations()) return;
         element.setAttribute(name, value);
    }
 
    public void removeAttribute(Element element, String name, DocumentModelAccess.NodeUpdater
updater) {
        if (noMutations()) return;
        element.removeAttribute(name);
    }
 
    public void removeChild(Node node, Node child, DocumentModelAccess.NodeUpdater updater) {
        if (noMutations()) return;
        node.removeChild(child);
    }

    public void insertBefore(Node node, Node newChild, Node refChild,
DocumentModelAccess.NodeUpdater updater) {
    if (noMutations()) return;
    node.insertBefore(newChild, refChild);
    }

    public void appendChild(Node node, Node newChild, DocumentModelAccess.NodeUpdater updater) {
    if (noMutations()) return;
    node.appendChild(newChild);
    }
   
}
********************************************************************************************
2- The DomAccessProvider class:

********************************************************************************************
package org.netbeans.modules.xml.xam.dom;

import java.io.File;

import org.netbeans.modules.xml.xam.ModelSource;
import org.netbeans.modules.xml.xam.dom.ReadOnlyAccess;
//import org.openide.loaders.DataObject;
import org.w3c.dom.Document;


 public class DomAccessProvider extends ReadOnlyAccess.Provider {
    public Object getModelSourceKey(ModelSource source) {
        Object key = source.getLookup().lookup(File.class);
        if(key == null) {
            key = source.getLookup().lookup(Document.class);
       }
        return key;
    }
  }

********************************************************************************************

I putted the compiled files .class into the "org-netbeans-modules-xml-xam" jar file under "org.netbeans.modules.xml.xam.dom".
Here is my main :

    public static void main(String[] args) throws IOException, BadLocationException, Exception {
        // TODO Auto-generated method stub      
        File bpelFile = new File("models/ProcessTest.bpel");          
        FileInputStream fis = new FileInputStream(bpelFile);
        myCatalogModel calg= new myCatalogModel();
        Lookup lookup = Lookups.fixed(new Object[]{bpelFile, calg.loadPlainDocument(fis),
                   calg});
        ModelSource source = new ModelSource(lookup,true);
        //BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
        BpelModelFactory factory = Lookup.getDefault().lookup(BpelModelFactory.class);
        BpelModel model = factory.getModel(source);      
        BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);        
        Assign asg=  bpelBuilder.createAssign();
        asg.setName("getAppeal");
        Sequence seq= (Sequence) bpelBuilder.getModel().getProcess().getActivity().getChildren().get(0);
        seq.setActivity(asg, 0);
}

When i execute it doesn't work. It throws an exception at this line in the main:  Assign asg=  bpelBuilder.createAssign();

Exception in thread "main" java.lang.UnsupportedOperationException: setAttribute access not supported.
    at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.setAttribute(ReadOnlyAccess.java:159)
    at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.setAttribute(AbstractDocumentComponent.java:483)
    at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.setAttributeQuietly(AbstractDocumentComponent.java:277)
    at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.setAttribute(AbstractDocumentComponent.java:124)
    at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setAttribute(BpelEntityImpl.java:340)
    at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:1048)
    at org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:232)
    at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:405)
    at org.netbeans.modules.bpel.model.impl.NamedElementImpl.setName(NamedElementImpl.java:61)
    at org.netbeans.modules.bpel.model.impl.services.DefaultNameService.postDispatch(DefaultNameService.java:74)
    at org.netbeans.modules.bpel.model.impl.BpelModelImpl.postInnerEventNotify(BpelModelImpl.java:647)
    at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:858)
    at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:92)
    at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:51)
    at org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:44)
    at org.netbeans.modules.bpel.model.impl.NamedElementImpl.<init>(NamedElementImpl.java:42)
    at org.netbeans.modules.bpel.model.impl.ActivityImpl.<init>(ActivityImpl.java:49)
    at org.netbeans.modules.bpel.model.impl.AssignImpl.<init>(AssignImpl.java:56)
    at org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:189)
    at Mytestpackage.MainTestClass.main(MainTestClass.java:59)

It is the same exception "sam" encountered in the post, but he resolved the problem through modifying the "org.netbeans.modules.xml.xam.dom.ReadOnlyAccess" class. I tried to solve the problem but id didn't success.

Could you please give me some hint about this problem, or a sample of code so i can create/insert BPEL activities.


Thank you very much in advance.