geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r934301 [2/2] - in /geronimo/yoko/trunk: ./ yoko-core/ yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ yoko-core/src/main/java/org/apache/yoko/orb/OB/ yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ yoko-core/src/main/java/org/apach...
Date Thu, 15 Apr 2010 07:03:03 GMT
Added: geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml?rev=934301&view=auto
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml (added)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml Thu
Apr 15 07:03:02 2010
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!--
+
+  blueprint configuration for jndi providers
+  -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <!--<service id="yokoRegistry"-->
+             <!--interface="org.apache.yoko.osgi.ProviderRegistry"-->
+             <!--activation="eager">-->
+        <!--<ref component-id="yokoRegistryBean"/>-->
+    <!--</service>-->
+    <service id="yokoRegister"
+             interface="org.apache.yoko.osgi.locator.Register"
+             activation="eager">
+        <ref component-id="yokoRegistryBean"/>
+    </service>
+    <bean id="yokoRegistryBean"
+          class="org.apache.yoko.osgi.locator.ProviderRegistryImpl"
+          init-method="start"
+          destroy-method="stop"
+          activation="eager"/>
+
+    <bean class="org.apache.yoko.osgi.locator.ProviderBean"
+          activation="eager"
+          init-method="start"
+          destroy-method="stop">
+        <argument>
+            <value>javax.rmi.CORBA.UtilClass</value>
+        </argument>
+        <argument>
+            <value>org.apache.yoko.rmi.impl.UtilImpl</value>
+        </argument>
+        <argument>
+            <ref component-id="blueprintBundle"/>
+        </argument>
+        <argument>
+            <ref component-id="yokoRegistryBean"/>
+        </argument>
+    </bean>
+    <bean class="org.apache.yoko.osgi.locator.ServiceBean"
+          activation="eager"
+          init-method="start"
+          destroy-method="stop">
+        <argument>
+            <value>javax.rmi.CORBA.PortableRemoteObjectClass</value>
+        </argument>
+        <argument>
+            <value>org.apache.yoko.rmi.impl.PortableRemoteObjectImpl</value>
+        </argument>
+        <argument>
+            <ref component-id="blueprintBundle"/>
+        </argument>
+        <argument>
+            <ref component-id="yokoRegistryBean"/>
+        </argument>
+    </bean>
+    <bean class="org.apache.yoko.osgi.locator.ServiceBean"
+          activation="eager"
+          init-method="start"
+          destroy-method="stop">
+        <argument>
+            <value>org.apache.yoko.rmi.PortableRemoteObjectExtClass</value>
+        </argument>
+        <argument>
+            <value>org.apache.yoko.rmi.impl.PortableRemoteObjectExtImpl</value>
+        </argument>
+        <argument>
+            <ref component-id="blueprintBundle"/>
+        </argument>
+        <argument>
+            <ref component-id="yokoRegistryBean"/>
+        </argument>
+    </bean>
+
+
+</blueprint>
\ No newline at end of file

Propchange: geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/yoko/trunk/yoko-rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java?rev=934301&r1=934300&r2=934301&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
(original)
+++ geronimo/yoko/trunk/yoko-rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
Thu Apr 15 07:03:02 2010
@@ -18,6 +18,8 @@
 
 package org.apache.yoko.rmispec.util;
 
+import org.apache.yoko.osgi.ProviderLocator;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -39,16 +41,10 @@ public class UtilLoader {
             throws ClassNotFoundException {
         Class result = null;
 
-        if (loader != null) {
-            try {
-                logger.finer("trying provided class loader");
-                result = loader.loadClass(name);
-            } catch (ClassNotFoundException ex) {
-                // skip //
-            }
-
-            if (result != null)
-                return result;
+        try {
+            return ProviderLocator.loadClass(name, null, loader);
+        } catch (ClassNotFoundException e) {
+            //skip
         }
 
         ClassLoader stackLoader = null;

Modified: geronimo/yoko/trunk/yoko-spec-corba/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-spec-corba/pom.xml?rev=934301&r1=934300&r2=934301&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-spec-corba/pom.xml (original)
+++ geronimo/yoko/trunk/yoko-spec-corba/pom.xml Thu Apr 15 07:03:02 2010
@@ -30,6 +30,16 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

Copied: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java
(from r932781, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java)
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java?p2=geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java&p1=geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java&r1=932781&r2=934301&rev=934301&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
(original)
+++ geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java
Thu Apr 15 07:03:02 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.geronimo.osgi.locator;
+package org.apache.yoko.osgi;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -33,58 +33,21 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.geronimo.osgi.registry.api.ProviderRegistry;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
 public class ProviderLocator {
-    // our bundle context
-    static private BundleContext context;
     // a service tracker for the registry service
     // NB:  This is declared as just Object to avoid classloading issues if we're running
     // outside of an OSGi environment.
-    static private Object registryTracker;
+    static private ProviderRegistry registry;
 
     private ProviderLocator() {
         // private constructor to prevent an instance from getting created.
     }
 
-    /**
-     * initialize the tracker statics for this bundle
-     *
-     * @param c      The starup BundleContext.
-     */
-    public static void init(BundleContext c) {
-        try {
-            // just create a tracker for our lookup service
-            // NB:  We use the hard coded name in case the registry service has not
-            // been started first.  The ServiceTracker itself only uses the string name.
-            // We need to avoid trying to load the ProviderRegistry interface until the
-            // registry tracker returns a non-null service instance.
-            registryTracker = new ServiceTracker(c, "org.apache.geronimo.osgi.registry.api.ProviderRegistry",
null);
-            ((ServiceTracker)registryTracker).open();
-            // do this last...it helps indicate if we have an initialized registry.
-            context = c;
-        } catch (Throwable e) {
-            // if there were any errors, then the registry is not available.
-            registryTracker = null;
-        }
-    }
-
 
-    /**
-     * Cleanup resources on bundle shutdown.
-     */
-    public static void destroy() {
-        if (registryTracker != null) {
-            // shutdown our tracking of the provider registry.
-            ((ServiceTracker)registryTracker).close();
-            registryTracker = null;
-        }
+    public static void setRegistry(ProviderRegistry registry) {
+        ProviderLocator.registry = registry;
     }
 
-
     /**
      * Locate a class by its provider id indicator. .
      *
@@ -95,7 +58,7 @@ public class ProviderLocator {
      *         loaded.
      */
     static public Class<?> locate(String providerId) {
-        Object registry = getRegistry();
+        ProviderRegistry registry = getRegistry();
         // if no registry service available, this is a failure
         if (registry == null) {
             return null;
@@ -105,7 +68,7 @@ public class ProviderLocator {
         // safe now.
 
         // the rest of the work is done by the registry
-        return ((ProviderRegistry)registry).locate(providerId);
+        return registry.locate(providerId);
     }
 
     /**
@@ -614,17 +577,7 @@ public class ProviderLocator {
      * @return The registry service instance, or null if it is not
      *         available for any reason.
      */
-    private static Object getRegistry() {
-        // if not initialized in an OSGi environment, this is a failure
-        if (registryTracker == null) {
-            return null;
-        }
-        // get the service, if it exists.  NB:  it is only safe to reference the
-        // interface class if the tracker returns a non-null service object.  The
-        // interface class will not be loaded in our bundle context until the
-        // service class can be statisfied.  Therefore, we always return this as
-        // just an object and the call needs to perform the cast, which will
-        // force the classload at that time.
-        return ((ServiceTracker)registryTracker).getService();
+    private static ProviderRegistry getRegistry() {
+        return registry;
     }
 }

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java
(from r932781, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java)
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java?p2=geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java&p1=geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java&r1=932781&r2=934301&rev=934301&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java
(original)
+++ geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java
Thu Apr 15 07:03:02 2010
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.osgi.registry.api;
+package org.apache.yoko.osgi;
 
 import java.util.List;
 
@@ -96,4 +96,5 @@ public interface ProviderRegistry {
      *         matching classes can be located.
      */
     public List<Class<?>> getServiceClasses(String providerId);
+
 }

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/apache/yoko/osgi/ProviderRegistry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java?rev=934301&r1=934300&r2=934301&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java (original)
+++ geronimo/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java Thu Apr 15 07:03:02
2010
@@ -16,8 +16,11 @@
  */
 package org.omg.CORBA;
 
+import org.apache.yoko.osgi.ProviderLocator;
+
 import java.security.PrivilegedAction;
 import java.security.AccessController;
+import java.util.Properties;
 
 public abstract class ORB {
 
@@ -170,89 +173,95 @@ public abstract class ORB {
     private static final String ORBSingletonPropertyKey = "org.omg.CORBA.ORBSingleton";
 
     public static ORB init(String[] args, java.util.Properties props) {
-        String orbClassName = null;
 
-        if (props != null)
-            orbClassName = props.getProperty(ORBClassPropertyKey);
+        ORB orb = newOrb(props);
 
-        if (orbClassName == null)
-            orbClassName = getSystemProperty(ORBClassPropertyKey);
+        ORBSingleton_ = orb;
 
-        if (orbClassName == null)
-            orbClassName = "org.apache.yoko.orb.CORBA.ORB";
+        orb.set_parameters(args, props);
 
-        ORB orb;
+        return orb;
+    }
 
-        try {
-            // get the appropriate class for the loading.
-            ClassLoader loader = Thread.currentThread().getContextClassLoader();
-            orb = (ORB) loader.loadClass(orbClassName).newInstance();
-        } catch (Throwable ex) {
-            throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE("Invalid ORB class:
"
-                    + orbClassName).initCause(ex);
-        }
+    public static ORB init(java.applet.Applet app, java.util.Properties props) {
+        ORB orb = newOrb(props);
 
         ORBSingleton_ = orb;
 
-        orb.set_parameters(args, props);
+        orb.set_parameters(app, props);
 
-        return orb;
+        return ORBSingleton_;
     }
 
-    public static ORB init(java.applet.Applet app, java.util.Properties props) {
+    private static ORB newOrb(Properties props) {
         String orbClassName = null;
 
-        if (props != null)
+        if (props != null) {
             orbClassName = props.getProperty(ORBClassPropertyKey);
-
-        try {
-            if (orbClassName == null)
-                orbClassName = getSystemProperty(ORBClassPropertyKey);
-        } catch (SecurityException ex) {
-            // ignore
         }
 
-        if (orbClassName == null)
-            orbClassName = "org.apache.yoko.orb.CORBA.ORB";
-
-        ORB orb;
-
-        try {
-            // get the appropriate class for the loading.
-            ClassLoader loader = Thread.currentThread().getContextClassLoader();
-            orb = (ORB) loader.loadClass(orbClassName).newInstance();
-        } catch (Throwable ex) {
-            throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE("Invalid ORB class:
"
-                    + orbClassName).initCause(ex);
+        ORB orb = null;
+        if (orbClassName == null) {
+            try {
+                orb = (ORB) ProviderLocator.getService(ORBClassPropertyKey, ORB.class, Thread.currentThread().getContextClassLoader());
+            } catch (Exception ex) {
+                throw (INITIALIZE)new INITIALIZE("Invalid ORB class from osgi: ").initCause(ex);
+            }
         }
 
-        ORBSingleton_ = orb;
+        if (orb == null) {
+            try {
+                if (orbClassName == null)
+                    orbClassName = getSystemProperty(ORBClassPropertyKey);
+            } catch (SecurityException ex) {
+                // ignore
+            }
 
-        orb.set_parameters(app, props);
+            if (orbClassName == null)
+                orbClassName = "org.apache.yoko.orb.CORBA.ORB";
 
+
+            try {
+                // get the appropriate class for the loading.
+                ClassLoader loader = Thread.currentThread().getContextClassLoader();
+                orb = (ORB) ProviderLocator.loadClass(orbClassName, ORB.class, loader).newInstance();
+            } catch (Throwable ex) {
+                throw (INITIALIZE)new INITIALIZE("Invalid ORB class: "
+                        + orbClassName).initCause(ex);
+            }
+        }
         return orb;
     }
 
     public static ORB init() {
         if (ORBSingleton_ == null) {
-            String orbClassName = getSystemProperty(ORBSingletonPropertyKey);
-        
-            if (orbClassName == null) {
-                orbClassName = "org.apache.yoko.orb.CORBA.ORBSingleton";
-            }
-
-            ORB orb;
-
             try {
-                // get the appropriate class for the loading.
-                ClassLoader loader = Thread.currentThread().getContextClassLoader();
-                orb = (ORB) loader.loadClass(orbClassName).newInstance();
-            } catch (Throwable ex) {
+                ORBSingleton_ = (ORB) ProviderLocator.getService(ORBSingletonPropertyKey,
ORB.class, Thread.currentThread().getContextClassLoader());
+            } catch (Exception ex) {
                 throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE(
-                        "Invalid ORB singleton class: " + orbClassName).initCause(ex);
+                        "Invalid ORB singleton class from osgi: ").initCause(ex);
+
             }
+            if (ORBSingleton_ == null) {
+                String orbClassName = getSystemProperty(ORBSingletonPropertyKey);
+
+                if (orbClassName == null) {
+                    orbClassName = "org.apache.yoko.orb.CORBA.ORBSingleton";
+                }
 
-            ORBSingleton_ = orb;
+                try {
+                    ORBSingleton_ = (ORB) ProviderLocator.loadClass(orbClassName, ORB.class,
Thread.currentThread().getContextClassLoader()).newInstance();
+                } catch (ClassNotFoundException ex) {
+                    throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE(
+                            "Invalid ORB singleton class from osgi: ").initCause(ex);
+                } catch (InstantiationException ex) {
+                    throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE(
+                            "Invalid ORB singleton class from osgi: ").initCause(ex);
+                } catch (IllegalAccessException ex) {
+                    throw (org.omg.CORBA.INITIALIZE)new org.omg.CORBA.INITIALIZE(
+                            "Invalid ORB singleton class from osgi: ").initCause(ex);
+                }
+            }
         }
 
         return ORBSingleton_;



Mime
View raw message