Java Code Examples for org.jboss.msc.service.ServiceName#parse()
The following examples show how to use
org.jboss.msc.service.ServiceName#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistrationAdvertiser.java From thorntail with Apache License 2.0 | 6 votes |
public static ServiceController<Void> install(ServiceTarget target, String serviceName, String socketBindingName, Collection<String> userDefinedTags) { List<String> tags = new ArrayList<>(userDefinedTags); tags.add(socketBindingName); ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName); RegistrationAdvertiser advertiser = new RegistrationAdvertiser(serviceName, tags.toArray(new String[tags.size()])); return target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser) .addDependency(CONNECTOR_SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector()) .addDependency(socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector()) .setInitialMode(ServiceController.Mode.PASSIVE) .install(); }
Example 2
Source File: RegistrationAdvertiserActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
private void installAdvertiser(ServiceTarget target, String serviceName, String socketBindingName) { ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName ); RegistrationAdvertiser advertiser = new RegistrationAdvertiser( serviceName, socketBindingName ); target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser) .addDependency(TopologyConnector.SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector()) .addDependency( socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector() ) .setInitialMode(ServiceController.Mode.PASSIVE) .install(); }
Example 3
Source File: CacheActivator.java From thorntail with Apache License 2.0 | 4 votes |
Type(String serviceNameBase) { this.serviceNameBase = ServiceName.parse(serviceNameBase); }
Example 4
Source File: ServiceNameFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Parses a string into a {@link ServiceName} using the same algorithm as {@link ServiceName#parse(String)} * but also attempts to ensure that once parsing occurs if any other name that is * {@link ServiceName#equals(ServiceName) equal to} the parsed name or one of its * {@link ServiceName#getParent() ancestors} has been parsed previously that that previously parsed name * is used. * * @param toParse the string form of a service name. Cannot be {@code null} * @return a {@code ServiceName} instance */ public static ServiceName parseServiceName(String toParse) { ServiceName original = ServiceName.parse(toParse); // Try to use cached elements of the ServiceName chain // Cost of a duplicate ServiceName instance // 1) int for hashCode // 2) pointer to simple name // 3) pointer to canonical name // 4) pointer to parent // 5) the simple name (cost depends on string length but at least 2 pointers plus the char[] and the object) // 6) Possibly a long string for canonicalName // Cost of a ConcurrentHashMap Node where key == value // 1) int for hash code // 2) pointer to key // 3) pointer to value // 4) pointer to next // 5) ~ 1 pointer to the Node itself in the table (some table elements have > 1 Node but some are empty // Based on this, if there's roughly a > 50% chance of a name being duplicated, it's worthwhile // to intern it. As a heuristic for whether there is a > 50% chance, we'll intern all names // of 4 elements or less and for larger names, all but the last element int length = original.length(); ServiceName[] ancestry = new ServiceName[length]; ServiceName sn = original; for (int i = length - 1; i >= 0 ; i--) { ancestry[i] = sn; sn = sn.getParent(); } int max = length > 4 ? length - 1 : length; for (int i = 0; i < max; i++) { ServiceName interned = cache.putIfAbsent(ancestry[i], ancestry[i]); if (interned != null && ancestry[i] != interned) { // Replace this one in the ancestry with the interned one ServiceName parent = ancestry[i] = interned; // Replace all descendants boolean checkCache = true; for (int j = i+1; j < length; j++) { parent = parent.append(ancestry[j].getSimpleName()); if (checkCache && j < max) { ServiceName cached = cache.get(parent); if (cached != null) { // Use what we already have parent = cached; // We don't need to recheck in the outer loop. i = j; } else { // Assume we'll miss the rest of the way checkCache = false; } } ancestry[j] = parent; } } } return ancestry[length - 1]; }
Example 5
Source File: Elytron.java From keycloak with Apache License 2.0 | 4 votes |
static boolean isElytronEnabled(DeploymentPhaseContext phaseContext) { String securityDomain = getSecurityDomain(phaseContext.getDeploymentUnit()); ServiceName serviceName = ServiceName.parse(new StringBuilder(UNDERTOW_APPLICATION_SECURITY_DOMAIN).append(securityDomain).toString()); return phaseContext.getServiceRegistry().getService(serviceName) != null; }
Example 6
Source File: KeycloakClusteredSsoDeploymentProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void addSamlReplicationConfiguration(DeploymentUnit deploymentUnit, DeploymentPhaseContext context) { WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { return; } JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) { webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } // Find out default names of cache container and cache String cacheContainer = DEFAULT_CACHE_CONTAINER; String deploymentSessionCacheName = (deploymentUnit.getParent() == null ? "" : deploymentUnit.getParent().getName() + ".") + deploymentUnit.getName(); // Update names from jboss-web.xml's <replicationConfig> if (webMetaData.getReplicationConfig() != null && webMetaData.getReplicationConfig().getCacheName() != null) { ServiceName sn = ServiceName.parse(webMetaData.getReplicationConfig().getCacheName()); cacheContainer = (sn.length() > 1) ? sn.getParent().getSimpleName() : sn.getSimpleName(); deploymentSessionCacheName = sn.getSimpleName(); } String ssoCacheName = deploymentSessionCacheName + ".ssoCache"; // Override if they were set in the context parameters List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null) { contextParams = new ArrayList<>(); } for (ParamValueMetaData contextParam : contextParams) { if (Objects.equals(contextParam.getParamName(), SSO_CACHE_CONTAINER_NAME_PARAM_NAME)) { cacheContainer = contextParam.getParamValue(); } else if (Objects.equals(contextParam.getParamName(), SSO_CACHE_NAME_PARAM_NAME)) { ssoCacheName = contextParam.getParamValue(); } } LOG.debugv("Determined SSO cache container configuration: container: {0}, cache: {1}", cacheContainer, ssoCacheName); // addCacheDependency(context, deploymentUnit, cacheContainer, cacheName); // Set context parameters for SSO cache container/name ParamValueMetaData paramContainer = new ParamValueMetaData(); paramContainer.setParamName(AdapterConstants.REPLICATION_CONFIG_CONTAINER_PARAM_NAME); paramContainer.setParamValue(cacheContainer); contextParams.add(paramContainer); ParamValueMetaData paramSsoCache = new ParamValueMetaData(); paramSsoCache.setParamName(AdapterConstants.REPLICATION_CONFIG_SSO_CACHE_PARAM_NAME); paramSsoCache.setParamValue(ssoCacheName); contextParams.add(paramSsoCache); webMetaData.setContextParams(contextParams); }
Example 7
Source File: KeycloakClusteredSsoDeploymentProcessor.java From keycloak with Apache License 2.0 | 4 votes |
private void addSamlReplicationConfiguration(DeploymentUnit deploymentUnit, DeploymentPhaseContext context) { WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { return; } JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) { webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } // Find out default names of cache container and cache String cacheContainer = DEFAULT_CACHE_CONTAINER; String deploymentSessionCacheName = (deploymentUnit.getParent() == null ? "" : deploymentUnit.getParent().getName() + ".") + deploymentUnit.getName(); // Update names from jboss-web.xml's <replicationConfig> if (webMetaData.getReplicationConfig() != null && webMetaData.getReplicationConfig().getCacheName() != null) { ServiceName sn = ServiceName.parse(webMetaData.getReplicationConfig().getCacheName()); cacheContainer = (sn.length() > 1) ? sn.getParent().getSimpleName() : sn.getSimpleName(); deploymentSessionCacheName = sn.getSimpleName(); } String ssoCacheName = deploymentSessionCacheName + ".ssoCache"; // Override if they were set in the context parameters List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null) { contextParams = new ArrayList<>(); } for (ParamValueMetaData contextParam : contextParams) { if (Objects.equals(contextParam.getParamName(), SSO_CACHE_CONTAINER_NAME_PARAM_NAME)) { cacheContainer = contextParam.getParamValue(); } else if (Objects.equals(contextParam.getParamName(), SSO_CACHE_NAME_PARAM_NAME)) { ssoCacheName = contextParam.getParamValue(); } } LOG.debugv("Determined SSO cache container configuration: container: {0}, cache: {1}", cacheContainer, ssoCacheName); addCacheDependency(context, deploymentUnit, cacheContainer, ssoCacheName); // Set context parameters for SSO cache container/name ParamValueMetaData paramContainer = new ParamValueMetaData(); paramContainer.setParamName(AdapterConstants.REPLICATION_CONFIG_CONTAINER_PARAM_NAME); paramContainer.setParamValue(cacheContainer); contextParams.add(paramContainer); ParamValueMetaData paramSsoCache = new ParamValueMetaData(); paramSsoCache.setParamName(AdapterConstants.REPLICATION_CONFIG_SSO_CACHE_PARAM_NAME); paramSsoCache.setParamValue(ssoCacheName); contextParams.add(paramSsoCache); webMetaData.setContextParams(contextParams); }
Example 8
Source File: Elytron.java From keycloak with Apache License 2.0 | 4 votes |
static boolean isElytronEnabled(DeploymentPhaseContext phaseContext) { String securityDomain = getSecurityDomain(phaseContext.getDeploymentUnit()); ServiceName serviceName = ServiceName.parse(new StringBuilder(UNDERTOW_APPLICATION_SECURITY_DOMAIN).append(securityDomain).toString()); return phaseContext.getServiceRegistry().getService(serviceName) != null; }