geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1236067 - in /geronimo/server/trunk: framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/ framework/modules/geronimo-naming/ framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/ testsuit...
Date Thu, 26 Jan 2012 08:31:07 GMT
Author: djencks
Date: Thu Jan 26 08:31:06 2012
New Revision: 1236067

URL: http://svn.apache.org/viewvc?rev=1236067&view=rev
Log:
GERONIMO-6255 start on InitialContextFactoryBuilder for default jndi context

Added:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/DefaultInitialContextFactoryBuilder.java
  (with props)
    geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
  (with props)
    geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
  (with props)
Modified:
    geronimo/server/trunk/framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/naming-providers.xml
    geronimo/server/trunk/framework/modules/geronimo-naming/pom.xml
    geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/resources/WEB-INF/web.xml

Modified: geronimo/server/trunk/framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/naming-providers.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/naming-providers.xml?rev=1236067&r1=1236066&r2=1236067&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/naming-providers.xml
(original)
+++ geronimo/server/trunk/framework/configs/rmi-naming/src/main/resources/OSGI-INF/blueprint/naming-providers.xml
Thu Jan 26 08:31:06 2012
@@ -77,4 +77,11 @@ limitations under the License.
         </bean>
     </service>
 
+    <service id="defaultInitialContextFactoryBuilder"
+             interface="javax.naming.spi.InitialContextFactoryBuilder">
+        <bean class="org.apache.geronimo.naming.defaultcontext.DefaultInitialContextFactoryBuilder">
+        </bean>
+    </service>
+
+
 </blueprint>

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/pom.xml?rev=1236067&r1=1236066&r2=1236067&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/pom.xml Thu Jan 26 08:31:06 2012
@@ -55,7 +55,25 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jta_1.1_spec</artifactId>
         </dependency>
+
+
     </dependencies>
-    
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.servicemix.tooling</groupId>
+          <artifactId>depends-maven-plugin</artifactId>
+          <executions>
+            <execution>
+              <id>generate-depends-file</id>
+              <goals>
+                <goal>generate-depends-file</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </build>
+
 </project>
 

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/DefaultInitialContextFactoryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/DefaultInitialContextFactoryBuilder.java?rev=1236067&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/DefaultInitialContextFactoryBuilder.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/defaultcontext/DefaultInitialContextFactoryBuilder.java
Thu Jan 26 08:31:06 2012
@@ -0,0 +1,55 @@
+/*
+ * 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.naming.defaultcontext;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.spi.InitialContextFactoryBuilder;
+import org.apache.xbean.naming.context.WritableContext;
+
+/**
+ * OSGI service that supplies a singleton InitialContextFactoryBuilder for the default /
context using a WritableContext.
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class DefaultInitialContextFactoryBuilder implements InitialContextFactoryBuilder
{
+    private final Context initialContext;
+
+    public DefaultInitialContextFactoryBuilder() throws NamingException {
+        initialContext = new WritableContext();
+    }
+
+    @Override
+    public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> hashtable)
throws NamingException {
+        return initialContextFactory;
+    }
+
+    private final InitialContextFactory initialContextFactory = new InitialContextFactory()
{
+        @Override
+        public Context getInitialContext(Hashtable<?, ?> hashtable) throws NamingException
{
+            return initialContext;
+        }
+    };
+
+}

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

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

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

Added: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java?rev=1236067&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
(added)
+++ geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
Thu Jan 26 08:31:06 2012
@@ -0,0 +1,70 @@
+/**
+ *  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.testsuite;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.geronimo.testsupport.HttpUtils;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.testng.annotations.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class DefaultJndiTest extends TestSupport
+{
+    private String baseURL = "http://localhost:8080/";
+
+    @Test
+    public void testServlet() throws Exception {
+        checkReply("/defaultjndiservlet");
+    }
+
+
+    private void checkReply(String address)
+        throws Exception {
+        String warName = System.getProperty("webAppName");
+        assertNotNull(warName);
+        URL url = new URL(baseURL + warName + address);
+        /**
+         * WABs are deployed asynchronously so it might take a
+         * bit to actually invoke the servlet.
+         */
+        String reply = doGET(url, 6, 10 * 1000);
+        assertTrue("WAB", 
+                   reply.contains("Value bound and retrieved from jndi default context"));
+        
+    }
+  
+    private String doGET(URL url, int repeat, long delay) {
+        for (int i = 0; i < repeat; i++) {
+            try {
+                return HttpUtils.doGET(url); 
+            } catch (IOException e) {
+                // ignore
+                try {
+                    Thread.sleep(delay);
+                } catch (Exception ee) {
+                    break;
+                }
+            }
+        }
+        fail("Did not get servlet response in time");
+        return "";
+    }
+}

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-eba/src/test/java/org/apache/geronimo/testsuite/DefaultJndiTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java?rev=1236067&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
(added)
+++ geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
Thu Jan 26 08:31:06 2012
@@ -0,0 +1,76 @@
+/**
+ *  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.testsuite.ds.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+
+
+/**
+ * Servlet implementation class DSServlet
+ */
+@WebServlet("/defaultjndiservlet")
+public class DefaultJndiServlet extends HttpServlet {
+   private static final long serialVersionUID = 1L;
+
+    /**
+     * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
+     */
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        performTask(request, response);
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
+     */
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        performTask(request, response);
+    }
+    
+    protected void performTask(HttpServletRequest request, HttpServletResponse response){
+        try {
+            PrintWriter pw = response.getWriter();
+            try {
+                Context ctx = new InitialContext();
+                ctx.createSubcontext("foo");
+                ctx.bind("foo/bar", "value");
+                String value = (String) ctx.lookup("foo/bar");
+                if ("value".equals(value)) {
+                    pw.println("Value bound and retrieved from jndi default context");
+                } else{
+                    pw.println("Value not bound or not retrieved from jndi default context");
+                }
+            } catch (NamingException e) {
+                e.printStackTrace(pw);
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/java/org/apache/geronimo/testsuite/ds/web/DefaultJndiServlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/resources/WEB-INF/web.xml?rev=1236067&r1=1236066&r2=1236067&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/resources/WEB-INF/web.xml
(original)
+++ geronimo/server/trunk/testsuite/aries-testsuite/ds-jndi/ds-wab/src/main/resources/WEB-INF/web.xml
Thu Jan 26 08:31:06 2012
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
-    metadata-complete="true">
+    >
 
        <welcome-file-list>
         <welcome-file>index.html</welcome-file>



Mime
View raw message