HiMark

Here the results of my further investigations.

1. Setting ProjectStage for JSF: Here you have mistaken me. The solution in the 
@Startup bean works as expected. The value is set in time and picked up by JSF 
on startup.

2. DS ProjectStage picked up from JNDI: This does obviously not work in Glassfish 4. The name space 
java:comp/env is not available until the application is deployed (name referenced in web.xml 
<resource-ref> or ejb-jar.xml <resource-env-ref>). If DS would query JNDI with the global 
name "deltaspike/org.apache.deltaspike.ProjectStage" then the value would be found (I 
tested this from the debugger). But this seems not to be portable. Did you test picking up 
ProjectStage from JNDI in Glassfish? If you got a green bar I wonder, what I'm doing wrong.

Regards, Rainer

Am 26.11.2013 10:11, schrieb Mark Struberg:
Hi Rainer!

Well, if I understood your original post correctly, then you try to set the 
values into JNDI in a @Singleton @Startup EJBs @PostConstruct method?

The problem is that this is _way_ too late!

Please debug into the following locations to get more details about what's 
going on:

ProjectStageProducer#resolveProjectStage()
ConfigResolver#getPropertyValue(String key)

You will see that those methods will get invoked long before you hit the 
@Startup breakpoint.
The reason is that the ProjectStage already gets evaluated during the CDI 
Container boot (via the registered CDI Extensions) and thus any JNDI value you 
set later will simply not get picked up.

You could e.g. even add an annotation 
@Exclude(ifProjectStage=ProjectStage.Production.class) to your @Startup bean - 
I hope this explains why we need to resolve the ProjectStage much earlier.

Could you please try to take the 0.6-SNAPSHOT from 
https://repository.apache.org/content/groups/snapshots/
or you just simply compile DeltaSpike locally yourself. This is really easy, 
see [1][2].
We've added some pickup of a few known locations like faces.PROJECT_STAGE and 
javax.faces.PROJECT_STAGE.
Will ask Ed if Mojarra does also pick up the ProjectStage from the environment.


Please don't hesitate to ping back about your progress, txs!


LieGrue,
strub


[1] http://deltaspike.apache.org/source.html
[2] http://deltaspike.apache.org/build.html



________________________________
From: Rainer Schön <[email protected]>
To: [email protected]
Sent: Monday, 25 November 2013, 15:46
Subject: Re: Project Stage in JSF and DeltaSpike - 2nd


I think, there is a missunderstanding. My problem is not the timing. As I 
wrote, the @Startup bean does the job for the JSF project stage. The problem is 
here, that DS does  n o t  pick up the ProjectStage at start up from JNDI 
(please see again my reply beneath).

Regrads, Rainer


Am 25.11.2013 15:33, schrieb Mark Struberg:
timing issue.

At the time @Startup beans get triggered, all the CDI booting is long time done 
already!

LieGrue,
strub




________________________________
From: Rainer Schön <[email protected]>
To: [email protected]
Sent: Monday, 25 November 2013, 12:20
Subject: Re: Project Stage in JSF and DeltaSpike - 2nd


Hi Mark

Thanks for your reply. I fiddled a little bit about this problem. The best way I think, 
is to set the values for ProjectStage (DS + JSF) into the JNDI environment. There you 
have both at the same place. I tried to set then the desired value programmatically 
before the JSF app is startet but in the web tier (ConextListener or 
"StartupServlet" with priority 1 and JSF servlet with priority 2) one is always 
to late to set the value in time. The solution is to set up a @Singleton @Startup ejb and 
set the JNDI value for the JSF ProjectStage in its @PostConstruct method (works in WAR 
and EAR deployments to GF4). This solution has the advantage to have control which DS 
stage should comply to which JSF stage.

But Alas, the devil is in the details! DS does not pick up its ProjectStage 
from JNDI (java:comp/env/deltaspike/ProjectStage). Where could be the problem 
here?

Regards, Rainer


Am 21.11.2013 13:09, schrieb Mark Struberg:



Hi!

The JSF spec does not really define environment properties for defining the 
ProjectStage. As per the JSF spec (parts are only documented in the API!) there 
are only the following 2 ways to define the JSF ProjectStage:
* JNDI java:comp/env/jsf/ProjectStage
* web.xml servlet param javax.faces.PROJECT_STAGE

Apache MyFaces does also pick up the ProjectStage from the environment via 
'-Dfaces.PROJECT_STAGE=..' and via JNDI. See [1] for more info.
I'm not sure whether Mojarra picks up those settings as well.



The configuration which gets picked up in DeltaSpike itself is:

* all ConfigResolver locations (JNDI + env + system + deltaspike properties, + 
custom ConfigResolvers)


Currently only the following configuration gets picked up
* org.apache.deltaspike.ProjectStage

I'm not sure if we already have a JIRA issue for it, but the plan is to 
'extend' this behaviour within the ds-jsf-impl to also pick up the JSF 
locations (except web.xml I'd say). I bet there is some hacking needed on the 
core-impl to allow for this to happen.
Any opinions?

LieGrue,
strub





[1] https://issues.apache.org/jira/browse/MYFACES-2545


________________________________
From: Rainer Schön <[email protected]>
To: [email protected]
Sent: Thursday, 21 November 2013, 11:42
Subject: Project Stage in JSF and DeltaSpike - 2nd


As a follower of the DRY principle, I would like to support Harald Wellmann's 
post of October 10th, to which there was no answer:


Is there an easy way to propagate the JSF project stage into
DeltaSpike, or vice versa?
<<

Any idea is appreciated.

Thanks and regards, Rainer











Reply via email to