Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Determining the client project of an EJB project from a plugin
Determining the client project of an EJB project from a plugin [message #222532] Wed, 01 October 2008 11:13 Go to next message
Stephen Burdeau is currently offline Stephen BurdeauFriend
Messages: 2
Registered: July 2009
Junior Member
I am writing a plugin where I have a handle to an EJB project (IProject)
and I want to determine what the corresponding client project is, if any.

I noticed that the file .settings/org.eclipse.wst.common.component for the
EJB project looks like the following:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="CreditQueryEJB">
<wb-resource deploy-path="/" source-path="/ejbModule"/>
<dependent-module deploy-path="/"
handle="module:/resource/CreditQueryEJBClient/CreditQueryEJBClient ">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path"/>
<property name="ClientProject" value="CreditQueryEJBClient"/>
<property name="ClientJARURI" value="CreditQueryEJBClient.jar"/>
</wb-module>
</project-modules>

So, it looks like I could get this information from the ClientProject
property in this file.

I have been searching the WTP documentation, google, and source code in an
effort to determine how I get at these properties from my plugin, but so
far with no luck.

Can anyone point me in the right direection?
Re: Determining the client project of an EJB project from a plugin [message #222540 is a reply to message #222532] Wed, 01 October 2008 13:34 Go to previous messageGo to next message
Stephen Burdeau is currently offline Stephen BurdeauFriend
Messages: 2
Registered: July 2009
Junior Member
OK, I was getting stuck because I could not find "ClientProject" anywhere
in the source code. Then I finally determined that it is in
org.eclipse.jst.j2ee.internal.common.CreationConstants, which I do not
seem to have the source code for.

Anyway, I answered my own question:


import java.util.Properties;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualCompo nent;

...

private String getDefaultClientProjectName(IJavaProject ejbJavaProject) {

final IVirtualComponent c = ComponentCore.createComponent
(ejbJavaProject.getProject());
Properties properties = c.getMetaProperties();

return properties.getProperty("ClientProject"); //$NON-NLS-1$
}
Re: Determining the client project of an EJB project from a plugin [message #222553 is a reply to message #222532] Thu, 02 October 2008 13:13 Go to previous message
Eclipse UserFriend
Originally posted by: k.mitov.xxx.xxx

Hi Stephen,
It is possible to find the client project in the following way:

IModelProvider provider = ModelProviderManager.getModelProvider(project);
String jarName = ((EJBJar)provider.getModelObject()).getEjbClientJar();
IProject clientProject =
ResourcesPlugin.getWorkspace().getRoot().getProject(getClien tNameFromJarName(jarName));

where the method getClientNameFromJarName is

private String getClientNameFromJarName(String jarName) {
if (jarName == null)
return null;
if (jarName.endsWith(".jar")) //$NON-NLS-1$
return jarName.substring(0, jarName.lastIndexOf(".jar")); //$NON-NLS-1$
return jarName;
}

You can see this code in
org.eclipse.jst.jee.model.internal.EJB3MergedModelProvider.j ava

Best Regards,
Kiril

Stephen Burdeau wrote:

> I am writing a plugin where I have a handle to an EJB project (IProject)
> and I want to determine what the corresponding client project is, if any.

> I noticed that the file .settings/org.eclipse.wst.common.component for the
> EJB project looks like the following:

> <?xml version="1.0" encoding="UTF-8"?>
> <project-modules id="moduleCoreId" project-version="1.5.0">
> <wb-module deploy-name="CreditQueryEJB">
> <wb-resource deploy-path="/" source-path="/ejbModule"/>
> <dependent-module deploy-path="/"
> handle="module:/resource/CreditQueryEJBClient/CreditQueryEJBClient ">
> <dependency-type>uses</dependency-type>
> </dependent-module>
> <property name="java-output-path"/>
> <property name="ClientProject" value="CreditQueryEJBClient"/>
> <property name="ClientJARURI" value="CreditQueryEJBClient.jar"/>
> </wb-module>
> </project-modules>

> So, it looks like I could get this information from the ClientProject
> property in this file.

> I have been searching the WTP documentation, google, and source code in an
> effort to determine how I get at these properties from my plugin, but so
> far with no luck.

> Can anyone point me in the right direection?
Previous Topic:Synchronous Publish to generic servers?
Next Topic:Why does completion work with a DTD, but not with a schema?
Goto Forum:
  


Current Time: Fri Apr 26 21:46:58 GMT 2024

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

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

Back to the top