alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Apache CXF example source code file (ServiceContractResolverRegistryImpl.java)

This example Apache CXF source code file (ServiceContractResolverRegistryImpl.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Apache CXF tags/keywords

bus, copyonwritearraylist, list, list, net, network, nojsr250annotations, servicecontractresolver, servicecontractresolver, servicecontractresolverregistry, servicecontractresolverregistryimpl, servicecontractresolverregistryimpl, threading, threads, uri, uri, util

The Apache CXF ServiceContractResolverRegistryImpl.java source code

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.cxf.endpoint;

import java.net.URI;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.xml.namespace.QName;

import org.apache.cxf.Bus;
import org.apache.cxf.common.injection.NoJSR250Annotations;

/**
 * A simple contract resolver registry. It maintains a list of contract resolvers in an
 * <code>ArrayList.
 */
@NoJSR250Annotations(unlessNull = "bus")
public class ServiceContractResolverRegistryImpl implements ServiceContractResolverRegistry {

    private Bus bus;
    private List<ServiceContractResolver> resolvers 
        = new CopyOnWriteArrayList<ServiceContractResolver>();

    public ServiceContractResolverRegistryImpl() {
        
    }
    public ServiceContractResolverRegistryImpl(Bus b) {
        setBus(b);
    }
    

    /**
     * Sets the bus with which the registry is associated.
     *
     * @param bus
     */
    public final void setBus(Bus b) {
        this.bus = b;
        if (bus != null) {
            bus.setExtension(this, ServiceContractResolverRegistry.class);
        }
    }

    /**
     * Calls each of the registered <code>ServiceContractResolver instances
     * to resolve the location of the service's contract. It returns the location 
     * from the first resolver that matches the QName to a location.
     *
     * @param qname QName to be resolved into a contract location
     * @return URI representing the location of the contract
    */
    public URI getContractLocation(QName qname) {
        for (ServiceContractResolver resolver : resolvers) {
            URI contractLocation = resolver.getContractLocation(qname);
            if (null != contractLocation) {
                return contractLocation;
            }
        }
        return null;
    }

    /**
     * Tests if a resolver is alreadey registered with this registry.
     *
     * @param resolver the contract resolver for which to searche
     * @return <code>true if the resolver is registered
     */
    public boolean isRegistered(ServiceContractResolver resolver) {
        return resolvers.contains(resolver);
    }

    /**
     * Registers a contract resolver with this registry.
     *
     * @param resolver the contract resolver to register
     */
    public synchronized void register(ServiceContractResolver resolver) {
        resolvers.add(resolver);        
    }

    /**
     * Removes a contract resolver from this registry.
     *
     * @param resolver the contract resolver to remove
     */
    public synchronized void unregister(ServiceContractResolver resolver) {
        resolvers.remove(resolver);        
    }

    
    protected List<ServiceContractResolver> getResolvers() {
        return resolvers;
    }

}

Other Apache CXF examples (source code examples)

Here is a short list of links related to this Apache CXF ServiceContractResolverRegistryImpl.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.