Roy Golan has posted comments on this change.

Change subject: core: Introduce CDI for Commands dependencies
......................................................................


Patch Set 8:

(4 comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
Line 15: import org.ovirt.engine.core.utils.log.Log;
Line 16: import org.ovirt.engine.core.utils.log.LogFactory;
Line 17: 
Line 18: public final class CommandsFactory {
Line 19:     private static Injector injector = new Injector();
indeed
Line 20:     private static final String CLASS_NAME_FORMAT = "%1$s.%2$s%3$s";
Line 21:     private static final String CommandSuffix = "Command";
Line 22:     private static final String QueryPrefix = "Query";
Line 23:     private static final String CTOR_MISMATCH =


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Injector.java
Line 4: import javax.enterprise.inject.spi.BeanManager;
Line 5: import javax.naming.InitialContext;
Line 6: import javax.naming.NamingException;
Line 7: 
Line 8: public class Injector {
the injector is intended for injecting command deps until  Backend.java will be 
itself a managed-bean and stop being an EJB

so future use:

class  Backend {

// this will implicitly inject commands deps without the injector

runAction(@Inject Command)  

}

then we would throw it (the Injector)
Line 9: 
Line 10:     private BeanManager manager;
Line 11: 
Line 12:     public Injector() {


Line 10:     private BeanManager manager;
Line 11: 
Line 12:     public Injector() {
Line 13:         try {
Line 14:             this.manager = (BeanManager) new 
InitialContext().lookup("java:comp/BeanManager");
once all our EJBs will be made into CDI beans JNDI lookups would be obsolete.

and meanwhile Liran I know I asked you about this and you answered but I really 
think this is a pre-optimisation so I'm still not convinced caching this is 
better. 

After all I see only one instance I need for this Injector.
Line 15:         } catch (NamingException e) {
Line 16:             // if the bean manager couldn't be fetched then we 
couldn't inject dependencies to non-bean objects
Line 17:             throw new RuntimeException("Couldn't locate a BeanManager 
instance due to " + e.getMessage()
Line 18:                     + " Actions will fail to perform due to runtime 
missing dependencies");


Line 14:             this.manager = (BeanManager) new 
InitialContext().lookup("java:comp/BeanManager");
Line 15:         } catch (NamingException e) {
Line 16:             // if the bean manager couldn't be fetched then we 
couldn't inject dependencies to non-bean objects
Line 17:             throw new RuntimeException("Couldn't locate a BeanManager 
instance due to " + e.getMessage()
Line 18:                     + " Actions will fail to perform due to runtime 
missing dependencies");
agree
Line 19:         }
Line 20:     }
Line 21: 
Line 22:     public <T extends  Object> void inject(T instance) {


-- 
To view, visit http://gerrit.ovirt.org/5575
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I7f604ff91847b698efe84a09f724ba0492a672c1
Gerrit-PatchSet: 8
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Asaf Shakarchi <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Laszlo Hornyak <[email protected]>
Gerrit-Reviewer: Liran Zelkha <[email protected]>
Gerrit-Reviewer: Liron Ar <[email protected]>
Gerrit-Reviewer: Maor Lipchuk <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
Gerrit-Reviewer: Sergey Gotliv <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: mooli tayer <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to