geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r451498 - in /geronimo/sandbox/plugins/global-jndi/src: main/java/org/apache/geronimo/gjndi/ main/java/org/apache/geronimo/gjndi/binding/ test/java/org/apache/geronimo/gjndi/ test/java/org/apache/geronimo/gjndi/binding/
Date Sat, 30 Sep 2006 00:13:16 GMT
Author: dain
Date: Fri Sep 29 17:13:15 2006
New Revision: 451498

URL: http://svn.apache.org/viewvc?view=rev&rev=451498
Log:
Added binding for a single gbean

Added:
    geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/WritableContextGBean.java
    geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
    geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/GBeanBindingTest.java
    geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/MockDataSource.java
Modified:
    geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/AbstractContextTest.java
    geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/ResourceBindingsTest.java

Added: geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/WritableContextGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/WritableContextGBean.java?view=auto&rev=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/WritableContextGBean.java
(added)
+++ geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/WritableContextGBean.java
Fri Sep 29 17:13:15 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2006 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.geronimo.gjndi;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.xbean.naming.context.ContextAccess;
+import org.apache.xbean.naming.context.WritableContext;
+
+import javax.naming.NamingException;
+import java.util.Collections;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WritableContextGBean extends WritableContext {
+    public WritableContextGBean(String nameInNamespace) throws NamingException {
+        super(nameInNamespace, Collections.EMPTY_MAP, ContextAccess.MODIFIABLE, false);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static GBeanInfo getGBeanInfo() {
+        return WritableContextGBean.GBEAN_INFO;
+    }
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(WritableContextGBean.class,
"Context");
+        builder.addAttribute("nameInNamespace", String.class, true);
+        builder.setConstructor(new String[]{"nameInNamespace"});
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+}

Added: geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java?view=auto&rev=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
(added)
+++ geronimo/sandbox/plugins/global-jndi/src/main/java/org/apache/geronimo/gjndi/binding/GBeanBinding.java
Fri Sep 29 17:13:15 2006
@@ -0,0 +1,231 @@
+/**
+ *
+ * Copyright 2006 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.geronimo.gjndi.binding;
+
+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.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+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$
+ */
+public class GBeanBinding implements GBeanLifecycle {
+    private static final Log log = LogFactory.getLog(GBeanBinding.class);
+
+    private final Context context;
+    private final String name;
+    private final AbstractNameQuery abstractNameQuery;
+    private final Kernel kernel;
+
+    private final LifecycleListener listener = new GBeanLifecycleListener();
+    private final LinkedHashMap bindings = new LinkedHashMap();
+
+    public GBeanBinding(Context context, String name, AbstractNameQuery abstractNameQuery,
Kernel kernel) {
+        this.context = context;
+        this.name = name;
+        this.abstractNameQuery = abstractNameQuery;
+        this.kernel = kernel;
+    }
+
+    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();
+            try {
+                if (kernel.isRunning(abstractName)) {
+                    addBinding(abstractName);
+                }
+            } catch (NamingException e) {
+                log.error("Error adding binding for " + abstractName, e);
+            }
+        }
+
+    }
+
+    public void doStop() {
+        destroy();
+    }
+
+    public void doFail() {
+        destroy();
+    }
+
+    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();
+            removeBinding(abstractName);
+        }
+        bindings.clear();
+    }
+
+    private class GBeanLifecycleListener extends LifecycleAdapter {
+        public void running(AbstractName abstractName) {
+            try {
+                addBinding(abstractName);
+            } catch (NamingException e) {
+                log.error("Error adding binding for " + abstractName);
+            }
+        }
+
+        public void stopping(AbstractName abstractName) {
+            removeBinding(abstractName);
+        }
+
+        public void stopped(AbstractName abstractName) {
+            removeBinding(abstractName);
+        }
+
+        public void failed(AbstractName abstractName) {
+            removeBinding(abstractName);
+        }
+
+        public void unloaded(AbstractName abstractName) {
+            removeBinding(abstractName);
+        }
+    }
+
+    /**
+     * Binds the specified gbean.  This method uses createBindingName and preprocessValue
before binding the object.
+     *
+     * @param abstractName the abstract name of the gbean to bind
+     * @throws NamingException if an error occurs during binding
+     */
+    protected synchronized void addBinding(AbstractName abstractName) throws NamingException
{
+        if (bindings.containsKey(abstractName)) {
+            // previously bound
+            return;
+        }
+
+        // get the gbean
+        Object instance = null;
+        try {
+            instance = kernel.getGBean(abstractName);
+        } catch (GBeanNotFoundException e) {
+            throw new NamingException("GBean not found: " + abstractName);
+        }
+
+        // preprocess the instance
+        instance = preprocessVaue(abstractName, instance);
+
+        addBinding(abstractName, instance);
+    }
+
+    private synchronized void addBinding(AbstractName abstractName, Object value) throws
NamingException {
+        if (bindings.isEmpty()) {
+            context.bind(name, value);
+        }
+        bindings.put(abstractName, value);
+    }
+
+    /**
+     * Unbinds the specified gbean.
+     *
+     * @param abstractName the abstract name of the gbean to unbind
+     */
+    protected synchronized void removeBinding(AbstractName abstractName) {
+        if (first(bindings).getKey().equals(abstractName)) {
+            Object oldValue = bindings.remove(abstractName);
+            Map.Entry newEntry = first(bindings);
+            if (newEntry != null) {
+                Object newAbstractName = newEntry.getValue();
+                Object newValue = newEntry.getValue();
+                try {
+                    context.rebind(name, newValue);
+                } catch (NamingException e) {
+                    boolean unbound = unbind(abstractName, oldValue);
+                    // avoid double logging
+                    if (unbound) log.error("Unable to rebind binding " + name + " to " +
newAbstractName);
+                }
+            } else {
+                unbind(abstractName, oldValue);
+            }
+        } else {
+            bindings.remove(abstractName);
+        }
+    }
+
+    private boolean unbind(AbstractName abstractName, Object value) {
+        // first check if we are still bound
+        try {
+            if (context.lookup(name) != value) {
+                return true;
+            }
+        } catch (NamingException ignored) {
+            // binding doesn't exist
+            return true;
+        }
+
+        try {
+            context.unbind(name);
+            return true;
+        } catch (NamingException e1) {
+            log.error("Unable to remove binding " + name + " to " + abstractName, e1);
+        }
+        return false;
+    }
+
+    private static Map.Entry first(LinkedHashMap map) {
+        if (map.isEmpty()) return null;
+        return (Map.Entry) map.entrySet().iterator().next();
+    }
+
+    /**
+     * 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
+     */
+    protected Object preprocessVaue(AbstractName abstractName, Object value) throws NamingException
{
+        return value;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(GBeanBinding.class, "GBeanBinding");
+        builder.addReference("Context", Context.class);
+        builder.addAttribute("name", String.class, true);
+        builder.addAttribute("abstractNameQuery", AbstractNameQuery.class, true);
+        builder.setConstructor(new String[]{"Context", "name", "abstractNameQuery", "kernel"});
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+}

Modified: geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/AbstractContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/AbstractContextTest.java?view=diff&rev=451498&r1=451497&r2=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/AbstractContextTest.java
(original)
+++ geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/AbstractContextTest.java
Fri Sep 29 17:13:15 2006
@@ -128,17 +128,17 @@
 
             Object actualValue = actualValues.get(expectedName);
 
-            assertNotNull("list of " + name + " on " + contextName + " did not find value
for " + name, actualValue);
+            assertNotNull("list of " + name + " on " + contextName + " did not find value
for " + expectedName, actualValue);
             if (wasListBinding) {
                 if (expectedValue instanceof ContextUtil.Node) {
-                    assertTrue("Expected list of " + name + " on " + contextName + " result
value for " + name + " to return a Context, but got a " + actualValue.getClass().getName(),
+                    assertTrue("Expected list of " + name + " on " + contextName + " result
value for " + expectedName + " to return a Context, but got a " + actualValue.getClass().getName(),
                         actualValue instanceof Context);
                 } else {
-                    assertEquals("list of " + name + " on " + contextName + " for value for
" + name, expectedValue, actualValue);
+                    assertEquals("list of " + name + " on " + contextName + " for value for
" + expectedName, expectedValue, actualValue);
                 }
             } else {
                 if (!(expectedValue instanceof ContextUtil.Node)) {
-                    assertEquals("list of " + name + " on " + contextName + " for value for
" + name, expectedValue.getClass().getName(), actualValue);
+                    assertEquals("list of " + name + " on " + contextName + " for value for
" + expectedName, expectedValue.getClass().getName(), actualValue);
                 } else {
                     // can't really test this since it the value is the name of a nested
node class
                 }

Added: geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/GBeanBindingTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/GBeanBindingTest.java?view=auto&rev=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/GBeanBindingTest.java
(added)
+++ geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/GBeanBindingTest.java
Fri Sep 29 17:13:15 2006
@@ -0,0 +1,168 @@
+/**
+ *
+ * Copyright 2006 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.geronimo.gjndi.binding;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gjndi.AbstractContextTest;
+import org.apache.geronimo.gjndi.GlobalContextGBean;
+import org.apache.geronimo.gjndi.WritableContextGBean;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.EditableConfigurationManager;
+import org.apache.geronimo.kernel.config.EditableKernelConfigurationManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.xbean.naming.global.GlobalContextManager;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GBeanBindingTest extends AbstractContextTest {
+    private Kernel kernel;
+
+    private Hashtable contextEnv;
+    private Map globalBindings;
+    private AbstractName ds1Name;
+    private AbstractName ds2Name;
+
+    public void testBasics() throws Exception {
+        InitialContext ctx = new InitialContext(contextEnv);
+        assertEq(globalBindings, ctx);
+
+        //
+        // stop ds1
+        //
+        kernel.stopGBean(ds1Name);
+        DataSource ds2 = (DataSource) kernel.getGBean(ds2Name);
+        globalBindings.put("writable/ds", ds2);
+        globalBindings.remove("writable/ds1");
+        assertEq(globalBindings, ctx);
+
+        //
+        // restart ds1
+        //
+        kernel.startGBean(ds1Name);
+        DataSource ds1 = (DataSource) kernel.getGBean(ds1Name);
+        globalBindings.put("writable/ds1", ds1);
+        assertEq(globalBindings, ctx);
+    }
+
+    protected Map getNestedBindings(Map globalBindings, String nestedPath) {
+        HashMap nestedBindings = new HashMap();
+        for (Iterator iterator = globalBindings.entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            String globalName = (String) entry.getKey();
+            Object value = entry.getValue();
+
+            if (globalName.startsWith(nestedPath)) {
+                String nestedName = globalName.substring(nestedPath.length());
+                nestedBindings.put(nestedName, value);
+            }
+        }
+        return nestedBindings;
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        kernel = KernelFactory.newInstance().createKernel("test");
+        kernel.boot();
+
+        ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap",
"", "car"), kernel.getNaming());
+
+        GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
+
+        GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
+        artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+
+        GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", EditableKernelConfigurationManager.GBEAN_INFO);
+        configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+        configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
+
+        ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
+
+        EditableConfigurationManager configurationManager = ConfigurationUtil.getEditableConfigurationManager(kernel);
+
+        ConfigurationData configurationData = new ConfigurationData(new Artifact("test",
"test", "", "car"), kernel.getNaming());
+        configurationData.addGBean("GlobalContext", GlobalContextGBean.GBEAN_INFO);
+
+        contextEnv = new Hashtable();
+        contextEnv.put(Context.INITIAL_CONTEXT_FACTORY, GlobalContextManager.class.getName());
+
+        // dataSources
+        GBeanData ds1GBean = configurationData.addGBean("ds1", MockDataSource.GBEAN_INFO);
+        ds1Name = ds1GBean.getAbstractName();
+
+        GBeanData ds2GBean = configurationData.addGBean("ds2", MockDataSource.GBEAN_INFO);
+        ds2Name = ds2GBean.getAbstractName();
+
+        // bindings
+        GBeanData writableGBean = configurationData.addGBean("writable", WritableContextGBean.GBEAN_INFO);
+        AbstractName writableName = writableGBean.getAbstractName();
+        writableGBean.setAttribute("nameInNamespace", "writable");
+
+        GBeanData dsBinding = configurationData.addGBean("dsBinding", GBeanBinding.GBEAN_INFO);
+        dsBinding.setReferencePattern("Context", writableName);
+        dsBinding.setAttribute("name", "ds");
+        dsBinding.setAttribute("abstractNameQuery", new AbstractNameQuery(null, Collections.EMPTY_MAP,
DataSource.class.getName()));
+
+        GBeanData ds1Binding = configurationData.addGBean("ds1Binding", GBeanBinding.GBEAN_INFO);
+        ds1Binding.setReferencePattern("Context", writableName);
+        ds1Binding.setAttribute("name", "ds1");
+        ds1Binding.setAttribute("abstractNameQuery", new AbstractNameQuery(null,
+                Collections.singletonMap("name", "ds1"),
+                DataSource.class.getName()));
+
+        GBeanData ds2Binding = configurationData.addGBean("ds2Binding", GBeanBinding.GBEAN_INFO);
+        ds2Binding.setReferencePattern("Context", writableName);
+        ds2Binding.setAttribute("name", "ds2");
+        ds2Binding.setAttribute("abstractNameQuery", new AbstractNameQuery(null,
+                Collections.singletonMap("name", "ds2"),
+                DataSource.class.getName()));
+
+        configurationManager.loadConfiguration(configurationData);
+        configurationManager.startConfiguration(configurationData.getId());
+
+        DataSource ds1 = (DataSource) kernel.getGBean(ds1Name);
+        DataSource ds2 = (DataSource) kernel.getGBean(ds2Name);
+
+        // global bindings
+        globalBindings = new HashMap();
+        globalBindings.put("writable/ds", ds1);
+        globalBindings.put("writable/ds1", ds1);
+        globalBindings.put("writable/ds2", ds2);
+    }
+
+    protected void tearDown() throws Exception {
+        kernel.shutdown();
+        super.tearDown();
+    }
+}

Added: geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/MockDataSource.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/MockDataSource.java?view=auto&rev=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/MockDataSource.java
(added)
+++ geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/MockDataSource.java
Fri Sep 29 17:13:15 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2006 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.geronimo.gjndi.binding;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MockDataSource implements DataSource {
+    public Connection getConnection() throws SQLException {
+        return null;
+    }
+
+    public Connection getConnection(String username, String password) throws SQLException
{
+        return null;
+    }
+
+    public PrintWriter getLogWriter() throws SQLException {
+        return null;
+    }
+
+    public void setLogWriter(PrintWriter out) throws SQLException {
+    }
+
+    public void setLoginTimeout(int seconds) throws SQLException {
+    }
+
+    public int getLoginTimeout() throws SQLException {
+        return 0;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static GBeanInfo getGBeanInfo() {
+        return MockDataSource.GBEAN_INFO;
+    }
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MockDataSource.class, "MockDataSource");
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+}

Modified: geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/ResourceBindingsTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/ResourceBindingsTest.java?view=diff&rev=451498&r1=451497&r2=451498
==============================================================================
--- geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/ResourceBindingsTest.java
(original)
+++ geronimo/sandbox/plugins/global-jndi/src/test/java/org/apache/geronimo/gjndi/binding/ResourceBindingsTest.java
Fri Sep 29 17:13:15 2006
@@ -40,9 +40,6 @@
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.sql.DataSource;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
@@ -261,30 +258,6 @@
             builder.addAttribute("resource", Object.class, true);
             builder.setConstructor(new String[]{"resource"});
             GBEAN_INFO = builder.getBeanInfo();
-        }
-    }
-
-    public static class MockDataSource implements DataSource {
-        public Connection getConnection() throws SQLException {
-            return null;
-        }
-
-        public Connection getConnection(String username, String password) throws SQLException
{
-            return null;
-        }
-
-        public PrintWriter getLogWriter() throws SQLException {
-            return null;
-        }
-
-        public void setLogWriter(PrintWriter out) throws SQLException {
-        }
-
-        public void setLoginTimeout(int seconds) throws SQLException {
-        }
-
-        public int getLoginTimeout() throws SQLException {
-            return 0;
         }
     }
 }



Mime
View raw message