当前位置: 首页>>代码示例>>Java>>正文


Java ServiceName.parse方法代码示例

本文整理汇总了Java中org.jboss.msc.service.ServiceName.parse方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceName.parse方法的具体用法?Java ServiceName.parse怎么用?Java ServiceName.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.msc.service.ServiceName的用法示例。


在下文中一共展示了ServiceName.parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: install

import org.jboss.msc.service.ServiceName; //导入方法依赖的package包/类
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();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:17,代码来源:RegistrationAdvertiser.java

示例2: installAdvertiser

import org.jboss.msc.service.ServiceName; //导入方法依赖的package包/类
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();
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology,代码行数:11,代码来源:RegistrationAdvertiserActivator.java

示例3: activate

import org.jboss.msc.service.ServiceName; //导入方法依赖的package包/类
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

        ServiceTarget target = serviceActivatorContext.getServiceTarget();
        ServiceController argsController = serviceActivatorContext.getServiceRegistry().getService(ServiceName.of("wildfly", "swarm", "main-args"));
        ValueService<String[]> argsService = (ValueService<String[]>) argsController.getService();
        String[] args = argsService.getValue();
        log.infof("Args available to services: %s\n", Arrays.asList(args));

        ScannerService service = new ScannerService(args);
        ServiceName serviceName = ServiceName.parse("org.jboss.rhiot.beacon.swarm.ScannerService");
        target.addService(serviceName, service)
            .install();
    }
 
开发者ID:RHioTResearch,项目名称:SwarmBeaconScanner,代码行数:14,代码来源:ScannerServiceActivator.java

示例4: installAdvertiser

import org.jboss.msc.service.ServiceName; //导入方法依赖的package包/类
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();
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:11,代码来源:RegistrationAdvertiserActivator.java

示例5: parseServiceName

import org.jboss.msc.service.ServiceName; //导入方法依赖的package包/类
/**
 * 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];
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:71,代码来源:ServiceNameFactory.java


注:本文中的org.jboss.msc.service.ServiceName.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。