org.jboss.as.clustering.naming.JndiNameFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wildfly-clustering-common Show documentation
Show all versions of wildfly-clustering-common Show documentation
The code in this module is not explicitly related to clustering, but rather contains resuable code used by clustering modules
and any modules that integrate with clustering.
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.as.clustering.naming;
import org.jboss.as.naming.deployment.JndiName;
/**
* Factory methods for creating a JndiName.
* @author Paul Ferraro
*/
public class JndiNameFactory {
public static final String DEFAULT_JNDI_NAMESPACE = "java:jboss";
public static final String DEFAULT_LOCAL_NAME = "default";
public static JndiName parse(String value) {
return value.startsWith("java:") ? JndiName.of(value) : createJndiName(DEFAULT_JNDI_NAMESPACE, value.startsWith("/") ? value.substring(1) : value);
}
public static JndiName createJndiName(String namespace, String... contexts) {
JndiName name = JndiName.of(namespace);
for (String context: contexts) {
name = name.append((context != null) ? context : DEFAULT_LOCAL_NAME);
}
return name;
}
private JndiNameFactory() {
// Hide
}
}