You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2003/10/18 21:52:15 UTC

cvs commit: jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps CommonPortletServices.java

weaver      2003/10/18 12:52:15

  Modified:    cps/src/java/org/apache/jetspeed/cps
                        CommonPortletServices.java
  Log:
  new method signature for init() that allows invocation to specify whether
  or not Log4j needs to be initialized
  
  Revision  Changes    Path
  1.2       +59 -22    jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/CommonPortletServices.java
  
  Index: CommonPortletServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/CommonPortletServices.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommonPortletServices.java	28 Jul 2003 23:46:42 -0000	1.1
  +++ CommonPortletServices.java	18 Oct 2003 19:52:15 -0000	1.2
  @@ -70,9 +70,7 @@
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
  -public class CommonPortletServices
  -    extends BaseServiceBroker
  -    implements ServiceManager, CPSConstants
  +public class CommonPortletServices extends BaseServiceBroker implements ServiceManager, CPSConstants
   {
       /** The single instance of this class. */
       private static CommonPortletServices instance = new CommonPortletServices();
  @@ -98,30 +96,50 @@
           return instance;
       }
   
  -    public void init(Configuration configuration, String applicationRoot)
  -       throws CPSInitializationException
  +    /**
  +     * 
  +     * <p>
  +     * init
  +     * </p>
  +     * Initializes th CPS with the <code>configuration</code>
  +     * and <code>applicationRoot provided</code>.
  +     * 
  +     * @param configuration Configuration to use to configure all CPS services
  +     * @param applicationRoot The application root of the system
  +     * @param initLog4j <code>true</code> means that CPS will attempt configure
  +     * Log4j, <code>false</code> Log4j will not be configured (used if the implementation
  +     * system already initializes Log4j)
  +     * @throws CPSInitializationException
  +     *
  +     */
  +    public void init(Configuration configuration, String applicationRoot, boolean initLog4j) throws CPSInitializationException
       {
           try
  -        {                
  +        {
               //
               // bootstrap the initable services
               //
               this.setApplicationRoot(applicationRoot);
               this.setConfiguration(configuration);
   
  -            String log4jFile = configuration.getString(LOG4J_CONFIG_FILE,
  -                                                       LOG4J_CONFIG_FILE_DEFAULT);
  -            log4jFile = this.getRealPath(log4jFile);
  -            Properties p = new Properties();
  -            p.load(new FileInputStream(log4jFile));
  -            p.setProperty(APPLICATION_ROOT_KEY, applicationRoot);
  -            PropertyConfigurator.configure(p);
  -            log.info("Configured log4j from " + log4jFile);
  -
  -            // Set up Commons Logging to use the Log4J Logging
  -            System.getProperties().setProperty(LogFactory.class.getName(),
  -                                               Log4jFactory.class.getName());
  +            if (initLog4j)
  +            {
   
  +                String log4jFile = configuration.getString(LOG4J_CONFIG_FILE, LOG4J_CONFIG_FILE_DEFAULT);
  +                log4jFile = this.getRealPath(log4jFile);
  +                Properties p = new Properties();
  +                p.load(new FileInputStream(log4jFile));
  +                p.setProperty(APPLICATION_ROOT_KEY, applicationRoot);
  +                PropertyConfigurator.configure(p);
  +                log.info("Configured log4j from " + log4jFile);
  +
  +                // Set up Commons Logging to use the Log4J Logging
  +                System.getProperties().setProperty(LogFactory.class.getName(), Log4jFactory.class.getName());
  +            }
  +            else
  +            {
  +                log.info("Skipping Log4j configuration");
  +            }
   
               this.init();
           }
  @@ -134,8 +152,26 @@
   
       }
   
  -    public void shutdown()
  -       throws CPSException
  +    /**
  +     * 
  +     * <p>
  +     * init
  +     * </p>
  +     * Initializes th CPS with the <code>configuration</code>
  +     * and <code>applicationRoot provided</code>.  Will configure Log4j
  +     * by default.  This is the same acalling <code>init(Configuration, AppRoot, true)</code>
  +     * 
  +     * @param configuration
  +     * @param applicationRoot
  +     * @throws CPSInitializationException
  +     *
  +     */
  +    public void init(Configuration configuration, String applicationRoot) throws CPSInitializationException
  +    {
  +        init(configuration, applicationRoot, true);
  +    }
  +
  +    public void shutdown() throws CPSException
       {
           getInstance().shutdownServices();
           System.gc();
  @@ -149,10 +185,11 @@
        */
       public static CommonService getPortalService(String name)
       {
  +
           Object service = getInstance().getService(name);
           if (service instanceof CommonService)
           {
  -            return (CommonService)service;
  +            return (CommonService) service;
           }
           return null;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org