Home » Language IDEs » ServerTools (WTP) » handle on web content
handle on web content [message #187510] |
Fri, 02 February 2007 16:58  |
Eclipse User |
|
|
|
Originally posted by: mremme.braintags.de
Hi,
i am working with wst 1.5. From out of a plugin i would like to get a reference to the web content directory of a
dynamic web project as IPath or else. Does anybody know how to manage this?
tia, Michael
|
|
| |
Re: handle on web content [message #187588 is a reply to message #187534] |
Tue, 06 February 2007 15:12   |
Eclipse User |
|
|
|
Originally posted by: mremme.braintags.de
hmm - so far it works, but i think i do not understand all.
In the example code above the nature is not null.
The project relative path for WEB-INF is correct,
ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature( module.getProject() );
IVirtualComponent vc = ComponentCore.createComponent( module.getProject() );
IVirtualFolder root = vc.getRootFolder();
IVirtualFolder webInf = root.getFolder( "WEB-INF" );
IPath path = webInf.getProjectRelativePath();
webInf.create( IResource.BACKGROUND_REFRESH, monitor );
IVirtualFolder clasDir = webInf.getFolder( "classes" );
clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
here its getting wrong for me, because exist is "true" but the path is returned as "/src"
boolean exist = clasDir.exists();
path = clasDir.getProjectRelativePath();
return path;
I mean, at the moment i am simply using the WEB-INF entry and pull down later, but i would like to understand.
Michael
Larry Isaacs schrieb:
> Michael,
>
> You can use ModuleCoreNature.isFlexibleProject(IProject) to confirm you
> have a WTP flexible project. If so, then
> ComponentCore.createComponent(IProject) will give you an
> IVirtualComponent which is the flexible project. Calling
> getRootFolder() on this flexible project will give you an IVirtualFolder
> as the root folder. If this is a Dynamic Web Project, this root folder
> will be the web content folder. You can call getProjectRelativePath()
> or getWorkspaceRelativePath() on this IVirtualFolder to get an IPath.
> Checkout the Javadoc of these methods for details. HTH.
>
> Cheers,
> Larry
>
> Michael Remme wrote:
>> Hi,
>>
>> i am working with wst 1.5. From out of a plugin i would like to get a
>> reference to the web content directory of a dynamic web project as
>> IPath or else. Does anybody know how to manage this?
>>
>> tia, Michael
|
|
|
Re: handle on web content [message #187596 is a reply to message #187588] |
Tue, 06 February 2007 15:36   |
Larry Isaacs Messages: 1354 Registered: July 2009 |
Senior Member |
|
|
Any Java related content in your project is assumed to be destined for
the WEB-INF/classes directory. This means the Java "content" should go
under the "Java Source" folder you specified when you created the
Dynamic Web Project. The default value for this "Java Source" folder is
"src". What you are seeing is the mapping that "redirects" build
artifacts that come from this "src" directory to the "WEB-INF/classes"
directory when the project is published to a server or assembled into a
war file.
Cheers,
Larry
Michael Remme wrote:
> hmm - so far it works, but i think i do not understand all.
> In the example code above the nature is not null.
> The project relative path for WEB-INF is correct,
>
>
> ModuleCoreNature nature = ModuleCoreNature.getModuleCoreNature(
> module.getProject() );
> IVirtualComponent vc = ComponentCore.createComponent(
> module.getProject() );
> IVirtualFolder root = vc.getRootFolder();
> IVirtualFolder webInf = root.getFolder( "WEB-INF" );
> IPath path = webInf.getProjectRelativePath();
>
> webInf.create( IResource.BACKGROUND_REFRESH, monitor );
> IVirtualFolder clasDir = webInf.getFolder( "classes" );
> clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
>
>
> here its getting wrong for me, because exist is "true" but the path is
> returned as "/src"
>
> boolean exist = clasDir.exists();
> path = clasDir.getProjectRelativePath();
> return path;
>
> I mean, at the moment i am simply using the WEB-INF entry and pull down
> later, but i would like to understand.
>
> Michael
>
> Larry Isaacs schrieb:
>> Michael,
>>
>> You can use ModuleCoreNature.isFlexibleProject(IProject) to confirm
>> you have a WTP flexible project. If so, then
>> ComponentCore.createComponent(IProject) will give you an
>> IVirtualComponent which is the flexible project. Calling
>> getRootFolder() on this flexible project will give you an
>> IVirtualFolder as the root folder. If this is a Dynamic Web Project,
>> this root folder will be the web content folder. You can call
>> getProjectRelativePath() or getWorkspaceRelativePath() on this
>> IVirtualFolder to get an IPath.
>> Checkout the Javadoc of these methods for details. HTH.
>>
>> Cheers,
>> Larry
>>
>> Michael Remme wrote:
>>> Hi,
>>>
>>> i am working with wst 1.5. From out of a plugin i would like to get a
>>> reference to the web content directory of a dynamic web project as
>>> IPath or else. Does anybody know how to manage this?
>>>
>>> tia, Michael
|
|
|
Re: handle on web content [message #187611 is a reply to message #187596] |
Tue, 06 February 2007 16:36   |
Eclipse User |
|
|
|
Originally posted by: mremme.braintags.de
ok - then this is not the right way for me to use this scheme.
Then another question which i did not goog so far neither:
Can i gain a handle to the webapp directory of the server ( e.g. tomcat ) where the project is published into?
best, Michael
Larry Isaacs schrieb:
> Any Java related content in your project is assumed to be destined for
> the WEB-INF/classes directory. This means the Java "content" should go
> under the "Java Source" folder you specified when you created the
> Dynamic Web Project. The default value for this "Java Source" folder is
> "src". What you are seeing is the mapping that "redirects" build
> artifacts that come from this "src" directory to the "WEB-INF/classes"
> directory when the project is published to a server or assembled into a
> war file.
>
> Cheers,
> Larry
>
> Michael Remme wrote:
>> hmm - so far it works, but i think i do not understand all.
>> In the example code above the nature is not null.
>> The project relative path for WEB-INF is correct,
>>
>>
>> ModuleCoreNature nature =
>> ModuleCoreNature.getModuleCoreNature( module.getProject() );
>> IVirtualComponent vc = ComponentCore.createComponent(
>> module.getProject() );
>> IVirtualFolder root = vc.getRootFolder();
>> IVirtualFolder webInf = root.getFolder( "WEB-INF" );
>> IPath path = webInf.getProjectRelativePath();
>>
>> webInf.create( IResource.BACKGROUND_REFRESH, monitor );
>> IVirtualFolder clasDir = webInf.getFolder( "classes" );
>> clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
>>
>>
>> here its getting wrong for me, because exist is "true" but the path is
>> returned as "/src"
>>
>> boolean exist = clasDir.exists();
>> path = clasDir.getProjectRelativePath();
>> return path;
>>
>> I mean, at the moment i am simply using the WEB-INF entry and pull
>> down later, but i would like to understand.
>>
>> Michael
>>
>> Larry Isaacs schrieb:
>>> Michael,
>>>
>>> You can use ModuleCoreNature.isFlexibleProject(IProject) to confirm
>>> you have a WTP flexible project. If so, then
>>> ComponentCore.createComponent(IProject) will give you an
>>> IVirtualComponent which is the flexible project. Calling
>>> getRootFolder() on this flexible project will give you an
>>> IVirtualFolder as the root folder. If this is a Dynamic Web Project,
>>> this root folder will be the web content folder. You can call
>>> getProjectRelativePath() or getWorkspaceRelativePath() on this
>>> IVirtualFolder to get an IPath.
>>> Checkout the Javadoc of these methods for details. HTH.
>>>
>>> Cheers,
>>> Larry
>>>
>>> Michael Remme wrote:
>>>> Hi,
>>>>
>>>> i am working with wst 1.5. From out of a plugin i would like to get
>>>> a reference to the web content directory of a dynamic web project as
>>>> IPath or else. Does anybody know how to manage this?
>>>>
>>>> tia, Michael
|
|
|
Re: handle on web content [message #187619 is a reply to message #187611] |
Tue, 06 February 2007 17:16   |
Larry Isaacs Messages: 1354 Registered: July 2009 |
Senior Member |
|
|
Michael Remme wrote:
> ok - then this is not the right way for me to use this scheme.
> Then another question which i did not goog so far neither:
> Can i gain a handle to the webapp directory of the server ( e.g. tomcat
> ) where the project is published into?
I'm not aware of any public API that would suffice. What is it you are
trying to do?
Larry
>
> best, Michael
>
> Larry Isaacs schrieb:
>> Any Java related content in your project is assumed to be destined for
>> the WEB-INF/classes directory. This means the Java "content" should
>> go under the "Java Source" folder you specified when you created the
>> Dynamic Web Project. The default value for this "Java Source" folder
>> is "src". What you are seeing is the mapping that "redirects" build
>> artifacts that come from this "src" directory to the "WEB-INF/classes"
>> directory when the project is published to a server or assembled into
>> a war file.
>>
>> Cheers,
>> Larry
>>
>> Michael Remme wrote:
>>> hmm - so far it works, but i think i do not understand all.
>>> In the example code above the nature is not null.
>>> The project relative path for WEB-INF is correct,
>>>
>>>
>>> ModuleCoreNature nature =
>>> ModuleCoreNature.getModuleCoreNature( module.getProject() );
>>> IVirtualComponent vc = ComponentCore.createComponent(
>>> module.getProject() );
>>> IVirtualFolder root = vc.getRootFolder();
>>> IVirtualFolder webInf = root.getFolder( "WEB-INF" );
>>> IPath path = webInf.getProjectRelativePath();
>>>
>>> webInf.create( IResource.BACKGROUND_REFRESH, monitor );
>>> IVirtualFolder clasDir = webInf.getFolder( "classes" );
>>> clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
>>>
>>>
>>> here its getting wrong for me, because exist is "true" but the path
>>> is returned as "/src"
>>>
>>> boolean exist = clasDir.exists();
>>> path = clasDir.getProjectRelativePath();
>>> return path;
>>>
>>> I mean, at the moment i am simply using the WEB-INF entry and pull
>>> down later, but i would like to understand.
>>>
>>> Michael
>>>
>>> Larry Isaacs schrieb:
>>>> Michael,
>>>>
>>>> You can use ModuleCoreNature.isFlexibleProject(IProject) to confirm
>>>> you have a WTP flexible project. If so, then
>>>> ComponentCore.createComponent(IProject) will give you an
>>>> IVirtualComponent which is the flexible project. Calling
>>>> getRootFolder() on this flexible project will give you an
>>>> IVirtualFolder as the root folder. If this is a Dynamic Web
>>>> Project, this root folder will be the web content folder. You can
>>>> call getProjectRelativePath() or getWorkspaceRelativePath() on this
>>>> IVirtualFolder to get an IPath.
>>>> Checkout the Javadoc of these methods for details. HTH.
>>>>
>>>> Cheers,
>>>> Larry
>>>>
>>>> Michael Remme wrote:
>>>>> Hi,
>>>>>
>>>>> i am working with wst 1.5. From out of a plugin i would like to get
>>>>> a reference to the web content directory of a dynamic web project
>>>>> as IPath or else. Does anybody know how to manage this?
>>>>>
>>>>> tia, Michael
|
|
|
Re: handle on web content [message #187659 is a reply to message #187619] |
Wed, 07 February 2007 09:18   |
Eclipse User |
|
|
|
Originally posted by: mremme.braintags.de
Hi Larry,
thank you for your help.
I am trying to solve our internal problem which was discussed earlyer under "extending dynamic webproject".
In short:
One dynamic Webproject A is extending another dynamic WebProject B. WebProject B uses s Java project.
Coming from sysdeo i am used to that all classes of all projects are synchronized into tomcat.
With wst i read and improved with the thread above that this is not possible.
Thus i started a plugin with the extendion point org.eclipse.wst.server.core.publishTasks.
My first idea was to copy the classes of the referenced projects into the WEB-INF/classes of the WebContent. I hoped
that - if my publish task would be processed before all others - that the copies would be synchronized by the standard
publish into the webapp. I know now that this is not working.
Thus now i want to copy the classes into the webapp directly and that for i would like to gain a handle onto the webapp
directory.
For now i will make something like a semi static solution for our internal use only, publishing into
"tomcatInstallDir/webapp/projectname/WEB-INF/classes". But at the end i would like to reach a dynamic solution.
best, Michael
Larry Isaacs schrieb:
> Michael Remme wrote:
>> ok - then this is not the right way for me to use this scheme.
>> Then another question which i did not goog so far neither:
>> Can i gain a handle to the webapp directory of the server ( e.g.
>> tomcat ) where the project is published into?
>
> I'm not aware of any public API that would suffice. What is it you are
> trying to do?
>
> Larry
>
>>
>> best, Michael
>>
>> Larry Isaacs schrieb:
>>> Any Java related content in your project is assumed to be destined
>>> for the WEB-INF/classes directory. This means the Java "content"
>>> should go under the "Java Source" folder you specified when you
>>> created the Dynamic Web Project. The default value for this "Java
>>> Source" folder is "src". What you are seeing is the mapping that
>>> "redirects" build artifacts that come from this "src" directory to
>>> the "WEB-INF/classes" directory when the project is published to a
>>> server or assembled into a war file.
>>>
>>> Cheers,
>>> Larry
>>>
>>> Michael Remme wrote:
>>>> hmm - so far it works, but i think i do not understand all.
>>>> In the example code above the nature is not null.
>>>> The project relative path for WEB-INF is correct,
>>>>
>>>>
>>>> ModuleCoreNature nature =
>>>> ModuleCoreNature.getModuleCoreNature( module.getProject() );
>>>> IVirtualComponent vc = ComponentCore.createComponent(
>>>> module.getProject() );
>>>> IVirtualFolder root = vc.getRootFolder();
>>>> IVirtualFolder webInf = root.getFolder( "WEB-INF" );
>>>> IPath path = webInf.getProjectRelativePath();
>>>>
>>>> webInf.create( IResource.BACKGROUND_REFRESH, monitor );
>>>> IVirtualFolder clasDir = webInf.getFolder( "classes" );
>>>> clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
>>>>
>>>>
>>>> here its getting wrong for me, because exist is "true" but the path
>>>> is returned as "/src"
>>>>
>>>> boolean exist = clasDir.exists();
>>>> path = clasDir.getProjectRelativePath();
>>>> return path;
>>>>
>>>> I mean, at the moment i am simply using the WEB-INF entry and pull
>>>> down later, but i would like to understand.
>>>>
>>>> Michael
>>>>
>>>> Larry Isaacs schrieb:
>>>>> Michael,
>>>>>
>>>>> You can use ModuleCoreNature.isFlexibleProject(IProject) to confirm
>>>>> you have a WTP flexible project. If so, then
>>>>> ComponentCore.createComponent(IProject) will give you an
>>>>> IVirtualComponent which is the flexible project. Calling
>>>>> getRootFolder() on this flexible project will give you an
>>>>> IVirtualFolder as the root folder. If this is a Dynamic Web
>>>>> Project, this root folder will be the web content folder. You can
>>>>> call getProjectRelativePath() or getWorkspaceRelativePath() on this
>>>>> IVirtualFolder to get an IPath.
>>>>> Checkout the Javadoc of these methods for details. HTH.
>>>>>
>>>>> Cheers,
>>>>> Larry
>>>>>
>>>>> Michael Remme wrote:
>>>>>> Hi,
>>>>>>
>>>>>> i am working with wst 1.5. From out of a plugin i would like to
>>>>>> get a reference to the web content directory of a dynamic web
>>>>>> project as IPath or else. Does anybody know how to manage this?
>>>>>>
>>>>>> tia, Michael
|
|
|
Re: handle on web content [message #187724 is a reply to message #187659] |
Wed, 07 February 2007 17:05  |
Larry Isaacs Messages: 1354 Registered: July 2009 |
Senior Member |
|
|
If it helps, the job of the publish task wouldn't be to copy the classes
of the referenced project to WebProject A (assuming I understand you
correctly), but to the destination of the publish. Your "source"
location for the classes in WebProject B wouldn't be the virtual folder
for its "WEB-INF/classes", but I believe, simply its Java output folder.
Cheers,
Larry
Michael Remme wrote:
> Hi Larry,
>
> thank you for your help.
>
> I am trying to solve our internal problem which was discussed earlyer
> under "extending dynamic webproject".
> In short:
> One dynamic Webproject A is extending another dynamic WebProject B.
> WebProject B uses s Java project.
> Coming from sysdeo i am used to that all classes of all projects are
> synchronized into tomcat.
> With wst i read and improved with the thread above that this is not
> possible.
>
> Thus i started a plugin with the extendion point
> org.eclipse.wst.server.core.publishTasks.
> My first idea was to copy the classes of the referenced projects into
> the WEB-INF/classes of the WebContent. I hoped that - if my publish task
> would be processed before all others - that the copies would be
> synchronized by the standard publish into the webapp. I know now that
> this is not working.
>
> Thus now i want to copy the classes into the webapp directly and that
> for i would like to gain a handle onto the webapp directory.
> For now i will make something like a semi static solution for our
> internal use only, publishing into
> "tomcatInstallDir/webapp/projectname/WEB-INF/classes". But at the end i
> would like to reach a dynamic solution.
>
> best, Michael
>
>
> Larry Isaacs schrieb:
>> Michael Remme wrote:
>>> ok - then this is not the right way for me to use this scheme.
>>> Then another question which i did not goog so far neither:
>>> Can i gain a handle to the webapp directory of the server ( e.g.
>>> tomcat ) where the project is published into?
>>
>> I'm not aware of any public API that would suffice. What is it you
>> are trying to do?
>>
>> Larry
>>
>>>
>>> best, Michael
>>>
>>> Larry Isaacs schrieb:
>>>> Any Java related content in your project is assumed to be destined
>>>> for the WEB-INF/classes directory. This means the Java "content"
>>>> should go under the "Java Source" folder you specified when you
>>>> created the Dynamic Web Project. The default value for this "Java
>>>> Source" folder is "src". What you are seeing is the mapping that
>>>> "redirects" build artifacts that come from this "src" directory to
>>>> the "WEB-INF/classes" directory when the project is published to a
>>>> server or assembled into a war file.
>>>>
>>>> Cheers,
>>>> Larry
>>>>
>>>> Michael Remme wrote:
>>>>> hmm - so far it works, but i think i do not understand all.
>>>>> In the example code above the nature is not null.
>>>>> The project relative path for WEB-INF is correct,
>>>>>
>>>>>
>>>>> ModuleCoreNature nature =
>>>>> ModuleCoreNature.getModuleCoreNature( module.getProject() );
>>>>> IVirtualComponent vc = ComponentCore.createComponent(
>>>>> module.getProject() );
>>>>> IVirtualFolder root = vc.getRootFolder();
>>>>> IVirtualFolder webInf = root.getFolder( "WEB-INF" );
>>>>> IPath path = webInf.getProjectRelativePath();
>>>>>
>>>>> webInf.create( IResource.BACKGROUND_REFRESH, monitor );
>>>>> IVirtualFolder clasDir = webInf.getFolder( "classes" );
>>>>> clasDir.create( IResource.BACKGROUND_REFRESH, monitor );
>>>>>
>>>>>
>>>>> here its getting wrong for me, because exist is "true" but the path
>>>>> is returned as "/src"
>>>>>
>>>>> boolean exist = clasDir.exists();
>>>>> path = clasDir.getProjectRelativePath();
>>>>> return path;
>>>>>
>>>>> I mean, at the moment i am simply using the WEB-INF entry and pull
>>>>> down later, but i would like to understand.
>>>>>
>>>>> Michael
>>>>>
>>>>> Larry Isaacs schrieb:
>>>>>> Michael,
>>>>>>
>>>>>> You can use ModuleCoreNature.isFlexibleProject(IProject) to
>>>>>> confirm you have a WTP flexible project. If so, then
>>>>>> ComponentCore.createComponent(IProject) will give you an
>>>>>> IVirtualComponent which is the flexible project. Calling
>>>>>> getRootFolder() on this flexible project will give you an
>>>>>> IVirtualFolder as the root folder. If this is a Dynamic Web
>>>>>> Project, this root folder will be the web content folder. You can
>>>>>> call getProjectRelativePath() or getWorkspaceRelativePath() on
>>>>>> this IVirtualFolder to get an IPath.
>>>>>> Checkout the Javadoc of these methods for details. HTH.
>>>>>>
>>>>>> Cheers,
>>>>>> Larry
>>>>>>
>>>>>> Michael Remme wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> i am working with wst 1.5. From out of a plugin i would like to
>>>>>>> get a reference to the web content directory of a dynamic web
>>>>>>> project as IPath or else. Does anybody know how to manage this?
>>>>>>>
>>>>>>> tia, Michael
|
|
|
Goto Forum:
Current Time: Thu Feb 06 14:11:40 GMT 2025
Powered by FUDForum. Page generated in 0.05024 seconds
|