weizhouapache commented on code in PR #13032:
URL: https://github.com/apache/cloudstack/pull/13032#discussion_r3333836190
##########
api/src/main/java/com/cloud/network/Network.java:
##########
@@ -250,11 +252,47 @@ public static Provider getProvider(String providerName) {
return null;
}
+ /** Private constructor for transient (non-registered) providers. */
+ private Provider(String name) {
+ this.name = name;
+ this.isExternal = false;
+ this.needCleanupOnShutdown = true;
+ // intentionally NOT added to supportedProviders
+ }
+
+ /**
+ * Creates a transient (non-registered) {@link Provider} with the
given name.
+ *
+ * <p>The new instance is <em>not</em> added to {@code
supportedProviders}, so it
+ * will never be returned by {@link #getProvider(String)} and will not
pollute the
+ * global provider registry. Use this for dynamic / extension-backed
providers
+ * whose names are only known at runtime (e.g. NetworkOrchestrator
extensions).</p>
+ *
+ * @param name the provider name (typically the extension name)
+ * @return a transient {@link Provider} instance with the given name
+ */
+ public static Provider createTransientProvider(String name) {
+ return new Provider(name);
+ }
+
@Override public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("name", name)
.toString();
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!(obj instanceof Provider)) return false;
+ Provider provider = (Provider) obj;
+ return this.name.equals(provider.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
Review Comment:
let's make the provider name case-sensitive
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]