Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 69412 invoked from network); 17 Aug 2006 15:12:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Aug 2006 15:12:33 -0000 Received: (qmail 98810 invoked by uid 500); 17 Aug 2006 15:12:30 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 98764 invoked by uid 500); 17 Aug 2006 15:12:29 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 98753 invoked by uid 99); 17 Aug 2006 15:12:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 08:12:29 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jason.dillon@gmail.com designates 64.233.182.190 as permitted sender) Received: from [64.233.182.190] (HELO nf-out-0910.google.com) (64.233.182.190) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 08:12:26 -0700 Received: by nf-out-0910.google.com with SMTP id n29so1124853nfc for ; Thu, 17 Aug 2006 08:12:05 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=C8yBx1fLzK0Gv4YMgCrjLgimtOGGjTBfIBYq22/bfe2l9j9Ft1b+Bhd79NxLznwIQV8UWtrexyN0o2HSegup9w9+Km2ItKI/UdCPr9Y0lqI65qJhoT3L7+dO86JH9h760ZsmuPcEIAzRpFrOrMmEyCZeL34UYguCuRoF8Ar9/uQ= Received: by 10.49.90.4 with SMTP id s4mr2435140nfl; Thu, 17 Aug 2006 08:12:04 -0700 (PDT) Received: from ?10.0.1.4? ( [24.7.69.241]) by mx.gmail.com with ESMTP id 2sm1194076huc.2006.08.17.08.12.01; Thu, 17 Aug 2006 08:12:04 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: References: <20060817013302.887F91A981A@eris.apache.org> <48A71250-3BFC-4C8C-BF58-C9E9B9148CE1@planet57.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <97AD0C4D-A850-4E5F-827D-34153CA3AC71@planet57.com> Content-Transfer-Encoding: 7bit From: Jason Dillon Subject: Re: svn commit: r432101 - in /geronimo/sandbox/plugins/global-jndi: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/geronimo/ src/java/org/apache/geronimo/gjndi/ src/java/org/apache/geronimo/gjndi/java/ src/site/ src/site/apt/ src/... Date: Thu, 17 Aug 2006 08:11:55 -0700 To: dev@geronimo.apache.org X-Mailer: Apple Mail (2.752.2) Sender: Jason Dillon X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Peep at modules/transaction/pom.xml, you just need to add the section to get the standard layout. I'd really like to fix all modules to use the standard layout... --jason On Aug 17, 2006, at 8:04 AM, Dain Sundstrom wrote: > I'm using the modules pom as a parent, so as soon as you change > that (or give me another correct pom), I'll move this to the > correct layout. > > -dain > > On Aug 16, 2006, at 7:28 PM, Jason Dillon wrote: > >> Hey if you are gonna add new modules, can you please use the m2 >> standard layout? >> >> --jason >> >> >> On Aug 16, 2006, at 6:33 PM, dain@apache.org wrote: >> >>> Author: dain >>> Date: Wed Aug 16 18:32:59 2006 >>> New Revision: 432101 >>> >>> URL: http://svn.apache.org/viewvc?rev=432101&view=rev >>> Log: >>> Starting of a global jndi plugin >>> >>> Added: >>> geronimo/sandbox/plugins/global-jndi/ >>> geronimo/sandbox/plugins/global-jndi/LICENSE.txt >>> geronimo/sandbox/plugins/global-jndi/NOTICE.txt >>> geronimo/sandbox/plugins/global-jndi/pom.xml >>> geronimo/sandbox/plugins/global-jndi/src/ >>> geronimo/sandbox/plugins/global-jndi/src/java/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextBootstrap.java >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextGBean.java >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/JavaCompContextGBean.java >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/KernelContextGBean.java >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/java/ >>> geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/java/javaURLContextFactory.java >>> geronimo/sandbox/plugins/global-jndi/src/site/ >>> geronimo/sandbox/plugins/global-jndi/src/site/apt/ >>> geronimo/sandbox/plugins/global-jndi/src/site/site.xml >>> geronimo/sandbox/plugins/global-jndi/src/test/ >>> geronimo/sandbox/plugins/global-jndi/src/test-data/ >>> geronimo/sandbox/plugins/global-jndi/src/test/org/ >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/ >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/ >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/AbstractContextTest.java >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/JavaCompContextTest.java >>> geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/KernelContextGBeanTest.java >>> >>> Added: geronimo/sandbox/plugins/global-jndi/LICENSE.txt >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/LICENSE.txt?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/LICENSE.txt (added) >>> +++ geronimo/sandbox/plugins/global-jndi/LICENSE.txt Wed Aug 16 >>> 18:32:59 2006 >>> @@ -0,0 +1,203 @@ >>> + >>> + Apache License >>> + Version 2.0, January 2004 >>> + http://www.apache.org/licenses/ >>> + >>> + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION >>> + >>> + 1. Definitions. >>> + >>> + "License" shall mean the terms and conditions for use, >>> reproduction, >>> + and distribution as defined by Sections 1 through 9 of >>> this document. >>> + >>> + "Licensor" shall mean the copyright owner or entity >>> authorized by >>> + the copyright owner that is granting the License. >>> + >>> + "Legal Entity" shall mean the union of the acting entity >>> and all >>> + other entities that control, are controlled by, or are >>> under common >>> + control with that entity. For the purposes of this >>> definition, >>> + "control" means (i) the power, direct or indirect, to >>> cause the >>> + direction or management of such entity, whether by >>> contract or >>> + otherwise, or (ii) ownership of fifty percent (50%) or >>> more of the >>> + outstanding shares, or (iii) beneficial ownership of such >>> entity. >>> + >>> + "You" (or "Your") shall mean an individual or Legal Entity >>> + exercising permissions granted by this License. >>> + >>> + "Source" form shall mean the preferred form for making >>> modifications, >>> + including but not limited to software source code, >>> documentation >>> + source, and configuration files. >>> + >>> + "Object" form shall mean any form resulting from mechanical >>> + transformation or translation of a Source form, including but >>> + not limited to compiled object code, generated documentation, >>> + and conversions to other media types. >>> + >>> + "Work" shall mean the work of authorship, whether in >>> Source or >>> + Object form, made available under the License, as >>> indicated by a >>> + copyright notice that is included in or attached to the work >>> + (an example is provided in the Appendix below). >>> + >>> + "Derivative Works" shall mean any work, whether in Source >>> or Object >>> + form, that is based on (or derived from) the Work and for >>> which the >>> + editorial revisions, annotations, elaborations, or other >>> modifications >>> + represent, as a whole, an original work of authorship. For >>> the purposes >>> + of this License, Derivative Works shall not include works >>> that remain >>> + separable from, or merely link (or bind by name) to the >>> interfaces of, >>> + the Work and Derivative Works thereof. >>> + >>> + "Contribution" shall mean any work of authorship, including >>> + the original version of the Work and any modifications or >>> additions >>> + to that Work or Derivative Works thereof, that is >>> intentionally >>> + submitted to Licensor for inclusion in the Work by the >>> copyright owner >>> + or by an individual or Legal Entity authorized to submit >>> on behalf of >>> + the copyright owner. For the purposes of this definition, >>> "submitted" >>> + means any form of electronic, verbal, or written >>> communication sent >>> + to the Licensor or its representatives, including but not >>> limited to >>> + communication on electronic mailing lists, source code >>> control systems, >>> + and issue tracking systems that are managed by, or on >>> behalf of, the >>> + Licensor for the purpose of discussing and improving the >>> Work, but >>> + excluding communication that is conspicuously marked or >>> otherwise >>> + designated in writing by the copyright owner as "Not a >>> Contribution." >>> + >>> + "Contributor" shall mean Licensor and any individual or >>> Legal Entity >>> + on behalf of whom a Contribution has been received by >>> Licensor and >>> + subsequently incorporated within the Work. >>> + >>> + 2. Grant of Copyright License. Subject to the terms and >>> conditions of >>> + this License, each Contributor hereby grants to You a >>> perpetual, >>> + worldwide, non-exclusive, no-charge, royalty-free, >>> irrevocable >>> + copyright license to reproduce, prepare Derivative Works of, >>> + publicly display, publicly perform, sublicense, and >>> distribute the >>> + Work and such Derivative Works in Source or Object form. >>> + >>> + 3. Grant of Patent License. Subject to the terms and >>> conditions of >>> + this License, each Contributor hereby grants to You a >>> perpetual, >>> + worldwide, non-exclusive, no-charge, royalty-free, >>> irrevocable >>> + (except as stated in this section) patent license to make, >>> have made, >>> + use, offer to sell, sell, import, and otherwise transfer >>> the Work, >>> + where such license applies only to those patent claims >>> licensable >>> + by such Contributor that are necessarily infringed by their >>> + Contribution(s) alone or by combination of their >>> Contribution(s) >>> + with the Work to which such Contribution(s) was submitted. >>> If You >>> + institute patent litigation against any entity (including a >>> + cross-claim or counterclaim in a lawsuit) alleging that >>> the Work >>> + or a Contribution incorporated within the Work constitutes >>> direct >>> + or contributory patent infringement, then any patent licenses >>> + granted to You under this License for that Work shall >>> terminate >>> + as of the date such litigation is filed. >>> + >>> + 4. Redistribution. You may reproduce and distribute copies of >>> the >>> + Work or Derivative Works thereof in any medium, with or >>> without >>> + modifications, and in Source or Object form, provided that >>> You >>> + meet the following conditions: >>> + >>> + (a) You must give any other recipients of the Work or >>> + Derivative Works a copy of this License; and >>> + >>> + (b) You must cause any modified files to carry prominent >>> notices >>> + stating that You changed the files; and >>> + >>> + (c) You must retain, in the Source form of any Derivative >>> Works >>> + that You distribute, all copyright, patent, trademark, >>> and >>> + attribution notices from the Source form of the Work, >>> + excluding those notices that do not pertain to any >>> part of >>> + the Derivative Works; and >>> + >>> + (d) If the Work includes a "NOTICE" text file as part of its >>> + distribution, then any Derivative Works that You >>> distribute must >>> + include a readable copy of the attribution notices >>> contained >>> + within such NOTICE file, excluding those notices that >>> do not >>> + pertain to any part of the Derivative Works, in at >>> least one >>> + of the following places: within a NOTICE text file >>> distributed >>> + as part of the Derivative Works; within the Source >>> form or >>> + documentation, if provided along with the Derivative >>> Works; or, >>> + within a display generated by the Derivative Works, if >>> and >>> + wherever such third-party notices normally appear. The >>> contents >>> + of the NOTICE file are for informational purposes only >>> and >>> + do not modify the License. You may add Your own >>> attribution >>> + notices within Derivative Works that You distribute, >>> alongside >>> + or as an addendum to the NOTICE text from the Work, >>> provided >>> + that such additional attribution notices cannot be >>> construed >>> + as modifying the License. >>> + >>> + You may add Your own copyright statement to Your >>> modifications and >>> + may provide additional or different license terms and >>> conditions >>> + for use, reproduction, or distribution of Your >>> modifications, or >>> + for any such Derivative Works as a whole, provided Your use, >>> + reproduction, and distribution of the Work otherwise >>> complies with >>> + the conditions stated in this License. >>> + >>> + 5. Submission of Contributions. Unless You explicitly state >>> otherwise, >>> + any Contribution intentionally submitted for inclusion in >>> the Work >>> + by You to the Licensor shall be under the terms and >>> conditions of >>> + this License, without any additional terms or conditions. >>> + Notwithstanding the above, nothing herein shall supersede >>> or modify >>> + the terms of any separate license agreement you may have >>> executed >>> + with Licensor regarding such Contributions. >>> + >>> + 6. Trademarks. This License does not grant permission to use >>> the trade >>> + names, trademarks, service marks, or product names of the >>> Licensor, >>> + except as required for reasonable and customary use in >>> describing the >>> + origin of the Work and reproducing the content of the >>> NOTICE file. >>> + >>> + 7. Disclaimer of Warranty. Unless required by applicable law or >>> + agreed to in writing, Licensor provides the Work (and each >>> + Contributor provides its Contributions) on an "AS IS" BASIS, >>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either >>> express or >>> + implied, including, without limitation, any warranties or >>> conditions >>> + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A >>> + PARTICULAR PURPOSE. You are solely responsible for >>> determining the >>> + appropriateness of using or redistributing the Work and >>> assume any >>> + risks associated with Your exercise of permissions under >>> this License. >>> + >>> + 8. Limitation of Liability. In no event and under no legal >>> theory, >>> + whether in tort (including negligence), contract, or >>> otherwise, >>> + unless required by applicable law (such as deliberate and >>> grossly >>> + negligent acts) or agreed to in writing, shall any >>> Contributor be >>> + liable to You for damages, including any direct, indirect, >>> special, >>> + incidental, or consequential damages of any character >>> arising as a >>> + result of this License or out of the use or inability to >>> use the >>> + Work (including but not limited to damages for loss of >>> goodwill, >>> + work stoppage, computer failure or malfunction, or any and >>> all >>> + other commercial damages or losses), even if such Contributor >>> + has been advised of the possibility of such damages. >>> + >>> + 9. Accepting Warranty or Additional Liability. While >>> redistributing >>> + the Work or Derivative Works thereof, You may choose to >>> offer, >>> + and charge a fee for, acceptance of support, warranty, >>> indemnity, >>> + or other liability obligations and/or rights consistent >>> with this >>> + License. However, in accepting such obligations, You may >>> act only >>> + on Your own behalf and on Your sole responsibility, not on >>> behalf >>> + of any other Contributor, and only if You agree to indemnify, >>> + defend, and hold each Contributor harmless for any liability >>> + incurred by, or claims asserted against, such Contributor >>> by reason >>> + of your accepting any such warranty or additional liability. >>> + >>> + END OF TERMS AND CONDITIONS >>> + >>> + APPENDIX: How to apply the Apache License to your work. >>> + >>> + To apply the Apache License to your work, attach the >>> following >>> + boilerplate notice, with the fields enclosed by brackets "[]" >>> + replaced with your own identifying information. (Don't >>> include >>> + the brackets!) The text should be enclosed in the >>> appropriate >>> + comment syntax for the file format. We also recommend that a >>> + file or class name and description of purpose be included >>> on the >>> + same "printed page" as the copyright notice for easier >>> + identification within third-party archives. >>> + >>> + Copyright [yyyy] [name of copyright owner] >>> + >>> + 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. >>> + >>> >>> Added: geronimo/sandbox/plugins/global-jndi/NOTICE.txt >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/NOTICE.txt?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/NOTICE.txt (added) >>> +++ geronimo/sandbox/plugins/global-jndi/NOTICE.txt Wed Aug 16 >>> 18:32:59 2006 >>> @@ -0,0 +1,3 @@ >>> +This product includes software developed by >>> +The Apache Software Foundation (http://www.apache.org/). >>> + >>> >>> Added: geronimo/sandbox/plugins/global-jndi/pom.xml >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/pom.xml?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/pom.xml (added) >>> +++ geronimo/sandbox/plugins/global-jndi/pom.xml Wed Aug 16 >>> 18:32:59 2006 >>> @@ -0,0 +1,52 @@ >>> + >>> + >>> + >>> + >>> + >>> +>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http:// >>> maven.apache.org/maven-v4_0_0.xsd"> >>> + >>> + 4.0.0 >>> + >>> + >>> + org.apache.geronimo.modules >>> + modules >>> + 1.2-SNAPSHOT >>> + ../pom.xml >>> + >>> + >>> + org.apache.geronimo.sandbox >>> + geronimo-global-jndi >>> + Geronimo :: Global JNDI >>> + >>> + >>> + >>> + org.apache.xbean >>> + xbean-naming >>> + COL-SNAPSHOT >>> + >>> + >>> + org.apache.geronimo.modules >>> + geronimo-naming >>> + ${pom.version} >>> + >>> + >>> + backport-util-concurrent >>> + backport-util-concurrent >>> + >>> + >>> + >>> + >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextBootstrap.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/java/org/apache/geronimo/gjndi/ >>> GlobalContextBootstrap.java?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextBootstrap.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextBootstrap.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,61 @@ >>> +/** >>> + * >>> + * 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.commons.logging.Log; >>> +import org.apache.commons.logging.LogFactory; >>> +import org.apache.geronimo.gbean.AbstractName; >>> +import org.apache.geronimo.gbean.GBeanData; >>> +import org.apache.geronimo.kernel.Kernel; >>> +import org.apache.geronimo.kernel.KernelRegistry; >>> +import org.apache.xbean.naming.global.GlobalContextManager; >>> + >>> +import java.net.URI; >>> + >>> +/** >>> + * URLContextFactory for the java: namespace. >>> + * >>> + * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 >>> (Sat, 10 Dec 2005) $ >>> + */ >>> +public class GlobalContextBootstrap extends GlobalContextManager { >>> + private static final Log log = LogFactory.getLog >>> (GlobalContextBootstrap.class); >>> + >>> + private static boolean initalized; >>> + >>> + public GlobalContextBootstrap() { >>> + synchronized (GlobalContextBootstrap.class) { >>> + if (!GlobalContextBootstrap.initalized) { >>> + ClassLoader classLoader = getClass >>> ().getClassLoader(); >>> + >>> + Kernel kernel = KernelRegistry.getSingleKernel(); >>> + >>> + try { >>> + AbstractName globalContextName = new >>> AbstractName(new URI("bootstrap/global-jndi/0/boot? >>> name=GlobalContext")); >>> + kernel.loadGBean(new GBeanData >>> (globalContextName, GlobalContextGBean.GBEAN_INFO), classLoader); >>> + kernel.startGBean(globalContextName); >>> + >>> + AbstractName javaCompName = new AbstractName >>> (new URI("bootstrap/global-jndi/0/boot?name=JavaComp")); >>> + kernel.loadGBean(new GBeanData(javaCompName, >>> JavaCompContextGBean.GBEAN_INFO), classLoader); >>> + kernel.startGBean(javaCompName); >>> + } catch (Exception e) { >>> + GlobalContextBootstrap.log.error("Unable to >>> bootstrap global jndi gbeans"); >>> + } >>> + GlobalContextBootstrap.initalized = true; >>> + } >>> + } >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextGBean.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/java/org/apache/geronimo/gjndi/GlobalContextGBean.java? >>> rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextGBean.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/GlobalContextGBean.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,76 @@ >>> +/** >>> + * >>> + * 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.geronimo.gbean.GBeanLifecycle; >>> +import org.apache.geronimo.gbean.AbstractNameQuery; >>> +import org.apache.geronimo.gbean.AbstractName; >>> +import org.apache.geronimo.kernel.Kernel; >>> +import org.apache.xbean.naming.global.GlobalContextManager; >>> + >>> +import javax.naming.Context; >>> +import javax.naming.NamingException; >>> +import java.util.Collections; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public class GlobalContextGBean extends KernelContextGBean >>> implements GBeanLifecycle { >>> + public GlobalContextGBean(Kernel kernel) throws >>> NamingException { >>> + super("", new AbstractNameQuery(null, >>> Collections.EMPTY_MAP, Context.class.getName()), kernel); >>> + } >>> + >>> + public void doStart() { >>> + super.doStart(); >>> + GlobalContextManager.setGlobalContext(this); >>> + } >>> + >>> + public void doStop() { >>> + GlobalContextManager.setGlobalContext(null); >>> + super.doStop(); >>> + } >>> + >>> + public void doFail() { >>> + GlobalContextManager.setGlobalContext(null); >>> + super.doFail(); >>> + } >>> + >>> + protected String createBindingName(AbstractName >>> abstractName, Object value) throws NamingException { >>> + if (value instanceof Context) { >>> + // don't bind yourself >>> + if (value == this) return null; >>> + >>> + Context context = (Context) value; >>> + return context.getNameInNamespace(); >>> + } >>> + throw new NamingException("value is not a context: >>> abstractName=" + abstractName + " valueType=" + value.getClass >>> ().getName()); >>> + } >>> + >>> + public static final GBeanInfo GBEAN_INFO; >>> + >>> + public static GBeanInfo getGBeanInfo() { >>> + return GBEAN_INFO; >>> + } >>> + >>> + static { >>> + GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic >>> (GlobalContextGBean.class, "GlobalContext"); >>> + builder.setConstructor(new String[]{"kernel"}); >>> + GBEAN_INFO = builder.getBeanInfo(); >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/JavaCompContextGBean.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/java/org/apache/geronimo/gjndi/JavaCompContextGBean.java? >>> rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/JavaCompContextGBean.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/JavaCompContextGBean.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,49 @@ >>> +/** >>> + * >>> + * 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.geronimo.naming.java.RootContext; >>> +import org.apache.xbean.naming.context.ContextFlyweight; >>> + >>> +import javax.naming.Context; >>> +import javax.naming.NamingException; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public class JavaCompContextGBean extends ContextFlyweight { >>> + protected Context getContext() { >>> + return RootContext.getComponentContext(); >>> + } >>> + >>> + public String getNameInNamespace() throws NamingException { >>> + return "java:comp"; >>> + } >>> + >>> + public static final GBeanInfo GBEAN_INFO; >>> + >>> + public static GBeanInfo getGBeanInfo() { >>> + return GBEAN_INFO; >>> + } >>> + >>> + static { >>> + GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic >>> (JavaCompContextGBean.class, "Context"); >>> + GBEAN_INFO = builder.getBeanInfo(); >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/KernelContextGBean.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/java/org/apache/geronimo/gjndi/KernelContextGBean.java? >>> rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/KernelContextGBean.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/KernelContextGBean.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,198 @@ >>> +/** >>> + * >>> + * 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.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 org.apache.xbean.naming.context.UnmodifiableContext; >>> + >>> +import javax.naming.NamingException; >>> +import java.util.Collections; >>> +import java.util.HashMap; >>> +import java.util.Map; >>> +import java.util.Iterator; >>> +import java.util.Set; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public class KernelContextGBean extends UnmodifiableContext >>> implements GBeanLifecycle { >>> + private static final Log log = LogFactory.getLog >>> (KernelContextGBean.class); >>> + >>> + private final Kernel kernel; >>> + private final AbstractNameQuery abstractNameQuery; >>> + private final LifecycleListener listener = new >>> ContextLifecycleListener(); >>> + private final Map bindingsByAbstractName = new HashMap(); >>> + >>> + public KernelContextGBean(String nameInNamespace, >>> AbstractNameQuery abstractNameQuery, Kernel kernel) throws >>> NamingException { >>> + super(nameInNamespace, Collections.EMPTY_MAP, false); >>> + 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); >>> + } >>> + } >>> + >>> + } >>> + >>> + public void doStop() { >>> + destroy(); >>> + } >>> + >>> + public void doFail() { >>> + destroy(); >>> + } >>> + >>> + private synchronized void destroy() { >>> + kernel.getLifecycleMonitor().removeLifecycleListener >>> (listener); >>> + for (Iterator iterator = bindingsByAbstractName.values >>> ().iterator(); iterator.hasNext();) { >>> + try { >>> + String name = (String) iterator.next(); >>> + removeDeepBinding(name); >>> + } catch (NamingException ignored) { >>> + } >>> + } >>> + bindingsByAbstractName.clear(); >>> + } >>> + >>> + private class ContextLifecycleListener 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 { >>> + // get the gbean >>> + Object value = null; >>> + try { >>> + value = kernel.getGBean(abstractName); >>> + } catch (GBeanNotFoundException e) { >>> + throw new NamingException("GBean not found: " + >>> abstractName); >>> + } >>> + >>> + // generate a name for this binding >>> + String name = createBindingName(abstractName, value); >>> + if (name == null) return; >>> + >>> + // give sub classes a chance to preprocess the value >>> + value = preprocessVaue(abstractName, name, value); >>> + if (value == null) return; >>> + >>> + // bind the value >>> + >>> + addDeepBinding(name, value); >>> + >>> + // remember where we bound this value >>> + bindingsByAbstractName.put(abstractName, name); >>> + } >>> + >>> + /** >>> + * Unbinds the specified gbean. >>> + * @param abstractName the abstract name of the gbean to unbind >>> + */ >>> + protected synchronized void removeBinding(AbstractName >>> abstractName) { >>> + String name = (String) bindingsByAbstractName.remove >>> (abstractName); >>> + if (name != null) { >>> + try { >>> + removeDeepBinding(name); >>> + } catch (NamingException ignored) { >>> + } >>> + } >>> + } >>> + >>> + /** >>> + * Create a name under which we will bind the specified >>> gbean with the specified value. >>> + * By default, this method simply returns the "name" element >>> of the abstract name >>> + * @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 >>> + */ >>> + protected String createBindingName(AbstractName >>> abstractName, Object value) throws NamingException { >>> + return (String) abstractName.getName().get("name"); >>> + } >>> + >>> + /** >>> + * 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 name the name under which the gbean will be bound >>> + * @param value the gbean instance >>> + * @return the value to bind >>> + */ >>> + protected Object preprocessVaue(AbstractName abstractName, >>> String name, Object value) throws NamingException { >>> + return value; >>> + } >>> + >>> + public static final GBeanInfo GBEAN_INFO; >>> + >>> + public static GBeanInfo getGBeanInfo() { >>> + return GBEAN_INFO; >>> + } >>> + >>> + static { >>> + GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic >>> (KernelContextGBean.class, "Context"); >>> + builder.addAttribute("nameInNamespace", String.class, >>> true); >>> + builder.addAttribute("abstractNameQuery", >>> AbstractNameQuery.class, true); >>> + builder.setConstructor(new String[]{"nameInNamespace", >>> "abstractNameQuery", "kernel"}); >>> + GBEAN_INFO = builder.getBeanInfo(); >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/java/javaURLContextFactory.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/java/org/apache/geronimo/gjndi/java/ >>> javaURLContextFactory.java?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/java/javaURLContextFactory.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/java/org/apache/ >>> geronimo/gjndi/java/javaURLContextFactory.java Wed Aug 16 >>> 18:32:59 2006 >>> @@ -0,0 +1,27 @@ >>> +/** >>> + * >>> + * 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.java; >>> + >>> +import org.apache.geronimo.gjndi.GlobalContextBootstrap; >>> + >>> +/** >>> + * URLContextFactory for the java: namespace. >>> + * >>> + * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 >>> (Sat, 10 Dec 2005) $ >>> + */ >>> +public class javaURLContextFactory extends GlobalContextBootstrap { >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/site/site.xml >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/site/site.xml?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/site/site.xml (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/site/site.xml Wed >>> Aug 16 18:32:59 2006 >>> @@ -0,0 +1,62 @@ >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + org.apache.geronimo.genesis.config >>> + geronimo-skin >>> + 1.0.0-SNAPSHOT >>> + >>> + >>> + >>> + >>> + >>> + images/topleft_logo_437x64.gif >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + >>> + ${reports} >>> + >>> + >>> + >>> + >>> + >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/AbstractContextTest.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/test/org/apache/geronimo/gjndi/AbstractContextTest.java? >>> rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/AbstractContextTest.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/AbstractContextTest.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,176 @@ >>> +/** >>> + * >>> + * 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 junit.framework.TestCase; >>> + >>> +import javax.naming.Context; >>> +import javax.naming.NamingException; >>> +import javax.naming.Name; >>> +import javax.naming.NamingEnumeration; >>> +import javax.naming.NameClassPair; >>> +import javax.naming.Binding; >>> +import java.util.Map; >>> +import java.util.Iterator; >>> +import java.util.TreeSet; >>> +import java.util.HashMap; >>> + >>> +import org.apache.xbean.naming.context.ContextUtil; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public abstract class AbstractContextTest extends TestCase { >>> + public static void assertEq(Map expected, Context actual) >>> throws NamingException { >>> + AbstractContextTest.assertEq(ContextUtil.buildMapTree >>> (expected), actual, actual, null); >>> + } >>> + >>> + public static void assertEq(Map expected, String >>> pathInExpected, Context actual) throws NamingException { >>> + ContextUtil.Node node = ContextUtil.buildMapTree(expected); >>> + Name parsedName = actual.getNameParser("").parse >>> (pathInExpected); >>> + for (int i = 0; i < parsedName.size(); i++) { >>> + String part = parsedName.get(i); >>> + Object value = node.get(part); >>> + if (value == null) { >>> + throw new NamingException("look for " + >>> parsedName.getPrefix(i+1) + " in node tree is null "); >>> + } >>> + node = (ContextUtil.Node) value; >>> + } >>> + >>> + AbstractContextTest.assertEq(node, actual, actual, null); >>> + } >>> + >>> + private static void assertEq(ContextUtil.Node node, Context >>> rootContext, Context currentContext, String path) throws >>> NamingException { >>> + for (Iterator iterator = node.entrySet().iterator(); >>> iterator.hasNext();) { >>> + Map.Entry entry = (Map.Entry) iterator.next(); >>> + String expectedName = (String) entry.getKey(); >>> + Object expectedValue = entry.getValue(); >>> + >>> + String fullName = path == null ? expectedName : path >>> + "/" + expectedName; >>> + >>> + // verify we can lookup by string name and parsed >>> name using the root context and current context >>> + Object value = AbstractContextTest.assertLookup >>> (expectedValue, currentContext, expectedName); >>> + Object absoluteValue = >>> AbstractContextTest.assertLookup(expectedValue, rootContext, >>> fullName); >>> + assertSame(fullName, value, absoluteValue); >>> + >>> + if (expectedValue instanceof ContextUtil.Node) { >>> + ContextUtil.Node expectedNode = >>> (ContextUtil.Node) expectedValue; >>> + >>> + // verufy listing of this context returns the >>> expected results >>> + AbstractContextTest.assertList(expectedNode, >>> currentContext, expectedName); >>> + AbstractContextTest.assertList(expectedNode, >>> rootContext, fullName); >>> + >>> + AbstractContextTest.assertEq(expectedNode, >>> rootContext, (Context) value, fullName); >>> + } >>> + } >>> + } >>> + >>> + public static Object assertLookup(Object expectedValue, >>> Context context, String name) throws NamingException { >>> + Object value = context.lookup(name); >>> + >>> + String contextName = context.getNameInNamespace(); >>> + if (contextName == null || contextName.length() == 0) >>> contextName = ""; >>> + >>> + assertNotNull("lookup of " + name + " on " + >>> contextName + " returned null", value); >>> + >>> + if (expectedValue instanceof ContextUtil.Node) { >>> + assertTrue("Expected lookup of " + name + " on " + >>> contextName + " to return a Context, but got a " + value.getClass >>> ().getName(), >>> + value instanceof Context); >>> + } else { >>> + assertEquals("lookup of " + name + " on " + >>> contextName, expectedValue, value); >>> + } >>> + >>> + Name parsedName = context.getNameParser("").parse(name); >>> + Object valueFromParsedName = context.lookup(parsedName); >>> + assertSame("lookup of " + name + " on " + contextName + >>> " using a parsed name", value, valueFromParsedName); >>> + >>> + return value; >>> + } >>> + >>> + public static void assertList(ContextUtil.Node node, Context >>> context, String name) throws NamingException { >>> + String contextName = context.getNameInNamespace(); >>> + if (contextName == null || contextName.length() == 0) >>> contextName = ""; >>> + >>> + AbstractContextTest.assertListResults(node, context.list >>> (name), contextName, name, false); >>> + AbstractContextTest.assertListResults(node, >>> context.listBindings(name), contextName, name, true); >>> + >>> + Name parsedName = context.getNameParser("").parse(name); >>> + AbstractContextTest.assertListResults(node, context.list >>> (parsedName), contextName, "parsed name " + name, false); >>> + AbstractContextTest.assertListResults(node, >>> context.listBindings(parsedName), contextName, "parsed name " + >>> name, true); >>> + } >>> + >>> + public static void assertListResults(ContextUtil.Node node, >>> NamingEnumeration enumeration, String contextName, String name, >>> boolean wasListBinding) { >>> + Map actualValues; >>> + if (wasListBinding) { >>> + actualValues = >>> AbstractContextTest.toListBindingResults(enumeration); >>> + } else { >>> + actualValues = AbstractContextTest.toListResults >>> (enumeration); >>> + } >>> + >>> + for (Iterator iterator = node.entrySet().iterator(); >>> iterator.hasNext();) { >>> + Map.Entry entry = (Map.Entry) iterator.next(); >>> + String expectedName = (String) entry.getKey(); >>> + Object expectedValue = entry.getValue(); >>> + >>> + Object actualValue = actualValues.get(expectedName); >>> + >>> + assertNotNull("list of " + name + " on " + >>> contextName + " did not find value for " + name, 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(), >>> + actualValue instanceof Context); >>> + } else { >>> + assertEquals("list of " + name + " on " + >>> contextName + " for value for " + name, expectedValue, actualValue); >>> + } >>> + } else { >>> + if (!(expectedValue instanceof ContextUtil.Node)) { >>> + assertEquals("list of " + name + " on " + >>> contextName + " for value for " + name, expectedValue.getClass >>> ().getName(), actualValue); >>> + } else { >>> + // can't really test this since it the value >>> is the name of a nested node class >>> + } >>> + } >>> + } >>> + >>> + TreeSet extraNames = new TreeSet(actualValues.keySet()); >>> + extraNames.removeAll(node.keySet()); >>> + if (!extraNames.isEmpty()) { >>> + fail("list of " + name + " on " + contextName + " >>> found extra values: " + extraNames); >>> + } >>> + } >>> + >>> + private static Map toListResults(NamingEnumeration >>> enumeration) { >>> + Map result = new HashMap(); >>> + while (enumeration.hasMoreElements()) { >>> + NameClassPair nameClassPair = (NameClassPair) >>> enumeration.nextElement(); >>> + String name = nameClassPair.getName(); >>> + assertFalse(result.containsKey(name)); >>> + result.put(name, nameClassPair.getClassName()); >>> + } >>> + return result; >>> + } >>> + >>> + private static Map toListBindingResults(NamingEnumeration >>> enumeration) { >>> + Map result = new HashMap(); >>> + while (enumeration.hasMoreElements()) { >>> + Binding binding = (Binding) enumeration.nextElement(); >>> + String name = binding.getName(); >>> + assertFalse(result.containsKey(name)); >>> + result.put(name, binding.getObject()); >>> + } >>> + return result; >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/JavaCompContextTest.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/test/org/apache/geronimo/gjndi/JavaCompContextTest.java? >>> rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/JavaCompContextTest.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/JavaCompContextTest.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,206 @@ >>> +/** >>> + * >>> + * 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 junit.framework.TestCase; >>> + >>> +import javax.naming.NamingException; >>> +import javax.naming.CompositeName; >>> +import javax.naming.CompoundName; >>> +import javax.naming.Context; >>> +import javax.naming.NamingEnumeration; >>> +import javax.naming.NameClassPair; >>> +import javax.naming.Binding; >>> +import javax.naming.LinkRef; >>> +import javax.naming.InitialContext; >>> +import java.util.Map; >>> +import java.util.HashMap; >>> +import java.util.Iterator; >>> +import java.util.NoSuchElementException; >>> +import java.util.Properties; >>> +import java.util.Collections; >>> + >>> +import org.apache.geronimo.naming.java.RootContext; >>> +import org.apache.xbean.naming.context.UnmodifiableContext; >>> +import org.apache.xbean.naming.context.ImmutableContext; >>> +import org.apache.xbean.naming.global.GlobalContextManager; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public class JavaCompContextTest extends TestCase { >>> + protected UnmodifiableContext readOnlyContext; >>> + protected Properties syntax; >>> + protected Map envBinding; >>> + protected Context initialContext; >>> + protected Context compContext; >>> + protected Context envContext; >>> + >>> + public void testInitialContext() throws NamingException { >>> + assertEquals("Hello", initialContext.lookup("java:comp/ >>> env/hello")); >>> + assertEquals("Hello", initialContext.lookup(new >>> CompositeName("java:comp/env/hello"))); >>> + } >>> + >>> + public void testLookup() throws NamingException { >>> + assertEquals("Hello", envContext.lookup("hello")); >>> + assertEquals("Hello", compContext.lookup("env/hello")); >>> + try { >>> + envContext.lookup("foo"); >>> + fail(); >>> + } catch (NamingException e) { >>> + // OK >>> + } >>> + assertEquals("Hello", envContext.lookup(new CompositeName >>> ("hello"))); >>> + assertEquals("Hello", compContext.lookup(new >>> CompositeName("env/hello"))); >>> + assertEquals("Hello", envContext.lookup(new CompoundName >>> ("hello", syntax))); >>> + assertEquals("Hello", compContext.lookup(new CompoundName >>> ("env/hello", syntax))); >>> + >>> + assertEquals(envContext, envContext.lookup("")); >>> + } >>> + >>> + public void testSubContext() throws NamingException { >>> + assertEquals("long name", initialContext.lookup >>> ("java:comp/env/here/there/anywhere")); >>> + Context intermediate = (Context)initialContext.lookup >>> ("java:comp/env/here/there"); >>> + assertNotNull(intermediate); >>> + assertEquals("long name", intermediate.lookup("anywhere")); >>> + } >>> + >>> + public void testSchemeLookup() throws NamingException { >>> +// envContext.lookup("dns:apache.org"); >>> + assertEquals("Hello", envContext.lookup("java:comp/env/ >>> hello")); >>> + assertEquals("Hello", compContext.lookup("java:comp/env/ >>> hello")); >>> + } >>> + >>> + public void testLookupLink() throws NamingException { >>> + assertEquals("Hello", envContext.lookup("link")); >>> + } >>> + >>> + public void testComposeName() throws NamingException { >>> + assertEquals("org/research/user/jane", >>> envContext.composeName("user/jane", "org/research")); >>> + assertEquals("research/user/jane", envContext.composeName >>> ("user/jane", "research")); >>> + assertEquals(new CompositeName("org/research/user/ >>> jane"), envContext.composeName(new CompositeName("user/jane"), >>> new CompositeName("org/research"))); >>> + assertEquals(new CompositeName("research/user/jane"), >>> envContext.composeName(new CompositeName("user/jane"), new >>> CompositeName("research"))); >>> + } >>> + >>> + public void testList() throws NamingException { >>> + NamingEnumeration ne; >>> + Map expected; >>> + Map result; >>> + >>> + expected = new HashMap(); >>> + for (Iterator i = envBinding.entrySet().iterator(); >>> i.hasNext();) { >>> + Map.Entry entry = (Map.Entry) i.next(); >>> + expected.put(entry.getKey(), entry.getValue >>> ().getClass().getName()); >>> + } >>> + ne = envContext.list(""); >>> + result = new HashMap(); >>> + while (ne.hasMore()) { >>> + NameClassPair pair = (NameClassPair) ne.next(); >>> + result.put(pair.getName(), pair.getClassName()); >>> + } >>> + assertEquals(expected, result); >>> + >>> + try { >>> + ne.next(); >>> + fail(); >>> + } catch (NoSuchElementException e) { >>> + // ok >>> + } >>> + try { >>> + ne.nextElement(); >>> + fail(); >>> + } catch (NoSuchElementException e) { >>> + // ok >>> + } >>> + } >>> + >>> + public void testListBindings() throws NamingException { >>> + NamingEnumeration ne; >>> + ne = envContext.listBindings(""); >>> + int count = 0; >>> + while (ne.hasMore()) { >>> + count ++; >>> + Binding pair = (Binding) ne.next(); >>> + assertTrue(envBinding.containsKey(pair.getName())); >>> + if (! (envBinding.get(pair.getName()) instanceof >>> Context)) { >>> + assertEquals(pair.getObject(), envBinding.get >>> (pair.getName())); >>> + } >>> + } >>> + assertEquals(envBinding.size(), count); >>> + >>> + try { >>> + ne.next(); >>> + fail(); >>> + } catch (NoSuchElementException e) { >>> + // ok >>> + } >>> + try { >>> + ne.nextElement(); >>> + fail(); >>> + } catch (NoSuchElementException e) { >>> + // ok >>> + } >>> + } >>> + >>> + public void testSpeed() throws NamingException { >>> + Context comp = (Context) initialContext.lookup >>> ("java:comp"); >>> + >>> + long start = System.currentTimeMillis(); >>> + for (int i=0; i < 1000000; i++) { >>> + // initialContext.lookup("java:comp/hello"); // this >>> is sloooow due to scheme resolution >>> + // envContext.lookup("hello"); >>> + comp.lookup("env/hello"); >>> + } >>> + >>> + long end = System.currentTimeMillis(); >>> + System.out.println("lookup(String) milliseconds: " + >>> (end - start)); >>> + } >>> + >>> + protected void setUp() throws Exception { >>> + super.setUp(); >>> + System.setProperty("java.naming.factory.initial", >>> GlobalContextManager.class.getName()); >>> + System.setProperty("java.naming.factory.url.pkgs", >>> "org.apache.geronimo.knaming"); >>> + >>> + LinkRef link = new LinkRef("java:comp/env/hello"); >>> + >>> + Map bindings = new HashMap(); >>> + bindings.put("env/hello", "Hello"); >>> + bindings.put("env/world", "Hello World"); >>> + bindings.put("env/here/there/anywhere", "long name"); >>> + bindings.put("env/link", link); >>> + >>> + readOnlyContext = new UnmodifiableContext(bindings); >>> + >>> + envBinding = new HashMap(); >>> + envBinding.put("hello", "Hello"); >>> + envBinding.put("world", "Hello World"); >>> + envBinding.put("here", readOnlyContext.lookup("env/here")); >>> + envBinding.put("link", link); >>> + >>> + RootContext.setComponentContext(readOnlyContext); >>> + >>> + Context javaCompContext = new JavaCompContextGBean(); >>> + Context globalContext = new ImmutableContext >>> (Collections.singletonMap(javaCompContext.getNameInNamespace(), >>> javaCompContext)); >>> + GlobalContextManager.setGlobalContext(globalContext); >>> + >>> + initialContext = new InitialContext(); >>> + compContext = (Context) initialContext.lookup("java:comp"); >>> + envContext = (Context) initialContext.lookup("java:comp/ >>> env"); >>> + >>> + syntax = new Properties(); >>> + } >>> +} >>> >>> Added: geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/KernelContextGBeanTest.java >>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/global- >>> jndi/src/test/org/apache/geronimo/gjndi/ >>> KernelContextGBeanTest.java?rev=432101&view=auto >>> ==================================================================== >>> ========== >>> --- geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/KernelContextGBeanTest.java (added) >>> +++ geronimo/sandbox/plugins/global-jndi/src/test/org/apache/ >>> geronimo/gjndi/KernelContextGBeanTest.java Wed Aug 16 18:32:59 2006 >>> @@ -0,0 +1,171 @@ >>> +/** >>> + * >>> + * 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.GBeanData; >>> +import org.apache.geronimo.gbean.GBeanInfo; >>> +import org.apache.geronimo.gbean.GBeanInfoBuilder; >>> +import org.apache.geronimo.gbean.AbstractName; >>> +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.geronimo.naming.java.RootContext; >>> +import org.apache.xbean.naming.context.ImmutableContext; >>> +import org.apache.xbean.naming.global.GlobalContextManager; >>> + >>> +import javax.naming.Context; >>> +import javax.naming.InitialContext; >>> +import java.util.HashMap; >>> +import java.util.Hashtable; >>> +import java.util.Map; >>> +import java.util.Iterator; >>> +import java.util.Collections; >>> + >>> +/** >>> + * @version $Rev$ $Date$ >>> + */ >>> +public class KernelContextGBeanTest extends AbstractContextTest { >>> + private Kernel kernel; >>> + private EditableConfigurationManager configurationManager; >>> + private ConfigurationData configurationData; >>> + private GBeanInfo immutableContextGBeanInfo; >>> + private Hashtable contextEnv; >>> + >>> + public void test() throws Exception { >>> + Map globalBindings = new HashMap(); >>> + globalBindings.put("java:comp/string", "foo"); >>> + globalBindings.put("java:comp/nested/context/string", >>> "bar"); >>> + globalBindings.put("java:comp/a/b/c/d/e/string", "beer"); >>> + globalBindings.put("java:comp/a/b/c/d/e/one", new Integer >>> (1)); >>> + globalBindings.put("java:comp/a/b/c/d/e/two", new Integer >>> (2)); >>> + globalBindings.put("java:comp/a/b/c/d/e/three", new >>> Integer(3)); >>> + globalBindings.put("test/env/foo", new Integer(42)); >>> + globalBindings.put("test/baz", "caz"); >>> + >>> + Map javaCompBindings = getNestedBindings(globalBindings, >>> "java:comp/"); >>> + ImmutableContext javaCompContext = new ImmutableContext >>> (javaCompBindings); >>> + RootContext.setComponentContext(javaCompContext); >>> + >>> + GBeanData javaComp = configurationData.addGBean >>> ("JavaComp", JavaCompContextGBean.GBEAN_INFO); >>> + AbstractName javaCompName = javaComp.getAbstractName(); >>> + >>> + GBeanData test = configurationData.addGBean("Test", >>> immutableContextGBeanInfo); >>> + AbstractName testName = test.getAbstractName(); >>> + test.setAttribute("nameInNamespace", "test"); >>> + Map testBindings = getNestedBindings(globalBindings, >>> "test/"); >>> + test.setAttribute("bindings", testBindings); >>> + >>> + configurationManager.loadConfiguration(configurationData); >>> + configurationManager.startConfiguration >>> (configurationData.getId()); >>> + >>> + InitialContext ctx = new InitialContext(contextEnv); >>> + assertEq(globalBindings, ctx); >>> + >>> + // >>> + // stop test context >>> + // >>> + kernel.stopGBean(testName); >>> + >>> + HashMap javaCompOnlyBindings = new HashMap(globalBindings); >>> + javaCompOnlyBindings.remove("test/env/foo"); >>> + javaCompOnlyBindings.remove("test/baz"); >>> + assertEq(javaCompOnlyBindings, ctx); >>> + >>> + // >>> + // stop java context >>> + // >>> + kernel.stopGBean(javaCompName); >>> + >>> + assertEq(Collections.EMPTY_MAP, ctx); >>> + >>> + >>> + // >>> + // restart java context >>> + // >>> + kernel.startGBean(javaCompName); >>> + >>> + assertEq(javaCompOnlyBindings, ctx); >>> + >>> + // >>> + // restart test context >>> + // >>> + kernel.startGBean(testName); >>> + >>> + 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()); >>> + >>> + configurationManager = >>> ConfigurationUtil.getEditableConfigurationManager(kernel); >>> + >>> + configurationData = new ConfigurationData(new Artifact >>> ("test", "test", "", "car"), kernel.getNaming()); >>> + configurationData.addGBean("GlobalContext", >>> GlobalContextGBean.GBEAN_INFO); >>> + >>> + GBeanInfoBuilder builder = new GBeanInfoBuilder >>> (ImmutableContext.class); >>> + builder.setConstructor(new String[] {"nameInNamespace", >>> "bindings", "cacheReferences"}); >>> + builder.addAttribute("nameInNamespace", String.class, >>> true); >>> + builder.addAttribute("bindings", Map.class, true); >>> + builder.addAttribute("cacheReferences", boolean.class, >>> true); >>> + immutableContextGBeanInfo = builder.getBeanInfo(); >>> + >>> + contextEnv = new Hashtable(); >>> + contextEnv.put(Context.INITIAL_CONTEXT_FACTORY, >>> GlobalContextManager.class.getName()); >>> + } >>> + >>> + protected void tearDown() throws Exception { >>> + kernel.shutdown(); >>> + super.tearDown(); >>> + } >>> +} >>> >>> >