Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (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 07:13 Go to next message
Stephen Burdeau is currently offline Stephen Burdeau
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 09:34 Go to previous messageGo to next message
Stephen Burdeau is currently offline Stephen Burdeau
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 09:13 Go to previous message
Eclipse User
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: Sun Apr 20 06:53:15 EDT 2014

Powered by FUDForum. Page generated in 0.01927 seconds