Skip to content
Permalink
Browse files
YOKO-431 use service class key to search impl. first in the blueprint…
… service registry, and correct a service key name for ORBSingleton

git-svn-id: https://svn.apache.org/repos/asf/geronimo/yoko/trunk@1071188 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Ming Xia committed Feb 16, 2011
1 parent c7706c3 commit 4a91008c4843c57f042e18528a2aecc8e02b87f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
@@ -48,7 +48,7 @@ limitations under the License.
init-method="start"
destroy-method="stop">
<argument>
<value>org.omg.CORBA.ORBSingleton</value>
<value>org.omg.CORBA.ORBSingletonClass</value>
</argument>
<argument>
<value>org.apache.yoko.orb.CORBA.ORBSingleton</value>
@@ -25,6 +25,7 @@
import java.security.AccessController;

import org.apache.yoko.rmispec.util.GetSystemPropertyAction;
import org.apache.yoko.rmispec.util.UtilLoader;
import org.omg.CORBA.ORB;
import org.omg.CORBA_2_3.portable.ObjectImpl;

@@ -33,14 +34,15 @@ public abstract class Stub extends ObjectImpl implements Serializable {

private transient StubDelegate delegate = null;
private static final String defaultDelegate = "org.apache.yoko.rmi.impl.StubImpl";
private static final String DELEGATEKEY = "javax.rmi.CORBA.StubClass";
// the class we use to create delegates. This is loaded once,
private static Class delegateClass = null;

static {
// Initialize delegate
String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.StubClass", defaultDelegate));
String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction(DELEGATEKEY, defaultDelegate));
try {
delegateClass = Util.loadClass(delegateName, null, null);
delegateClass = UtilLoader.loadServiceClass(delegateName, DELEGATEKEY);
} catch (Exception e) {
org.omg.CORBA.INITIALIZE ex = new org.omg.CORBA.INITIALIZE("Can not create Stub delegate: " + delegateName);
ex.initCause(e);
@@ -32,18 +32,19 @@
public class Util {
private static UtilDelegate delegate = null;
private static final String defaultDelegate = "org.apache.yoko.rmi.impl.UtilImpl";
private static final String DELEGATEKEY = "javax.rmi.CORBA.UtilClass";

// To hide the default constructor we should implement empty private constructor
private Util() {}

static {
// Initialize delegate
String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.UtilClass", defaultDelegate));
String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction(DELEGATEKEY, defaultDelegate));
try {

// this is a little bit recursive, but this will use the full default search order for locating
// this.
delegate = (UtilDelegate)Util.loadClass(delegateName, null, null).newInstance();
delegate = (UtilDelegate)UtilLoader.loadServiceClass(delegateName, DELEGATEKEY).newInstance();
} catch (Throwable e) {
org.omg.CORBA.INITIALIZE ex = new org.omg.CORBA.INITIALIZE("Can not create Util delegate: "+delegateName);
ex.initCause(e);
@@ -36,18 +36,36 @@ public class UtilLoader {
// since that method will call loadClass0 which uses this field... if it is below the static
// initializer the _secman field will be null
private static final SecMan _secman = getSecMan();

static public Class<?> loadServiceClass(String delegateName, String delegateKey) throws ClassNotFoundException {

try {
return ProviderLocator.getServiceClass(delegateKey, null, null);
} catch (ClassNotFoundException e){
// skip
}

return loadClass0(delegateName, null, null);
}

static public Class loadClass(String name, String codebase, ClassLoader loader)
throws ClassNotFoundException {
Class result = null;


try {
return ProviderLocator.loadClass(name, null, loader);
} catch (ClassNotFoundException e) {
//skip
}

ClassLoader stackLoader = null;
return loadClass0(name, codebase, loader);
}

private static Class<?> loadClass0(String name, String codebase, ClassLoader loader)
throws ClassNotFoundException {
Class result = null;

ClassLoader stackLoader = null;
ClassLoader thisLoader = UtilLoader.class.getClassLoader();
Class[] stack = _secman.getClassContext();
for (int i = 1; i < stack.length; i++) {

0 comments on commit 4a91008

Please sign in to comment.