Package org.jboss.as.console.client.v3.stores.domain

Source Code of org.jboss.as.console.client.v3.stores.domain.ServerStoreAdapter

package org.jboss.as.console.client.v3.stores.domain;

import javax.annotation.Generated;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import org.jboss.gwt.circuit.Action;
import org.jboss.gwt.circuit.Agreement;
import org.jboss.gwt.circuit.Dispatcher;
import org.jboss.gwt.circuit.PropagatesChange.Handler;
import org.jboss.gwt.circuit.StoreCallback;

/*
* WARNING! This class is generated. Do not modify.
*/
@ApplicationScoped
@Generated("org.jboss.gwt.circuit.processor.StoreProcessor")
public class ServerStoreAdapter {

    private final ServerStore delegate;

    @Inject
    public ServerStoreAdapter(final ServerStore delegate, final Dispatcher dispatcher) {
        this.delegate = delegate;

        dispatcher.register(ServerStore.class, new StoreCallback() {
            @Override
            public Agreement voteFor(final Action action) {
                if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.HostSelection) {
                    return new Agreement(true, org.jboss.as.console.client.v3.stores.domain.HostStore.class);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.RefreshServer) {
                    return new Agreement(true, org.jboss.as.console.client.v3.stores.domain.HostStore.class);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.AddServer) {
                    return new Agreement(true);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.RemoveServer) {
                    return new Agreement(true, org.jboss.as.console.client.v3.stores.domain.HostStore.class);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.UpdateServer) {
                    return new Agreement(true);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.CopyServer) {
                    return new Agreement(true);
                }
                else {
                    return Agreement.NONE;
                }
            }

            @Override
            public void complete(final Action action, final Dispatcher.Channel channel) {
                if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.HostSelection) {
                    delegate.onSelectHost(((org.jboss.as.console.client.v3.stores.domain.actions.HostSelection)action).getPayload(), channel);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.RefreshServer) {
                    delegate.onRefresh(channel);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.AddServer) {
                    delegate.onAddServer(((org.jboss.as.console.client.v3.stores.domain.actions.AddServer)action).getPayload(), channel);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.RemoveServer) {
                    delegate.onRemoveServer(((org.jboss.as.console.client.v3.stores.domain.actions.RemoveServer)action).getPayload(), channel);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.UpdateServer) {
                    delegate.onUpdateServer(((org.jboss.as.console.client.v3.stores.domain.actions.UpdateServer)action).getPayload(), channel);
                }
                else if (action instanceof org.jboss.as.console.client.v3.stores.domain.actions.CopyServer) {
                    delegate.onSaveCopy(((org.jboss.as.console.client.v3.stores.domain.actions.CopyServer)action).getPayload(), channel);
                }
                else {
                    System.out.println("WARN: Unmatched action " + action.getClass().getName() + " in store " + delegate.getClass());
                    channel.ack();
                }
            }

            @Override
            public void signalChange(final Action action) {
                Class<? extends Action> actionType = action.getClass();
                Iterable<Handler> actionHandlers = delegate.getActionHandler(actionType);
                for (Handler actionHandler : actionHandlers) {
                    actionHandler.onChange(actionType);
                }
                Iterable<Handler> storeHandlers = delegate.getHandler();
                for (Handler storeHandler : storeHandlers) {
                    storeHandler.onChange(actionType);
                }
            }
        });
    }
}
TOP

Related Classes of org.jboss.as.console.client.v3.stores.domain.ServerStoreAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.