geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject Re: svn commit: r226753 - in /geronimo/branches/v1_0_M4-QA/modules: deployment/src/java/org/apache/geronimo/deployment/ kernel/src/java/org/apache/geronimo/gbean/ kernel/src/java/org/apache/geronimo/kernel/basic/ kernel/src/test/org/apache/geronimo/gbean/
Date Mon, 01 Aug 2005 16:37:19 GMT
I believe it is only a back out.

-dain

On Aug 1, 2005, at 7:01 AM, Geir Magnusson Jr. wrote:

> is this a backout only, or is there new code here?
>
> On Aug 1, 2005, at 2:21 AM, dain@apache.org wrote:
>
>
>> Author: dain
>> Date: Sun Jul 31 23:21:08 2005
>> New Revision: 226753
>>
>> URL: http://svn.apache.org/viewcvs?rev=226753&view=rev
>> Log:
>> Remove GBeanName code
>>
>> Removed:
>>     geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/gbean/GBeanName.java
>>     geronimo/branches/v1_0_M4-QA/modules/kernel/src/test/org/ 
>> apache/geronimo/gbean/GBeanNameTest.java
>> Modified:
>>     geronimo/branches/v1_0_M4-QA/modules/deployment/src/java/org/ 
>> apache/geronimo/deployment/GBeanDataRegistry.java
>>     geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicKernel.java
>>     geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicRegistry.java
>>
>> Modified: geronimo/branches/v1_0_M4-QA/modules/deployment/src/java/ 
>> org/apache/geronimo/deployment/GBeanDataRegistry.java
>> URL: http://svn.apache.org/viewcvs/geronimo/branches/v1_0_M4-QA/ 
>> modules/deployment/src/java/org/apache/geronimo/deployment/ 
>> GBeanDataRegistry.java?rev=226753&r1=226752&r2=226753&view=diff
>> ===================================================================== 
>> =========
>> --- geronimo/branches/v1_0_M4-QA/modules/deployment/src/java/org/ 
>> apache/geronimo/deployment/GBeanDataRegistry.java (original)
>> +++ geronimo/branches/v1_0_M4-QA/modules/deployment/src/java/org/ 
>> apache/geronimo/deployment/GBeanDataRegistry.java Sun Jul 31  
>> 23:21:08 2005
>> @@ -25,7 +25,6 @@
>>  import javax.management.ObjectName;
>>
>>  import org.apache.geronimo.gbean.GBeanData;
>> -import org.apache.geronimo.gbean.GBeanName;
>>  import org.apache.geronimo.kernel.GBeanNotFoundException;
>>
>>  /**
>>
>> Modified: geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicKernel.java
>> URL: http://svn.apache.org/viewcvs/geronimo/branches/v1_0_M4-QA/ 
>> modules/kernel/src/java/org/apache/geronimo/kernel/basic/ 
>> BasicKernel.java?rev=226753&r1=226752&r2=226753&view=diff
>> ===================================================================== 
>> =========
>> --- geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicKernel.java (original)
>> +++ geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicKernel.java Sun Jul 31 23:21:08  
>> 2005
>> @@ -21,7 +21,6 @@
>>  import java.util.HashSet;
>>  import java.util.Iterator;
>>  import java.util.LinkedList;
>> -import java.util.Map;
>>  import java.util.Set;
>>  import javax.management.ObjectName;
>>
>> @@ -29,7 +28,6 @@
>>  import org.apache.commons.logging.LogFactory;
>>  import org.apache.geronimo.gbean.GBeanData;
>>  import org.apache.geronimo.gbean.GBeanInfo;
>> -import org.apache.geronimo.gbean.GBeanName;
>>  import org.apache.geronimo.gbean.runtime.GBeanInstance;
>>  import org.apache.geronimo.kernel.DependencyManager;
>>  import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
>> @@ -128,7 +126,7 @@
>>              throw new IllegalArgumentException("Kernel name may  
>> not contain a ':', '*' or '?' character");
>>          }
>>          this.kernelName = kernelName;
>> -        this.registry = new BasicRegistry();
>> +        this.registry = new BasicRegistry(kernelName);
>>      }
>>
>>      public String getKernelName() {
>> @@ -158,97 +156,88 @@
>>          return proxyManager;
>>      }
>>
>> -    public Object getAttribute(ObjectName objectName, String  
>> attributeName) throws GBeanNotFoundException,  
>> NoSuchAttributeException, Exception {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(objectName));
>> +    public Object getAttribute(ObjectName name, String  
>> attributeName) throws GBeanNotFoundException,  
>> NoSuchAttributeException, Exception {
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getAttribute(attributeName);
>>      }
>>
>> -    public void setAttribute(ObjectName objectName, String  
>> attributeName, Object attributeValue) throws  
>> GBeanNotFoundException, NoSuchAttributeException, Exception {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(objectName));
>> +    public void setAttribute(ObjectName name, String  
>> attributeName, Object attributeValue) throws  
>> GBeanNotFoundException, NoSuchAttributeException, Exception {
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.setAttribute(attributeName, attributeValue);
>>      }
>>
>> -    public Object invoke(ObjectName objectName, String  
>> methodName) throws GBeanNotFoundException,  
>> NoSuchOperationException, InternalKernelException, Exception {
>> -        return invoke(objectName, methodName, NO_ARGS, NO_TYPES);
>> +    public Object invoke(ObjectName name, String methodName)  
>> throws GBeanNotFoundException, NoSuchOperationException,  
>> InternalKernelException, Exception {
>> +        return invoke(name, methodName, NO_ARGS, NO_TYPES);
>>      }
>>
>> -    public Object invoke(ObjectName objectName, String  
>> methodName, Object[] args, String[] types) throws  
>> GBeanNotFoundException, NoSuchOperationException,  
>> InternalKernelException, Exception {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(objectName));
>> +    public Object invoke(ObjectName name, String methodName,  
>> Object[] args, String[] types) throws GBeanNotFoundException,  
>> NoSuchOperationException, InternalKernelException, Exception {
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.invoke(methodName, args, types);
>>      }
>>
>>      public boolean isLoaded(ObjectName name) {
>> -        return registry.isRegistered(createGBeanName(name));
>> +        return registry.isRegistered(name);
>>      }
>>
>>      public GBeanInfo getGBeanInfo(ObjectName name) throws  
>> GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getGBeanInfo();
>>      }
>>
>>      public GBeanData getGBeanData(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getGBeanData();
>>      }
>>
>>      public void loadGBean(GBeanData gbeanData, ClassLoader  
>> classLoader) throws GBeanAlreadyExistsException,  
>> InternalKernelException {
>> -        ObjectName objectName = gbeanData.getName();
>> -        GBeanInstance gbeanInstance = new GBeanInstance 
>> (gbeanData, this, dependencyManager,  
>> lifecycleMonitor.createLifecycleBroadcaster(objectName),  
>> classLoader);
>> +        ObjectName name = gbeanData.getName();
>> +        GBeanInstance gbeanInstance = new GBeanInstance 
>> (gbeanData, this, dependencyManager,  
>> lifecycleMonitor.createLifecycleBroadcaster(name), classLoader);
>>          registry.register(gbeanInstance);
>>      }
>>
>>      public void startGBean(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException,  
>> IllegalStateException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.start();
>>      }
>>
>>      public void startRecursiveGBean(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException,  
>> IllegalStateException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.startRecursive();
>>      }
>>
>>      public void stopGBean(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException,  
>> IllegalStateException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.stop();
>>      }
>>
>>      public void unloadGBean(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException,  
>> IllegalStateException {
>> -        GBeanName gbeanName = createGBeanName(name);
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (gbeanName);
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.die();
>> -        registry.unregister(gbeanName);
>> +        registry.unregister(name);
>>      }
>>
>>      public int getGBeanState(ObjectName name) throws  
>> GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getState();
>>      }
>>
>>      public long getGBeanStartTime(ObjectName name) throws  
>> GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getStartTime();
>>      }
>>
>>      public boolean isGBeanEnabled(ObjectName name) throws  
>> GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.isEnabled();
>>      }
>>
>>      public void setGBeanEnabled(ObjectName name, boolean enabled)  
>> throws GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          gbeanInstance.setEnabled(enabled);
>>      }
>>
>>      public Set listGBeans(ObjectName pattern) {
>> -        String domain = (pattern == null ||  
>> pattern.isDomainPattern()) ? null : pattern.getDomain();
>> -        Map props = pattern == null ? null :  
>> pattern.getKeyPropertyList();
>> -        Set gbeans = registry.listGBeans(domain, props);
>> -        Set result = new HashSet(gbeans.size());
>> -        for (Iterator i = gbeans.iterator(); i.hasNext();) {
>> -            GBeanInstance instance = (GBeanInstance) i.next();
>> -            result.add(instance.getObjectNameObject());
>> -        }
>> -        return result;
>> +        return registry.listGBeans(pattern);
>>      }
>>
>>      public Set listGBeans(Set patterns) {
>> @@ -356,14 +345,7 @@
>>      }
>>
>>      public ClassLoader getClassLoaderFor(ObjectName name) throws  
>> GBeanNotFoundException {
>> -        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (createGBeanName(name));
>> +        GBeanInstance gbeanInstance = registry.getGBeanInstance 
>> (name);
>>          return gbeanInstance.getClassLoader();
>> -    }
>> -
>> -    private GBeanName createGBeanName(ObjectName objectName) {
>> -        if (objectName.getDomain().length() == 0) {
>> -            return new GBeanName(kernelName,  
>> objectName.getKeyPropertyList());
>> -        }
>> -        return new GBeanName(objectName);
>>      }
>>  }
>>
>> Modified: geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicRegistry.java
>> URL: http://svn.apache.org/viewcvs/geronimo/branches/v1_0_M4-QA/ 
>> modules/kernel/src/java/org/apache/geronimo/kernel/basic/ 
>> BasicRegistry.java?rev=226753&r1=226752&r2=226753&view=diff
>> ===================================================================== 
>> =========
>> --- geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicRegistry.java (original)
>> +++ geronimo/branches/v1_0_M4-QA/modules/kernel/src/java/org/ 
>> apache/geronimo/kernel/basic/BasicRegistry.java Sun Jul 31  
>> 23:21:08 2005
>> @@ -21,15 +21,17 @@
>>  import java.util.Set;
>>  import java.util.HashSet;
>>  import java.util.Iterator;
>> +import java.util.List;
>> +import java.util.ArrayList;
>> +import java.util.Collections;
>> +import java.util.regex.Pattern;
>>
>>  import javax.management.ObjectName;
>> -import javax.management.MalformedObjectNameException;
>>
>>  import org.apache.geronimo.kernel.Kernel;
>>  import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
>>  import org.apache.geronimo.kernel.GBeanNotFoundException;
>>  import org.apache.geronimo.kernel.InternalKernelException;
>> -import org.apache.geronimo.gbean.GBeanName;
>>  import org.apache.geronimo.gbean.runtime.GBeanInstance;
>>
>>  /**
>> @@ -37,23 +39,27 @@
>>   */
>>  public class BasicRegistry {
>>      private final Map registry = new HashMap();
>> -    private String kernelName = "";
>> +    private final Map domainIndex = new HashMap();
>> +    private String defaultDomainName;
>> +
>> +    public BasicRegistry(String defaultDomainName) {
>> +        this.defaultDomainName = defaultDomainName;
>> +    }
>>
>>      /**
>> -     * Start the registry and associate it with a kernel.
>> -     *
>> -     * @param kernel the kernel to associate with
>> +     * Start the registry.
>>       */
>>      public void start(Kernel kernel) {
>> -        kernelName = kernel.getKernelName();
>>      }
>>
>>      /**
>>       * Shut down the registry and unregister any GBeans
>>       */
>> -    public synchronized void stop() {
>> -        registry.clear();
>> -        kernelName = "";
>> +    public void stop() {
>> +        synchronized (this) {
>> +            registry.clear();
>> +            domainIndex.clear();
>> +        }
>>      }
>>
>>      /**
>> @@ -62,8 +68,10 @@
>>       * @param name the name of the GBean to check for
>>       * @return true if there is a GBean registered with that name
>>       */
>> -    public synchronized boolean isRegistered(GBeanName name) {
>> -        return registry.containsKey(name);
>> +    public boolean isRegistered(ObjectName name) {
>> +        synchronized (this) {
>> +            return registry.containsKey(name);
>> +        }
>>      }
>>
>>      /**
>> @@ -73,11 +81,30 @@
>>       * @throws GBeanAlreadyExistsException if there is already a  
>> GBean registered with the instance's name
>>       */
>>      public synchronized void register(GBeanInstance  
>> gbeanInstance) throws GBeanAlreadyExistsException {
>> -        GBeanName name = createGBeanName 
>> (gbeanInstance.getObjectNameObject());
>> +        // do as much work as possible outside of the  
>> synchronized block
>> +        ObjectName name = gbeanInstance.getObjectNameObject();
>>          if (registry.containsKey(name)) {
>> -            throw new GBeanAlreadyExistsException("GBean already  
>> registered: " + name);
>> +            throw new GBeanAlreadyExistsException("GBean already  
>> registered: " + name.getCanonicalName());
>> +        }
>> +
>> +        String domainName = name.getDomain();
>> +        if (domainName.length() == 0) {
>> +            domainName = defaultDomainName;
>> +        }
>> +
>> +        // convert properties list to a HashMap as it is more  
>> efficient then the synchronized Hashtable
>> +        Map properties = new HashMap(name.getKeyPropertyList());
>> +
>> +        synchronized (this) {
>> +            registry.put(name, gbeanInstance);
>> +
>> +            Map nameToProperties = (Map) domainIndex.get 
>> (domainName);
>> +            if (nameToProperties == null) {
>> +                nameToProperties = new HashMap();
>> +                domainIndex.put(domainName, nameToProperties);
>> +            }
>> +            nameToProperties.put(name, properties);
>>          }
>> -        registry.put(name, gbeanInstance);
>>      }
>>
>>      /**
>> @@ -86,12 +113,15 @@
>>       * @param name the name of the GBean to unregister
>>       * @throws GBeanNotFoundException if there is no GBean  
>> registered with the supplied name
>>       */
>> -    public synchronized void unregister(GBeanName name) throws  
>> GBeanNotFoundException, InternalKernelException {
>> -        if (registry.remove(name) == null) {
>> -            try {
>> -                throw new GBeanNotFoundException 
>> (name.getObjectName());
>> -            } catch (MalformedObjectNameException e) {
>> -                throw new InternalKernelException(e);
>> +    public synchronized void unregister(ObjectName name) throws  
>> GBeanNotFoundException, InternalKernelException {
>> +        String domainName = name.getDomain();
>> +        synchronized (this) {
>> +            registry.remove(name);
>> +
>> +            // just leave the an empty nameToProperty map
>> +            Map nameToProperties = (Map) domainIndex.get 
>> (domainName);
>> +            if (nameToProperties != null) {
>> +                nameToProperties.remove(name);
>>              }
>>          }
>>      }
>> @@ -103,14 +133,13 @@
>>       * @return the GBeanInstance
>>       * @throws GBeanNotFoundException if there is no GBean  
>> registered with the supplied name
>>       */
>> -    public synchronized GBeanInstance getGBeanInstance(GBeanName  
>> name) throws GBeanNotFoundException {
>> -        GBeanInstance instance = (GBeanInstance) registry.get(name);
>> +    public synchronized GBeanInstance getGBeanInstance(ObjectName  
>> name) throws GBeanNotFoundException {
>> +        GBeanInstance instance;
>> +        synchronized (this) {
>> +            instance = (GBeanInstance) registry.get(name);
>> +        }
>>          if (instance == null) {
>> -            try {
>> -                throw new GBeanNotFoundException 
>> (name.getObjectName());
>> -            } catch (MalformedObjectNameException e) {
>> -                throw new InternalKernelException(e);
>> -            }
>> +            throw new GBeanNotFoundException(name);
>>          }
>>          return instance;
>>      }
>> @@ -119,31 +148,131 @@
>>      /**
>>       * Search the registry for GBeans matching a name pattern.
>>       *
>> -     * @param domain the domain to query in; null indicates all
>> -     * @param properties the properties the GBeans must have
>> +     * @param pattern object name pattern
>>       * @return an unordered Set<GBeanInstance> of GBeans that  
>> matched the pattern
>>       */
>> -    public Set listGBeans(String domain, Map properties) {
>> -        // fairly dumb implementation that iterates the list of  
>> all registered GBeans
>> -        Map clone;
>> -        synchronized(this) {
>> -            clone = new HashMap(registry);
>> +    public Set listGBeans(ObjectName pattern) {
>> +        if (pattern == null) {
>> +            synchronized (this) {
>> +                return new HashSet(registry.keySet());
>> +            }
>>          }
>> -        Set result = new HashSet(clone.size());
>> -        for (Iterator i = clone.entrySet().iterator(); i.hasNext 
>> ();) {
>> -            Map.Entry entry = (Map.Entry) i.next();
>> -            GBeanName name = (GBeanName) entry.getKey();
>> -            if (name.matches(domain, properties)) {
>> -                result.add(entry.getValue());
>> +
>> +        String patternDomain = pattern.getDomain();
>> +        if (patternDomain.length() == 0) {
>> +            patternDomain = defaultDomainName;
>> +        }
>> +
>> +        // work with a copy of the registry key set
>> +        List nameToProperties;
>> +        if (!pattern.isDomainPattern()) {
>> +            synchronized (this) {
>> +                // create an array list big enough to match all  
>> names... extra space is better than resizing
>> +                nameToProperties = new ArrayList(registry.size());
>> +
>> +                // find we are only matching one specific domain, so
>> +                // just grab it directly from the index
>> +                Map map = (Map) domainIndex.get(patternDomain);
>> +                if (map != null) {
>> +                    nameToProperties.addAll(map.entrySet());
>> +                }
>> +            }
>> +        } else if (patternDomain.equals("*")) {
>> +            // this
>> +            //  is very commmon, so support it directly
>> +            synchronized (this) {
>> +                // create an array list big enough to match all  
>> names... extra space is better than resizing
>> +                nameToProperties = new ArrayList(registry.size());
>> +
>> +                // find we are matching all domain, so just grab  
>> all of them directly
>> +                for (Iterator iterator = domainIndex.values 
>> ().iterator(); iterator.hasNext();) {
>> +                    Map map = (Map) iterator.next();
>> +
>> +                    // we can just copy the entry set directly  
>> into the list we don't
>> +                    // have to worry about duplicates as the maps  
>> are mutually exclusive
>> +                    nameToProperties.addAll(map.entrySet());
>> +                }
>> +            }
>> +        } else {
>> +            String perl5Pattern = domainPatternToPerl5 
>> (patternDomain);
>> +            Pattern domainPattern = Pattern.compile(perl5Pattern);
>> +
>> +            synchronized (this) {
>> +                // create an array list big enough to match all  
>> names... extra space is better than resizing
>> +                nameToProperties = new ArrayList(registry.size());
>> +
>> +                // find all of the matching domains
>> +                for (Iterator iterator = domainIndex.entrySet 
>> ().iterator(); iterator.hasNext();) {
>> +                    Map.Entry entry = (Map.Entry) iterator.next();
>> +                    String domain = (String) entry.getKey();
>> +                    if (domainPattern.matcher(domain).matches()) {
>> +                        // we can just copy the entry set  
>> directly into the list we don't
>> +                        // have to worry about duplicates as the  
>> maps are mutually exclusive
>> +                        Map map = (Map) entry.getValue();
>> +                        nameToProperties.addAll(map.entrySet());
>> +                    }
>> +                }
>>              }
>>          }
>> -        return result;
>> +
>> +        if (nameToProperties.isEmpty()) {
>> +            return Collections.EMPTY_SET;
>> +        }
>> +
>> +        // convert the pattern property list to a HashMap as it  
>> is not synchronized
>> +        Map patternProperties = new HashMap 
>> (pattern.getKeyPropertyList());
>> +        patternProperties.remove("*");
>> +        boolean isMatchAll = patternProperties.isEmpty();
>> +        boolean isPropertyPattern = pattern.isPropertyPattern();
>> +
>> +        Set matchingNames = new HashSet();
>> +        for (Iterator iterator = nameToProperties.iterator();  
>> iterator.hasNext();) {
>> +            Map.Entry entry = (Map.Entry) iterator.next();
>> +            Map properties = (Map) entry.getValue();
>> +
>> +            if (isMatchAll) {
>> +                matchingNames.add(entry.getKey());
>> +            } else if (isPropertyPattern) {
>> +                if (properties.entrySet().containsAll 
>> (patternProperties.entrySet())) {
>> +                    matchingNames.add(entry.getKey());
>> +                }
>> +            } else {
>> +                if (properties.entrySet().equals 
>> (patternProperties.entrySet())) {
>> +                    matchingNames.add(entry.getKey());
>> +                }
>> +            }
>> +        }
>> +        return matchingNames;
>>      }
>>
>> -    private GBeanName createGBeanName(ObjectName objectName) {
>> -        if (objectName.getDomain().length() == 0) {
>> -            return new GBeanName(kernelName,  
>> objectName.getKeyPropertyList());
>> +    private static String domainPatternToPerl5(String pattern) {
>> +        char[] patternCharacters = pattern.toCharArray();
>> +        StringBuffer buffer = new StringBuffer(2 *  
>> patternCharacters.length);
>> +        for (int position = 0; position <  
>> patternCharacters.length; position++) {
>> +            char character = patternCharacters[position];
>> +            switch (character) {
>> +                case '*':
>> +                    // replace '*' with '.*'
>> +                    buffer.append(".*");
>> +                    break;
>> +                case '?':
>> +                    // replace '?' with '.'
>> +                    buffer.append('.');
>> +                    break;
>> +                default:
>> +                    // escape any perl5 characters with '\'
>> +                    if (isPerl5MetaCharacter(character)) {
>> +                        buffer.append('\\');
>> +                    }
>> +                    buffer.append(character);
>> +                    break;
>> +            }
>>          }
>> -        return new GBeanName(objectName);
>> +
>> +        return buffer.toString();
>> +    }
>> +
>> +    private static boolean isPerl5MetaCharacter(char character) {
>> +        return ("'*?+[]()|^$.{}\\".indexOf(character) >= 0);
>>      }
>>  }
>>
>>
>>
>>
>
> -- 
> Geir Magnusson Jr                                  +1-203-665-6437
> geirm@apache.org
>
>


Mime
View raw message