egovframework.rte.itl.integration.metadata.IntegrationDefinition.java Source code

Java tutorial

Introduction

Here is the source code for egovframework.rte.itl.integration.metadata.IntegrationDefinition.java

Source

/*
 * Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security).
 *
 * Licensed 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 egovframework.rte.itl.integration.metadata;

import java.util.Calendar;
import java.util.concurrent.atomic.AtomicBoolean;

import org.springframework.util.StringUtils;

import egovframework.rte.itl.integration.util.Validatable;

/**
 *    ??  ' ?'  ?
 * <p>
 * <b>NOTE:</b> ?    ??  ' ?' 
 * class?.
 * @author   ?
 * @since 2009.06.01
 * @version 1.0
 * @see <pre>
 *  == ?(Modification Information) ==
 *   
 *   ?      ?           
 *  -------    --------    ---------------------------
 *   2009.06.01  ?            ?
 * 
 * </pre>
 */
public class IntegrationDefinition implements Validatable {
    /**  ID */
    private String id;

    /**   */
    private ServiceDefinition provider;

    /**   */
    private SystemDefinition consumer;

    /** default timeout */
    private long defaultTimeout;

    /**   */
    private boolean using;

    /**   () */
    private Calendar validateFrom;

    /**   (??) */
    private Calendar validateTo;

    /** valid */
    private boolean valid = false;

    /** statucChanged flag */
    private AtomicBoolean statusChanged = new AtomicBoolean(false);

    /**
     * Default Constructor
     */
    public IntegrationDefinition() {
        super();
    }

    /**
     * Constructor
     * @param id
     *         ID
     * @param provider
     *         
     * @param consumer
     *         
     * @param defaultTimeout
     *        default timeout
     * @param using
     *         
     * @param validateFrom
     *          ()
     * @param validateTo
     *          (??)
     */
    public IntegrationDefinition(String id, ServiceDefinition provider, SystemDefinition consumer,
            long defaultTimeout, boolean using, Calendar validateFrom, Calendar validateTo) {
        super();
        this.id = id;
        this.provider = provider;
        this.consumer = consumer;
        this.defaultTimeout = defaultTimeout;
        this.using = using;
        this.validateFrom = validateFrom;
        this.validateTo = validateTo;
        this.statusChanged.set(true);
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id
     *        the id to set
     */
    public void setId(String id) {
        this.id = id;
        this.statusChanged.set(true);
    }

    /**
     * @return the provider
     */
    public ServiceDefinition getProvider() {
        return provider;
    }

    /**
     * @param provider
     *        the provider to set
     */
    public void setProvider(ServiceDefinition provider) {
        this.provider = provider;
        this.statusChanged.set(true);
    }

    /**
     * @return the consumer
     */
    public SystemDefinition getConsumer() {
        return consumer;
    }

    /**
     * @param consumer
     *        the consumer to set
     */
    public void setConsumer(SystemDefinition consumer) {
        this.consumer = consumer;
        this.statusChanged.set(true);
    }

    /**
     * @return the defaultTimeout
     */
    public long getDefaultTimeout() {
        return defaultTimeout;
    }

    /**
     * @param defaultTimeout
     *        the defaultTimeout to set
     */
    public void setDefaultTimeout(long defaultTimeout) {
        this.defaultTimeout = defaultTimeout;
        // this.statusChanged.set(true);
    }

    /**
     * @return the using
     */
    public boolean isUsing() {
        return using;
    }

    /**
     * @param using
     *        the using to set
     */
    public void setUsing(boolean using) {
        this.using = using;
        // this.statusChanged.set(true);
    }

    /**
     * @return the validateFrom
     */
    public Calendar getValidateFrom() {
        return validateFrom;
    }

    /**
     * @param validateFrom
     *        the validateFrom to set
     */
    public void setValidateFrom(Calendar validateFrom) {
        this.validateFrom = validateFrom;
        // this.statusChanged.set(true);
    }

    /**
     * @return the validateTo
     */
    public Calendar getValidateTo() {
        return validateTo;
    }

    /**
     * @param validateTo
     *        the validateTo to set
     */
    public void setValidateTo(Calendar validateTo) {
        this.validateTo = validateTo;
        // this.statusChanged.set(true);
    }

    public boolean isValid() {
        if (statusChanged.getAndSet(false)) {
            valid = (StringUtils.hasText(id) && provider != null && consumer != null);
            if (provider != null) {
                valid = valid && provider.isValid();
            }
            if (consumer != null) {
                valid = valid && consumer.isValid();
            }
        }
        return valid;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(this.getClass().getName()).append(" {").append("\n\tid = ").append(StringUtils.quote(id))
                .append("\n\tprovider = ").append(provider == null ? "" : "\n").append(provider)
                .append("\n\tconsumer = ").append(consumer == null ? "" : "\n").append(consumer)
                .append("\n\tdefaultTimeout = ").append(defaultTimeout).append("\n\tusing = ").append(using)
                .append("\n\tvalidateFrom = ").append(validateFrom).append("\n\tvalidateTo = ").append(validateTo)
                .append("\n}");
        return sb.toString();
    }
}