Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Best way to get information about a web module?
Best way to get information about a web module? [message #106531] Sat, 21 May 2005 14:42 Go to next message
Eclipse UserFriend
Hi - I'm writing some plugin code that needs to get information about a web
module in a flexible project, and stay up-to-date if it changes. For example
I need to get the project relative path of that module's webapp root; I
didn't see a direct API to do that so I've been getting the StructureEdit
for the project by calling StructureEdit.getStructureEditForRead, then going
through the components to find the WorkbenchComponent for the module, then
calling WebArtifactEdit.getWebArtifactEditForRead to get a WebArtifactEdit,
then calling getDeploymentDescriptorPath on that, and, assuming that returns
something under {webapp root}/WEB-INF, walking up two folders to find the
root. After all that I dispose the StructureEdit and the WebArtifactEdit.

Obviously that's not very straightforward but it seems to work :)

The thing is, I am calling this fairly frequently, and both
StructureEdit.getStructureEditForRead and
WebArtifactEdit.getWebArtifactEditForRead seem to be pretty expensive calls.
I looked at them in a profiler and it seems they are re-parsing wtpmodules
every time, which requires a network call to validate it...? Not to mention
allocating large amounts of memory for the DOM each time. I tried hanging on
to one or the other of the *Edit objects, and not disposing them until my
plugin is completely done and disposed, but couldn't find a way to avoid
getting an exception like:

This exception was generated to indicate an invalid usage of reference
counts. Please examine the stack trace.
Client Access Exception of type DANGLING_REFERENCE

So, is there a way to either hang onto these objects safely, or at least
hang onto a reference to them, and listen for changes? If there is a way to
hang onto them, are they "live" objects, that I can re-query to get the most
up-to-date information about the module?

(I'm using WTP M4 with eclipse platform M6)

thanks,
-Tom
Re: Best way to get information about a web module? [message #106588 is a reply to message #106531] Sun, 22 May 2005 20:12 Go to previous messageGo to next message
Eclipse UserFriend
Tom Stamm wrote:
> Hi - I'm writing some plugin code that needs to get information about a web
> module in a flexible project, and stay up-to-date if it changes. For example
> I need to get the project relative path of that module's webapp root; I
> didn't see a direct API to do that so I've been getting the StructureEdit
> for the project by calling StructureEdit.getStructureEditForRead, then going
> through the components to find the WorkbenchComponent for the module, then
> calling WebArtifactEdit.getWebArtifactEditForRead to get a WebArtifactEdit,
> then calling getDeploymentDescriptorPath on that, and, assuming that returns
> something under {webapp root}/WEB-INF, walking up two folders to find the
> root. After all that I dispose the StructureEdit and the WebArtifactEdit.
>
> Obviously that's not very straightforward but it seems to work :)
>
> The thing is, I am calling this fairly frequently, and both
> StructureEdit.getStructureEditForRead and
> WebArtifactEdit.getWebArtifactEditForRead seem to be pretty expensive calls.
> I looked at them in a profiler and it seems they are re-parsing wtpmodules
> every time, which requires a network call to validate it...? Not to mention
> allocating large amounts of memory for the DOM each time. I tried hanging on
> to one or the other of the *Edit objects, and not disposing them until my
> plugin is completely done and disposed, but couldn't find a way to avoid
> getting an exception like:
>
> This exception was generated to indicate an invalid usage of reference
> counts. Please examine the stack trace.
> Client Access Exception of type DANGLING_REFERENCE
>
> So, is there a way to either hang onto these objects safely, or at least
> hang onto a reference to them, and listen for changes? If there is a way to
> hang onto them, are they "live" objects, that I can re-query to get the most
> up-to-date information about the module?
>
> (I'm using WTP M4 with eclipse platform M6)
>
> thanks,
> -Tom
>
>
Tom,

Initially StructureEdit and WorkbenchComponent are internal classes and
not api so you should not use them and use ComponentCore and Vitual
Component api. The ComponentCore api for flex project are eclipse
platform kind api to get to the Flex project artifacts.

Secondly using ComponentCore api you need not worry about releasing the
objects you get back using its api. You still need to release the
objects that you get back using artifact edit api. The objects that you
get back using using artifact edit api are EMF objects. If you are
interested in only working with eclipse IResource objects you need not
use artifact edits.

In M5 milestone you will notice that you will be forced to use
VirtualComponent api to get to artifact edits and not WorkbenchComponent

For e.g for something you are trying to do here is what i suggest

try {
IVirtualComponent vc = ComponentCore.createComponent(IProject project,
IVirtualComponent componentName);
WebArtifactEdit edit =
WebArtifactEdit.getWebArtifactEditForRead(getWebArtifactEdit ForRead(IVirtualComponent
aModule));
edit.getDeploymentDescriptorRoot();
} finally {
if(edit != null)
edit.dispose();
}

Hope this helps
Re: Best way to get information about a web module? [message #107404 is a reply to message #106588] Wed, 25 May 2005 12:01 Go to previous message
Eclipse UserFriend
"Vijay Bhadriraju" <vbhadrir@us.ibm.com> wrote in message
news:d6r7a8$3kl$1@news.eclipse.org...
>
> Initially StructureEdit and WorkbenchComponent are internal classes and
> not api so you should not use them and use ComponentCore and Vitual
> Component api. The ComponentCore api for flex project are eclipse platform
> kind api to get to the Flex project artifacts.
>
> Secondly using ComponentCore api you need not worry about releasing the
> objects you get back using its api. You still need to release the objects
> that you get back using artifact edit api. The objects that you get back
> using using artifact edit api are EMF objects. If you are interested in
> only working with eclipse IResource objects you need not use artifact
> edits.


What's the difference between an ArtifactEdit and a StructureEdit? I thought
they were the same thing...?

I am actually interested in only working with IResource objects - what I
really need is the IContainer that is the webapp root for a web module; is
there a way to get this without using an artifact edit? Or did I
misunderstand...?

thanks
-Tom
Previous Topic:Import existing EJB project into M4
Next Topic:Where can I find a more complete installation guide?
Goto Forum:
  


Current Time: Wed Jul 16 23:55:31 EDT 2025

Powered by FUDForum. Page generated in 0.11479 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top