From 9faf5eab3d803675b2b7e6c2ac8ec4a810f7c65e Mon Sep 17 00:00:00 2001
From: Joe Chacko <143064+joe-chacko@users.noreply.github.com>
Date: Mon, 28 Oct 2024 12:05:47 +0000
Subject: [PATCH] fix: put an ApplicationPrereq in jndi.iiop
---
dev/com.ibm.ws.jndi.iiop/bnd.bnd | 9 ++++--
.../resources/OSGI-INF/metatype/metatype.xml | 29 +++++++++++++++++++
.../OSGI-INF/wlp/defaultInstance.xml | 15 ++++++++++
.../jndi/iiop/CorbanameUrlContextFactory.java | 27 ++++++++++-------
4 files changed, 67 insertions(+), 13 deletions(-)
create mode 100644 dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/metatype/metatype.xml
create mode 100644 dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/wlp/defaultInstance.xml
diff --git a/dev/com.ibm.ws.jndi.iiop/bnd.bnd b/dev/com.ibm.ws.jndi.iiop/bnd.bnd
index 38850c12205..ec0abfaf6e2 100644
--- a/dev/com.ibm.ws.jndi.iiop/bnd.bnd
+++ b/dev/com.ibm.ws.jndi.iiop/bnd.bnd
@@ -1,10 +1,10 @@
#*******************************************************************************
-# Copyright (c) 2017,2021 IBM Corporation and others.
+# Copyright (c) 2017,2024 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-2.0/
-#
+#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
@@ -21,7 +21,7 @@ Bundle-Description: This bundle provides a way to access CosNaming via JNDI; ver
WS-TraceGroup: Naming
# For each exported package, create (in that package) a package-info.java
-# file, and place an @version javadoc tag in package-level javadoc.
+# file, and place an @version javadoc tag in package-level javadoc.
# Append ";provide:=true" if this bundle also provides an implementation
# for the exported API.
@@ -33,6 +33,9 @@ Import-Package: \
javax.rmi.*;version="[2.4,3.0)", \
*
+Include-Resource: OSGI-INF=resources/OSGI-INF
+IBM-Default-Config: OSGI-INF/wlp/defaultInstances.xml
+
-dsannotations-inherit: true
-dsannotations: com.ibm.ws.jndi.iiop.*UrlContextFactory
diff --git a/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/metatype/metatype.xml b/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/metatype/metatype.xml
new file mode 100644
index 00000000000..bec5252ea63
--- /dev/null
+++ b/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/metatype/metatype.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/wlp/defaultInstance.xml b/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/wlp/defaultInstance.xml
new file mode 100644
index 00000000000..2d411e6a806
--- /dev/null
+++ b/dev/com.ibm.ws.jndi.iiop/resources/OSGI-INF/wlp/defaultInstance.xml
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/dev/com.ibm.ws.jndi.iiop/src/com/ibm/ws/jndi/iiop/CorbanameUrlContextFactory.java b/dev/com.ibm.ws.jndi.iiop/src/com/ibm/ws/jndi/iiop/CorbanameUrlContextFactory.java
index 3b68ae0842a..22597c39ed0 100644
--- a/dev/com.ibm.ws.jndi.iiop/src/com/ibm/ws/jndi/iiop/CorbanameUrlContextFactory.java
+++ b/dev/com.ibm.ws.jndi.iiop/src/com/ibm/ws/jndi/iiop/CorbanameUrlContextFactory.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2017 IBM Corporation and others.
+ * Copyright (c) 2017,2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
- *
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -12,9 +12,8 @@
*******************************************************************************/
package com.ibm.ws.jndi.iiop;
-import static org.osgi.service.component.annotations.ConfigurationPolicy.IGNORE;
+import static org.osgi.service.component.annotations.ConfigurationPolicy.REQUIRE;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.BitSet;
import java.util.regex.Matcher;
@@ -26,10 +25,18 @@
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;
+import com.ibm.wsspi.application.lifecycle.ApplicationPrereq;
import com.ibm.wsspi.application.lifecycle.ApplicationRecycleComponent;
-@Component(configurationPolicy=IGNORE,property={"service.vendor=ibm","osgi.jndi.url.scheme=corbaname"})
-public class CorbanameUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent {
+/**
+ * One of the context factories should be an {@link ApplicationPrereq}
+ * to represent this bundle being up and running.
+ * This (the most commonly used one) was chosen.
+ */
+
+
+@Component(configurationPolicy=REQUIRE,property={"service.vendor=ibm","osgi.jndi.url.scheme=corbaname"})
+public class CorbanameUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent, ApplicationPrereq {
static class Escaper{
static final TraceComponent tc = Tr.register(CorbanameUrlContextFactory.Escaper.class);
private static final Pattern PERCENT_TRIPLET = Pattern.compile("%(?:[0-9a-f]{2}|[0-9A-F]{2})");
@@ -88,7 +95,7 @@ public static String escapeCorbanameUrlIfNecessary(String url) {
// escape dots
n = n.replaceAll("\\.", "\\\\.");
- //
+ //
sn.append(n).append("/");
}
@@ -118,8 +125,8 @@ public static String escapeCorbanameUrlIfNecessary(String url) {
return escaped.toString();
}
-
+
}
-
-
+
+
}