Java Code Examples for com.sun.xml.internal.bind.v2.runtime.Coordinator

Following code examples demonstrate how to use com.sun.xml.internal.bind.v2.runtime.Coordinatorfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.sun.xml.internal.bind.v2.runtime.Coordinatorand various code implementation of this class.

    private XmlAdapter<OnWireValueT, InMemValueT> getAdapter() {
        Coordinator coordinator = Coordinator._getInstance();
        if(coordinator!=null)
            return coordinator.getAdapter(adapter);
        else {
            synchronized(this) {
                if(staticAdapter==null)
                    staticAdapter = ClassFactory.create(adapter);
            }
            return staticAdapter;
        }
    } 


    public static void main(String args[]) throws InterruptedException, IOException {
        Coordinater coordinator = new SimpleCoordinator();

        Thread evenPrinter = new Thread(new EvenNumbers(LIMIT, coordinator));
        Thread oddPrinter = new Thread(new OddNumbers(LIMIT, coordinator));
        Thread additionPrinter = new Thread(new Addition(LIMIT, coordinator));

        coordinator.register(evenPrinter);
        coordinator.register(oddPrinter);
        coordinator.register(additionPrinter);

        evenPrinter.start();
        oddPrinter.start();
        additionPrinter.start();

        evenPrinter.join();
        oddPrinter.join();
        additionPrinter.join();

        System.out.println("\nMain task done");

    } 

Advertisement
Javadoc
Object that coordinates the marshalling/unmarshalling.

This class takes care of the logi

c that allows code to obtain UnmarshallingContext and XMLSerializer instances during the unmarshalling/marshalling.

This is done by using a ThreadLocal. Therefore one unmarshalling/marshalling episode has to be done from the beginning till end by the same thread. (Note that the same Coordinator can be then used by a different thread for an entirely different episode.) This class also maintains the user-configured instances of XmlAdapters.

This class implements ErrorHandler and propages erros to this object as the ValidationEventHandler, which will be implemented in a derived class. @author Kohsuke Kawaguchi

Read More
Advertisement