still about how to generate BPEL process without GUI designer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

still about how to generate BPEL process without GUI designer

sam wang-2
Dear all,

I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled with NB
GUI. For example, first I want to generate a blank BPEL process through:
org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl

However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled with the
NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".

Another potential approach seems through
"org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an empty
"EjbProject". I have two questions about "EjbProject". First, if it can be treated as a "BPEL"
project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
"synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can generate
this simple BPEL project through NB GUI first, and then trying to load this project into some
class in order to retrieve the BPEL process with the resources. But I don't know how to do this. I
think once I get the BPEL instance, I can manipulate it through all the classes in the package
"org.netbeans.modules.bpel.model.impl".

In a word, my requirement is very simple. First, I want to generate a quite simple BPEL process as
the template (just like the synchronizing BPEL example provided by NB SOA example), then
manipulating this BPEL process through NB's BPEL model (for example, adding activities such as
"receive", "reply", "invoke","assign", etc.)

Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
hint/suggestion will be greatly appreciated!!

Sam


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

Jason Baragry-2
Hi Sam,

BPEL is just an XML document. Why can't you just use XML apis to
programmatically create the BPEL XML document and then import it into
netbeans?

regards
Jason

> Dear all,
>
> I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled with NB
> GUI. For example, first I want to generate a blank BPEL process through:
> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
>
> However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled with the
> NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
>
> Another potential approach seems through
> "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an empty
> "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a "BPEL"
> project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can generate
> this simple BPEL project through NB GUI first, and then trying to load this project into some
> class in order to retrieve the BPEL process with the resources. But I don't know how to do this. I
> think once I get the BPEL instance, I can manipulate it through all the classes in the package
> "org.netbeans.modules.bpel.model.impl".
>
> In a word, my requirement is very simple. First, I want to generate a quite simple BPEL process as
> the template (just like the synchronizing BPEL example provided by NB SOA example), then
> manipulating this BPEL process through NB's BPEL model (for example, adding activities such as
> "receive", "reply", "invoke","assign", etc.)
>
> Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
> hint/suggestion will be greatly appreciated!!
>
> Sam
>
>
>       ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>  

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
Hi Jason,

Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
reinvent the wheel :-)

Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.

Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL file
without GUI.

Any hint will be greatly appreciated!
Sam




--- Jason Baragry <[hidden email]> wrote:

> Hi Sam,
>
> BPEL is just an XML document. Why can't you just use XML apis to
> programmatically create the BPEL XML document and then import it into
> netbeans?
>
> regards
> Jason
>
> > Dear all,
> >
> > I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled with
> NB
> > GUI. For example, first I want to generate a blank BPEL process through:
> > org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >
> > However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled with
> the
> > NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >
> > Another potential approach seems through
> > "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an empty
> > "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a "BPEL"
> > project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> > "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> generate
> > this simple BPEL project through NB GUI first, and then trying to load this project into some
> > class in order to retrieve the BPEL process with the resources. But I don't know how to do
> this. I
> > think once I get the BPEL instance, I can manipulate it through all the classes in the package
> > "org.netbeans.modules.bpel.model.impl".
> >
> > In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> process as
> > the template (just like the synchronizing BPEL example provided by NB SOA example), then
> > manipulating this BPEL process through NB's BPEL model (for example, adding activities such as
> > "receive", "reply", "invoke","assign", etc.)
> >
> > Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
> > hint/suggestion will be greatly appreciated!!
> >
> > Sam
> >
> >
> >       ____________________________________________________________________________________
> > Never miss a thing.  Make Yahoo your home page.
> > http://www.yahoo.com/r/hs
> >  
>
>



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

Vaughn Spurlin-2
In reply to this post by sam wang-2
Hi Sam,

Perhaps you should also look for advice at https://open-esb.dev.java.net/. See the BPEL Service Engine User's Guide at https://open-esb.dev.java.net/kb/preview3/ep-bpel-se.html for BPEL's XML language. Consider reporting your question to [hidden email], which you can join at https://open-esb.dev.java.net/servlets/ProjectMailingListList.html.

Vaughn

----- Original Message ----
From: sam wang <[hidden email]>
To: [hidden email]
Sent: Friday, March 7, 2008 7:01:41 AM
Subject: Re: [entpack] still about how to generate BPEL process without GUI designer

Hi Jason,

Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
reinvent the wheel :-)

Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.

Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL file
without GUI.

Any hint will be greatly appreciated!
Sam




--- Jason Baragry <[hidden email]> wrote:

> Hi Sam,
>
> BPEL is just an XML document. Why can't you just use XML apis to
> programmatically create the BPEL XML document and then import it into
> netbeans?
>
> regards
> Jason
>
> > Dear all,
> >
> > I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled with
> NB
> > GUI. For example, first I want to generate a blank BPEL process through:
> > org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >
> > However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled with
> the
> > NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >
> > Another potential approach seems through
> > "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an empty
> > "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a "BPEL"
> > project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> > "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> generate
> > this simple BPEL project through NB GUI first, and then trying to load this project into some
> > class in order to retrieve the BPEL process with the resources. But I don't know how to do
> this. I
> > think once I get the BPEL instance, I can manipulate it through all the classes in the package
> > "org.netbeans.modules.bpel.model.impl".
> >
> > In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> process as
> > the template (just like the synchronizing BPEL example provided by NB SOA example), then
> > manipulating this BPEL process through NB's BPEL model (for example, adding activities such as
> > "receive", "reply", "invoke","assign", etc.)
> >
> > Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
> > hint/suggestion will be greatly appreciated!!
> >
> > Sam
> >
> >
> >      ____________________________________________________________________________________
> > Never miss a thing.  Make Yahoo your home page.
> > http://www.yahoo.com/r/hs
> >  
>
>



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

jdcondor
In reply to this post by sam wang-2
It supposed to be that openide.util is the *only* small basic NB module needed for using this stack:

..bpel.model
..wsdl.model
..wsdlext
..schema.model
..xam

I just discovered some unwanted dependencies introduce since the sierra merge.  We have removed the extra dependencies.  You can try out the following code after get the latest daily NB build at http://bits.nbextras.org/download/trunk/nightly/latest/

To create a bpel model, do something like this:

         File bpelFile = new File(pathToSourceFile);
         Lookup lookup = Lookups.fixed(new Object[]{
                bpelFile,
                myLoadPlainDocumentMethod(bpelFile),
                myCatalogModel,
            });
         ModelSource source = new ModelSource(lookup, editable);
         BpelModelFactory factory = Lookup.getDefault().lookup(BpelModelFactory.class);
         BpelModel model = factory.getModel (source);

For more detail on myCatalogModel, look at file CliValidateBpelProjectDelegate in bpel.project module.  You can reimplement it quickly removing dependency on the retriever Utilities.

-Nam

sam wang wrote:
Hi Jason,

Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
reinvent the wheel :-)

Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility. 

Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL file
without GUI.

Any hint will be greatly appreciated!
Sam




--- Jason Baragry [hidden email] wrote:

  
Hi Sam,

BPEL is just an XML document. Why can't you just use XML apis to 
programmatically create the BPEL XML document and then import it into 
netbeans?

regards
Jason

    
Dear all,

I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled with
      
NB
    
GUI. For example, first I want to generate a blank BPEL process through:
org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl

However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled with
      
the
    
NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".

Another potential approach seems through
"org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an empty
"EjbProject". I have two questions about "EjbProject". First, if it can be treated as a "BPEL"
project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
"synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
      
generate
    
this simple BPEL project through NB GUI first, and then trying to load this project into some
class in order to retrieve the BPEL process with the resources. But I don't know how to do
      
this. I
    
think once I get the BPEL instance, I can manipulate it through all the classes in the package
"org.netbeans.modules.bpel.model.impl".

In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
      
process as
    
the template (just like the synchronizing BPEL example provided by NB SOA example), then
manipulating this BPEL process through NB's BPEL model (for example, adding activities such as
"receive", "reply", "invoke","assign", etc.)

Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
hint/suggestion will be greatly appreciated!!

Sam


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
  
      
    



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

  

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
Great! That's just what I need. Thank you so much, Nam!

have a great weekend,
Sam


--- Nam Nguyen <[hidden email]> wrote:

> It supposed to be that openide.util is the *only* small basic NB module
> needed for using this stack:
>
> ..bpel.model
> ..wsdl.model
> ..wsdlext
> ..schema.model
> ..xam
>
> I just discovered some unwanted dependencies introduce since the sierra
> merge.  We have removed the extra dependencies.  You can try out the
> following code after get the latest daily NB build at
> http://bits.nbextras.org/download/trunk/nightly/latest/
>
> To create a bpel model, do something like this:
>
>          File bpelFile = new File(pathToSourceFile);
>          Lookup lookup = Lookups.fixed(new Object[]{
>                 bpelFile,
>                 myLoadPlainDocumentMethod(bpelFile),
>                 myCatalogModel,
>             });
>          ModelSource source = new ModelSource(lookup, editable);
>          BpelModelFactory factory =
> Lookup.getDefault().lookup(BpelModelFactory.class);
>          BpelModel model = factory.getModel (source);
>
> For more detail on myCatalogModel, look at file
> CliValidateBpelProjectDelegate in bpel.project module.  You can
> reimplement it quickly removing dependency on the retriever Utilities.
>
> -Nam
>
> sam wang wrote:
> > Hi Jason,
> >
> > Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
> > reinvent the wheel :-)
> >
> > Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
> > NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
> > better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.
> >
> > Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL
> file
> > without GUI.
> >
> > Any hint will be greatly appreciated!
> > Sam
> >
> >
> >
> >
> > --- Jason Baragry <[hidden email]> wrote:
> >
> >  
> >> Hi Sam,
> >>
> >> BPEL is just an XML document. Why can't you just use XML apis to
> >> programmatically create the BPEL XML document and then import it into
> >> netbeans?
> >>
> >> regards
> >> Jason
> >>
> >>    
> >>> Dear all,
> >>>
> >>> I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled
> with
> >>>      
> >> NB
> >>    
> >>> GUI. For example, first I want to generate a blank BPEL process through:
> >>> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >>>
> >>> However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled
> with
> >>>      
> >> the
> >>    
> >>> NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >>>
> >>> Another potential approach seems through
> >>> "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an
> empty
> >>> "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a
> "BPEL"
> >>> project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> >>> "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> >>>      
> >> generate
> >>    
> >>> this simple BPEL project through NB GUI first, and then trying to load this project into
> some
> >>> class in order to retrieve the BPEL process with the resources. But I don't know how to do
> >>>      
> >> this. I
> >>    
> >>> think once I get the BPEL instance, I can manipulate it through all the classes in the
> package
> >>> "org.netbeans.modules.bpel.model.impl".
> >>>
> >>> In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> >>>      
> >> process as
> >>    
> >>> the template (just like the synchronizing BPEL example provided by NB SOA example), then
> >>> manipulating this BPEL process through NB's BPEL model (for example, adding activities such
> as
> >>> "receive", "reply", "invoke","assign", etc.)
> >>>
> >>> Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
> >>> hint/suggestion will be greatly appreciated!!
> >>>
> >>> Sam
> >>>
> >>>
> >>>       ____________________________________________________________________________________
> >>> Never miss a thing.  Make Yahoo your home page.
> >>> http://www.yahoo.com/r/hs
> >>>  
> >>>      
> >>    
> >
> >
> >
> >       ____________________________________________________________________________________
> > Be a better friend, newshound, and
> > know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
> >
> >  
>
>



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
In reply to this post by jdcondor
Dear Nam,

I am very sorry to interrupt you again. The URL
"http://bits.nbextras.org/download/trunk/nightly/latest/" in your email is for NB 6.1 beta, right?
I download it and create the correct environment based on NB 6.1 beta. However, I still got
confused about the following questions:

First, I don't know what's myCatalogModel, even after I read the code of
"CliValidateBpelProjectDelegate" in bpel.project. I attached the source code at the attachment for
your reference.

Second, I have no clue about "myLoadPlainDocumentMethod". Could you please explain a little bit
more for me, or even better, provide me a simple sample?

Third, is your sample code for creating a blank BPEL process or reading a BPEL process project
created by NB GUI? If it's latter, the "pathToSourceFile" means the BPEL file directory or the
BPEL project src directory?

Fourth, does NB BPEL provide the API to process WSDL file? for example, partnerlink definition in
the WSDL file? (from your last email, it seems NB BPEL provides such kind of capability:
wsdl.model, wsdlext). Could you please give me a simple sample to demonstrate the usage? If the
sample code from your last email is for reading a BPEL process, is there a way to retrieve the
corresponding WSDL file in this BPEL project for further processing, and how?


Thank you very much for the great help!
Sam





--- Nam Nguyen <[hidden email]> wrote:

> It supposed to be that openide.util is the *only* small basic NB module
> needed for using this stack:
>
> ..bpel.model
> ..wsdl.model
> ..wsdlext
> ..schema.model
> ..xam
>
> I just discovered some unwanted dependencies introduce since the sierra
> merge.  We have removed the extra dependencies.  You can try out the
> following code after get the latest daily NB build at
> http://bits.nbextras.org/download/trunk/nightly/latest/
>
> To create a bpel model, do something like this:
>
>          File bpelFile = new File(pathToSourceFile);
>          Lookup lookup = Lookups.fixed(new Object[]{
>                 bpelFile,
>                 myLoadPlainDocumentMethod(bpelFile),
>                 myCatalogModel,
>             });
>          ModelSource source = new ModelSource(lookup, editable);
>          BpelModelFactory factory =
> Lookup.getDefault().lookup(BpelModelFactory.class);
>          BpelModel model = factory.getModel (source);
>
> For more detail on myCatalogModel, look at file
> CliValidateBpelProjectDelegate in bpel.project module.  You can
> reimplement it quickly removing dependency on the retriever Utilities.
>
> -Nam
>
> sam wang wrote:
> > Hi Jason,
> >
> > Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
> > reinvent the wheel :-)
> >
> > Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
> > NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
> > better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.
> >
> > Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL
> file
> > without GUI.
> >
> > Any hint will be greatly appreciated!
> > Sam
> >
> >
> >
> >
> > --- Jason Baragry <[hidden email]> wrote:
> >
> >  
> >> Hi Sam,
> >>
> >> BPEL is just an XML document. Why can't you just use XML apis to
> >> programmatically create the BPEL XML document and then import it into
> >> netbeans?
> >>
> >> regards
> >> Jason
> >>
> >>    
> >>> Dear all,
> >>>
> >>> I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled
> with
> >>>      
> >> NB
> >>    
> >>> GUI. For example, first I want to generate a blank BPEL process through:
> >>> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >>>
> >>> However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled
> with
> >>>      
> >> the
> >>    
> >>> NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >>>
> >>> Another potential approach seems through
> >>> "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an
> empty
> >>> "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a
> "BPEL"
> >>> project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> >>> "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> >>>      
> >> generate
> >>    
> >>> this simple BPEL project through NB GUI first, and then trying to load this project into
> some
> >>> class in order to retrieve the BPEL process with the resources. But I don't know how to do
> >>>      
> >> this. I
> >>    
> >>> think once I get the BPEL instance, I can manipulate it through all the classes in the
> package
> >>> "org.netbeans.modules.bpel.model.impl".
> >>>
> >>> In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> >>>      
> >> process as
> >>    
> >>> the template (just like the synchronizing BPEL example provided by NB SOA example), then
> >>> manipulating this BPEL process through NB's BPEL model (for example, adding activities such
> as
> >>> "receive", "reply", "invoke","assign", etc.)
> >>>
> >>> Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
> >>> hint/suggestion will be greatly appreciated!!
> >>>
> >>> Sam
> >>>
> >>>
> >>>       ____________________________________________________________________________________
> >>> Never miss a thing.  Make Yahoo your home page.
> >>> http://www.yahoo.com/r/hs
> >>>  
> >>>      
> >>    
> >
> >
> >
> >       ____________________________________________________________________________________
> > Be a better friend, newshound, and
> > know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
> >
> >  
>
>


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common
 * Development and Distribution License("CDDL") (collectively, the
 * "License"). You may not use this file except in compliance with the
 * License. You can obtain a copy of the License at
 * http://www.netbeans.org/cddl-gplv2.html
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 * specific language governing permissions and limitations under the
 * License.  When distributing the software, include this License Header
 * Notice in each file and include the License file at
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the GPL Version 2 section of the License file that
 * accompanied this code. If applicable, add the following below the
 * License Header, with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Contributor(s):
 *
 * The Original Software is NetBeans. The Initial Developer of the Original
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
 * Microsystems, Inc. All Rights Reserved.
 *
 * If you wish your version of this file to be governed by only the CDDL
 * or only the GPL Version 2, indicate your decision by adding
 * "[Contributor] elects to include this software in this distribution
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 * single choice of license, a recipient has the option to distribute
 * your version of this file under either the CDDL, the GPL Version 2 or
 * to extend the choice of license to its licensees as provided above.
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 * Version 2 license, then the option applies only if the new code is
 * made subject to such option by the copyright holder.
 */
package org.netbeans.modules.bpel.project.anttasks.cli;

import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Reference;
import org.netbeans.modules.bpel.model.api.BpelModel;
import org.netbeans.modules.bpel.project.CommandlineBpelProjectXmlCatalogProvider;
import org.netbeans.modules.bpel.project.anttasks.util.Util;
import org.netbeans.modules.xml.xam.Component;
import org.netbeans.modules.xml.xam.Model;
import org.netbeans.modules.xml.xam.spi.Validation;
import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
import org.netbeans.modules.xml.xam.spi.Validator;
import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;

/**
 * Validates BPEL Module
 * @author Sreenivasan Genipudi
 */
public class CliValidateBpelProjectDelegate extends Task {
   
    private String mSourceDirectory;
    private String mProjectClassPath;
    private String mBuildDirectory;
    private String mBuildDependentProjectFilesDirectory;
    private File mSourceDir;
    private File mBuildDir;
    private Map mBpelFileNamesToFileInBuildDir = new HashMap();
    private boolean isFoundErrors = false;
    private boolean mAllowBuildWithError = false;
   
    public CliValidateBpelProjectDelegate() {
        // Does nothing
    }
   
    public void setSourceDirectory(String srcDir) {
        this.mSourceDirectory = srcDir;
    }
   
    public void setBuildDirectory(String buildDir) {
        this.mBuildDirectory = buildDir;
    }
   
    public void setRunValidation(String flag) {
        setAllowBuildWithError(flag);
        mAllowBuildWithError = !mAllowBuildWithError;
    }
   
    public void setAllowBuildWithError(String flag) {
        if (flag != null) {
            if (flag.equals("false")) {
                mAllowBuildWithError = false;
            } else if (flag.equals("true")) {
                mAllowBuildWithError = true;
            }
        }
    }
   
    public void setClasspathRef(Reference ref) {
    }
   
    public void setProjectClassPath(String projectClassPath) {
        this.mProjectClassPath = projectClassPath;
    }
   
    public void setBuildDependentProjectDir(String dependentProjectFilesDir) {
        this.mBuildDependentProjectFilesDirectory = dependentProjectFilesDir;
    }
   
    public boolean isFoundErrors() {
        return this.isFoundErrors;
    }
   
    @Override
    public void execute() throws BuildException {
        if (this.mSourceDirectory == null) {
            throw new BuildException("No directory is set for source files.");
        }

        if (this.mBuildDirectory == null) {
            throw new BuildException("No build directory is set.");
        }

        if (this.mBuildDependentProjectFilesDirectory == null) {
            throw new BuildException("No dependentProjectFiles directory is set.");
        }

        try {
            this.mSourceDir = new File(this.mSourceDirectory);
            CommandlineBpelProjectXmlCatalogProvider.getInstance().setSourceDirectory(this.mSourceDirectory);

        } catch (Exception ex) {
            throw new BuildException("Failed to get File object for project source directory " + this.mSourceDirectory, ex);
        }

        try {
            this.mBuildDir = new File(this.mBuildDirectory);
        } catch (Exception ex) {
            throw new BuildException("Failed to get File object for project build directory " + this.mBuildDirectory, ex);
        }

        processBuildDir(this.mBuildDir);
        processSourceDir(this.mSourceDir);
    }
   
    private void processBuildDir(File folder) {
        final File files[] = folder.listFiles(new Util.BpelFileFilter());
       
        if (files == null) return; // no children
       
        for (int i = 0; i < files.length; i++) {
            final File file = files[i];
           
            if (file.isFile()) {
                this.mBpelFileNamesToFileInBuildDir.put(
                        Util.getRelativePath(this.mBuildDir, file),
                        file);
            } else {
                processBuildDir(file);
            }
        }
    }
   
    private void processSourceDir(File file) {
        if (file.isDirectory()) {
            final File[] children = file.listFiles(new Util.BpelFileFilter());
           
            if (children == null) return; // no children
           
            for (int i = 0; i < children.length; i++) {
                processSourceDir(children[i]);
            }
        } else {
            if (isModified(file)) {
                validate(file);
            }
        }
    }
   
    private boolean isModified(File bpelFile) {
        boolean modified = true;
        String relativePath = Util.getRelativePath(this.mSourceDir, bpelFile);
        File bpelFileInBuildDir = (File) this.mBpelFileNamesToFileInBuildDir.get(relativePath);

        if (bpelFileInBuildDir != null) {
            if (bpelFileInBuildDir.lastModified() == bpelFile.lastModified()) {
                modified = false;
            }
        }
        return modified;
    }
   
    private void validate(File bpelFile) throws BuildException {
        try {
            BpelModel model = CliBpelCatalogModel.
                    getDefault().getBPELModel(bpelFile.toURI());
                   
            Validation validation = new Validation();
            validation.validate((Model) model, ValidationType.COMPLETE);
            Collection col = validation.getValidationResult();
            boolean isError = false;
           
            for (Iterator itr = col.iterator(); itr.hasNext();) {
                ResultItem resultItem = (ResultItem) itr.next();
               
                if (!mAllowBuildWithError) {
                    if (resultItem.getType() == Validator.ResultType.ERROR) {
                        System.out.println(getValidationError(resultItem));
                        System.out.println();
                    }
                }
               
                if (resultItem.getType() == Validator.ResultType.ERROR) {
                    isError = true;
                }
            }

            if (isError) {
                this.isFoundErrors = true;
            }
        } catch (Throwable e) {
            if (!mAllowBuildWithError) {
                throw new BuildException(e);
            }
        }
    }
   
    private String getValidationError(ResultItem resultItem) {
        int lineNumber = 0;
        int columnNumber = 0;
        String errorDescription = resultItem.getDescription();
        String msgType = resultItem.getType().name();
        Component component = resultItem.getComponents();
        File file = null;

        if (component == null) {
            columnNumber = resultItem.getColumnNumber();
            lineNumber = resultItem.getLineNumber();
            file = (File) resultItem.getModel().getModelSource().getLookup().lookup(File.class);
        } else {
            lineNumber = Util.getLineNumber(component);
            columnNumber = Util.getColumnNumber(component);
            file = (File) component.getModel().getModelSource().getLookup().lookup(File.class);
        }
        return Util.getError(file, columnNumber, lineNumber, errorDescription, msgType);
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

jdcondor
Hi Sam,

See in-line...

sam wang wrote:
Dear Nam,

I am very sorry to interrupt you again. The URL
"http://bits.nbextras.org/download/trunk/nightly/latest/" in your email is for NB 6.1 beta, right?
  
It is nightly build.  Beta1 build already released, does not container these fixes...
I download it and create the correct environment based on NB 6.1 beta. However, I still got
confused about the following questions:

First, I don't know what's myCatalogModel, even after I read the code of
"CliValidateBpelProjectDelegate" in bpel.project. I attached the source code at the attachment for
your reference.
  
My mistake during cut-n-paste the class name.  It should be CliBpelCatalogModel.  An implementation of CatalogModel is required to be in the lookup to resolve external references (to wsdl / xsd) from the bpel you are trying to load.
Second, I have no clue about "myLoadPlainDocumentMethod". Could you please explain a little bit
more for me, or even better, provide me a simple sample?
  
Look at xml.xam/src/org/netbeans/modules/xml/xam/dom/ReadOnlyAccess#loadSwingDocument
Third, is your sample code for creating a blank BPEL process or reading a BPEL process project
created by NB GUI? If it's latter, the "pathToSourceFile" means the BPEL file directory or the
BPEL project src directory?
  
It could be any bpel sources.  In case for creating a new bpel process you could just provide your own skeleton template file.
Fourth, does NB BPEL provide the API to process WSDL file? for example, partnerlink definition in
the WSDL file? (from your last email, it seems NB BPEL provides such kind of capability:
wsdl.model, wsdlext). Could you please give me a simple sample to demonstrate the usage? If the
sample code from your last email is for reading a BPEL process, is there a way to retrieve the
corresponding WSDL file in this BPEL project for further processing, and how?
  
I would let other BPEL model experts give you sample code.

(just a hint: there are PartnerLinkReference and PortTypeReference in bpel.model, which help you navigate to the referenced WSDL elements)

Thank you very much for the great help!
Sam





--- Nam Nguyen [hidden email] wrote:

  
It supposed to be that openide.util is the *only* small basic NB module 
needed for using this stack:

..bpel.model
..wsdl.model
..wsdlext
..schema.model
..xam

I just discovered some unwanted dependencies introduce since the sierra 
merge.  We have removed the extra dependencies.  You can try out the 
following code after get the latest daily NB build at 
http://bits.nbextras.org/download/trunk/nightly/latest/

To create a bpel model, do something like this:

         File bpelFile = new File(pathToSourceFile);
         Lookup lookup = Lookups.fixed(new Object[]{
                bpelFile,
                myLoadPlainDocumentMethod(bpelFile),
                myCatalogModel,
            });
         ModelSource source = new ModelSource(lookup, editable);
         BpelModelFactory factory = 
Lookup.getDefault().lookup(BpelModelFactory.class);
         BpelModel model = factory.getModel (source);

For more detail on myCatalogModel, look at file 
CliValidateBpelProjectDelegate in bpel.project module.  You can 
reimplement it quickly removing dependency on the retriever Utilities.

-Nam

sam wang wrote:
    
Hi Jason,

Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
reinvent the wheel :-)

Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process, I'd
better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility. 

Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL
      
file
    
without GUI.

Any hint will be greatly appreciated!
Sam




--- Jason Baragry [hidden email] wrote:

  
      
Hi Sam,

BPEL is just an XML document. Why can't you just use XML apis to 
programmatically create the BPEL XML document and then import it into 
netbeans?

regards
Jason

    
        
Dear all,

I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled
          
with
    
      
          
NB
    
        
GUI. For example, first I want to generate a blank BPEL process through:
org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl

However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled
          
with
    
      
          
the
    
        
NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".

Another potential approach seems through
"org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an
          
empty
    
"EjbProject". I have two questions about "EjbProject". First, if it can be treated as a
          
"BPEL"
    
project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
"synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
      
          
generate
    
        
this simple BPEL project through NB GUI first, and then trying to load this project into
          
some
    
class in order to retrieve the BPEL process with the resources. But I don't know how to do
      
          
this. I
    
        
think once I get the BPEL instance, I can manipulate it through all the classes in the
          
package
    
"org.netbeans.modules.bpel.model.impl".

In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
      
          
process as
    
        
the template (just like the synchronizing BPEL example provided by NB SOA example), then
manipulating this BPEL process through NB's BPEL model (for example, adding activities such
          
as
    
"receive", "reply", "invoke","assign", etc.)

Since this is part of my Ph.D research and I am in huge pressure to graduate, any quick
hint/suggestion will be greatly appreciated!!

Sam


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
  
      
          
    
        

      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now. 
      
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
    
  
      
    



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
  

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
Thank you very much for the quick reply, Nam!

However, I don't know how to download the latest version
(http://bits.nbextras.org/download/trunk/nightly/latest/). I tried both "cvs" and "Mercurial's
hg". Neither of them works! Besides, I can't find any more detailed download information from NB
website. Could you please let me know how to access the latest version?

In fact, I just want to SOA package, not the whole NB project's sourecode. Is there a URL to
access SOA branch? Another question, can I use NB6.1 beta's jar files to compile the
latest/nightlybuild SOA package? Since I know SOA package will use XML and openide packages at
least.

Thanks again!
Sam


--- Nam Nguyen <[hidden email]> wrote:

> Hi Sam,
>
> See in-line...
>
> sam wang wrote:
> > Dear Nam,
> >
> > I am very sorry to interrupt you again. The URL
> > "http://bits.nbextras.org/download/trunk/nightly/latest/" in your email is for NB 6.1 beta,
> right?
> >  
> It is nightly build.  Beta1 build already released, does not container
> these fixes...
> > I download it and create the correct environment based on NB 6.1 beta. However, I still got
> > confused about the following questions:
> >
> > First, I don't know what's myCatalogModel, even after I read the code of
> > "CliValidateBpelProjectDelegate" in bpel.project. I attached the source code at the attachment
> for
> > your reference.
> >  
> My mistake during cut-n-paste the class name.  It should be
> CliBpelCatalogModel.  An implementation of CatalogModel is required to
> be in the lookup to resolve external references (to wsdl / xsd) from the
> bpel you are trying to load.
> > Second, I have no clue about "myLoadPlainDocumentMethod". Could you please explain a little
> bit
> > more for me, or even better, provide me a simple sample?
> >  
> Look at
> xml.xam/src/org/netbeans/modules/xml/xam/dom/ReadOnlyAccess#loadSwingDocument
> > Third, is your sample code for creating a blank BPEL process or reading a BPEL process project
> > created by NB GUI? If it's latter, the "pathToSourceFile" means the BPEL file directory or the
> > BPEL project src directory?
> >  
> It could be any bpel sources.  In case for creating a new bpel process
> you could just provide your own skeleton template file.
> > Fourth, does NB BPEL provide the API to process WSDL file? for example, partnerlink definition
> in
> > the WSDL file? (from your last email, it seems NB BPEL provides such kind of capability:
> > wsdl.model, wsdlext). Could you please give me a simple sample to demonstrate the usage? If
> the
> > sample code from your last email is for reading a BPEL process, is there a way to retrieve the
> > corresponding WSDL file in this BPEL project for further processing, and how?
> >  
> I would let other BPEL model experts give you sample code.
>
> (just a hint: there are PartnerLinkReference and PortTypeReference in
> bpel.model, which help you navigate to the referenced WSDL elements)
> >
> > Thank you very much for the great help!
> > Sam
> >
> >
> >
> >
> >
> > --- Nam Nguyen <[hidden email]> wrote:
> >
> >  
> >> It supposed to be that openide.util is the *only* small basic NB module
> >> needed for using this stack:
> >>
> >> ..bpel.model
> >> ..wsdl.model
> >> ..wsdlext
> >> ..schema.model
> >> ..xam
> >>
> >> I just discovered some unwanted dependencies introduce since the sierra
> >> merge.  We have removed the extra dependencies.  You can try out the
> >> following code after get the latest daily NB build at
> >> http://bits.nbextras.org/download/trunk/nightly/latest/
> >>
> >> To create a bpel model, do something like this:
> >>
> >>          File bpelFile = new File(pathToSourceFile);
> >>          Lookup lookup = Lookups.fixed(new Object[]{
> >>                 bpelFile,
> >>                 myLoadPlainDocumentMethod(bpelFile),
> >>                 myCatalogModel,
> >>             });
> >>          ModelSource source = new ModelSource(lookup, editable);
> >>          BpelModelFactory factory =
> >> Lookup.getDefault().lookup(BpelModelFactory.class);
> >>          BpelModel model = factory.getModel (source);
> >>
> >> For more detail on myCatalogModel, look at file
> >> CliValidateBpelProjectDelegate in bpel.project module.  You can
> >> reimplement it quickly removing dependency on the retriever Utilities.
> >>
> >> -Nam
> >>
> >> sam wang wrote:
> >>    
> >>> Hi Jason,
> >>>
> >>> Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
> >>> reinvent the wheel :-)
> >>>
> >>> Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
> >>> NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process,
> I'd
> >>> better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.
> >>>
> >>> Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL
> >>>      
> >> file
> >>    
> >>> without GUI.
> >>>
> >>> Any hint will be greatly appreciated!
> >>> Sam
> >>>
> >>>
> >>>
> >>>
> >>> --- Jason Baragry <[hidden email]> wrote:
> >>>
> >>>  
> >>>      
> >>>> Hi Sam,
> >>>>
> >>>> BPEL is just an XML document. Why can't you just use XML apis to
> >>>> programmatically create the BPEL XML document and then import it into
> >>>> netbeans?
> >>>>
> >>>> regards
> >>>> Jason
> >>>>
> >>>>    
> >>>>        
> >>>>> Dear all,
> >>>>>
> >>>>> I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled
> >>>>>          
> >> with
> >>    
> >>>>>      
> >>>>>          
> >>>> NB
> >>>>    
> >>>>        
> >>>>> GUI. For example, first I want to generate a blank BPEL process through:
> >>>>> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >>>>>
> >>>>> However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled
> >>>>>          
> >> with
> >>    
> >>>>>      
> >>>>>          
> >>>> the
> >>>>    
> >>>>        
> >>>>> NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >>>>>
> >>>>> Another potential approach seems through
> >>>>> "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an
> >>>>>          
> >> empty
> >>    
> >>>>> "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a
> >>>>>          
> >> "BPEL"
> >>    
> >>>>> project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> >>>>> "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> >>>>>      
> >>>>>          
> >>>> generate
> >>>>    
> >>>>        
> >>>>> this simple BPEL project through NB GUI first, and then trying to load this project into
> >>>>>          
> >> some
> >>    
> >>>>> class in order to retrieve the BPEL process with the resources. But I don't know how to do
> >>>>>      
> >>>>>          
> >>>> this. I
> >>>>    
> >>>>        
> >>>>> think once I get the BPEL instance, I can manipulate it through all the classes in the
> >>>>>          
> >> package
> >>    
> >>>>> "org.netbeans.modules.bpel.model.impl".
> >>>>>
> >>>>> In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> >>>>>      
> >>>>>          
> >>>> process as
> >>>>    
> >>>>        
> >>>>> the template (just like the synchronizing BPEL example provided by NB SOA example), then
> >>>>> manipulating this BPEL process through NB's BPEL model (for example, adding activities
> such
> >>>>>          
> >> as
> >>    
>
=== message truncated ===



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

jdcondor
sam wang wrote:
> Thank you very much for the quick reply, Nam!
>
> However, I don't know how to download the latest version
> (http://bits.nbextras.org/download/trunk/nightly/latest/).
This is for latest binary downloads.
> I tried both "cvs" and "Mercurial's
> hg". Neither of them works! Besides, I can't find any more detailed download information from NB
> website.
To get latest source, refer to http://wiki.netbeans.org/HgHowTos
> Could you please let me know how to access the latest version?
>  
There are instructions at the bottom left of the above download page
referring to cluster zips and sources.
> In fact, I just want to SOA package, not the whole NB project's sourecode. Is there a URL to
> access SOA branch? Another question, can I use NB6.1 beta's jar files to compile the
> latest/nightlybuild SOA package? Since I know SOA package will use XML and openide packages at
> least.
>
> Thanks again!
> Sam
>  

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
In reply to this post by jdcondor
Hi, Nam,

Thank you very much for the great help! I have found the link to download the night source code
according to your suggestion.

As for the loading BPEL model from BPEL file, I still have two questions. The following is your
original suggestion code:

*****************************************************************************
File bpelFile = new File(pathToSourceFile);
Lookup lookup = Lookups.fixed(new Object[]{
        bpelFile,
        myLoadPlainDocumentMethod(bpelFile),
        myCatalogModel,
});
ModelSource source = new ModelSource(lookup, editable);
BpelModelFactory factory =
Lookup.getDefault().lookup(BpelModelFactory.class);
BpelModel model = factory.getModel (source);
*****************************************************************************

As for the "myLoadPlainDocumentMethod", if I understand correctly, I can directly reuse the method
"loadSwingDocument" in the class of "ReadOnlyAccess". So the type of "myLoadPlainDocumentMethod"
is  "javax.swing.text.Document" (not a BpelModel type). I don't understand why I need load a swing
doc.

As for the "myCatalogModel" class, I only change the following line in the class of
"CliBpelCatalogModel":
"URI catalogFileLocPath=
CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"

to the following line in my own class "MyCatalogModel":
"catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"

Then in my main class, I invoke as following:

File bpelFile = new File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");

lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
MyCatalogModel.getDefault().getBPELModel(bpelURI),});

However, the lookup is always null. Did I miss something or implement wrong?

Since all I need is to load the BPEL file (with WSDL) into BpelModel, I wonder if there is a
simple approach to do this without all the error-prone "lookup" methods?


Thank you very much for the time and help!
Sam





--- Nam Nguyen <[hidden email]> wrote:

> Hi Sam,
>
> See in-line...
>
> sam wang wrote:
> > Dear Nam,
> >
> > I am very sorry to interrupt you again. The URL
> > "http://bits.nbextras.org/download/trunk/nightly/latest/" in your email is for NB 6.1 beta,
> right?
> >  
> It is nightly build.  Beta1 build already released, does not container
> these fixes...
> > I download it and create the correct environment based on NB 6.1 beta. However, I still got
> > confused about the following questions:
> >
> > First, I don't know what's myCatalogModel, even after I read the code of
> > "CliValidateBpelProjectDelegate" in bpel.project. I attached the source code at the attachment
> for
> > your reference.
> >  
> My mistake during cut-n-paste the class name.  It should be
> CliBpelCatalogModel.  An implementation of CatalogModel is required to
> be in the lookup to resolve external references (to wsdl / xsd) from the
> bpel you are trying to load.
> > Second, I have no clue about "myLoadPlainDocumentMethod". Could you please explain a little
> bit
> > more for me, or even better, provide me a simple sample?
> >  
> Look at
> xml.xam/src/org/netbeans/modules/xml/xam/dom/ReadOnlyAccess#loadSwingDocument
> > Third, is your sample code for creating a blank BPEL process or reading a BPEL process project
> > created by NB GUI? If it's latter, the "pathToSourceFile" means the BPEL file directory or the
> > BPEL project src directory?
> >  
> It could be any bpel sources.  In case for creating a new bpel process
> you could just provide your own skeleton template file.
> > Fourth, does NB BPEL provide the API to process WSDL file? for example, partnerlink definition
> in
> > the WSDL file? (from your last email, it seems NB BPEL provides such kind of capability:
> > wsdl.model, wsdlext). Could you please give me a simple sample to demonstrate the usage? If
> the
> > sample code from your last email is for reading a BPEL process, is there a way to retrieve the
> > corresponding WSDL file in this BPEL project for further processing, and how?
> >  
> I would let other BPEL model experts give you sample code.
>
> (just a hint: there are PartnerLinkReference and PortTypeReference in
> bpel.model, which help you navigate to the referenced WSDL elements)
> >
> > Thank you very much for the great help!
> > Sam
> >
> >
> >
> >
> >
> > --- Nam Nguyen <[hidden email]> wrote:
> >
> >  
> >> It supposed to be that openide.util is the *only* small basic NB module
> >> needed for using this stack:
> >>
> >> ..bpel.model
> >> ..wsdl.model
> >> ..wsdlext
> >> ..schema.model
> >> ..xam
> >>
> >> I just discovered some unwanted dependencies introduce since the sierra
> >> merge.  We have removed the extra dependencies.  You can try out the
> >> following code after get the latest daily NB build at
> >> http://bits.nbextras.org/download/trunk/nightly/latest/
> >>
> >> To create a bpel model, do something like this:
> >>
> >>          File bpelFile = new File(pathToSourceFile);
> >>          Lookup lookup = Lookups.fixed(new Object[]{
> >>                 bpelFile,
> >>                 myLoadPlainDocumentMethod(bpelFile),
> >>                 myCatalogModel,
> >>             });
> >>          ModelSource source = new ModelSource(lookup, editable);
> >>          BpelModelFactory factory =
> >> Lookup.getDefault().lookup(BpelModelFactory.class);
> >>          BpelModel model = factory.getModel (source);
> >>
> >> For more detail on myCatalogModel, look at file
> >> CliValidateBpelProjectDelegate in bpel.project module.  You can
> >> reimplement it quickly removing dependency on the retriever Utilities.
> >>
> >> -Nam
> >>
> >> sam wang wrote:
> >>    
> >>> Hi Jason,
> >>>
> >>> Thank you for the reply. Since there are existing codes for generating BPEL, I prefer not to
> >>> reinvent the wheel :-)
> >>>
> >>> Eclipse BPEL also provides an open source BPEL model, which is more clear and simple than
> >>> NetBeans'. However, since I want to use NetBeans execution engine to run the BPEL process,
> I'd
> >>> better use NetBeans' BPEL model to generate BPEL file to make sure the compatibility.
> >>>
> >>> Anyway, I really don't think there is no way to re-use NetBeans BPEL model to generate BPEL
> >>>      
> >> file
> >>    
> >>> without GUI.
> >>>
> >>> Any hint will be greatly appreciated!
> >>> Sam
> >>>
> >>>
> >>>
> >>>
> >>> --- Jason Baragry <[hidden email]> wrote:
> >>>
> >>>  
> >>>      
> >>>> Hi Sam,
> >>>>
> >>>> BPEL is just an XML document. Why can't you just use XML apis to
> >>>> programmatically create the BPEL XML document and then import it into
> >>>> netbeans?
> >>>>
> >>>> regards
> >>>> Jason
> >>>>
> >>>>    
> >>>>        
> >>>>> Dear all,
> >>>>>
> >>>>> I just checked the source code of BPEL, I found that the BPEL model seems tightly coupled
> >>>>>          
> >> with
> >>    
> >>>>>      
> >>>>>          
> >>>> NB
> >>>>    
> >>>>        
> >>>>> GUI. For example, first I want to generate a blank BPEL process through:
> >>>>> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl
> >>>>>
> >>>>> However, I need to get "org.netbeans.modules.xml.xam.ModelSource", which tightly coupled
> >>>>>          
> >> with
> >>    
> >>>>>      
> >>>>>          
> >>>> the
> >>>>    
> >>>>        
> >>>>> NB GUI through "org.openide.util.Lookup". I don't know how to instantiate "Lookup".
> >>>>>
> >>>>> Another potential approach seems through
> >>>>> "org.netbeans.modules.bpel.project.BpelproProjectGenerator". However, it only creates an
> >>>>>          
> >> empty
> >>    
> >>>>> "EjbProject". I have two questions about "EjbProject". First, if it can be treated as a
> >>>>>          
> >> "BPEL"
> >>    
> >>>>> project. Second, if it can be treated as a "BPEL" project, how can I create a very simple
> >>>>> "synchronizing BPEL example", just like the example provided by NB SOA. Or simpler, I can
> >>>>>      
> >>>>>          
> >>>> generate
> >>>>    
> >>>>        
> >>>>> this simple BPEL project through NB GUI first, and then trying to load this project into
> >>>>>          
> >> some
> >>    
> >>>>> class in order to retrieve the BPEL process with the resources. But I don't know how to do
> >>>>>      
> >>>>>          
> >>>> this. I
> >>>>    
> >>>>        
> >>>>> think once I get the BPEL instance, I can manipulate it through all the classes in the
> >>>>>          
> >> package
> >>    
> >>>>> "org.netbeans.modules.bpel.model.impl".
> >>>>>
> >>>>> In a word, my requirement is very simple. First, I want to generate a quite simple BPEL
> >>>>>      
> >>>>>          
> >>>> process as
> >>>>    
> >>>>        
> >>>>> the template (just like the synchronizing BPEL example provided by NB SOA example), then
> >>>>> manipulating this BPEL process through NB's BPEL model (for example, adding activities
> such
> >>>>>          
> >> as
> >>    
>
=== message truncated ===



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

jdcondor
sam wang wrote:

> Hi, Nam,
>
> Thank you very much for the great help! I have found the link to download the night source code
> according to your suggestion.
>
> As for the loading BPEL model from BPEL file, I still have two questions. The following is your
> original suggestion code:
>
> *****************************************************************************
> File bpelFile = new File(pathToSourceFile);
> Lookup lookup = Lookups.fixed(new Object[]{
> bpelFile,
> myLoadPlainDocumentMethod(bpelFile),
> myCatalogModel,
> });
> ModelSource source = new ModelSource(lookup, editable);
> BpelModelFactory factory =
> Lookup.getDefault().lookup(BpelModelFactory.class);
> BpelModel model = factory.getModel (source);
> *****************************************************************************
>
> As for the "myLoadPlainDocumentMethod", if I understand correctly, I can directly reuse the method
> "loadSwingDocument" in the class of "ReadOnlyAccess". So the type of "myLoadPlainDocumentMethod"
> is  "javax.swing.text.Document" (not a BpelModel type).
Correct.
> I don't understand why I need load a swing
> doc.
>  
The ModelSource object needs to provide context for the model factory to
load the model.  Providing context through Lookup is a flexible  way to
shield API from differences in environment details (e.g. inside the IDE
or outside the IDE, the actual provided document instance are of
different implementations.  Same with catalog provider).

> As for the "myCatalogModel" class, I only change the following line in the class of
> "CliBpelCatalogModel":
> "URI catalogFileLocPath=
> CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
>
> to the following line in my own class "MyCatalogModel":
> "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
>
> Then in my main class, I invoke as following:
>
> File bpelFile = new File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
>
> lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
> MyCatalogModel.getDefault().getBPELModel(bpelURI),});
>
> However, the lookup is always null. Did I miss something or implement wrong?
>  
Do you really mean lookup is null or the requested bpel model is null?
I recommend you create a simple Java application (using NB 6.1 beta) and
add the required jars as libraries, do some simple testing and
debugging, trying to isolate problem element using elimination
approach.   As far as I can tell, simple lookup with only File and
Document objects works fine.
> Since all I need is to load the BPEL file (with WSDL) into BpelModel, I wonder if there is a
> simple approach to do this without all the error-prone "lookup" methods?
>  
Lookup itself is very simple and powerful.  And the model loading
mechanism is relatively simple and flexible.  You just need a bit of
patience to debug the provision of the lookup objects.

-Nam
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

sam wang-2
Hi, Nam,

I got the latest source code and the jar files (March, 11). However, I still got "null pointer"
problems when generating "model" in the line:
BpelModel model = factory.getModel(source);

The following is from my main method:

1. File bpelFile = new File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
2. bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
3. FileInputStream fis = new FileInputStream(bpelFile);
4. Lookup lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
5.                 MyCatalogModel.getDefault().getBPELModel(bpelURI),});
6. ModelSource source = new ModelSource(lookup,true);
7. BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
8. BpelModel model = factory.getModel(source);


*****************************************************************************************
As for "loadPlainDocument" method, I just copy the method "loadSwingDocument" in the class of
"ReadOnlyAccess". As for "MyCatalogModel" class, I just copy the class "CliBpelCatalogModel" with
only one modification:
"URI catalogFileLocPath=
CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
changing to:
"catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"

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

I change your code:
BpelModelFactory factory = Lookup.getDefault().lookup(BpelModelFactory.class);

to: BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
because I can't find BpelModelFactory instance from the default of Lookup.

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

In line 5, I also tried another approach: MyCatalogModel.getDefault(),
However, both approaches will get "null pointer" exception at the method "getSwingDocument" in the
class of "org.netbeans.modules.xml.xdm.XDMModel":

private BaseDocument getSwingDocument() {
        BaseDocument bd = (BaseDocument)
        source.getLookup().lookup(BaseDocument.class);
        return bd;}


The following is the error message:
Cannot find null
java.lang.NullPointerException
        at org.netbeans.modules.xml.xdm.XDMModel.prepareSync(XDMModel.java:166)
        at org.netbeans.modules.xml.xdm.XDMModel.sync(XDMModel.java:156)
        at org.netbeans.modules.xml.xdm.xam.XDMAccess.sync(XDMAccess.java:126)
        at org.netbeans.modules.xml.xam.AbstractModel.sync(AbstractModel.java:259)
        at org.netbeans.modules.bpel.model.impl.BpelModelImpl.sync(BpelModelImpl.java:380)
        at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:137)
        at
org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
        at mybpel.MyCatalogModel.getBPELModel(MyCatalogModel.java:229)
        at mybpel.BpelProcess.main(BpelProcess.java:69)
Exception in thread "main" java.lang.NullPointerException
        at
org.netbeans.modules.xml.xam.AbstractModelFactory.getEffectiveAccessProvider(AbstractModelFactory.java:116)
        at org.netbeans.modules.xml.xam.AbstractModelFactory.getKey(AbstractModelFactory.java:108)
        at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:129)
        at
org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
        at mybpel.BpelProcess.main(BpelProcess.java:81)


I understand this error, because "BaseDocument" extends "AbstractDocument", however, in line 4, I
put "PlainDocument" in Lookup.  "PlainDocument" is also extends "AbstractDocument". So
"PlainDocument" is not an instance of "BaseDocument" class.

Dose that mean that I need instantiate "BaseDocument" and put into Lookup in line 4? but how? or
something else wrong?

Thank you so much for the help!
Sam














--- Nam Nguyen <[hidden email]> wrote:

> sam wang wrote:
> > Hi, Nam,
> >
> > Thank you very much for the great help! I have found the link to download the night source
> code
> > according to your suggestion.
> >
> > As for the loading BPEL model from BPEL file, I still have two questions. The following is
> your
> > original suggestion code:
> >
> > *****************************************************************************
> > File bpelFile = new File(pathToSourceFile);
> > Lookup lookup = Lookups.fixed(new Object[]{
> > bpelFile,
> > myLoadPlainDocumentMethod(bpelFile),
> > myCatalogModel,
> > });
> > ModelSource source = new ModelSource(lookup, editable);
> > BpelModelFactory factory =
> > Lookup.getDefault().lookup(BpelModelFactory.class);
> > BpelModel model = factory.getModel (source);
> > *****************************************************************************
> >
> > As for the "myLoadPlainDocumentMethod", if I understand correctly, I can directly reuse the
> method
> > "loadSwingDocument" in the class of "ReadOnlyAccess". So the type of
> "myLoadPlainDocumentMethod"
> > is  "javax.swing.text.Document" (not a BpelModel type).
> Correct.
> > I don't understand why I need load a swing
> > doc.
> >  
> The ModelSource object needs to provide context for the model factory to
> load the model.  Providing context through Lookup is a flexible  way to
> shield API from differences in environment details (e.g. inside the IDE
> or outside the IDE, the actual provided document instance are of
> different implementations.  Same with catalog provider).
> > As for the "myCatalogModel" class, I only change the following line in the class of
> > "CliBpelCatalogModel":
> > "URI catalogFileLocPath=
> > CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
> >
> > to the following line in my own class "MyCatalogModel":
> > "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
> >
> > Then in my main class, I invoke as following:
> >
> > File bpelFile = new
> File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> > bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> >
> > lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
> > MyCatalogModel.getDefault().getBPELModel(bpelURI),});
> >
> > However, the lookup is always null. Did I miss something or implement wrong?
> >  
> Do you really mean lookup is null or the requested bpel model is null?
> I recommend you create a simple Java application (using NB 6.1 beta) and
> add the required jars as libraries, do some simple testing and
> debugging, trying to isolate problem element using elimination
> approach.   As far as I can tell, simple lookup with only File and
> Document objects works fine.
> > Since all I need is to load the BPEL file (with WSDL) into BpelModel, I wonder if there is a
> > simple approach to do this without all the error-prone "lookup" methods?
> >  
> Lookup itself is very simple and powerful.  And the model loading
> mechanism is relatively simple and flexible.  You just need a bit of
> patience to debug the provision of the lookup objects.
>
> -Nam
>



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Reply | Threaded
Open this post in threaded view
|

Re: still about how to generate BPEL process without GUI designer

jdcondor
sam wang wrote:

> Hi, Nam,
>
> I got the latest source code and the jar files (March, 11). However, I still got "null pointer"
> problems when generating "model" in the line:
> BpelModel model = factory.getModel(source);
>
> The following is from my main method:
>
> 1. File bpelFile = new File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> 2. bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> 3. FileInputStream fis = new FileInputStream(bpelFile);
> 4. Lookup lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
> 5.                 MyCatalogModel.getDefault().getBPELModel(bpelURI),});
>  
Why getBPELModel ?  Should be an instance of CatalogModel used to
resolve external references (<import>) by the BpelModel.

> 6. ModelSource source = new ModelSource(lookup,true);
> 7. BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
> 8. BpelModel model = factory.getModel(source);
>
>
> *****************************************************************************************
> As for "loadPlainDocument" method, I just copy the method "loadSwingDocument" in the class of
> "ReadOnlyAccess". As for "MyCatalogModel" class, I just copy the class "CliBpelCatalogModel" with
> only one modification:
> "URI catalogFileLocPath=
> CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
> changing to:
> "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
>
> *****************************************************************************************
>
> I change your code:
> BpelModelFactory factory = Lookup.getDefault().lookup(BpelModelFactory.class);
>
> to: BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
> because I can't find BpelModelFactory instance from the default of Lookup.
>  
This tell that you don't have proper Libraries dependency.  You NB
dependencies should looks like this:
    ${base}/org-netbeans-libs-jxpath.jar:\
    ${base}/org-netbeans-modules-bpel-model.jar:\
    ${base}/org-netbeans-modules-xml-schema-model.jar:\
    ${base}/org-netbeans-modules-xml-wsdl-extensions.jar:\
    ${base}/org-netbeans-modules-xml-wsdl-model.jar:\
    ${base}/org-netbeans-modules-xml-xam.jar:\
    ${base}/org-openide-util.jar

You should not have other NB modules dependency.  If you do, be careful
not to pull in ...xml.xdm or ...xml.retriever or any modules that have
dependencies on UI modules.

> *****************************************************************************************
>
> In line 5, I also tried another approach: MyCatalogModel.getDefault(),
> However, both approaches will get "null pointer" exception at the method "getSwingDocument" in the
> class of "org.netbeans.modules.xml.xdm.XDMModel":
>
> private BaseDocument getSwingDocument() {
> BaseDocument bd = (BaseDocument)
>         source.getLookup().lookup(BaseDocument.class);
>         return bd;}
>
>
> The following is the error message:
> Cannot find null
> java.lang.NullPointerException
> at org.netbeans.modules.xml.xdm.XDMModel.prepareSync(XDMModel.java:166)
> at org.netbeans.modules.xml.xdm.XDMModel.sync(XDMModel.java:156)
> at org.netbeans.modules.xml.xdm.xam.XDMAccess.sync(XDMAccess.java:126)
>  
You should not pull ..xml.xdm module in your dependencies.

> at org.netbeans.modules.xml.xam.AbstractModel.sync(AbstractModel.java:259)
> at org.netbeans.modules.bpel.model.impl.BpelModelImpl.sync(BpelModelImpl.java:380)
> at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:137)
> at
> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
> at mybpel.MyCatalogModel.getBPELModel(MyCatalogModel.java:229)
> at mybpel.BpelProcess.main(BpelProcess.java:69)
> Exception in thread "main" java.lang.NullPointerException
> at
> org.netbeans.modules.xml.xam.AbstractModelFactory.getEffectiveAccessProvider(AbstractModelFactory.java:116)
> at org.netbeans.modules.xml.xam.AbstractModelFactory.getKey(AbstractModelFactory.java:108)
> at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:129)
> at
> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
> at mybpel.BpelProcess.main(BpelProcess.java:81)
>
>
> I understand this error, because "BaseDocument" extends "AbstractDocument", however, in line 4, I
> put "PlainDocument" in Lookup.  "PlainDocument" is also extends "AbstractDocument". So
> "PlainDocument" is not an instance of "BaseDocument" class.
>
> Dose that mean that I need instantiate "BaseDocument" and put into Lookup in line 4? but how?
No.
>  or
> something else wrong?
>  
Yes the extra dependencies on ...xml.xdm

> Thank you so much for the help!
> Sam
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --- Nam Nguyen <[hidden email]> wrote:
>
>  
>> sam wang wrote:
>>    
>>> Hi, Nam,
>>>
>>> Thank you very much for the great help! I have found the link to download the night source
>>>      
>> code
>>    
>>> according to your suggestion.
>>>
>>> As for the loading BPEL model from BPEL file, I still have two questions. The following is
>>>      
>> your
>>    
>>> original suggestion code:
>>>
>>> *****************************************************************************
>>> File bpelFile = new File(pathToSourceFile);
>>> Lookup lookup = Lookups.fixed(new Object[]{
>>> bpelFile,
>>> myLoadPlainDocumentMethod(bpelFile),
>>> myCatalogModel,
>>> });
>>> ModelSource source = new ModelSource(lookup, editable);
>>> BpelModelFactory factory =
>>> Lookup.getDefault().lookup(BpelModelFactory.class);
>>> BpelModel model = factory.getModel (source);
>>> *****************************************************************************
>>>
>>> As for the "myLoadPlainDocumentMethod", if I understand correctly, I can directly reuse the
>>>      
>> method
>>    
>>> "loadSwingDocument" in the class of "ReadOnlyAccess". So the type of
>>>      
>> "myLoadPlainDocumentMethod"
>>    
>>> is  "javax.swing.text.Document" (not a BpelModel type).
>>>      
>> Correct.
>>    
>>> I don't understand why I need load a swing
>>> doc.
>>>  
>>>      
>> The ModelSource object needs to provide context for the model factory to
>> load the model.  Providing context through Lookup is a flexible  way to
>> shield API from differences in environment details (e.g. inside the IDE
>> or outside the IDE, the actual provided document instance are of
>> different implementations.  Same with catalog provider).
>>    
>>> As for the "myCatalogModel" class, I only change the following line in the class of
>>> "CliBpelCatalogModel":
>>> "URI catalogFileLocPath=
>>> CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
>>>
>>> to the following line in my own class "MyCatalogModel":
>>> "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
>>>
>>> Then in my main class, I invoke as following:
>>>
>>> File bpelFile = new
>>>      
>> File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
>>    
>>> bpelURI = new URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
>>>
>>> lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
>>> MyCatalogModel.getDefault().getBPELModel(bpelURI),});
>>>
>>> However, the lookup is always null. Did I miss something or implement wrong?
>>>  
>>>      
>> Do you really mean lookup is null or the requested bpel model is null?
>> I recommend you create a simple Java application (using NB 6.1 beta) and
>> add the required jars as libraries, do some simple testing and
>> debugging, trying to isolate problem element using elimination
>> approach.   As far as I can tell, simple lookup with only File and
>> Document objects works fine.
>>    
>>> Since all I need is to load the BPEL file (with WSDL) into BpelModel, I wonder if there is a
>>> simple approach to do this without all the error-prone "lookup" methods?
>>>  
>>>      
>> Lookup itself is very simple and powerful.  And the model loading
>> mechanism is relatively simple and flexible.  You just need a bit of
>> patience to debug the provision of the lookup objects.
>>
>> -Nam
>>
>>    
>
>
>
>       ____________________________________________________________________________________
> Looking for last minute shopping deals?  
> Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>  

Reply | Threaded
Open this post in threaded view
|

Thank you so much!

sam wang-2
Hi, Nam,

Finally it works after removing unnecessary jar files based on your suggestion! Thank you so much
for the great help! I never thought it's caused by jars, now I learn a lesson :-)

Thanks again!
Sam



--- Nam Nguyen <[hidden email]> wrote:

> sam wang wrote:
> > Hi, Nam,
> >
> > I got the latest source code and the jar files (March, 11). However, I still got "null
> pointer"
> > problems when generating "model" in the line:
> > BpelModel model = factory.getModel(source);
> >
> > The following is from my main method:
> >
> > 1. File bpelFile = new
> File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> > 2. bpelURI = new
> URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> > 3. FileInputStream fis = new FileInputStream(bpelFile);
> > 4. Lookup lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
> > 5.                 MyCatalogModel.getDefault().getBPELModel(bpelURI),});
> >  
> Why getBPELModel ?  Should be an instance of CatalogModel used to
> resolve external references (<import>) by the BpelModel.
> > 6. ModelSource source = new ModelSource(lookup,true);
> > 7. BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
> > 8. BpelModel model = factory.getModel(source);
> >
> >
> > *****************************************************************************************
> > As for "loadPlainDocument" method, I just copy the method "loadSwingDocument" in the class of
> > "ReadOnlyAccess". As for "MyCatalogModel" class, I just copy the class "CliBpelCatalogModel"
> with
> > only one modification:
> > "URI catalogFileLocPath=
> > CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
> > changing to:
> > "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
> >
> > *****************************************************************************************
> >
> > I change your code:
> > BpelModelFactory factory = Lookup.getDefault().lookup(BpelModelFactory.class);
> >
> > to: BpelModelFactoryImpl factory = new BpelModelFactoryImpl();
> > because I can't find BpelModelFactory instance from the default of Lookup.
> >  
> This tell that you don't have proper Libraries dependency.  You NB
> dependencies should looks like this:
>     ${base}/org-netbeans-libs-jxpath.jar:\
>     ${base}/org-netbeans-modules-bpel-model.jar:\
>     ${base}/org-netbeans-modules-xml-schema-model.jar:\
>     ${base}/org-netbeans-modules-xml-wsdl-extensions.jar:\
>     ${base}/org-netbeans-modules-xml-wsdl-model.jar:\
>     ${base}/org-netbeans-modules-xml-xam.jar:\
>     ${base}/org-openide-util.jar
>
> You should not have other NB modules dependency.  If you do, be careful
> not to pull in ...xml.xdm or ...xml.retriever or any modules that have
> dependencies on UI modules.
> > *****************************************************************************************
> >
> > In line 5, I also tried another approach: MyCatalogModel.getDefault(),
> > However, both approaches will get "null pointer" exception at the method "getSwingDocument" in
> the
> > class of "org.netbeans.modules.xml.xdm.XDMModel":
> >
> > private BaseDocument getSwingDocument() {
> > BaseDocument bd = (BaseDocument)
> >         source.getLookup().lookup(BaseDocument.class);
> >         return bd;}
> >
> >
> > The following is the error message:
> > Cannot find null
> > java.lang.NullPointerException
> > at org.netbeans.modules.xml.xdm.XDMModel.prepareSync(XDMModel.java:166)
> > at org.netbeans.modules.xml.xdm.XDMModel.sync(XDMModel.java:156)
> > at org.netbeans.modules.xml.xdm.xam.XDMAccess.sync(XDMAccess.java:126)
> >  
> You should not pull ..xml.xdm module in your dependencies.
> > at org.netbeans.modules.xml.xam.AbstractModel.sync(AbstractModel.java:259)
> > at org.netbeans.modules.bpel.model.impl.BpelModelImpl.sync(BpelModelImpl.java:380)
> > at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:137)
> > at
> >
> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
> > at mybpel.MyCatalogModel.getBPELModel(MyCatalogModel.java:229)
> > at mybpel.BpelProcess.main(BpelProcess.java:69)
> > Exception in thread "main" java.lang.NullPointerException
> > at
> >
>
org.netbeans.modules.xml.xam.AbstractModelFactory.getEffectiveAccessProvider(AbstractModelFactory.java:116)

> > at org.netbeans.modules.xml.xam.AbstractModelFactory.getKey(AbstractModelFactory.java:108)
> > at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:129)
> > at
> >
> org.netbeans.modules.bpel.model.impl.BpelModelFactoryImpl.getModel(BpelModelFactoryImpl.java:40)
> > at mybpel.BpelProcess.main(BpelProcess.java:81)
> >
> >
> > I understand this error, because "BaseDocument" extends "AbstractDocument", however, in line
> 4, I
> > put "PlainDocument" in Lookup.  "PlainDocument" is also extends "AbstractDocument". So
> > "PlainDocument" is not an instance of "BaseDocument" class.
> >
> > Dose that mean that I need instantiate "BaseDocument" and put into Lookup in line 4? but how?
> No.
> >  or
> > something else wrong?
> >  
> Yes the extra dependencies on ...xml.xdm
> > Thank you so much for the help!
> > Sam
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --- Nam Nguyen <[hidden email]> wrote:
> >
> >  
> >> sam wang wrote:
> >>    
> >>> Hi, Nam,
> >>>
> >>> Thank you very much for the great help! I have found the link to download the night source
> >>>      
> >> code
> >>    
> >>> according to your suggestion.
> >>>
> >>> As for the loading BPEL model from BPEL file, I still have two questions. The following is
> >>>      
> >> your
> >>    
> >>> original suggestion code:
> >>>
> >>> *****************************************************************************
> >>> File bpelFile = new File(pathToSourceFile);
> >>> Lookup lookup = Lookups.fixed(new Object[]{
> >>> bpelFile,
> >>> myLoadPlainDocumentMethod(bpelFile),
> >>> myCatalogModel,
> >>> });
> >>> ModelSource source = new ModelSource(lookup, editable);
> >>> BpelModelFactory factory =
> >>> Lookup.getDefault().lookup(BpelModelFactory.class);
> >>> BpelModel model = factory.getModel (source);
> >>> *****************************************************************************
> >>>
> >>> As for the "myLoadPlainDocumentMethod", if I understand correctly, I can directly reuse the
> >>>      
> >> method
> >>    
> >>> "loadSwingDocument" in the class of "ReadOnlyAccess". So the type of
> >>>      
> >> "myLoadPlainDocumentMethod"
> >>    
> >>> is  "javax.swing.text.Document" (not a BpelModel type).
> >>>      
> >> Correct.
> >>    
> >>> I don't understand why I need load a swing
> >>> doc.
> >>>  
> >>>      
> >> The ModelSource object needs to provide context for the model factory to
> >> load the model.  Providing context through Lookup is a flexible  way to
> >> shield API from differences in environment details (e.g. inside the IDE
> >> or outside the IDE, the actual provided document instance are of
> >> different implementations.  Same with catalog provider).
> >>    
> >>> As for the "myCatalogModel" class, I only change the following line in the class of
> >>> "CliBpelCatalogModel":
> >>> "URI catalogFileLocPath=
> >>> CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();"
> >>>
> >>> to the following line in my own class "MyCatalogModel":
> >>> "catalogFileLocPath = new URI("file:/NetBeansProjects/StockQuote/StockQuote");"
> >>>
> >>> Then in my main class, I invoke as following:
> >>>
> >>> File bpelFile = new
> >>>      
> >> File("/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> >>    
> >>> bpelURI = new
> URI("file:/NetBeansProjects/StockQuote/StockQuote/src/SynchronousSample.bpel");
> >>>
> >>> lookup = Lookups.fixed(new Object[]{bpelFile, loadPlainDocument(fis),
> >>> MyCatalogModel.getDefault().getBPELModel(bpelURI),});
> >>>
> >>> However, the lookup is always null. Did I miss something or implement wrong?
> >>>  
> >>>      
>
=== message truncated ===



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Reply | Threaded
Open this post in threaded view
|

two questions about how to extend BPEL model

sam wang-2
In reply to this post by jdcondor
Hi, Nam,

Sorry to interrupt you again. I have two questions about extending BPEL model. First question is
about how to create new BPEL entity/activity. Second question is about how to add new created BPEL
activity into activity container/composition. I have tried all my best without any luck. I would
greatly appreciate your help!

First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file, there
includes several imports, a partnerlink container, a variable container and a sequence activity.
In the sequence activity, there is a receive, two assigns, an invoke and an reply activity. I can
get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the model.
However, I don't know how to create new activity and put the new created activity into activity
container/composition.

As for the first question about how to create activity, I tried the following approaches:
(1) Creating BpelBuilderImpl through BpelModelImpl:
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
then creating activity. However, I get the error message like "setAttribute access not supported."
Please check the detailed error message at (1) at the bottom of this email.

(2) Creating activity from BpelBuilderImpl directly:
Receive receive1 = new ReceiveImpl(bpelBuilder);
However, the same error message as the above approach. Please check the detailed error log at (2)
at the bottom email.

(3) Creating activity's XML file, then creating DOM Element from the XML file, and then creating
activity. In this approach, I can create an activity. I want to create an empty activity XML file,
an example of a "Receive" activity XML is defined as following:

<?xml version="1.0" encoding="UTF-8"?>
<receive />

After getting Element from the above file and creating the empty activity, I find that I can't set
properties of this activity. The detailed error message is shown as (3) at the bottom email. Of
course, I can create an complete XML file which specifies all the attributes. However, considering
how tightly coupled between "Import", "Variable" and "Activity", I prefer to create an empty
activity first and then setup the corresponding attributes through retrieving the corresponding
parts from "Import", "Variable" and "PartnerLink".


The following approaches are about the second question, how to add activity to activity container
(same problem as adding BpelEntity to BpelProcess). In order to guarantee the activity itself
correct, I first get the BPEL model from reading the BPEL file, then retrieving the activity from
the BPEL model. The main "sequence" activity (seqActivity) is retrieved as following:
Process process = model.getProcess();
ExtendableActivity seqActivity = process.getActivity();

(1) I cast "seqActivity" as "Sequence" and try to add activity as following:
((Sequence)seqActivity).setActivity(assign, 3);
The error message is shown as (4).

(2) I cast "seqActivity" as "CompositeActivityImpl" and tried two ways to insert/add activity:
((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);  //error message shown in (5)
((CompositeActivityImpl)seqActivity).addActivity(receive);  ////error message shown in (6)


As you can see, I tried many different approaches without success. Could you please give me
hint/suggestions to solve the above two questions? By the way, how to save the modified BPEL model
to the BPEL file? Does it automatically save when the program exits or should I invoke some
methods to save the change?

Thank you very much in advance!
Sam


The following is the code caused the error and the detailed error message:


(1) *****************************************************************************************
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
Assign assign = 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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at
org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        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:635)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
        at
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
        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:50)
        at org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:188)
        at mybpel.BpelProcess.main(BpelProcess.java:79)


(2)*****************************************************************************************
Receive receive1 = new ReceiveImpl(bpelBuilder);

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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at
org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        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:635)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
        at
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
        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.InvokeReceiveReplyCommonImpl.<init>(InvokeReceiveReplyCommonImpl.java:59)
        at
org.netbeans.modules.bpel.model.impl.ReplyReceiveIntersectImpl.<init>(ReplyReceiveIntersectImpl.java:52)
        at org.netbeans.modules.bpel.model.impl.ReceiveImpl.<init>(ReceiveImpl.java:50)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:100)


(3)*****************************************************************************************
receive.setName("start");

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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at
org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        at org.netbeans.modules.bpel.model.impl.NamedElementImpl.setName(NamedElementImpl.java:61)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:115)


(4)*****************************************************************************************
Assign assign = (Assign) ((Sequence)seqActivity).getActivity(1);
((Sequence)seqActivity).setActivity(assign, 3);

Exception in thread "main" java.lang.UnsupportedOperationException: removeChild access not
supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.removeChild(ReadOnlyAccess.java:352)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChild(AbstractDocumentComponent.java:491)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:303)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:74)
        at org.netbeans.modules.xml.xam.AbstractComponent._removeChildQuietly(AbstractComponent.java:128)
        at org.netbeans.modules.xml.xam.AbstractComponent.removeChild(AbstractComponent.java:363)
        at
org.netbeans.modules.bpel.model.impl.BpelContainerImpl.setChildAtIndex(BpelContainerImpl.java:472)
        at
org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.setActivity(CompositeActivityImpl.java:74)
        at mybpel.BpelProcess.main(BpelProcess.java:95)


(5)*****************************************************************************************
((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);

Exception in thread "main" java.lang.UnsupportedOperationException: insertBefore access not
supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.insertBefore(ReadOnlyAccess.java:348)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertBefore(AbstractDocumentComponent.java:487)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:295)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:74)
        at
org.netbeans.modules.xml.xam.AbstractComponent._insertAtIndexQuietly(AbstractComponent.java:122)
        at org.netbeans.modules.xml.xam.AbstractComponent.insertAtIndex(AbstractComponent.java:346)
        at
org.netbeans.modules.bpel.model.impl.BpelContainerImpl.insertAtIndex(BpelContainerImpl.java:376)
        at
org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.insertActivity(CompositeActivityImpl.java:88)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:122)

(6)*****************************************************************************************
((CompositeActivityImpl)seqActivity).addActivity(receive);

Exception in thread "main" java.lang.UnsupportedOperationException: appendChild access not
supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.appendChild(ReadOnlyAccess.java:344)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:287)
        at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:74)
        at org.netbeans.modules.xml.xam.AbstractComponent._appendChildQuietly(AbstractComponent.java:113)
        at org.netbeans.modules.xml.xam.AbstractComponent.addChild(AbstractComponent.java:276)
        at org.netbeans.modules.xml.xam.AbstractComponent.addBefore(AbstractComponent.java:241)
        at
org.netbeans.modules.bpel.model.impl.BpelContainerImpl.addChildBefore(BpelContainerImpl.java:302)
        at
org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.addActivity(CompositeActivityImpl.java:97)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:123)






      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Hi, Nam,

Sorry to interrupt you again. I have two questions about generating BPEL file. First question is about how to create new BPEL entity/activity. Second question is about how to add new created BPEL activity into activity container/composition. I have tried all my best without any luck. I would greatly appreciate your help!

First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file, there includes several imports, a partnerlink container, a viariable container and a sequence activity. In the sequence activity, there is a receive, two assigns, an invoke and an reply activity. I can get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the model. However, I don't know how to create new activity and put the new created activity into activity container/composition.

As for the first question about how to create activity, I tried the following approaches:
(1) Creating BpelBuilderImpl through BpelModelImpl:
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
then creating activity. However, I get the error message like "setAttribute access not supported." Please check the detailed error message at (1) at the bottom of this email.

(2) Creating activity from BpelBuilderImpl directly:
Receive receive1 = new ReceiveImpl(bpelBuilder);
However, the same error message as the above approach. Please check the detailed error log at (2) at the bottom email.

(3) Creating activity's XML file, then creating DOM Element from the XML file, and then creating activity. In this approach, I can create an activity. I want to create an empty activity XML file, an exmple of a "Receive" activity XML is defined as following:

<?xml version="1.0" encoding="UTF-8"?>
<receive />

After getting Element from the above file and creating the empty activity, I find that I can't set properties of this activity. The detailed error message is shown as (3) at the bottom email. Of course, I can create an complete XML file which specifies all the attributes. However, considering how tightly coupled between "Import", "Variable" and "Activity", I prefer to create an empty activity first and then setup the corresponding attributes through retrieving the corresponding parts from "Import", "Variable" and "PartnerLink".


The following approaches are about the second question, how to add activity to activity container (same problem as adding BpelEntity to BpelProcess). In order to gurantee the activity itself correct, I first get the BPEL model from reading the BPEL file, then retrieving the activity from the BPEL model. The main "sequence" activity (seqActivity) is retrieved as following:
Process process = model.getProcess();
ExtendableActivity seqActivity = process.getActivity();

(1) I cast "seqActivity" as "Sequence" and try to add activity as following:
((Sequence)seqActivity).setActivity(assign, 3);
The error message is shown as (4).

(2) I cast "seqActivity" as "CompositeActivityImpl" and tried two ways to insert/add activity:
((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);  //error message shown in (5)
((CompositeActivityImpl)seqActivity).addActivity(receive);  ////error message shown in (6)


As you can see, I tried many different approaches without sucess. Could you please give me hint/suggestions to solve the above two questions? By the way, how to save the modified BPEL model to the BPEL file? Does it automatically save when the program exits or should I invoke some methods to save the change?

Thank you very much in advance!
Sam


The following is the code caused the error and the detailed error message:


(1) *****************************************************************************************
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
Assign assign = 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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        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:635)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
        at org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
        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:50)
        at org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:188)
        at mybpel.BpelProcess.main(BpelProcess.java:79)


(2)*****************************************************************************************
Receive receive1 = new ReceiveImpl(bpelBuilder);

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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        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:635)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
        at org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
        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.InvokeReceiveReplyCommonImpl.<init>(InvokeReceiveReplyCommonImpl.java:59)
        at org.netbeans.modules.bpel.model.impl.ReplyReceiveIntersectImpl.<init>(ReplyReceiveIntersectImpl.java:52)
        at org.netbeans.modules.bpel.model.impl.ReceiveImpl.<init>(ReceiveImpl.java:50)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:100)


(3)*****************************************************************************************
receive.setName("start");

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:321)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
        at org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
        at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
        at org.netbeans.modules.bpel.model.impl.NamedElementImpl.setName(NamedElementImpl.java:61)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:115)


(4)*****************************************************************************************
Assign assign = (Assign) ((Sequence)seqActivity).getActivity(1);
((Sequence)seqActivity).setActivity(assign, 3);

Exception in thread "main" java.lang.UnsupportedOperationException: removeChild access not supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.removeChild(ReadOnlyAccess.java:352)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChild(AbstractDocumentComponent.java:491)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:303)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:74)
        at org.netbeans.modules.xml.xam.AbstractComponent._removeChildQuietly(AbstractComponent.java:128)
        at org.netbeans.modules.xml.xam.AbstractComponent.removeChild(AbstractComponent.java:363)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.setChildAtIndex(BpelContainerImpl.java:472)
        at org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.setActivity(CompositeActivityImpl.java:74)
        at mybpel.BpelProcess.main(BpelProcess.java:95)


(5)*****************************************************************************************
((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);

Exception in thread "main" java.lang.UnsupportedOperationException: insertBefore access not supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.insertBefore(ReadOnlyAccess.java:348)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertBefore(AbstractDocumentComponent.java:487)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:295)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:74)
        at org.netbeans.modules.xml.xam.AbstractComponent._insertAtIndexQuietly(AbstractComponent.java:122)
        at org.netbeans.modules.xml.xam.AbstractComponent.insertAtIndex(AbstractComponent.java:346)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.insertAtIndex(BpelContainerImpl.java:376)
        at org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.insertActivity(CompositeActivityImpl.java:88)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:122)

(6)*****************************************************************************************
((CompositeActivityImpl)seqActivity).addActivity(receive);

Exception in thread "main" java.lang.UnsupportedOperationException: appendChild access not supported.
        at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.appendChild(ReadOnlyAccess.java:344)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:287)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:74)
        at org.netbeans.modules.xml.xam.AbstractComponent._appendChildQuietly(AbstractComponent.java:113)
        at org.netbeans.modules.xml.xam.AbstractComponent.addChild(AbstractComponent.java:276)
        at org.netbeans.modules.xml.xam.AbstractComponent.addBefore(AbstractComponent.java:241)
        at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.addChildBefore(BpelContainerImpl.java:302)
        at org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.addActivity(CompositeActivityImpl.java:97)
        at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:123)




Reply | Threaded
Open this post in threaded view
|

Re: two questions about how to extend BPEL model

jdcondor
ReadOnlyAccess is not suitable for your usage here.  You have to extends
it, for example:

public class DomAccess extends ReadOnlyAccess {
    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);
    }
     /// .... same override for other tree mutation access methods when
you hit trouble with unsupported operation exceptions.
}

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

Make sure you declare DomAccessProvider service through file:
   META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider



sam wang wrote:

> Hi, Nam,
>
> Sorry to interrupt you again. I have two questions about extending BPEL model. First question is
> about how to create new BPEL entity/activity. Second question is about how to add new created BPEL
> activity into activity container/composition. I have tried all my best without any luck. I would
> greatly appreciate your help!
>
> First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file, there
> includes several imports, a partnerlink container, a variable container and a sequence activity.
> In the sequence activity, there is a receive, two assigns, an invoke and an reply activity. I can
> get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the model.
> However, I don't know how to create new activity and put the new created activity into activity
> container/composition.
>
> As for the first question about how to create activity, I tried the following approaches:
> (1) Creating BpelBuilderImpl through BpelModelImpl:
> BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
> then creating activity. However, I get the error message like "setAttribute access not supported."
> Please check the detailed error message at (1) at the bottom of this email.
>
> (2) Creating activity from BpelBuilderImpl directly:
> Receive receive1 = new ReceiveImpl(bpelBuilder);
> However, the same error message as the above approach. Please check the detailed error log at (2)
> at the bottom email.
>
> (3) Creating activity's XML file, then creating DOM Element from the XML file, and then creating
> activity. In this approach, I can create an activity. I want to create an empty activity XML file,
> an example of a "Receive" activity XML is defined as following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <receive />
>
> After getting Element from the above file and creating the empty activity, I find that I can't set
> properties of this activity. The detailed error message is shown as (3) at the bottom email. Of
> course, I can create an complete XML file which specifies all the attributes. However, considering
> how tightly coupled between "Import", "Variable" and "Activity", I prefer to create an empty
> activity first and then setup the corresponding attributes through retrieving the corresponding
> parts from "Import", "Variable" and "PartnerLink".
>
>
> The following approaches are about the second question, how to add activity to activity container
> (same problem as adding BpelEntity to BpelProcess). In order to guarantee the activity itself
> correct, I first get the BPEL model from reading the BPEL file, then retrieving the activity from
> the BPEL model. The main "sequence" activity (seqActivity) is retrieved as following:
> Process process = model.getProcess();
> ExtendableActivity seqActivity = process.getActivity();
>
> (1) I cast "seqActivity" as "Sequence" and try to add activity as following:
> ((Sequence)seqActivity).setActivity(assign, 3);
> The error message is shown as (4).
>
> (2) I cast "seqActivity" as "CompositeActivityImpl" and tried two ways to insert/add activity:
> ((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);  //error message shown in (5)
> ((CompositeActivityImpl)seqActivity).addActivity(receive);  ////error message shown in (6)
>
>
> As you can see, I tried many different approaches without success. Could you please give me
> hint/suggestions to solve the above two questions? By the way, how to save the modified BPEL model
> to the BPEL file? Does it automatically save when the program exits or should I invoke some
> methods to save the change?
>
> Thank you very much in advance!
> Sam
>
>
> The following is the code caused the error and the detailed error message:
>
>
> (1) *****************************************************************************************
> BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
> Assign assign = 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:321)
> at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
> at
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
> 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:635)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
> at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
> at
> org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
> 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:50)
> at org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:188)
> at mybpel.BpelProcess.main(BpelProcess.java:79)
>
>
> (2)*****************************************************************************************
> Receive receive1 = new ReceiveImpl(bpelBuilder);
>
> 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:321)
> at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
> at
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
> 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:635)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
> at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
> at
> org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
> 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.InvokeReceiveReplyCommonImpl.<init>(InvokeReceiveReplyCommonImpl.java:59)
> at
> org.netbeans.modules.bpel.model.impl.ReplyReceiveIntersectImpl.<init>(ReplyReceiveIntersectImpl.java:52)
> at org.netbeans.modules.bpel.model.impl.ReceiveImpl.<init>(ReceiveImpl.java:50)
> at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:100)
>
>
> (3)*****************************************************************************************
> receive.setName("start");
>
> 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:321)
> at org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
> at
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
> at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
> at org.netbeans.modules.bpel.model.impl.NamedElementImpl.setName(NamedElementImpl.java:61)
> at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:115)
>
>
> (4)*****************************************************************************************
> Assign assign = (Assign) ((Sequence)seqActivity).getActivity(1);
> ((Sequence)seqActivity).setActivity(assign, 3);
>
> Exception in thread "main" java.lang.UnsupportedOperationException: removeChild access not
> supported.
> at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.removeChild(ReadOnlyAccess.java:352)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChild(AbstractDocumentComponent.java:491)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:303)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:74)
> at org.netbeans.modules.xml.xam.AbstractComponent._removeChildQuietly(AbstractComponent.java:128)
> at org.netbeans.modules.xml.xam.AbstractComponent.removeChild(AbstractComponent.java:363)
> at
> org.netbeans.modules.bpel.model.impl.BpelContainerImpl.setChildAtIndex(BpelContainerImpl.java:472)
> at
> org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.setActivity(CompositeActivityImpl.java:74)
> at mybpel.BpelProcess.main(BpelProcess.java:95)
>
>
> (5)*****************************************************************************************
> ((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);
>
> Exception in thread "main" java.lang.UnsupportedOperationException: insertBefore access not
> supported.
> at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.insertBefore(ReadOnlyAccess.java:348)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertBefore(AbstractDocumentComponent.java:487)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:295)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.insertAtIndexQuietly(AbstractDocumentComponent.java:74)
> at
> org.netbeans.modules.xml.xam.AbstractComponent._insertAtIndexQuietly(AbstractComponent.java:122)
> at org.netbeans.modules.xml.xam.AbstractComponent.insertAtIndex(AbstractComponent.java:346)
> at
> org.netbeans.modules.bpel.model.impl.BpelContainerImpl.insertAtIndex(BpelContainerImpl.java:376)
> at
> org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.insertActivity(CompositeActivityImpl.java:88)
> at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:122)
>
> (6)*****************************************************************************************
> ((CompositeActivityImpl)seqActivity).addActivity(receive);
>
> Exception in thread "main" java.lang.UnsupportedOperationException: appendChild access not
> supported.
> at org.netbeans.modules.xml.xam.dom.ReadOnlyAccess.appendChild(ReadOnlyAccess.java:344)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:287)
> at
> org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.appendChildQuietly(AbstractDocumentComponent.java:74)
> at org.netbeans.modules.xml.xam.AbstractComponent._appendChildQuietly(AbstractComponent.java:113)
> at org.netbeans.modules.xml.xam.AbstractComponent.addChild(AbstractComponent.java:276)
> at org.netbeans.modules.xml.xam.AbstractComponent.addBefore(AbstractComponent.java:241)
> at
> org.netbeans.modules.bpel.model.impl.BpelContainerImpl.addChildBefore(BpelContainerImpl.java:302)
> at
> org.netbeans.modules.bpel.model.impl.CompositeActivityImpl.addActivity(CompositeActivityImpl.java:97)
> at org.netbeans.modules.bpel.model.impl.MyBpelProcess.main(MyBpelProcess.java:123)
>
>
>
>
>
>
>       ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>  

Reply | Threaded
Open this post in threaded view
|

Re: two questions about how to extend BPEL model

sam wang-2
Thank you very much for the quick reply, Nam!
Could you please explain more about "Make sure you declare DomAccessProvider service through file:
META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider"?
First, is it a Java class or just a text file/property file, what's the exact format? (There are
several formats for the property file.)
Second, where should I put this file? In my application, I just import the source code of NB's
Bpel api and impl module. It's not a standard NB Bpel project. Also, under the directory of
"org.netbeans.modules.bpel.model.xam.spi", there are only two java classes:
ExternalModelRetriever.java and InnerEventDispatcher.java".

Another question, how to save the modified BPEL model to the BPEL file? Does it automatically save
when the program exits or should I invoke some methods to save the change after I extend the BPEL
model?

By the way, I have implemented both "DomAccess" and "DomAccessProvider" class based on your
suggestion. I paste my implementation of "DomAccess" with this email. Could you please take a look
if it's correct?

Thanks again!
Sam

*********************************************************************************
The following is the implementation of "DomAccess":

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

import org.netbeans.modules.bpel.model.api.BpelModel;
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);
    }
     
}

















--- Nam Nguyen <[hidden email]> wrote:

> ReadOnlyAccess is not suitable for your usage here.  You have to extends
> it, for example:
>
> public class DomAccess extends ReadOnlyAccess {
>     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);
>     }
>      /// .... same override for other tree mutation access methods when
> you hit trouble with unsupported operation exceptions.
> }
>
> public class DomAccessProvider extends ReadOnlyAccess.Provider {
>     public Object getModelSourceKey(ModelSource source) {
>         Object key = source.getLookup().lookup(DataObject.class);
>         if(key != null) {
>             key = source.getLookup().lookup(Document.class);
>        }
>         return key;
>     }
> }
>
> Make sure you declare DomAccessProvider service through file:
>    META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider
>
>
>
> sam wang wrote:
> > Hi, Nam,
> >
> > Sorry to interrupt you again. I have two questions about extending BPEL model. First question
> is
> > about how to create new BPEL entity/activity. Second question is about how to add new created
> BPEL
> > activity into activity container/composition. I have tried all my best without any luck. I
> would
> > greatly appreciate your help!
> >
> > First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file,
> there
> > includes several imports, a partnerlink container, a variable container and a sequence
> activity.
> > In the sequence activity, there is a receive, two assigns, an invoke and an reply activity. I
> can
> > get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the
> model.
> > However, I don't know how to create new activity and put the new created activity into
> activity
> > container/composition.
> >
> > As for the first question about how to create activity, I tried the following approaches:
> > (1) Creating BpelBuilderImpl through BpelModelImpl:
> > BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
> > then creating activity. However, I get the error message like "setAttribute access not
> supported."
> > Please check the detailed error message at (1) at the bottom of this email.
> >
> > (2) Creating activity from BpelBuilderImpl directly:
> > Receive receive1 = new ReceiveImpl(bpelBuilder);
> > However, the same error message as the above approach. Please check the detailed error log at
> (2)
> > at the bottom email.
> >
> > (3) Creating activity's XML file, then creating DOM Element from the XML file, and then
> creating
> > activity. In this approach, I can create an activity. I want to create an empty activity XML
> file,
> > an example of a "Receive" activity XML is defined as following:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <receive />
> >
> > After getting Element from the above file and creating the empty activity, I find that I can't
> set
> > properties of this activity. The detailed error message is shown as (3) at the bottom email.
> Of
> > course, I can create an complete XML file which specifies all the attributes. However,
> considering
> > how tightly coupled between "Import", "Variable" and "Activity", I prefer to create an empty
> > activity first and then setup the corresponding attributes through retrieving the
> corresponding
> > parts from "Import", "Variable" and "PartnerLink".
> >
> >
> > The following approaches are about the second question, how to add activity to activity
> container
> > (same problem as adding BpelEntity to BpelProcess). In order to guarantee the activity itself
> > correct, I first get the BPEL model from reading the BPEL file, then retrieving the activity
> from
> > the BPEL model. The main "sequence" activity (seqActivity) is retrieved as following:
> > Process process = model.getProcess();
> > ExtendableActivity seqActivity = process.getActivity();
> >
> > (1) I cast "seqActivity" as "Sequence" and try to add activity as following:
> > ((Sequence)seqActivity).setActivity(assign, 3);
> > The error message is shown as (4).
> >
> > (2) I cast "seqActivity" as "CompositeActivityImpl" and tried two ways to insert/add activity:
> > ((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);  //error message shown in (5)
> > ((CompositeActivityImpl)seqActivity).addActivity(receive);  ////error message shown in (6)
> >
> >
> > As you can see, I tried many different approaches without success. Could you please give me
> > hint/suggestions to solve the above two questions? By the way, how to save the modified BPEL
> model
> > to the BPEL file? Does it automatically save when the program exits or should I invoke some
> > methods to save the change?
> >
> > Thank you very much in advance!
> > Sam
> >
> >
> > The following is the code caused the error and the detailed error message:
> >
> >
> > (1) *****************************************************************************************
> > BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
> > Assign assign = 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:321)
> > at
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
> > at
> >
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
> > at
> org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
> > 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:635)
> > at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
> > at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
> > at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
> > at
> >
>
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)

> > 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:50)
> > at
> org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:188)
> > at mybpel.BpelProcess.main(BpelProcess.java:79)
> >
> >
> > (2)*****************************************************************************************
> > Receive receive1 = new ReceiveImpl(bpelBuilder);
> >
> > 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:321)
> > at
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
> > at
> >
> org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
> > at
> org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
> > 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:635)
> > at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
> > at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
> > at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
> > at
> >
>
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
>
=== message truncated ===



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Reply | Threaded
Open this post in threaded view
|

Re: two questions about how to extend BPEL model

jdcondor
sam wang wrote:
Thank you very much for the quick reply, Nam! 
Could you please explain more about "Make sure you declare DomAccessProvider service through file:
META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider"?
First, is it a Java class or just a text file/property file, what's the exact format? (There are
several formats for the property file.)
  
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider
Basically just a single line with the qualified name of the SPI implementation class.
Second, where should I put this file? 
File name:
org.netbeans.modules.xml.xam.spi.ModelAccessProvider

under directory:

<your-src-root>/META-INF/services/
In my application, I just import the source code of NB's
Bpel api and impl module. It's not a standard NB Bpel project. Also, under the directory of
"org.netbeans.modules.bpel.model.xam.spi", there are only two java classes:
ExternalModelRetriever.java and InnerEventDispatcher.java".

Another question, how to save the modified BPEL model to the BPEL file? Does it automatically save
when the program exits or should I invoke some methods to save the change after I extend the BPEL
model?
  
You have to save the swing document buffer to the file yourself.
By the way, I have implemented both "DomAccess" and "DomAccessProvider" class based on your
suggestion. I paste my implementation of "DomAccess" with this email. Could you please take a look
if it's correct?
  
Looks fine.
Thanks again!
Sam

*********************************************************************************
The following is the implementation of "DomAccess":

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

import org.netbeans.modules.bpel.model.api.BpelModel;
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);
    }
     
}

















--- Nam Nguyen [hidden email] wrote:

  
ReadOnlyAccess is not suitable for your usage here.  You have to extends 
it, for example:

public class DomAccess extends ReadOnlyAccess {
    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);
    }
     /// .... same override for other tree mutation access methods when 
you hit trouble with unsupported operation exceptions.
}

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

Make sure you declare DomAccessProvider service through file:
   META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider



sam wang wrote:
    
Hi, Nam,

Sorry to interrupt you again. I have two questions about extending BPEL model. First question
      
is
    
about how to create new BPEL entity/activity. Second question is about how to add new created
      
BPEL
    
activity into activity container/composition. I have tried all my best without any luck. I
      
would
    
greatly appreciate your help!

First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file,
      
there
    
includes several imports, a partnerlink container, a variable container and a sequence
      
activity.
    
In the sequence activity, there is a receive, two assigns, an invoke and an reply activity. I
      
can
    
get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the
      
model.
    
However, I don't know how to create new activity and put the new created activity into
      
activity
    
container/composition.

As for the first question about how to create activity, I tried the following approaches:
(1) Creating BpelBuilderImpl through BpelModelImpl: 
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
then creating activity. However, I get the error message like "setAttribute access not
      
supported."
    
Please check the detailed error message at (1) at the bottom of this email.

(2) Creating activity from BpelBuilderImpl directly:
Receive receive1 = new ReceiveImpl(bpelBuilder);
However, the same error message as the above approach. Please check the detailed error log at
      
(2)
    
at the bottom email.

(3) Creating activity's XML file, then creating DOM Element from the XML file, and then
      
creating
    
activity. In this approach, I can create an activity. I want to create an empty activity XML
      
file,
    
an example of a "Receive" activity XML is defined as following:

<?xml version="1.0" encoding="UTF-8"?>
<receive />

After getting Element from the above file and creating the empty activity, I find that I can't
      
set
    
properties of this activity. The detailed error message is shown as (3) at the bottom email.
      
Of
    
course, I can create an complete XML file which specifies all the attributes. However,
      
considering
    
how tightly coupled between "Import", "Variable" and "Activity", I prefer to create an empty
activity first and then setup the corresponding attributes through retrieving the
      
corresponding
    
parts from "Import", "Variable" and "PartnerLink".


The following approaches are about the second question, how to add activity to activity
      
container
    
(same problem as adding BpelEntity to BpelProcess). In order to guarantee the activity itself
correct, I first get the BPEL model from reading the BPEL file, then retrieving the activity
      
from
    
the BPEL model. The main "sequence" activity (seqActivity) is retrieved as following:
Process process = model.getProcess();
ExtendableActivity seqActivity = process.getActivity();

(1) I cast "seqActivity" as "Sequence" and try to add activity as following:
((Sequence)seqActivity).setActivity(assign, 3);
The error message is shown as (4).

(2) I cast "seqActivity" as "CompositeActivityImpl" and tried two ways to insert/add activity:
((CompositeActivityImpl)seqActivity).insertActivity(receive, 2);  //error message shown in (5)
((CompositeActivityImpl)seqActivity).addActivity(receive);  ////error message shown in (6)


As you can see, I tried many different approaches without success. Could you please give me
hint/suggestions to solve the above two questions? By the way, how to save the modified BPEL
      
model
    
to the BPEL file? Does it automatically save when the program exits or should I invoke some
methods to save the change?

Thank you very much in advance!
Sam


The following is the code caused the error and the detailed error message:


(1) *****************************************************************************************
BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
Assign assign = 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:321)
	at
      
org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
    
	at

      
org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
    
	at
      
org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
    
	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:635)
    
	at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
	at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
	at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
	at

      
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
  
	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:50)
	at
      
org.netbeans.modules.bpel.model.impl.BpelBuilderImpl.createAssign(BpelBuilderImpl.java:188)
    
	at mybpel.BpelProcess.main(BpelProcess.java:79)


(2)*****************************************************************************************
Receive receive1 = new ReceiveImpl(bpelBuilder);

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:321)
	at
      
org.netbeans.modules.bpel.model.impl.AttributeAccess.setAttribute(AttributeAccess.java:938)
    
	at

      
org.netbeans.modules.bpel.model.impl.AttributeAccess.setBpelAttribute(AttributeAccess.java:215)
    
	at
      
org.netbeans.modules.bpel.model.impl.BpelEntityImpl.setBpelAttribute(BpelEntityImpl.java:368)
    
	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:635)
    
	at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.postEvent(BpelEntityImpl.java:708)
	at org.netbeans.modules.bpel.model.impl.BpelEntityImpl.<init>(BpelEntityImpl.java:87)
	at org.netbeans.modules.bpel.model.impl.BpelContainerImpl.<init>(BpelContainerImpl.java:53)
	at

      
org.netbeans.modules.bpel.model.impl.ExtensibleElementsImpl.<init>(ExtensibleElementsImpl.java:46)
  
=== message truncated ===



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
  

Reply | Threaded
Open this post in threaded view
|

Re: two questions about how to extend BPEL model

sam wang-2
Hi, Nam,

It won't work even after I did according to your suggestion. I still got the same error message.
The following is how I did:

I made the service provider file and put it under the correct position. Please check my
"DomAccessProvider" implementation at the bottom of this email. I can see the system visit
DomAccessProvider during the execution. Although it seems the key value(in line 7) is always
"null". I must import two extra jars in order to use org.openide.loaders.DataObject in line 7. The
two jars are: org-openide-loader.jar and org-openide-nodes.jar. (The reason why I import
org-openide-nodes.jar is because org-openide-loader.jar seems need it.)

Could you please let me know what I should do next?

Thanks!
Sam


*************************************************************************
The following is "DomAccessProvider" class implementation with line number:

1. package org.netbeans.modules.xml.xam.dom;
2. import org.netbeans.modules.xml.xam.ModelSource;
3. import org.openide.loaders.DataObject;
4. import org.w3c.dom.Document;
5. public class DomAccessProvider extends ReadOnlyAccess.Provider {
6.    public Object getModelSourceKey(ModelSource source) {
7.        Object key = source.getLookup().lookup(DataObject.class);
8.        if(key != null) {
9.            key = source.getLookup().lookup(Document.class);
10.       }
11.        return key;
12.    }}











--- Nam Nguyen <[hidden email]> wrote:

> sam wang wrote:
> > Thank you very much for the quick reply, Nam!
> > Could you please explain more about "Make sure you declare DomAccessProvider service through
> file:
> > META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider"?
> > First, is it a Java class or just a text file/property file, what's the exact format? (There
> are
> > several formats for the property file.)
> >  
> http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider
> Basically just a single line with the qualified name of the SPI
> implementation class.
> > Second, where should I put this file?
> File name:
>
> org.netbeans.modules.xml.xam.spi.ModelAccessProvider
>
> under directory:
>
> <your-src-root>/META-INF/services/
>
> > In my application, I just import the source code of NB's
> > Bpel api and impl module. It's not a standard NB Bpel project. Also, under the directory of
> > "org.netbeans.modules.bpel.model.xam.spi", there are only two java classes:
> > ExternalModelRetriever.java and InnerEventDispatcher.java".
> >
> > Another question, how to save the modified BPEL model to the BPEL file? Does it automatically
> save
> > when the program exits or should I invoke some methods to save the change after I extend the
> BPEL
> > model?
> >  
> You have to save the swing document buffer to the file yourself.
> > By the way, I have implemented both "DomAccess" and "DomAccessProvider" class based on your
> > suggestion. I paste my implementation of "DomAccess" with this email. Could you please take a
> look
> > if it's correct?
> >  
> Looks fine.
> > Thanks again!
> > Sam
> >
> > *********************************************************************************
> > The following is the implementation of "DomAccess":
> >
> > package org.netbeans.modules.xml.xam.dom;
> >
> > import org.netbeans.modules.bpel.model.api.BpelModel;
> > 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);
> >     }
> >      
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --- Nam Nguyen <[hidden email]> wrote:
> >
> >  
> >> ReadOnlyAccess is not suitable for your usage here.  You have to extends
> >> it, for example:
> >>
> >> public class DomAccess extends ReadOnlyAccess {
> >>     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);
> >>     }
> >>      /// .... same override for other tree mutation access methods when
> >> you hit trouble with unsupported operation exceptions.
> >> }
> >>
> >> public class DomAccessProvider extends ReadOnlyAccess.Provider {
> >>     public Object getModelSourceKey(ModelSource source) {
> >>         Object key = source.getLookup().lookup(DataObject.class);
> >>         if(key != null) {
> >>             key = source.getLookup().lookup(Document.class);
> >>        }
> >>         return key;
> >>     }
> >> }
> >>
> >> Make sure you declare DomAccessProvider service through file:
> >>    META-INF/services/org.netbeans.modules.xml.xam.spi.ModelAccessProvider
> >>
> >>
> >>
> >> sam wang wrote:
> >>    
> >>> Hi, Nam,
> >>>
> >>> Sorry to interrupt you again. I have two questions about extending BPEL model. First
> question
> >>>      
> >> is
> >>    
> >>> about how to create new BPEL entity/activity. Second question is about how to add new
> created
> >>>      
> >> BPEL
> >>    
> >>> activity into activity container/composition. I have tried all my best without any luck. I
> >>>      
> >> would
> >>    
> >>> greatly appreciate your help!
> >>>
> >>> First, I use NetBeans to generate a simple BPEL file as the start point. In this BPEL file,
> >>>      
> >> there
> >>    
> >>> includes several imports, a partnerlink container, a variable container and a sequence
> >>>      
> >> activity.
> >>    
> >>> In the sequence activity, there is a receive, two assigns, an invoke and an reply activity.
> I
> >>>      
> >> can
> >>    
> >>> get "BpelModelImpl" through reading this file. I can retrieve all the BPEL entities in the
> >>>      
> >> model.
> >>    
> >>> However, I don't know how to create new activity and put the new created activity into
> >>>      
> >> activity
> >>    
> >>> container/composition.
> >>>
> >>> As for the first question about how to create activity, I tried the following approaches:
> >>> (1) Creating BpelBuilderImpl through BpelModelImpl:
> >>> BpelBuilderImpl bpelBuilder = new BpelBuilderImpl((BpelModelImpl) model);
> >>> then creating activity. However, I get the error message like "setAttribute access not
> >>>      
> >> supported."
> >>    
> >>> Please check the detailed error message at (1) at the bottom of this email.
> >>>
> >>> (2) Creating activity from BpelBuilderImpl directly:
> >>> Receive receive1 = new ReceiveImpl(bpelBuilder);
> >>> However, the same error message as the above approach. Please check the detailed error log
> at
>
=== message truncated ===



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs
12