All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.petals.bc.quartz.utils.QuartzUtils Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
/**
 * Copyright (c) 2009-2012 EBM WebSourcing, 2012-2017 Linagora
 * 
 * This program/library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * This program/library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program/library; If not, see http://www.gnu.org/licenses/
 * for the GNU Lesser General Public License version 2.1.
 */
package org.ow2.petals.bc.quartz.utils;

import org.ow2.petals.component.framework.jbidescriptor.generated.Consumes;

import com.ebmwebsourcing.easycommons.lang.StringHelper;

/**
 * @author Adrien LOUIS - EBM WebSourcing
 * @author Vincent Zurczak - EBM WebSourcing
 */
public class QuartzUtils {

    private QuartzUtils() {
        // No constructor because it's an utility class
    }

    /**
     * @param consume
     *            a consume section
     * @return a job name to invoke the target service
     */
    public static String generateJobName(final Consumes consume) {

        return String.format("JOB_%s/%s/%s", consume.getInterfaceName().toString(), consume.getServiceName().toString(),
                consume.getEndpointName());
    }

    /**
     * @param consume
     *            a consume section
     * @return a trigger name for the target service
     */
    public static String generateTriggerName(final Consumes consume) {

        return String.format("TRIGGER_%s/%s/%s", consume.getInterfaceName().toString(),
                consume.getServiceName().toString(), consume.getEndpointName());
    }

    /**
     * Builds the identifier of the consumed service.
     * 

* This method is mainly intended for a logging usage. *

* * @param consume * a consumes section * @return the service */ public static String buildTargetServiceIdentifier(final Consumes consume) { String itfName = consume.getInterfaceName() != null ? consume.getInterfaceName().getLocalPart() : null; if (StringHelper.isNullOrEmpty(itfName)) itfName = "unknown"; String srvName = consume.getServiceName() != null ? consume.getServiceName().getLocalPart() : null; if (StringHelper.isNullOrEmpty(srvName)) srvName = "unknown"; String edptName = consume.getEndpointName(); if (StringHelper.isNullOrEmpty(edptName)) edptName = "unknown"; return itfName + "/" + srvName + "/" + edptName; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy