morciuch    2005/01/17 15:35:30

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets
                        PsmlManagerAction.java PsmlUpdateAction.java
               src/java/org/apache/jetspeed/services/forward
                        JetspeedForwardService.java
               src/java/org/apache/jetspeed/services/psmlmanager
                        CastorPsmlManagerService.java
               src/java/org/apache/jetspeed/services/psmlmanager/db
                        DatabasePsmlManagerService.java
               src/java/org/apache/jetspeed/services/registry
                        CastorRegistryService.java
                        LateInitCastorRegistryService.java
  Added:       src/java/org/apache/jetspeed/util SynchronizedMapping.java
  Log:
  Applying a patch by Bjorn Vidar Remme to synchronize access to mappings for 
psml manager, registry and forwarding service (see issue 
http://issues.apache.org/jira/browse/JS1-526)
  
  Revision  Changes    Path
  1.8       +3 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlManagerAction.java
  
  Index: PsmlManagerAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlManagerAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PsmlManagerAction.java    23 Feb 2004 02:56:58 -0000      1.7
  +++ PsmlManagerAction.java    17 Jan 2005 23:35:29 -0000      1.8
  @@ -26,6 +26,7 @@
   import org.apache.jetspeed.util.PortletConfigState;
   import org.apache.jetspeed.util.PortletUtils;
   import org.apache.jetspeed.util.PortletSessionState;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.services.security.PortalResource;
   import org.apache.jetspeed.om.security.JetspeedUser;
   import org.apache.jetspeed.services.JetspeedSecurity;
  @@ -1275,7 +1276,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource( new FileReader(map) );
                       is.setSystemId( mapFile );
                       mapping.loadMapping( is );
  
  
  
  1.19      +3 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlUpdateAction.java
  
  Index: PsmlUpdateAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlUpdateAction.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- PsmlUpdateAction.java     31 Mar 2004 04:49:10 -0000      1.18
  +++ PsmlUpdateAction.java     17 Jan 2005 23:35:30 -0000      1.19
  @@ -52,6 +52,7 @@
   import org.apache.jetspeed.services.PsmlManager;
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
   import org.apache.jetspeed.services.logging.JetspeedLogger;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.util.template.JetspeedLink;
   import org.apache.jetspeed.util.template.JetspeedLinkFactory;
   import org.apache.jetspeed.services.resources.JetspeedResources;
  @@ -859,7 +860,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource( new FileReader(map) );
                       is.setSystemId( mapFile );
                       mapping.loadMapping( is );
  
  
  
  1.8       +8 -7      
jakarta-jetspeed/src/java/org/apache/jetspeed/services/forward/JetspeedForwardService.java
  
  Index: JetspeedForwardService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/forward/JetspeedForwardService.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JetspeedForwardService.java       23 Feb 2004 03:51:09 -0000      1.7
  +++ JetspeedForwardService.java       17 Jan 2005 23:35:30 -0000      1.8
  @@ -50,6 +50,7 @@
   // jetspeed
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
   import org.apache.jetspeed.services.logging.JetspeedLogger;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.util.template.JetspeedLink;
   import org.apache.jetspeed.util.template.JetspeedLinkFactory;
   
  @@ -83,7 +84,7 @@
       /**
        * Static initialization of the logger for this class
        */    
  -    private static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(JetspeedForwardService.class.getName());
  +    protected static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(JetspeedForwardService.class.getName());
       
       // configuration keys
       protected final static String CONFIG_MAPPING = "mapping";
  @@ -200,7 +201,7 @@
        *                     static PortletForward parameters and static 
Forwards query parameters     
        * @return DynamicURI the full link to the referenced page     
        */
  -    private DynamicURI forwardInternal(RunData rundata, 
  +    protected DynamicURI forwardInternal(RunData rundata, 
                                      String  forwardName,
                                      Map staticParams,
                                      Map dynamicParams)
  @@ -344,7 +345,7 @@
        *                     static PortletForward parameters and static 
Forwards query parameters     
        * @return DynamicURI The new URI including query parameters
        */
  -    private DynamicURI setQueryParams(DynamicURI duri, 
  +    protected DynamicURI setQueryParams(DynamicURI duri, 
                                         Map baseQueryParams, 
                                         Map staticParams,
                                         Map dynamicParams)
  @@ -400,7 +401,7 @@
       }
   
       
  -    private void dumpMap(String mapName, Map map)
  +    protected void dumpMap(String mapName, Map map)
       {
           System.out.println("----------- MAP: " + mapName);
           Iterator it = map.values().iterator();
  @@ -527,7 +528,7 @@
           {
               try
               {
  -                this.mapper = new Mapping();
  +                this.mapper = new SynchronizedMapping();
                   InputSource is = new InputSource(new FileReader(map));
                   is.setSystemId(this.mapping);
                   this.mapper.loadMapping(is);
  @@ -640,7 +641,7 @@
   
       }
   
  -    private void resyncParamMap(Map map)
  +    protected void resyncParamMap(Map map)
       {
           // Castor doesn't set the keys properly for maps
           // get the base query params        
  
  
  
  1.47      +6 -5      
jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/CastorPsmlManagerService.java
  
  Index: CastorPsmlManagerService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/CastorPsmlManagerService.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- CastorPsmlManagerService.java     28 Aug 2004 19:07:00 -0000      1.46
  +++ CastorPsmlManagerService.java     17 Jan 2005 23:35:30 -0000      1.47
  @@ -21,6 +21,7 @@
   import org.apache.jetspeed.om.profile.QueryLocator;
   import org.apache.jetspeed.util.FileCopy;
   import org.apache.jetspeed.util.DirectoryUtils;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.services.Messenger;
   import org.apache.jetspeed.services.Profiler;
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
  @@ -109,7 +110,7 @@
       /**
        * Static initialization of the logger for this class
        */    
  -    private static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(CastorPsmlManagerService.class.getName());
  +    protected static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(CastorPsmlManagerService.class.getName());
       
       // resource path constants
       protected static final String PATH_GROUP              = "group";
  @@ -162,7 +163,7 @@
       /** The default encoding used to serialize PSML files to disk */
       protected String defaultEncoding = 
JetspeedResources.getString(JetspeedResources.CONTENT_ENCODING_KEY, "utf-8");
       
  -    private boolean enableMessaging = false;
  +    protected boolean enableMessaging = false;
   
       /**
        * This is the early initialization method called by the
  @@ -653,7 +654,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource( new FileReader(map) );
                       is.setSystemId( mapFile );
                       mapping.loadMapping( is );
  @@ -1646,7 +1647,7 @@
           System.out.println("entry is evicting: " + 
entry.getFile().getName());
       }
   
  -    private Message createMessage(Serializable messageObject)
  +    protected Message createMessage(Serializable messageObject)
       {
           ObjectMessage msg = (ObjectMessage) 
Messenger.createMessage(MessagingService.OBJECT_MESSAGE);
           
  
  
  
  1.37      +24 -23    
jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java
  
  Index: DatabasePsmlManagerService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- DatabasePsmlManagerService.java   28 Aug 2004 19:05:36 -0000      1.36
  +++ DatabasePsmlManagerService.java   17 Jan 2005 23:35:30 -0000      1.37
  @@ -60,6 +60,7 @@
   import org.apache.jetspeed.om.security.Group;
   import org.apache.jetspeed.om.security.JetspeedGroupFactory;
   import org.apache.jetspeed.services.security.JetspeedSecurityException;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   
   //Servlet API
   import javax.jms.JMSException;
  @@ -108,40 +109,40 @@
       /**
        * Static initialization of the logger for this class
        */    
  -    private static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(DatabasePsmlManagerService.class.getName());
  +    protected static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(DatabasePsmlManagerService.class.getName());
       
  -    private Map psmlCache = new HashMap();
  +    protected Map psmlCache = new HashMap();
   
       /** The watcher for the document locations */
  -    private CacheRefresher refresher = null;
  +    protected CacheRefresher refresher = null;
   
       /** the base refresh rate for documents */
  -    private long refreshRate;  // default will be 8 hours
  +    protected long refreshRate;  // default will be 8 hours
   
  -    private final static String REFRESH_RATE = "refresh-rate";
  -    private final static long DEFAULT_REFRESH_RATE = 60 * 60 * 8 * 1000; 
//8hrs
  +    protected final static String REFRESH_RATE = "refresh-rate";
  +    protected final static long DEFAULT_REFRESH_RATE = 60 * 60 * 8 * 1000; 
//8hrs
   
       /** whether caching is allowed */
  -    private boolean cachingOn;  // default will be false
  +    protected boolean cachingOn;  // default will be false
   
  -    private final static String CACHING_ON = "caching-on";
  -    private final static boolean DEFAULT_CACHING_ON = false;
  +    protected final static String CACHING_ON = "caching-on";
  +    protected final static boolean DEFAULT_CACHING_ON = false;
   
  -    private final static String POOL_NAME = "database";
  +    protected final static String POOL_NAME = "database";
   
       /** the import/export consumer service **/
  -    private PsmlManagerService consumer = null;
  +    protected PsmlManagerService consumer = null;
   
       // castor mapping
       public static final String DEFAULT_MAPPING = 
"${webappRoot}/WEB-INF/conf/psml-mapping.xml";
       String mapFile = null;
       /** the Castor mapping file name */
  -    private Mapping mapping = null;
  +    protected Mapping mapping = null;
   
       /** The pool name to use for database requests. */
  -    private String poolName = null;
  +    protected String poolName = null;
       
  -    private boolean enableMessaging = false;
  +    protected boolean enableMessaging = false;
   
       /**
        * This is the early initialization method called by the
  @@ -168,7 +169,7 @@
        * @exception throws a <code>InitializationException</code> if the 
service
        * fails to initialize
        */
  -    private void initConfiguration(ServletConfig conf)
  +    protected void initConfiguration(ServletConfig conf)
                               throws InitializationException
       {
   
  @@ -274,7 +275,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource( new FileReader(map) );
                       is.setSystemId( mapFile );
                       mapping.loadMapping( is );
  @@ -384,7 +385,7 @@
       /**
        * Return a unique string identifying this object.
        */
  -    private String locatorToString(ProfileLocator locator)
  +    protected String locatorToString(ProfileLocator locator)
       {
           StringBuffer keybuf = new StringBuffer();
   
  @@ -435,7 +436,7 @@
           return keybuf.toString();
       }
   
  -    private ProfileLocator stringToLocator(String locstr) throws Exception
  +    protected ProfileLocator stringToLocator(String locstr) throws Exception
       {
           ProfileLocator locator = Profiler.createLocator();
           String entity = null;
  @@ -596,7 +597,7 @@
           return createOrSaveDocument(profile, UPDATE) != null;
       }
   
  -    private PSMLDocument createOrSaveDocument(Profile profile, int operation)
  +    protected PSMLDocument createOrSaveDocument(Profile profile, int 
operation)
       {
           // create record in the database for Portlets for the given
           // profile/PSMLDocuemnt,use marsheller to create Portlets
  @@ -854,7 +855,7 @@
        * JetspeedRoleProfile, objects
        * @return List of profiles
        */
  -    private List getProfiles(List data)
  +    protected List getProfiles(List data)
       {
           List list = new ArrayList();
   
  @@ -891,7 +892,7 @@
        * @param page page name for this resource
        * @return PSMLDocument object for given page and portlets
        */
  -    private PSMLDocument getPSMLDocument(String page, Portlets portlets)
  +    protected PSMLDocument getPSMLDocument(String page, Portlets portlets)
       {
           PSMLDocument psmldoc = new BasePSMLDocument();
           psmldoc.setName(page);
  @@ -1330,7 +1331,7 @@
       /**
       * Get a database connection to the default or specifed torque database 
pool
       */
  -    private Connection getDbConnection()
  +    protected Connection getDbConnection()
       {
           try
           {
  
  
  
  1.45      +13 -14    
jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
  
  Index: CastorRegistryService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- CastorRegistryService.java        5 Aug 2004 04:27:03 -0000       1.44
  +++ CastorRegistryService.java        17 Jan 2005 23:35:30 -0000      1.45
  @@ -21,6 +21,7 @@
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
   import org.apache.jetspeed.services.logging.JetspeedLogger;
   import org.apache.jetspeed.services.messaging.MessagingService;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.om.registry.Registry;
   import org.apache.jetspeed.om.registry.RegistryEntry;
   import org.apache.jetspeed.om.registry.RegistryException;
  @@ -101,38 +102,38 @@
       /**
        * Static initialization of the logger for this class
        */    
  -    private static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(CastorRegistryService.class.getName());
  +    protected static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(CastorRegistryService.class.getName());
       
       public static final int DEFAULT_REFRESH = 300;
       public static final String DEFAULT_EXTENSION = ".xreg";
       public static final String DEFAULT_MAPPING = 
"${webapp}/WEB-INF/conf/mapping.xml";
   
       /** regsitry type keyed list of entries */
  -    private Hashtable registries = new Hashtable();
  +    protected Hashtable registries = new Hashtable();
   
       /** The Castor generated RegsitryFragment objects */
  -    private Hashtable fragments = new Hashtable();
  +    protected Hashtable fragments = new Hashtable();
   
       /** The list of default fragments stores for newly created objects */
  -    private Hashtable defaults = new Hashtable();
  +    protected Hashtable defaults = new Hashtable();
   
       /** Associates entries with their fragments name for quick lookup */
  -    private Hashtable entryIndex = new Hashtable();
  +    protected Hashtable entryIndex = new Hashtable();
   
       /** the Watcher object which monitors the regsitry directory */
  -    private RegistryWatcher watcher = null;
  +    protected RegistryWatcher watcher = null;
   
       /** the Castor mapping file name */
  -    private Mapping mapping = null;
  +    protected Mapping mapping = null;
   
       /** the output format for pretty printing when saving registries */
  -    private OutputFormat format = null;
  +    protected OutputFormat format = null;
   
       /** the base regsitry directory */
  -    private String directory = null;
  +    protected String directory = null;
   
       /** the extension for registry files */
  -    private String extension = null;
  +    protected String extension = null;
       
       /** enable messaging */
       protected boolean enableMessaging = false;
  @@ -416,7 +417,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource(new FileReader(map));
                       is.setSystemId(mapFile);
                       mapping.loadMapping(is);
  @@ -435,7 +436,6 @@
   
           // Set directory watcher if directory exists
           File base = new File(directory);
  -        File[] files = null;
   
           if (base.exists() && base.isDirectory() && base.canRead())
           {
  @@ -816,7 +816,6 @@
           }
   
           int count = 0;
  -        int counDeleted = 0;
           LocalRegistry registry = (LocalRegistry) get(regName);
   
           Vector toDelete = new Vector();
  
  
  
  1.4       +3 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/LateInitCastorRegistryService.java
  
  Index: LateInitCastorRegistryService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/LateInitCastorRegistryService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateInitCastorRegistryService.java        17 Aug 2004 04:54:49 -0000      
1.3
  +++ LateInitCastorRegistryService.java        17 Jan 2005 23:35:30 -0000      
1.4
  @@ -21,6 +21,7 @@
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
   import org.apache.jetspeed.services.logging.JetspeedLogger;
   import org.apache.jetspeed.services.messaging.MessagingService;
  +import org.apache.jetspeed.util.SynchronizedMapping;
   import org.apache.jetspeed.om.registry.Registry;
   import org.apache.jetspeed.om.registry.RegistryEntry;
   import org.apache.jetspeed.om.registry.RegistryException;
  @@ -407,7 +408,7 @@
               {
                   try
                   {
  -                    mapping = new Mapping();
  +                    mapping = new SynchronizedMapping();
                       InputSource is = new InputSource(new FileReader(map));
                       is.setSystemId(mapFile);
                       mapping.loadMapping(is);
  
  
  
  1.1                  
jakarta-jetspeed/src/java/org/apache/jetspeed/util/SynchronizedMapping.java
  
  Index: SynchronizedMapping.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.util;
  
  import java.io.IOException;
  import java.net.URL;
  
  import org.exolab.castor.mapping.Mapping;
  import org.exolab.castor.mapping.MappingException;
  import org.xml.sax.InputSource;
  
  /**
   * Thread safe wrapper for the castor Mapping class.<br>
   * This wrapper serializes all thread access to the loadMapping() methods.
   * 
   */
   public class SynchronizedMapping extends Mapping {
  
        private static final Object global_synch = new Object();
  
  
        /**
         *  
         */
        public SynchronizedMapping() 
        {
                super();
        }
  
        /**
         * @param arg0
         */
        public SynchronizedMapping(ClassLoader arg0) 
        {
                super(arg0);
        }
  
  
        public void loadMapping(InputSource input) throws MappingException, 
IOException 
        {
                synchronized (global_synch) 
                {
                        super.loadMapping(input);
                }
        }
  
        public void loadMapping(String input) throws MappingException, 
IOException 
        {
                synchronized (global_synch) 
                {
                        super.loadMapping(input);
                }
        }
  
        public void loadMapping(URL input) throws MappingException, IOException 
        {
                synchronized (global_synch) 
                {
                        super.loadMapping(input);
                }
        }
  
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to