Search in sources :

Example 6 with MessageRecordFactory

use of jp.ossc.nimbus.service.message.MessageRecordFactory in project nimbus by nimbus-org.

the class SimpleCategoryService method setLabel.

/**
 * ログの優先順位に対応するラベルを設定する。<p>
 *
 * @param min 優先順位範囲の最小値
 * @param max 優先順位範囲の最大値
 * @param label ラベル
 * @exception IllegalArgumentException 優先順位範囲の指定が不正な場合。
 */
public void setLabel(int min, int max, String label) throws IllegalArgumentException {
    if (min > max) {
        final MessageRecordFactory message = getMessageRecordFactory();
        throw new IllegalArgumentException(message.findMessage(SCGRY00002));
    }
    final Range range = new Range(min, max);
    labelMap.put(range, label);
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 7 with MessageRecordFactory

use of jp.ossc.nimbus.service.message.MessageRecordFactory in project nimbus by nimbus-org.

the class SimpleCategoryService method parseRange.

private Range parseRange(String range) throws IllegalArgumentException {
    final MessageRecordFactory message = getMessageRecordFactory();
    final StringTokenizer tokens = new StringTokenizer(range, PRIORITY_RANGE_DELIMITER);
    if (tokens.countTokens() != 2) {
        throw new IllegalArgumentException(message.findMessage(SCGRY00001));
    }
    final String minStr = tokens.nextToken();
    final String maxStr = tokens.nextToken();
    int min = 0;
    int max = 0;
    try {
        min = Integer.parseInt(minStr);
        max = Integer.parseInt(maxStr);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException(message.findMessage(SCGRY00001));
    }
    if (min > max) {
        throw new IllegalArgumentException(message.findMessage(SCGRY00002));
    }
    return new Range(min, max);
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 8 with MessageRecordFactory

use of jp.ossc.nimbus.service.message.MessageRecordFactory in project nimbus by nimbus-org.

the class SimpleCategoryService method setLabels.

// SimpleCategoryServiceMBeanのJavaDoc
public void setLabels(Properties labels) throws IllegalArgumentException {
    final Iterator ranges = labels.keySet().iterator();
    while (ranges.hasNext()) {
        final String rangeStr = (String) ranges.next();
        final Range range = parseRange(rangeStr);
        if (labelMap.containsKey(new Integer(range.min)) || labelMap.containsKey(new Integer(range.max))) {
            final MessageRecordFactory message = getMessageRecordFactory();
            throw new IllegalArgumentException(message.findMessage(SCGRY00003));
        }
        labelMap.put(range, labels.get(rangeStr));
    }
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 9 with MessageRecordFactory

use of jp.ossc.nimbus.service.message.MessageRecordFactory in project nimbus by nimbus-org.

the class DefaultServiceLoaderService method setServiceManagerClassName.

// ServiceLoaderのJavaDoc
public void setServiceManagerClassName(String className) throws ClassNotFoundException, IllegalArgumentException {
    final Logger logger = getLogger();
    if (className != null && className.length() != 0) {
        Class clazz = null;
        try {
            clazz = Class.forName(className, true, NimbusClassLoader.getInstance());
        } catch (ClassNotFoundException e) {
            logger.write(SVCL_00001, new Object[] { ServiceManager.class, className }, e);
            throw e;
        }
        if (ServiceManager.class.isAssignableFrom(clazz)) {
            serviceManagerClassName = className;
            logger.write(SVCL_00002, className);
        } else {
            final MessageRecordFactory message = getMessageRecordFactory();
            throw new IllegalArgumentException(message.findEmbedMessage(SVCL_00003, className));
        }
    }
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 10 with MessageRecordFactory

use of jp.ossc.nimbus.service.message.MessageRecordFactory in project nimbus by nimbus-org.

the class DefaultServiceLoaderService method deployServiceMetaData.

/**
 * サービス定義&lt;service&gt;要素メタデータを配置する。<p>
 *
 * @param serviceData サービス定義&lt;service&gt;要素メタデータ
 * @exception DeploymentException サービス定義の設定に誤りがある場合
 */
protected void deployServiceMetaData(ServiceMetaData serviceData) throws DeploymentException {
    final Logger logger = getLogger();
    logger.write(SVCL_00021, serviceData);
    final String managerName = serviceData.getManager().getName();
    final String serviceName = serviceData.getName();
    ServiceManager manager = ServiceManagerFactory.findManager(managerName);
    if (manager == null) {
        manager = (ServiceManager) managerMap.get(managerName);
    }
    if (manager == null) {
        final MessageRecordFactory message = getMessageRecordFactory();
        throw new DeploymentException(message.findEmbedMessage(SVCL_00029, managerName));
    }
    final Map serviceMetaMap = (Map) managersServiceMetaMap.get(managerName);
    if (serviceData.isTemplate()) {
        if (manager.isRegisteredService(serviceName) || serviceMetaMap.containsKey(serviceName)) {
            final MessageRecordFactory message = getMessageRecordFactory();
            throw new DeploymentException(message.findEmbedMessage(SVCL_00034, new Object[] { managerName, serviceName }));
        }
        serviceMetaMap.put(serviceName, serviceData);
    } else {
        serviceData = serviceData.applyTemplate(this);
        if (manager.isRegisteredService(serviceName) || serviceMetaMap.containsKey(serviceName)) {
            final MessageRecordFactory message = getMessageRecordFactory();
            throw new DeploymentException(message.findEmbedMessage(SVCL_00034, new Object[] { managerName, serviceName }));
        }
        logger.write(SVCL_00023, new Object[] { managerName, serviceName });
        serviceMetaMap.put(serviceName, serviceData);
        try {
            manager.registerService(serviceData);
        } catch (Exception e) {
            logger.write(SVCL_00022, new Object[] { managerName, serviceName }, e);
            throw new DeploymentException(e);
        }
    }
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Aggregations

MessageRecordFactory (jp.ossc.nimbus.service.message.MessageRecordFactory)16 Log (org.apache.commons.logging.Log)2 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)2