Class AbstractSpringPentahoObjectFactory

  • All Implemented Interfaces:
    org.pentaho.platform.api.engine.IPentahoObjectFactory
    Direct Known Subclasses:
    StandaloneSpringPentahoObjectFactory

    public abstract class AbstractSpringPentahoObjectFactory
    extends Object
    implements org.pentaho.platform.api.engine.IPentahoObjectFactory
    Framework for Spring-based object factories. Subclasses are required only to implement the init method, which is responsible for setting the ApplicationContext.

    A note on creation and management of objects: Object creation and scoping is handled by Spring with one exception: in the case of a StandaloneSession. Spring's session scope relates a bean to an javax.servlet.http.HttpSession, and as such it does not know about custom sessions. The correct approach to solve this problem is to write a custom Spring scope (called something like "pentahosession"). Unfortunately, we cannot implement a custom scope to handle the StandaloneSession because the custom scope would not be able to access it. There is currently no way to statically obtain a reference to a pentaho session. So we are left with using custom logic in this factory to execute a different non-Spring logic path when the IPentahoSession is of type StandaloneSession.

    Author:
    Aaron Phillips
    See Also:
    IPentahoObjectFactory
    • Field Detail

      • beanFactory

        protected org.springframework.context.ConfigurableApplicationContext beanFactory
      • logger

        protected static final org.apache.commons.logging.Log logger
    • Constructor Detail

      • AbstractSpringPentahoObjectFactory

        protected AbstractSpringPentahoObjectFactory()
      • AbstractSpringPentahoObjectFactory

        protected AbstractSpringPentahoObjectFactory​(String name)
    • Method Detail

      • get

        public <T> T get​(Class<T> interfaceClass,
                         org.pentaho.platform.api.engine.IPentahoSession session)
                  throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        get in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
        See Also:
        IPentahoObjectFactory.get(Class, IPentahoSession)
      • get

        public <T> T get​(Class<T> interfaceClass,
                         String key,
                         org.pentaho.platform.api.engine.IPentahoSession session)
                  throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        get in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
        See Also:
        IPentahoObjectFactory.get(Class, String, IPentahoSession)
      • get

        public <T> T get​(Class<T> interfaceClass,
                         org.pentaho.platform.api.engine.IPentahoSession session,
                         Map<String,​String> props)
                  throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        get in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getAll

        public <T> List<T> getAll​(Class<T> interfaceClass,
                                  org.pentaho.platform.api.engine.IPentahoSession curSession,
                                  Map<String,​String> properties)
                           throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getAll in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getAll

        public <T> List<T> getAll​(Class<T> interfaceClass,
                                  org.pentaho.platform.api.engine.IPentahoSession curSession)
                           throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getAll in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • instanceClass

        protected Object instanceClass​(String simpleName)
                                throws org.pentaho.platform.api.engine.ObjectFactoryException
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • instanceClass

        protected Object instanceClass​(String simpleName,
                                       String key)
                                throws org.pentaho.platform.api.engine.ObjectFactoryException
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • instanceClass

        protected Object instanceClass​(Class<?> interfaceClass,
                                       String key)
                                throws org.pentaho.platform.api.engine.ObjectFactoryException
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • retrieveViaSpring

        protected Object retrieveViaSpring​(String beanId)
                                    throws org.pentaho.platform.api.engine.ObjectFactoryException
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • retreiveObjects

        protected <T> List<T> retreiveObjects​(Class<T> type,
                                              org.pentaho.platform.api.engine.IPentahoSession session,
                                              Map<String,​String> properties)
                                       throws org.pentaho.platform.api.engine.ObjectFactoryException
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • objectDefined

        public boolean objectDefined​(String key)
        Specified by:
        objectDefined in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        See Also:
        IPentahoObjectFactory.objectDefined(String)
      • objectDefined

        public boolean objectDefined​(Class<?> clazz)
        Specified by:
        objectDefined in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Parameters:
        clazz - Interface or class literal to search for
        Returns:
        true if a definition exists
      • getImplementingClass

        public Class getImplementingClass​(String key)
        Specified by:
        getImplementingClass in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        See Also:
        IPentahoObjectFactory.getImplementingClass(String)
      • setBeanFactory

        protected void setBeanFactory​(org.springframework.context.ConfigurableApplicationContext context)
      • getObjectReference

        public <T> org.pentaho.platform.api.engine.IPentahoObjectReference<T> getObjectReference​(Class<T> clazz,
                                                                                                 org.pentaho.platform.api.engine.IPentahoSession curSession)
                                                                                          throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getObjectReference in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getObjectReference

        public <T> org.pentaho.platform.api.engine.IPentahoObjectReference<T> getObjectReference​(Class<T> clazz,
                                                                                                 org.pentaho.platform.api.engine.IPentahoSession curSession,
                                                                                                 Map<String,​String> properties)
                                                                                          throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getObjectReference in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getObjectReferences

        public <T> List<org.pentaho.platform.api.engine.IPentahoObjectReference<T>> getObjectReferences​(Class<T> interfaceClass,
                                                                                                        org.pentaho.platform.api.engine.IPentahoSession curSession)
                                                                                                 throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getObjectReferences in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getObjectReferences

        public <T> List<org.pentaho.platform.api.engine.IPentahoObjectReference<T>> getObjectReferences​(Class<T> interfaceClass,
                                                                                                        org.pentaho.platform.api.engine.IPentahoSession curSession,
                                                                                                        Map<String,​String> properties)
                                                                                                 throws org.pentaho.platform.api.engine.ObjectFactoryException
        Specified by:
        getObjectReferences in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
        Throws:
        org.pentaho.platform.api.engine.ObjectFactoryException
      • getName

        public String getName()
        Specified by:
        getName in interface org.pentaho.platform.api.engine.IPentahoObjectFactory
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object