You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ri...@apache.org on 2006/11/21 12:03:25 UTC
svn commit: r477622 - in /incubator/openejb/trunk/openejb2/modules:
openejb-corba/src/main/java/org/apache/openejb/corba/
openejb-corba/src/main/java/org/apache/openejb/corba/security/config/
openejb-yoko/src/main/java/org/apache/openejb/yoko/
Author: rickmcguire
Date: Tue Nov 21 03:03:24 2006
New Revision: 477622
URL: http://svn.apache.org/viewvc?view=rev&rev=477622
Log:
OPENEJB-338 CSSBean needs to use a second ORB instance for accessing the NameService to resolve beans
Modified:
incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/CSSBean.java
incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/security/config/ConfigAdapter.java
incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
Modified: incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/CSSBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/CSSBean.java?view=diff&rev=477622&r1=477621&r2=477622
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/CSSBean.java (original)
+++ incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/CSSBean.java Tue Nov 21 03:03:24 2006
@@ -59,7 +59,10 @@
private String description;
private CSSConfig cssConfig;
private SSLConfig sslConfig;
+ // ORB used for activating and accessing the target bean.
private ORB cssORB;
+ // ORB used for nameservice lookups.
+ private ORB nssORB;
private ClientContext context;
private AbstractName abstractName;
@@ -136,18 +139,26 @@
log.debug(description + " - Looking up home from " + nsURI.toString() + " at " + name);
try {
- org.omg.CORBA.Object ref = cssORB.string_to_object(nsURI.toString());
+ // The following may seem unncecessary, but it isn't. We need to use one ORB to
+ // retrieve the object reference from the NameService because the SecurityInterceptor
+ // attached to the main ORB instance may add additional service contexts to the
+ // NameService request that will cause failures. We use one configuration to access
+ // the server, and the activate the object on the real one.
+ org.omg.CORBA.Object ref = nssORB.string_to_object(nsURI.toString());
NamingContextExt ic = NamingContextExtHelper.narrow(ref);
NameComponent[] nameComponent = ic.to_name(name);
+ org.omg.CORBA.Object bean = ic.resolve(nameComponent);
+ String beanIOR = nssORB.object_to_string(bean);
ClientContext oldClientContext = ClientContextManager.getClientContext();
try {
ClientContextManager.setClientContext(context);
- return ic.resolve(nameComponent);
+ bean = cssORB.string_to_object(beanIOR);
} finally {
ClientContextManager.setClientContext(oldClientContext);
}
+ return bean;
} catch (UserException ue) {
log.error(description + " - Looking up home", ue);
throw new RuntimeException(ue);
@@ -173,6 +184,9 @@
log.debug("Starting CSS ORB " + getURI());
Thread.currentThread().setContextClassLoader(classLoader);
+
+ // create an ORB using the name service.
+ nssORB = configAdapter.createNameServiceClientORB(this);
// the configAdapter creates the ORB instance for us.
cssORB = configAdapter.createClientORB(this);
@@ -193,6 +207,9 @@
public void doStop() throws Exception {
cssORB.destroy();
+ nssORB.destroy();
+ cssORB = null;
+ nssORB = null;
log.debug("Stopped CORBA Client Security Server - " + description);
}
Modified: incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/security/config/ConfigAdapter.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/security/config/ConfigAdapter.java?view=diff&rev=477622&r1=477621&r2=477622
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/security/config/ConfigAdapter.java (original)
+++ incubator/openejb/trunk/openejb2/modules/openejb-corba/src/main/java/org/apache/openejb/corba/security/config/ConfigAdapter.java Tue Nov 21 03:03:24 2006
@@ -43,6 +43,16 @@
*/
public ORB createServerORB(CORBABean server) throws ConfigException;
/**
+ * Create an ORB for a CSSBean nameservice client context.
+ *
+ * @param client The configured CSSBean used for access.
+ *
+ * @return An ORB instance configured for this client access.
+ * @exception ConfigException
+ */
+
+ public ORB createNameServiceClientORB(CSSBean client) throws ConfigException;
+ /**
* Create an ORB for a CSSBean client context.
*
* @param client The configured CSSBean used for access.
Modified: incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java?view=diff&rev=477622&r1=477621&r2=477622
==============================================================================
--- incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java (original)
+++ incubator/openejb/trunk/openejb2/modules/openejb-yoko/src/main/java/org/apache/openejb/yoko/ORBConfigAdapter.java Tue Nov 21 03:03:24 2006
@@ -139,6 +139,18 @@
}
/**
+ * Create an ORB for a CSSBean name service client context.
+ *
+ * @param client The configured CSSBean used for access.
+ *
+ * @return An ORB instance configured for this client access.
+ * @exception ConfigException
+ */
+ public ORB createNameServiceClientORB(CSSBean client) throws ConfigException {
+ return createORB(client.getURI(), (ORBConfiguration)client, translateToArgs(client), translateToNameServiceProps(client));
+ }
+
+ /**
* Create a transient name service instance using the
* specified host name and port.
*
@@ -275,14 +287,14 @@
result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.transaction.TransactionInitializer", "");
result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.corba.security.SecurityInitializer", "");
result.put("org.omg.PortableInterceptor.ORBInitializerClass.org.apache.openejb.yoko.ORBInitializer", "");
- // don't specify the port if we're allowing this to default.
+ // don't specify the port if we're allowing this to default.
if (server.getPort() > 0) {
result.put("yoko.orb.oa.endpoint", "iiop --host " + server.getHost() + " --port " + server.getPort());
}
else {
result.put("yoko.orb.oa.endpoint", "iiop --host " + server.getHost());
}
-
+
if (log.isDebugEnabled()) {
log.debug("translateToProps(TSSConfig)");
for (Enumeration iter = result.keys(); iter.hasMoreElements();) {
@@ -356,6 +368,33 @@
if (log.isDebugEnabled()) {
log.debug("translateToProps(CSSConfig)");
+ for (Enumeration iter = result.keys(); iter.hasMoreElements();) {
+ String key = (String) iter.nextElement();
+ log.debug(key + " = " + result.getProperty(key));
+ }
+ }
+ return result;
+ }
+
+
+ /**
+ * Translate a CSSBean configuration into the
+ * property bundle necessary to configure the
+ * ORB instance.
+ *
+ * @param client The CSSBean holding the configuration.
+ *
+ * @return A property bundle that can be passed to ORB.init();
+ * @exception ConfigException
+ */
+ private Properties translateToNameServiceProps(CSSBean client) throws ConfigException {
+ Properties result = new Properties();
+
+ result.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ result.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+
+ if (log.isDebugEnabled()) {
+ log.debug("translateToNameServiceProps(CSSConfig)");
for (Enumeration iter = result.keys(); iter.hasMoreElements();) {
String key = (String) iter.nextElement();
log.debug(key + " = " + result.getProperty(key));