aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alasdair Nottingham <...@apache.org>
Subject Re: svn commit: r1040645 - in /incubator/aries/trunk/jndi: ./ jndi-bundle/ jndi-bundle/src/main/java/org/apache/aries/jndi/priv/ jndi-rmi/ jndi-rmi/src/ jndi-rmi/src/main/ jndi-rmi/src/main/java/ jndi-rmi/src/main/java/org/ jndi-rmi/src/main/java/org
Date Thu, 02 Dec 2010 09:41:25 GMT
I don't think you should throw an Exception if you can't load the
rmiURLContextFactory from the JVM. The class is a JVM internal which
means that it isn't guaranteed to run on all JVMs. The result of
throwing the Exception is it will escape and cause the bundle to be
stopped by the framework. When merged into the uber bundle it will
cause the JNDI function to not work if this rmiURLContextFactory class
cannot be loaded.

Alasdair

On 30 November 2010 17:02,  <gnodet@apache.org> wrote:
> Author: gnodet
> Date: Tue Nov 30 17:02:46 2010
> New Revision: 1040645
>
> URL: http://svn.apache.org/viewvc?rev=1040645&view=rev
> Log:
> [ARIES-503] Support for JNDI RMI URL Handler
>
> Added:
>    incubator/aries/trunk/jndi/jndi-rmi/
>    incubator/aries/trunk/jndi/jndi-rmi/pom.xml
>    incubator/aries/trunk/jndi/jndi-rmi/src/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/
>    incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/Activator.java
> Modified:
>    incubator/aries/trunk/jndi/jndi-bundle/pom.xml
>    incubator/aries/trunk/jndi/jndi-bundle/src/main/java/org/apache/aries/jndi/priv/Activator.java
>    incubator/aries/trunk/jndi/pom.xml
>
> Modified: incubator/aries/trunk/jndi/jndi-bundle/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-bundle/pom.xml?rev=1040645&r1=1040644&r2=1040645&view=diff
> ==============================================================================
> --- incubator/aries/trunk/jndi/jndi-bundle/pom.xml (original)
> +++ incubator/aries/trunk/jndi/jndi-bundle/pom.xml Tue Nov 30 17:02:46 2010
> @@ -59,6 +59,10 @@
>         </dependency>
>         <dependency>
>             <groupId>org.apache.aries.jndi</groupId>
> +            <artifactId>org.apache.aries.jndi.rmi</artifactId>
> +        </dependency>
> +        <dependency>
> +            <groupId>org.apache.aries.jndi</groupId>
>             <artifactId>org.apache.aries.jndi.api</artifactId>
>         </dependency>
>         <dependency>
> @@ -87,6 +91,7 @@
>                                 <includes>
>                                     <include>org.apache.aries.jndi:org.apache.aries.jndi.core</include>
>                                     <include>org.apache.aries.jndi:org.apache.aries.jndi.url</include>
> +                                    <include>org.apache.aries.jndi:org.apache.aries.jndi.rmi</include>
>                                     <include>org.apache.aries.jndi:org.apache.aries.jndi.api</include>
>                                 </includes>
>                             </artifactSet>
> @@ -104,6 +109,12 @@
>                                     </excludes>
>                                 </filter>
>                                 <filter>
> +                                    <artifact>org.apache.aries.jndi:org.apache.aries.jndi.rmi</artifact>
> +                                    <excludes>
> +                                        <exclude>org/**</exclude>
> +                                    </excludes>
> +                                </filter>
> +                                <filter>
>                                     <artifact>org.apache.aries.jndi:org.apache.aries.jndi.api</artifact>
>                                     <excludes>
>                                         <exclude>org/**</exclude>
> @@ -152,6 +163,11 @@
>                                         </artifactItem>
>                                         <artifactItem>
>                                             <groupId>org.apache.aries.jndi</groupId>
> +                                            <artifactId>org.apache.aries.jndi.rmi</artifactId>
> +                                            <classifier>sources</classifier>
> +                                        </artifactItem>
> +                                        <artifactItem>
> +                                            <groupId>org.apache.aries.jndi</groupId>
>                                             <artifactId>org.apache.aries.jndi.api</artifactId>
>                                             <classifier>sources</classifier>
>                                         </artifactItem>
>
> Modified: incubator/aries/trunk/jndi/jndi-bundle/src/main/java/org/apache/aries/jndi/priv/Activator.java
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-bundle/src/main/java/org/apache/aries/jndi/priv/Activator.java?rev=1040645&r1=1040644&r2=1040645&view=diff
> ==============================================================================
> --- incubator/aries/trunk/jndi/jndi-bundle/src/main/java/org/apache/aries/jndi/priv/Activator.java
(original)
> +++ incubator/aries/trunk/jndi/jndi-bundle/src/main/java/org/apache/aries/jndi/priv/Activator.java
Tue Nov 30 17:02:46 2010
> @@ -28,7 +28,8 @@ public class Activator implements Bundle
>     public Activator() {
>         this.activators = new BundleActivator[]{
>                 new org.apache.aries.jndi.startup.Activator(),
> -                new org.apache.aries.jndi.url.Activator()
> +                new org.apache.aries.jndi.url.Activator(),
> +                new org.apache.aries.jndi.rmi.Activator()
>         };
>     }
>
>
> Added: incubator/aries/trunk/jndi/jndi-rmi/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-rmi/pom.xml?rev=1040645&view=auto
> ==============================================================================
> --- incubator/aries/trunk/jndi/jndi-rmi/pom.xml (added)
> +++ incubator/aries/trunk/jndi/jndi-rmi/pom.xml Tue Nov 30 17:02:46 2010
> @@ -0,0 +1,57 @@
> +<!--
> + 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.
> +-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
> +    <modelVersion>4.0.0</modelVersion>
> +    <parent>
> +        <groupId>org.apache.aries.jndi</groupId>
> +        <artifactId>jndi</artifactId>
> +        <version>0.3-incubating-SNAPSHOT</version>
> +    </parent>
> +
> +    <artifactId>org.apache.aries.jndi.rmi</artifactId>
> +    <packaging>bundle</packaging>
> +    <name>Apache Aries JNDI RMI Handler</name>
> +    <description>
> +      This bundle contains the JNDI RMI handler
> +    </description>
> +
> +    <properties>
> +        <aries.osgi.activator>
> +            org.apache.aries.jndi.rmi.Activator
> +        </aries.osgi.activator>
> +    </properties>
> +
> +    <dependencies>
> +        <dependency>
> +            <groupId>org.apache.aries.jndi</groupId>
> +            <artifactId>org.apache.aries.jndi.api</artifactId>
> +            <scope>provided</scope>
> +        </dependency>
> +        <dependency>
> +            <groupId>org.apache.aries</groupId>
> +            <artifactId>org.apache.aries.util</artifactId>
> +        </dependency>
> +        <dependency>
> +            <groupId>org.osgi</groupId>
> +            <artifactId>org.osgi.core</artifactId>
> +            <scope>provided</scope>
> +        </dependency>
> +    </dependencies>
> +
> +</project>
>
> Added: incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/Activator.java
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/Activator.java?rev=1040645&view=auto
> ==============================================================================
> --- incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/Activator.java
(added)
> +++ incubator/aries/trunk/jndi/jndi-rmi/src/main/java/org/apache/aries/jndi/rmi/Activator.java
Tue Nov 30 17:02:46 2010
> @@ -0,0 +1,57 @@
> +/*
> + * 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.aries.jndi.rmi;
> +
> +import java.util.Hashtable;
> +import java.util.logging.Logger;
> +
> +import javax.naming.spi.ObjectFactory;
> +
> +import org.osgi.framework.BundleActivator;
> +import org.osgi.framework.BundleContext;
> +import org.osgi.framework.ServiceRegistration;
> +import org.osgi.service.jndi.JNDIConstants;
> +
> +public class Activator implements BundleActivator {
> +
> +    private ServiceRegistration reg;
> +
> +    public void start(BundleContext context) {
> +
> +        Logger.getLogger("org.apache.aries.jndi.rmi").fine("Registering RMI url
handler");
> +
> +        try {
> +            Hashtable<Object, Object> props = new Hashtable<Object, Object>();
> +            props.put(JNDIConstants.JNDI_URLSCHEME, new String[] { "rmi" });
> +            reg = context.registerService(
> +                        ObjectFactory.class.getName(),
> +                        ClassLoader.getSystemClassLoader().loadClass("com.sun.jndi.url.rmi.rmiURLContextFactory").newInstance(),
> +                        props);
> +        }
> +        catch (Exception e)
> +        {
> +            throw new RuntimeException("Unable to register jndi url handler for
rmi", e);
> +        }
> +    }
> +
> +    public void stop(BundleContext context) {
> +        reg.unregister();
> +    }
> +
> +}
>
> Modified: incubator/aries/trunk/jndi/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/pom.xml?rev=1040645&r1=1040644&r2=1040645&view=diff
> ==============================================================================
> --- incubator/aries/trunk/jndi/pom.xml (original)
> +++ incubator/aries/trunk/jndi/pom.xml Tue Nov 30 17:02:46 2010
> @@ -62,6 +62,11 @@
>             </dependency>
>             <dependency>
>                 <groupId>org.apache.aries.jndi</groupId>
> +                <artifactId>org.apache.aries.jndi.rmi</artifactId>
> +                <version>${version}</version>
> +            </dependency>
> +            <dependency>
> +                <groupId>org.apache.aries.jndi</groupId>
>                 <artifactId>org.apache.aries.jndi</artifactId>
>                 <version>${version}</version>
>             </dependency>
> @@ -98,6 +103,7 @@
>         <module>jndi-api</module>
>         <module>jndi-core</module>
>         <module>jndi-url</module>
> +        <module>jndi-rmi</module>
>         <module>jndi-bundle</module>
>     </modules>
>
>
>
>



-- 
Alasdair Nottingham
not@apache.org

Mime
View raw message