geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r615514 - in /geronimo/server/trunk: framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/ framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ framework/modules/geronimo-naming/src/test/ja...
Date Sat, 26 Jan 2008 22:08:27 GMT
Author: djencks
Date: Sat Jan 26 14:08:26 2008
New Revision: 615514

URL: http://svn.apache.org/viewvc?rev=615514&view=rev
Log:
GERONIMO-2971 automatically bind jca resources (connection factories and admin objects) to
jndi

Added:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
  (with props)
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
  (with props)
    geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
  (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
    geronimo/server/trunk/plugins/connector/transaction/pom.xml
    geronimo/server/trunk/plugins/connector/transaction/src/main/plan/plan.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java?rev=615514&r1=615513&r2=615514&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/KernelContextGBean.java
Sat Jan 26 14:08:26 2008
@@ -16,6 +16,16 @@
  */
 package org.apache.geronimo.gjndi;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.AbstractName;
@@ -30,16 +40,6 @@
 import org.apache.xbean.naming.context.ContextAccess;
 import org.apache.xbean.naming.context.WritableContext;
 
-import javax.naming.Name;
-import javax.naming.NamingException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -49,7 +49,7 @@
     private final Kernel kernel;
     private final AbstractNameQuery abstractNameQuery;
     private final LifecycleListener listener = new ContextLifecycleListener();
-    private final Map bindingsByAbstractName = new HashMap();
+    private final Map<AbstractName, Set<Name>> bindingsByAbstractName = new HashMap<AbstractName,
Set<Name>>();
 
     public KernelContextGBean(String nameInNamespace, AbstractNameQuery abstractNameQuery,
Kernel kernel) throws NamingException {
         super(nameInNamespace, Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
@@ -59,15 +59,14 @@
 
     public synchronized void doStart() {
         kernel.getLifecycleMonitor().addLifecycleListener(listener, abstractNameQuery);
-        Set set = kernel.listGBeans(abstractNameQuery);
-        for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-            AbstractName abstractName = (AbstractName) iterator.next();
+        Set<AbstractName> set = kernel.listGBeans(abstractNameQuery);
+        for (AbstractName abstractName : set) {
             try {
                 if (kernel.isRunning(abstractName)) {
                     addBinding(abstractName);
                 }
             } catch (NamingException e) {
-                log.error("Error adding binding for " + abstractName);
+                log.error("Error adding binding for " + abstractName, e);
             }
         }
 
@@ -83,9 +82,8 @@
 
     private synchronized void destroy() {
         kernel.getLifecycleMonitor().removeLifecycleListener(listener);
-        Set abstractNames = new HashSet(bindingsByAbstractName.keySet());
-        for (Iterator iterator = abstractNames.iterator(); iterator.hasNext();) {
-            AbstractName abstractName = (AbstractName) iterator.next();
+        Set<AbstractName> abstractNames = new HashSet<AbstractName>(bindingsByAbstractName.keySet());
+        for (AbstractName abstractName : abstractNames) {
             removeBinding(abstractName);
         }
         bindingsByAbstractName.clear();
@@ -130,7 +128,7 @@
         }
 
         // get the gbean
-        Object instance = null;
+        Object instance;
         try {
             instance = kernel.getGBean(abstractName);
         } catch (GBeanNotFoundException e) {
@@ -138,15 +136,14 @@
         }
 
         // create the bindings for this object
-        Map bindings = createBindings(abstractName, instance);
+        Map<Name, Object> bindings = createBindings(abstractName, instance);
         if (bindings == null || bindings.isEmpty()) {
             return;
         }
 
         // bind the value
-        for (Iterator iterator = bindings.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            Name name = (Name) entry.getKey();
+        for (Map.Entry<Name, Object> entry : bindings.entrySet()) {
+            Name name = entry.getKey();
             Object value = entry.getValue();
             addBinding(abstractName, name, value);
         }
@@ -155,16 +152,17 @@
         bindingsByAbstractName.put(abstractName, bindings.keySet());
     }
 
-    private Map bindingsByName = new HashMap();
+    private Map<Name, LinkedHashMap<AbstractName, Object>> bindingsByName = new
HashMap<Name, LinkedHashMap<AbstractName, Object>>();
 
     private synchronized void addBinding(AbstractName abstractName, Name name, Object value)
throws NamingException {
-        LinkedHashMap bindings = (LinkedHashMap) bindingsByName.get(name);
+        LinkedHashMap<AbstractName, Object> bindings = bindingsByName.get(name);
         if (bindings == null) {
             addDeepBinding(name, value, true, true);
 
-            bindings = new LinkedHashMap();
+            bindings = new LinkedHashMap<AbstractName, Object>();
             bindings.put(abstractName, value);
             bindingsByName.put(name, bindings);
+            log.info("bound gbean " + abstractName + " at name " + name);
         } else {
             bindings.put(abstractName, value);
         }
@@ -176,20 +174,18 @@
      * @param abstractName the abstract name of the gbean to unbind
      */
     protected synchronized void removeBinding(AbstractName abstractName) {
-        Set bindingNames = (Set) bindingsByAbstractName.remove(abstractName);
+        Set<Name> bindingNames = bindingsByAbstractName.remove(abstractName);
         if (bindingNames == null) return;
 
-        for (Iterator iterator = bindingNames.iterator(); iterator.hasNext();) {
-            Name name = (Name) iterator.next();
+        for (Name name : bindingNames) {
 
-            LinkedHashMap bindings = (LinkedHashMap) bindingsByName.get(name);
+            LinkedHashMap<AbstractName, Object> bindings = bindingsByName.get(name);
             if (bindings == null) continue;
 
             if (first(bindings).getKey().equals(abstractName)) {
                 bindings.remove(abstractName);
-                Map.Entry newEntry = first(bindings);
+                Map.Entry<AbstractName, Object> newEntry = first(bindings);
                 if (newEntry != null) {
-                    Object newAbstractName = newEntry.getValue();
                     Object newValue = newEntry.getValue();
                     try {
                         addDeepBinding(name, newValue, true, true);
@@ -201,7 +197,7 @@
                             logged = true;
                             log.error("Unable to remove binding " + name + " to " + abstractName,
e);
                         }
-                        if (!logged) log.error("Unable to rebind binding " + name + " to
" + newAbstractName);
+                        if (!logged) log.error("Unable to rebind binding " + name + " to
" + newEntry.getKey());
                     }
                 } else {
                     bindingsByName.remove(name);
@@ -210,6 +206,7 @@
                     } catch (NamingException e) {
                         log.error("Unable to remove binding " + name + " to " + abstractName,
e);
                     }
+                    log.info("unbound gbean " + abstractName + " at name " + name);
                 }
             } else {
                 bindings.remove(abstractName);
@@ -217,12 +214,12 @@
         }
     }
 
-    private static Map.Entry first(LinkedHashMap map) {
+    private static Map.Entry<AbstractName, Object> first(LinkedHashMap<AbstractName,
Object> map) {
         if (map.isEmpty()) return null;
-        return (Map.Entry) map.entrySet().iterator().next();
+        return map.entrySet().iterator().next();
     }
 
-    protected Map createBindings(AbstractName abstractName, Object value) throws NamingException
{
+    protected Map<Name, Object> createBindings(AbstractName abstractName, Object value)
throws NamingException {
         // generate a name for this binding
         Name name = createBindingName(abstractName, value);
         if (name == null) return null;
@@ -231,8 +228,7 @@
         value = preprocessVaue(abstractName, name, value);
         if (value == null) return null;
 
-        Map bindings = Collections.singletonMap(name, value);
-        return bindings;
+        return Collections.singletonMap(name, value);
     }
 
     /**
@@ -242,6 +238,7 @@
      * @param abstractName the abstract name of the gbean to bind
      * @param value        the gbean instance
      * @return the name under which the gbean should be bound
+     * @throws javax.naming.NamingException should something go wrong
      */
     protected Name createBindingName(AbstractName abstractName, Object value) throws NamingException
{
         String shortName = (String) abstractName.getName().get("name");
@@ -256,6 +253,7 @@
      * @param name         the name under which the gbean will be bound
      * @param value        the gbean instance
      * @return the value to bind
+     * @throws javax.naming.NamingException should something go wrong
      */
     protected Object preprocessVaue(AbstractName abstractName, Name name, Object value) throws
NamingException {
         return value;

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java?rev=615514&r1=615513&r2=615514&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
Sat Jan 26 14:08:26 2008
@@ -16,6 +16,14 @@
  */
 package org.apache.geronimo.gjndi.binding;
 
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.AbstractName;
@@ -28,14 +36,6 @@
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -48,7 +48,7 @@
     private final Kernel kernel;
 
     private final LifecycleListener listener = new GBeanLifecycleListener();
-    private final LinkedHashMap bindings = new LinkedHashMap();
+    private final LinkedHashMap<AbstractName, Object> bindings = new LinkedHashMap<AbstractName,
Object>();
 
     public GBeanBinding(Context context, String name, AbstractNameQuery abstractNameQuery,
Kernel kernel) {
         this.context = context;
@@ -59,9 +59,8 @@
 
     public synchronized void doStart() {
         kernel.getLifecycleMonitor().addLifecycleListener(listener, abstractNameQuery);
-        Set set = kernel.listGBeans(abstractNameQuery);
-        for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-            AbstractName abstractName = (AbstractName) iterator.next();
+        Set<AbstractName> set = kernel.listGBeans(abstractNameQuery);
+        for (AbstractName abstractName : set) {
             try {
                 if (kernel.isRunning(abstractName)) {
                     addBinding(abstractName);
@@ -83,9 +82,8 @@
 
     private synchronized void destroy() {
         kernel.getLifecycleMonitor().removeLifecycleListener(listener);
-        Set abstractNames = new HashSet(bindings.keySet());
-        for (Iterator iterator = abstractNames.iterator(); iterator.hasNext();) {
-            AbstractName abstractName = (AbstractName) iterator.next();
+        Set<AbstractName> abstractNames = new HashSet<AbstractName>(bindings.keySet());
+        for (AbstractName abstractName : abstractNames) {
             removeBinding(abstractName);
         }
         bindings.clear();
@@ -130,7 +128,7 @@
         }
 
         // get the gbean
-        Object instance = null;
+        Object instance;
         try {
             instance = kernel.getGBean(abstractName);
         } catch (GBeanNotFoundException e) {

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java?rev=615514&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
Sat Jan 26 14:08:26 2008
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.geronimo.gjndi.binding;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gjndi.KernelContextGBean;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GBeanFormatBinding extends KernelContextGBean {
+    protected static final Log log = LogFactory.getLog(GBeanFormatBinding.class);
+    private static final Pattern PATTERN = Pattern.compile("(\\{)(\\w+)(})");
+
+    protected final String format;
+    protected final Pattern namePattern;
+
+    public GBeanFormatBinding(String format, String namePattern, String nameInNamespace,
AbstractNameQuery abstractNameQuery, Kernel kernel) throws NamingException {
+        super(nameInNamespace, abstractNameQuery, kernel);
+        this.format = format;
+        if (namePattern != null && namePattern.length() > 0) {
+            this.namePattern = Pattern.compile(namePattern);
+        } else {
+            this.namePattern = null;
+        }
+    }
+
+    @Override
+    protected Name createBindingName(AbstractName abstractName, Object value) throws NamingException
{
+        String name = abstractName.getNameProperty("name");
+        if (namePattern != null) {
+            Matcher matcher = namePattern.matcher(name);
+            if (!matcher.matches()) {
+                return null;
+            }
+        }
+        Map<String, String> map = new HashMap<String, String>(abstractName.getName());
+        Artifact artifact = abstractName.getArtifact();
+        map.put("groupId", artifact.getGroupId());
+        map.put("artifactId", artifact.getArtifactId());
+        map.put("version", artifact.getVersion().toString());
+        map.put("type", artifact.getType());
+        String fullName = format(format, map);
+        return getNameParser().parse(fullName);
+    }
+
+    static String format(String input, Map<String, String> map) {
+        Matcher matcher = PATTERN.matcher(input);
+        StringBuffer buf = new StringBuffer();
+        while (matcher.find()) {
+            String key = matcher.group(2);
+            String value = map.get(key);
+            matcher.appendReplacement(buf, value);
+        }
+        matcher.appendTail(buf);
+        return buf.toString();
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(GBeanFormatBinding.class,
KernelContextGBean.GBEAN_INFO, "Context");
+        builder.addAttribute("format", String.class, true);
+        builder.addAttribute("namePattern", String.class, true);
+        builder.setConstructor(new String[]{"format", "namePattern", "nameInNamespace", "abstractNameQuery",
"kernel"});
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/GBeanFormatBinding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java?rev=615514&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
Sat Jan 26 14:08:26 2008
@@ -0,0 +1,68 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.geronimo.gjndi.binding;
+
+import javax.naming.NamingException;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.naming.ResourceSource;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceBinding extends GBeanFormatBinding {
+
+    public ResourceBinding(String format, String namePattern, String nameInNamespace, AbstractNameQuery
abstractNameQuery, Kernel kernel) throws NamingException {
+        super(format, namePattern, nameInNamespace, abstractNameQuery, kernel);
+    }
+
+    /**
+     * Preprocess the value before it is bound.  This is usefult for wrapping values with
reference objects.
+     * By default, this method simply return the value.
+     *
+     * @param abstractName the abstract name of the gbean to bind
+     * @param value        the gbean instance
+     * @return the value to bind  or null if there was a problem
+     */
+    protected Object preprocessVaue(AbstractName abstractName, Object value) {
+        if (!(value instanceof ResourceSource)) {
+            log.info("value at " + abstractName + " is not a ResourceSource: " + value.getClass().getName());
+            return null;
+        }
+        try {
+            return ((ResourceSource) value).$getResource();
+        } catch (Throwable throwable) {
+            log.info("Could not get resource from gbean at " + abstractName,throwable);
+            return null;
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(ResourceBinding.class, GBeanFormatBinding.GBEAN_INFO,
"Context");
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/gjndi/binding/ResourceBinding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java?rev=615514&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
Sat Jan 26 14:08:26 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.geronimo.gjndi.binding;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.gbean.GBeanInfo;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class FormatTest extends TestCase {
+
+    public void testPattern() throws Exception {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("foo", "white");
+        map.put("bar", "black");
+        assertEquals("white/black", GBeanFormatBinding.format("{foo}/{bar}", map));
+        assertEquals("black/black", GBeanFormatBinding.format("{bar}/{bar}", map));
+        assertEquals("java:white/test/black/test", GBeanFormatBinding.format("java:{foo}/test/{bar}/test",
map));
+    }
+
+    public void testGBeanInfos() throws Exception {
+        GBeanInfo info = ResourceBinding.getGBeanInfo();
+        info = GBeanFormatBinding.getGBeanInfo();
+    }
+
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/test/java/org/apache/geronimo/gjndi/binding/FormatTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/connector/transaction/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector/transaction/pom.xml?rev=615514&r1=615513&r2=615514&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector/transaction/pom.xml (original)
+++ geronimo/server/trunk/plugins/connector/transaction/pom.xml Sat Jan 26 14:08:26 2008
@@ -108,6 +108,22 @@
                         <value>true</value>
                         <includeVersion>true</includeVersion>
                     </useMavenDependencies>
+                    <instance>
+                        <plugin-artifact>
+                            <config-xml-content>
+                                <gbean name="ResourceBindings" class="org.apache.geronimo.gjndi.binding.ResourceBinding">
+                                    <attribute name="format">${ResourceBindingsFormat}</attribute>
+                                    <attribute name="nameInNamespace">${ResourceBindingsNameInNamespace}</attribute>
+                                    <attribute name="namePattern">${ResourceBindingsNamePattern}</attribute>
+                                    <attribute name="abstractNameQuery">${ResourceBindingsQuery}</attribute>
+                                </gbean>
+                            </config-xml-content>
+                            <config-substitution key="ResourceBindingsFormat">{groupId}/{artifactId}/{j2eeType}/{name}</config-substitution>
+                            <config-substitution key="ResourceBindingsNameInNamespace">jca:</config-substitution>
+                            <config-substitution key="ResourceBindingsNamePattern"></config-substitution>
+                            <config-substitution key="ResourceBindingsQuery">?#org.apache.geronimo.naming.ResourceSource</config-substitution>
+                        </plugin-artifact>
+                    </instance>
                 </configuration>
             </plugin>
         </plugins>

Modified: geronimo/server/trunk/plugins/connector/transaction/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector/transaction/src/main/plan/plan.xml?rev=615514&r1=615513&r2=615514&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector/transaction/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/connector/transaction/src/main/plan/plan.xml Sat Jan 26
14:08:26 2008
@@ -100,4 +100,10 @@
         </reference>
     </gbean>
 
+    <gbean name="ResourceBindings" class="org.apache.geronimo.gjndi.binding.ResourceBinding">
+        <attribute name="format">{groupId}/{artifactId}/{j2eeType}/{name}</attribute>
+        <attribute name="nameInNamespace">jca:</attribute>
+        <attribute name="abstractNameQuery">?#org.apache.geronimo.naming.ResourceSource</attribute>
+    </gbean>
+
 </module>



Mime
View raw message