Package org.apache.jetspeed.om.registry.base

Examples of org.apache.jetspeed.om.registry.base.LocalRegistry


        if (entry == null)
        {
            return;
        }

    LocalRegistry registry = (LocalRegistry) registries.get(regName);

        if (registry != null)
        {
            String fragmentName = (String) entryIndex.get(entry.getName());

            if (fragmentName == null)
            {
                // either the entry was deleted or it does not exist
                // in both cases, use the default fragment
                fragmentName = (String) defaults.get(regName);
            }

            RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);

            //Fragment can be (and sometimes is, but should not be) null
            if (fragment == null)
            {
                fragment = new RegistryFragment();
                fragment.put(regName, new Vector());
                fragments.put(fragmentName, fragment);
            }
            else
            {
                Vector vectRegistry = (Vector) fragment.get(regName);
                if (vectRegistry == null)
                {
                    fragment.put(regName, new Vector());
                }
            }

            synchronized (entryIndex)
            {
                if (registry.hasEntry(entry.getName()))
                {
                    fragment.setEntry(regName, entry);
                    registry.setLocalEntry(entry);
                }
                else
                {
                    fragment.addEntry(regName, entry);
                    registry.addLocalEntry(entry);
                }

                entryIndex.put(entry.getName(), fragmentName);
                // mark this fragment so that it's persisted next time
                // the registry watcher is running
View Full Code Here


        if (entryName == null)
        {
            return;
        }

    LocalRegistry registry = (LocalRegistry) registries.get(regName);

        if (registry != null)
        {
            String fragmentName = (String) entryIndex.get(entryName);

            if (fragmentName != null)
            {
                RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);

                synchronized (entryIndex)
                {
                    fragment.removeEntry(regName, entryName);
                    entryIndex.remove(entryName);

                    // mark this fragment so that it's persisted next time
                    // the registry watcher is running
                    fragment.setDirty(true);
                }
            }

            // the entry is physically removed, remove the dangling reference
            registry.removeLocalEntry(entryName);

            if(enableMessaging)
            {
                Message msg = createMessage(regName, entryName);
                Messenger.sendMessage(msg, MessagingService.REGISTRY_UPDATE_SUBJECT);
View Full Code Here

        {
            logger.debug("RegistryService: Updating the " + regName + " registry");
        }

        int count = 0;
        LocalRegistry registry = (LocalRegistry) get(regName);

        Vector toDelete = new Vector();
        Iterator i = registry.listEntryNames();

        while (i.hasNext())
        {
            toDelete.add(i.next());
        }

        if (registry == null)
        {
            logger.error("RegistryService: Null " + name + " registry in refresh");
            return;
        }

        // for each fragment...
        Enumeration en = fragments.keys();
        while (en.hasMoreElements())
        {
            String location = (String) en.nextElement();
            RegistryFragment fragment = (RegistryFragment) fragments.get(location);
            int fragCount = 0;

            if (!fragment.hasChanged())
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("RegistryService: Skipping fragment " + location);
                }

                //remove this fragment entries from the delete list
                Vector entries = fragment.getEntries(regName);
                i = entries.iterator();
                while (i.hasNext())
                {
                    toDelete.remove(((RegistryEntry) i.next()).getName());
                }

                continue;
            }

            //the fragment has some changes, iterate over its entries...

            Vector entries = fragment.getEntries(regName);

            //... if it has entries related to this regsistry,
            if (entries != null)
            {
                // for all these entries
                Enumeration en2 = entries.elements();
                while (en2.hasMoreElements())
                {
                    RegistryEntry entry = (RegistryEntry) en2.nextElement();
                    // update or add the entry in the registry
                    try
                    {
                        if (registry.hasEntry(entry.getName()))
                        {
                            if (registry.getEntry(entry.getName()).equals(entry))
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("RegistryService: No changes to entry " + entry.getName());
                                }
                            }
                            else
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("RegistryService: Updating entry " + entry.getName()
                                        + " of class " + entry.getClass() + " to registry " + name);
                                }

                                registry.setLocalEntry(entry);
                                // Initialize the entry index
                                this.entryIndex.put(entry.getName(), location);
                                ++fragCount;
                            }
                        }
                        else
                        {
                            registry.addLocalEntry(entry);
                            // Initialize the entry index
                            this.entryIndex.put(entry.getName(), location);
                            ++fragCount;

                            if (logger.isDebugEnabled())
                            {
                                logger.debug("RegistryService: Adding entry " + entry.getName() + " of class "
                                    + entry.getClass() + " to registry " + name);
                            }
                        }
                    }
                    catch (RegistryException e)
                    {
                        logger.error("RegistryService: RegistryException while adding " + entry.getName() + "from " + location, e);
                    }

                    //remove this entry from the delete list
                    toDelete.remove(entry.getName());
                }
            }

            count += fragCount;
        }

        //now delete the entries not found in any fragment
        i = toDelete.iterator();
        while (i.hasNext())
        {
            String entryName = (String) i.next();

            if (logger.isDebugEnabled())
            {
                logger.debug("RegistryService: removing entry " + entryName);
            }

            registry.removeLocalEntry(entryName);
        }


        if (logger.isDebugEnabled())
        {
View Full Code Here

        if (entry == null)
        {
            return;
        }

    LocalRegistry registry = (LocalRegistry) registries.get(regName);

        if (registry != null)
        {
            String fragmentName = (String) entryIndex.get(entry.getName());

            if (fragmentName == null)
            {
                // either the entry was deleted or it does not exist
                // in both cases, use the default fragment
                fragmentName = (String) defaults.get(regName);
            }

            RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);

            //Fragment can be (and sometimes is, but should not be) null
            if (fragment == null)
            {
                fragment = new RegistryFragment();
                fragment.put(regName, new Vector());
                fragments.put(fragmentName, fragment);
            }
            else
            {
                Vector vectRegistry = (Vector) fragment.get(regName);
                if (vectRegistry == null)
                {
                    fragment.put(regName, new Vector());
                }
            }

            synchronized (entryIndex)
            {
                if (registry.hasEntry(entry.getName()))
                {
                    fragment.setEntry(regName, entry);
                    registry.setLocalEntry(entry);
                }
                else
                {
                    fragment.addEntry(regName, entry);
                    registry.addLocalEntry(entry);
                }

                entryIndex.put(entry.getName(), fragmentName);
                // mark this fragment so that it's persisted next time
                // the registry watcher is running
View Full Code Here

        if (entryName == null)
        {
            return;
        }

    LocalRegistry registry = (LocalRegistry) registries.get(regName);

        if (registry != null)
        {
            String fragmentName = (String) entryIndex.get(entryName);

            if (fragmentName != null)
            {
                RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);

                synchronized (entryIndex)
                {
                    fragment.removeEntry(regName, entryName);
                    entryIndex.remove(entryName);

                    // mark this fragment so that it's persisted next time
                    // the registry watcher is running
                    fragment.setDirty(true);
                }
            }

            // the entry is physically removed, remove the dangling reference
            registry.removeLocalEntry(entryName);

            if(enableMessaging)
            {
                Message msg = createMessage(regName, entryName);
                Messenger.sendMessage(msg, MessagingService.REGISTRY_UPDATE_SUBJECT);
View Full Code Here

            logger.debug("RegistryService: Updating the " + regName + " registry");
        }

        int count = 0;
        int counDeleted = 0;
        LocalRegistry registry = (LocalRegistry) get(regName);

        Vector toDelete = new Vector();
        Iterator i = registry.listEntryNames();

        while (i.hasNext())
        {
            toDelete.add(i.next());
        }

        if (registry == null)
        {
            logger.error("RegistryService: Null " + name + " registry in refresh");
            return;
        }

        // for each fragment...
        Enumeration en = fragments.keys();
        while (en.hasMoreElements())
        {
            String location = (String) en.nextElement();
            RegistryFragment fragment = (RegistryFragment) fragments.get(location);
            int fragCount = 0;

            if (!fragment.hasChanged())
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("RegistryService: Skipping fragment " + location);
                }

                //remove this fragment entries from the delete list
                Vector entries = fragment.getEntries(regName);
                i = entries.iterator();
                while (i.hasNext())
                {
                    toDelete.remove(((RegistryEntry) i.next()).getName());
                }

                continue;
            }

            //the fragment has some changes, iterate over its entries...

            Vector entries = fragment.getEntries(regName);

            //... if it has entries related to this regsistry,
            if (entries != null)
            {
                // for all these entries
                Enumeration en2 = entries.elements();
                while (en2.hasMoreElements())
                {
                    RegistryEntry entry = (RegistryEntry) en2.nextElement();
                    // update or add the entry in the registry
                    try
                    {
                        if (registry.hasEntry(entry.getName()))
                        {
                            if (registry.getEntry(entry.getName()).equals(entry))
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("RegistryService: No changes to entry " + entry.getName());
                                }
                            }
                            else
                            {
                                if (logger.isDebugEnabled())
                                {
                                    logger.debug("RegistryService: Updating entry " + entry.getName()
                                        + " of class " + entry.getClass() + " to registry " + name);
                                }

                                registry.setLocalEntry(entry);
                                // Initialize the entry index
                                this.entryIndex.put(entry.getName(), location);
                                ++fragCount;
                            }
                        }
                        else
                        {
                            registry.addLocalEntry(entry);
                            // Initialize the entry index
                            this.entryIndex.put(entry.getName(), location);
                            ++fragCount;

                            if (logger.isDebugEnabled())
                            {
                                logger.debug("RegistryService: Adding entry " + entry.getName() + " of class "
                                    + entry.getClass() + " to registry " + name);
                            }
                        }
                    }
                    catch (RegistryException e)
                    {
                        logger.error("RegistryService: RegistryException while adding " + entry.getName() + "from " + location, e);
                    }

                    //remove this entry from the delete list
                    toDelete.remove(entry.getName());
                }
            }

            count += fragCount;
        }

        //now delete the entries not found in any fragment
        i = toDelete.iterator();
        while (i.hasNext())
        {
            String entryName = (String) i.next();

            if (logger.isDebugEnabled())
            {
                logger.debug("RegistryService: removing entry " + entryName);
            }

            registry.removeLocalEntry(entryName);
        }


        if (logger.isDebugEnabled())
        {
View Full Code Here

    }
   
    private void loadCache(String registryName, Registry registry)
    throws InitializationException
    {
        LocalRegistry local = (LocalRegistry)registry;
        try
        {
            if (registryName.equals(org.apache.jetspeed.services.Registry.SECURITY))
            {               
                Iterator extent = SecurityDbEntryPeer.fetchExtent().iterator();               
                while (extent.hasNext())
                {
                    SecurityEntry se = (SecurityEntry)extent.next();
                    local.addLocalEntry((RegistryEntry)se);                   
                }
            }
            else if (registryName.equals(org.apache.jetspeed.services.Registry.PORTLET))
            {
                System.out.println("Portlet: Loading cache for " + registryName);
               
                Iterator extent = PortletDbEntryPeer.fetchExtent().iterator();               
                while (extent.hasNext())
                {
                    PortletEntry pe = (PortletEntry)extent.next();
                    System.out.println("Portlet: Loading cache for " + pe.getName());
                    if (!local.hasEntry(pe.getName()))
                    {
                        local.addLocalEntry((RegistryEntry)pe);
                    }
                }
                System.out.println("Portlet: done Loading cache for " + registryName);
               
            }
View Full Code Here

            {                                        
                entry = (RegistryEntry)PortletDbEntryPeer.lookupPortletEntry(entryName);
            }
            if (entry != null)
            {
                LocalRegistry local = (LocalRegistry)registry;
                try
                {
                    local.addLocalEntry(entry);
                }
                catch (RegistryException e)
                {
                    if (logger.isInfoEnabled())
                    {
View Full Code Here

    }
   
    public void addEntry(String registryName, RegistryEntry entry)
    throws RegistryException
    {
        LocalRegistry registry = (LocalRegistry)dbRegistries.get(registryName);
        if (null == registry)
        {
            if (hybrid)
            {           
                super.addEntry(registryName, entry);
View Full Code Here

   
    public void removeEntry(String registryName, String entryName)
    {
        try
        {
            LocalRegistry registry = (LocalRegistry)dbRegistries.get(registryName);
            if (null == registry)
            {
                if (hybrid)
                {
                    super.removeEntry(registryName, entryName);
                }
                return;           
            }                   
            if (entryName == null)
            {
                return;
            }
            if (registryName.equals(org.apache.jetspeed.services.Registry.SECURITY))
            {                                        
                    SecurityDbEntryPeer.removeSecurityEntry(entryName);       
                    registry.removeLocalEntry(entryName);
            }
            else if (registryName.equals(org.apache.jetspeed.services.Registry.PORTLET))
            {
                PortletDbEntryPeer.removePortletEntry(entryName);       
                registry.removeLocalEntry(entryName);               
            }
           
            Message msg = createMessage(registryName, entryName);
            Messenger.sendMessage(msg, MessagingService.REGISTRY_UPDATE_SUBJECT);
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.registry.base.LocalRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.