-
15. Re: Deploying ValidatorFactory
alesj Aug 13, 2009 10:17 AM (in response to epbernard)"stan.silvert@jboss.com" wrote:
Does it hurt anything to go ahead and put a VF in JNDI for all deployments?
If we did bind a VF for all, would there be much of a perf hit?
If we did bind a VF for all, would finding the markers be more expensive than just creating and binding a VF?
I guess it doesn't hurt, but I would still like to limit it a bit.
Currently I have this simple check:if (attachmentNames != null && attachmentNames.isEmpty() == false) { for (String name : attachmentNames) { if (unit.isAttachmentPresent(name)) return true; } } return false;
where attachment names are our jee metadata classes<property name="attachmentNames"> <set> <value>org.jboss.metadata.web.jboss.JBossWebMetaData</value> <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value> </set> </property>
so in this case only web, ejb deployments get VF.
ps: the code is committed here: http://anonsvn.jboss.org/repos/jbossas/projects/jboss-jsr303/trunk/deployers/ -
16. Re: Deploying ValidatorFactory
wolfc Aug 13, 2009 11:00 AM (in response to epbernard)You can't bind in java:comp, because you haven't established the right context. (You need to know the component and establish it currently via ENCFactory.pushContextId(id). It's going to change into something like ENCFactory.pushComponent(component).)
public String createName(DeploymentUnit unit, ValidatorFactory factory) { return "java:comp/env/" + unit.getSimpleName(); // TODO - fix this }
You are probably better off binding it into global JNDI.
Another way which I'm looking into (for EJB3) is binding an ObjectFactory which starts the (on-demand) MC bean on lookup. The binding itself isn't a performance issue.
For the dependency something must supply jndi:name though. Or the bean name which does the binding should come from a resolver. -
17. Re: Deploying ValidatorFactory
epbernard Aug 13, 2009 11:02 AM (in response to epbernard)Thanks Ales for the starting code.
Two things:
1.
I've created a LazyValidatorFactory that allows to not initialize the VF until it's really needed. It's required to use it to avoid messing with JPA's class transformation which happens later in the deployment process
http://anonsvn.jboss.org/repos/hibernate/validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/LazyValidatorFactory.java
That should solve the overhead risk feared when the unit does not need BV (which is none AFAIK anyways as it is mandatory in EE 6
2.
On Ales's code I would change the package name from jsr303 to beanvalidation as the spec will likely make babies one day. -
18. Re: Deploying ValidatorFactory
alesj Aug 13, 2009 11:05 AM (in response to epbernard)"wolfc" wrote:
You are probably better off binding it into global JNDI.
Yeah, this was just an initial mock/hack.
I was just about to poke Stan about his proposal :-)"stan.silvert@jboss.com" wrote:
If you want me to do the JNDI part then I'll be glad to take a crack at it if you can give me a little guidance."wolfc" wrote:
Another way which I'm looking into (for EJB3) is binding an ObjectFactory which starts the (on-demand) MC bean on lookup. The binding itself isn't a performance issue.
You mean this ;-)
- http://www.jboss.org/index.html?module=bb&op=viewtopic&t=155226 -
19. Re: Deploying ValidatorFactory
alesj Aug 13, 2009 11:13 AM (in response to epbernard)"epbernard" wrote:
I've created a LazyValidatorFactory that allows to not initialize the VF until it's really needed. It's required to use it to avoid messing with JPA's class transformation which happens later in the deployment process
http://anonsvn.jboss.org/repos/hibernate/validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/LazyValidatorFactory.java
OK, changed."epbernard" wrote:
On Ales's code I would change the package name from jsr303 to beanvalidation as the spec will likely make babies one day.
OK, I'll rename it. Or did you already? -
20. Re: Deploying ValidatorFactory
epbernard Aug 13, 2009 11:20 AM (in response to epbernard)no I haven't On an other codebase atm :)
-
21. Re: Deploying ValidatorFactory
alesj Aug 13, 2009 11:29 AM (in response to epbernard)OK, it's changed now: jsr303 --> beanvalidation
-
22. Re: Deploying ValidatorFactory
pmuir Aug 16, 2009 12:31 PM (in response to epbernard)I need to inject the "default validator factory" into the Web Beans bootstrap, so that it can be made available for injection CDI-style. What MC bean should I use? ValidatorFactoryFactory?
-
23. Re: Deploying ValidatorFactory
alesj Aug 17, 2009 2:29 AM (in response to epbernard)"pete.muir@jboss.org" wrote:
I need to inject the "default validator factory" into the Web Beans bootstrap, so that it can be made available for injection CDI-style. What MC bean should I use? ValidatorFactoryFactory?
You could definitely use that, but a VFDeployer already creates a VF for you - how that is created should be impl detail;
e.g. currently it is created via VFF, in the future it might be something else
Hence you should simply pick up VF from DeploymentUnit's attachments and properly apply it in our Bootstrap deployer. -
24. Re: Deploying ValidatorFactory
pmuir Aug 17, 2009 3:28 PM (in response to epbernard)I wasn't precise, this is another of the "services" that WB, in an EE env, requires:
http://fisheye.jboss.org/browse/JBossAS/projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/validation/JBossValidationServices.java
http://fisheye.jboss.org/browse/JBossAS/projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-services-jboss-beans.xml?#l37
Currently my approach was to write this as an MC Bean (like other services we have), and then tell the WebBeansBootstrap about it in the deployer -
25. Re: Deploying ValidatorFactory
alesj Aug 17, 2009 3:53 PM (in response to epbernard)If all you need is VF, we can wire it up in bootstrap deployer.
But if this is not all, or it doesn't suite us best, I guess there is no harm in using VFF. -
26. Re: Deploying ValidatorFactory
epbernard Aug 17, 2009 4:10 PM (in response to epbernard)Well it has to be the same instance of VF for all consumers of an application (at least per module). Otherwise we pay the price of initialization several times.
-
27. Re: Deploying ValidatorFactory
ssilvert Aug 17, 2009 4:16 PM (in response to epbernard)"wolfc" wrote:
You can't bind in java:comp, because you haven't established the right context. (You need to know the component and establish it currently via ENCFactory.pushContextId(id). It's going to change into something like ENCFactory.pushComponent(component).)public String createName(DeploymentUnit unit, ValidatorFactory factory) { return "java:comp/env/" + unit.getSimpleName(); // TODO - fix this }
You are probably better off binding it into global JNDI.
Another way which I'm looking into (for EJB3) is binding an ObjectFactory which starts the (on-demand) MC bean on lookup. The binding itself isn't a performance issue.
For the dependency something must supply jndi:name though. Or the bean name which does the binding should come from a resolver.
JSF requires that a VF reference be put into application scope. Because I don't yet have a JSFDeployer, I do this in our JSF ServletContextListener. The only way I can do it is to create the VF myself or get it from JNDI.
So where are we with the JNDI part?
Stan -
28. Re: Deploying ValidatorFactory
pmuir Aug 17, 2009 4:34 PM (in response to epbernard)Ales is right, I can wire it up in Bootstrap.
-
29. Re: Deploying ValidatorFactory
alesj Aug 17, 2009 4:43 PM (in response to epbernard)"stan.silvert@jboss.com" wrote:
Because I don't yet have a JSFDeployer, I do this in our JSF ServletContextListener. The only way I can do it is to create the VF myself or get it from JNDI.
Stan
Not true. ;-)
You can use my MC-int/servlet code and get VF from DeploymentUnit or VFF for that matter.
You should definitely not create it yourself, if we want to have a common VF for the whole module.
For MC-int usage see here:
- http://anonsvn.jboss.org/repos/jbossas/projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java
VDFConnector as an entry point.