You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stephen Connolly <st...@gmail.com> on 2011/03/04 17:45:58 UTC

RE: JSF2 and content from the classpath?

Hi,

Just a quick question as I am doing some research.

I cannot remember (and my google searches are just turning up far far too
much noize) whether it is possible to server content directly from jars on
the classpath rather than only from the wars.

I'm thinking of a case where you might have a plugin mechanism, or a core
functionality and you want to be able to merge that into your web
application without expanding the jar file as a war overlay.

I cannot recall if I only dreamt reading that you could do the following, or
if you actually can.

Jar would look something like:

/
  com
    somecompany
      ...
  META-INF
    faces-config.xml
    content
      plugin.xhtml

And then if the webapp had that jar on the classpath, a request for
/contextRoot/plugin.xhtml would server the content from the jar file and not
bomb out because the file does not exist in the war file itself.

-Stephen

Re: JSF2 and content from the classpath?

Posted by Kito Mann <ki...@virtua.com>.
On Fri, Mar 4, 2011 at 11:59 AM, Stephen Connolly <
stephen.alan.connolly@gmail.com> wrote:

> is there any example code you know of that you could share?


Just copy the CustomResourceResolver and web.xml section from
http://ocpsoft.com/opensource/create-common-facelets-jar/.

>
> And can I have a pony?
>

That'll cost you :-).

>
>

>
> On 4 March 2011 16:56, Kito Mann <ki...@virtua.com> wrote:
>
>>
>>
>> On Fri, Mar 4, 2011 at 11:55 AM, Stephen Connolly <
>> stephen.alan.connolly@gmail.com> wrote:
>>
>>> and if this/these .xhtml file(s) are actually facelets pages... will that
>>> work?
>>
>>
>> Yep.
>>
>>>
>>>
>>> On 4 March 2011 16:54, Kito Mann <ki...@virtua.com> wrote:
>>>
>>>> Hello Stephen,
>>>>
>>>> With JSF 2, you can use the resource handling mechanism to load
>>>> resources from META-INF/resources -- this works for composite components,
>>>> images, etc. If you want to serve .xhtml files from a JAR, you need to write
>>>> a custom ResourceResolver, which is a trivial exercise. See:
>>>> http://ocpsoft.com/opensource/create-common-facelets-jar/.
>>>> ---
>>>> Kito D. Mann | twitter: kito99 | Author, JSF in Action
>>>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>>>> consulting
>>>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
>>>> twitter: jsfcentral
>>>> +1 203-404-4848 x3
>>>>
>>>> * Listen to the latest headlines in the JSF and Java EE newscast:
>>>> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
>>>> * See you at JAX and JSF Summit 2010 June 20-23rd in San Jose:
>>>> http://jaxconf.com/
>>>>
>>>>
>>>>
>>>> On Fri, Mar 4, 2011 at 11:45 AM, Stephen Connolly <
>>>> stephen.alan.connolly@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Just a quick question as I am doing some research.
>>>>>
>>>>> I cannot remember (and my google searches are just turning up far far
>>>>> too
>>>>> much noize) whether it is possible to server content directly from jars
>>>>> on
>>>>> the classpath rather than only from the wars.
>>>>>
>>>>> I'm thinking of a case where you might have a plugin mechanism, or a
>>>>> core
>>>>> functionality and you want to be able to merge that into your web
>>>>> application without expanding the jar file as a war overlay.
>>>>>
>>>>> I cannot recall if I only dreamt reading that you could do the
>>>>> following, or
>>>>> if you actually can.
>>>>>
>>>>> Jar would look something like:
>>>>>
>>>>> /
>>>>>  com
>>>>>    somecompany
>>>>>      ...
>>>>>  META-INF
>>>>>    faces-config.xml
>>>>>    content
>>>>>      plugin.xhtml
>>>>>
>>>>> And then if the webapp had that jar on the classpath, a request for
>>>>> /contextRoot/plugin.xhtml would server the content from the jar file
>>>>> and not
>>>>> bomb out because the file does not exist in the war file itself.
>>>>>
>>>>> -Stephen
>>>>>
>>>>
>>>>
>>>
>>
>

Re: JSF2 and content from the classpath?

Posted by Stephen Connolly <st...@gmail.com>.
is there any example code you know of that you could share?

And can I have a pony?

;-)

On 4 March 2011 16:56, Kito Mann <ki...@virtua.com> wrote:

>
>
> On Fri, Mar 4, 2011 at 11:55 AM, Stephen Connolly <
> stephen.alan.connolly@gmail.com> wrote:
>
>> and if this/these .xhtml file(s) are actually facelets pages... will that
>> work?
>
>
> Yep.
>
>>
>>
>> On 4 March 2011 16:54, Kito Mann <ki...@virtua.com> wrote:
>>
>>> Hello Stephen,
>>>
>>> With JSF 2, you can use the resource handling mechanism to load resources
>>> from META-INF/resources -- this works for composite components, images, etc.
>>> If you want to serve .xhtml files from a JAR, you need to write a custom
>>> ResourceResolver, which is a trivial exercise. See:
>>> http://ocpsoft.com/opensource/create-common-facelets-jar/.
>>> ---
>>> Kito D. Mann | twitter: kito99 | Author, JSF in Action
>>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>>> consulting
>>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
>>> twitter: jsfcentral
>>> +1 203-404-4848 x3
>>>
>>> * Listen to the latest headlines in the JSF and Java EE newscast:
>>> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
>>> * See you at JAX and JSF Summit 2010 June 20-23rd in San Jose:
>>> http://jaxconf.com/
>>>
>>>
>>>
>>> On Fri, Mar 4, 2011 at 11:45 AM, Stephen Connolly <
>>> stephen.alan.connolly@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Just a quick question as I am doing some research.
>>>>
>>>> I cannot remember (and my google searches are just turning up far far
>>>> too
>>>> much noize) whether it is possible to server content directly from jars
>>>> on
>>>> the classpath rather than only from the wars.
>>>>
>>>> I'm thinking of a case where you might have a plugin mechanism, or a
>>>> core
>>>> functionality and you want to be able to merge that into your web
>>>> application without expanding the jar file as a war overlay.
>>>>
>>>> I cannot recall if I only dreamt reading that you could do the
>>>> following, or
>>>> if you actually can.
>>>>
>>>> Jar would look something like:
>>>>
>>>> /
>>>>  com
>>>>    somecompany
>>>>      ...
>>>>  META-INF
>>>>    faces-config.xml
>>>>    content
>>>>      plugin.xhtml
>>>>
>>>> And then if the webapp had that jar on the classpath, a request for
>>>> /contextRoot/plugin.xhtml would server the content from the jar file and
>>>> not
>>>> bomb out because the file does not exist in the war file itself.
>>>>
>>>> -Stephen
>>>>
>>>
>>>
>>
>

Re: JSF2 and content from the classpath?

Posted by Kito Mann <ki...@virtua.com>.
On Fri, Mar 4, 2011 at 11:55 AM, Stephen Connolly <
stephen.alan.connolly@gmail.com> wrote:

> and if this/these .xhtml file(s) are actually facelets pages... will that
> work?


Yep.

>
>
> On 4 March 2011 16:54, Kito Mann <ki...@virtua.com> wrote:
>
>> Hello Stephen,
>>
>> With JSF 2, you can use the resource handling mechanism to load resources
>> from META-INF/resources -- this works for composite components, images, etc.
>> If you want to serve .xhtml files from a JAR, you need to write a custom
>> ResourceResolver, which is a trivial exercise. See:
>> http://ocpsoft.com/opensource/create-common-facelets-jar/.
>> ---
>> Kito D. Mann | twitter: kito99 | Author, JSF in Action
>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>> consulting
>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
>> twitter: jsfcentral
>> +1 203-404-4848 x3
>>
>> * Listen to the latest headlines in the JSF and Java EE newscast:
>> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
>> * See you at JAX and JSF Summit 2010 June 20-23rd in San Jose:
>> http://jaxconf.com/
>>
>>
>>
>> On Fri, Mar 4, 2011 at 11:45 AM, Stephen Connolly <
>> stephen.alan.connolly@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Just a quick question as I am doing some research.
>>>
>>> I cannot remember (and my google searches are just turning up far far too
>>> much noize) whether it is possible to server content directly from jars
>>> on
>>> the classpath rather than only from the wars.
>>>
>>> I'm thinking of a case where you might have a plugin mechanism, or a core
>>> functionality and you want to be able to merge that into your web
>>> application without expanding the jar file as a war overlay.
>>>
>>> I cannot recall if I only dreamt reading that you could do the following,
>>> or
>>> if you actually can.
>>>
>>> Jar would look something like:
>>>
>>> /
>>>  com
>>>    somecompany
>>>      ...
>>>  META-INF
>>>    faces-config.xml
>>>    content
>>>      plugin.xhtml
>>>
>>> And then if the webapp had that jar on the classpath, a request for
>>> /contextRoot/plugin.xhtml would server the content from the jar file and
>>> not
>>> bomb out because the file does not exist in the war file itself.
>>>
>>> -Stephen
>>>
>>
>>
>

Re: JSF2 and content from the classpath?

Posted by Stephen Connolly <st...@gmail.com>.
and if this/these .xhtml file(s) are actually facelets pages... will that
work?

On 4 March 2011 16:54, Kito Mann <ki...@virtua.com> wrote:

> Hello Stephen,
>
> With JSF 2, you can use the resource handling mechanism to load resources
> from META-INF/resources -- this works for composite components, images, etc.
> If you want to serve .xhtml files from a JAR, you need to write a custom
> ResourceResolver, which is a trivial exercise. See:
> http://ocpsoft.com/opensource/create-common-facelets-jar/.
> ---
> Kito D. Mann | twitter: kito99 | Author, JSF in Action
> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
> twitter: jsfcentral
> +1 203-404-4848 x3
>
> * Listen to the latest headlines in the JSF and Java EE newscast:
> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
> * See you at JAX and JSF Summit 2010 June 20-23rd in San Jose:
> http://jaxconf.com/
>
>
>
> On Fri, Mar 4, 2011 at 11:45 AM, Stephen Connolly <
> stephen.alan.connolly@gmail.com> wrote:
>
>> Hi,
>>
>> Just a quick question as I am doing some research.
>>
>> I cannot remember (and my google searches are just turning up far far too
>> much noize) whether it is possible to server content directly from jars on
>> the classpath rather than only from the wars.
>>
>> I'm thinking of a case where you might have a plugin mechanism, or a core
>> functionality and you want to be able to merge that into your web
>> application without expanding the jar file as a war overlay.
>>
>> I cannot recall if I only dreamt reading that you could do the following,
>> or
>> if you actually can.
>>
>> Jar would look something like:
>>
>> /
>>  com
>>    somecompany
>>      ...
>>  META-INF
>>    faces-config.xml
>>    content
>>      plugin.xhtml
>>
>> And then if the webapp had that jar on the classpath, a request for
>> /contextRoot/plugin.xhtml would server the content from the jar file and
>> not
>> bomb out because the file does not exist in the war file itself.
>>
>> -Stephen
>>
>
>

Re: JSF2 and content from the classpath?

Posted by Kito Mann <ki...@virtua.com>.
Hello Stephen,

With JSF 2, you can use the resource handling mechanism to load resources
from META-INF/resources -- this works for composite components, images, etc.
If you want to serve .xhtml files from a JAR, you need to write a custom
ResourceResolver, which is a trivial exercise. See:
http://ocpsoft.com/opensource/create-common-facelets-jar/.
---
Kito D. Mann | twitter: kito99 | Author, JSF in Action
Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info | twitter:
jsfcentral
+1 203-404-4848 x3

* Listen to the latest headlines in the JSF and Java EE newscast:
http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
* See you at JAX and JSF Summit 2010 June 20-23rd in San Jose:
http://jaxconf.com/



On Fri, Mar 4, 2011 at 11:45 AM, Stephen Connolly <
stephen.alan.connolly@gmail.com> wrote:

> Hi,
>
> Just a quick question as I am doing some research.
>
> I cannot remember (and my google searches are just turning up far far too
> much noize) whether it is possible to server content directly from jars on
> the classpath rather than only from the wars.
>
> I'm thinking of a case where you might have a plugin mechanism, or a core
> functionality and you want to be able to merge that into your web
> application without expanding the jar file as a war overlay.
>
> I cannot recall if I only dreamt reading that you could do the following,
> or
> if you actually can.
>
> Jar would look something like:
>
> /
>  com
>    somecompany
>      ...
>  META-INF
>    faces-config.xml
>    content
>      plugin.xhtml
>
> And then if the webapp had that jar on the classpath, a request for
> /contextRoot/plugin.xhtml would server the content from the jar file and
> not
> bomb out because the file does not exist in the war file itself.
>
> -Stephen
>