Search in sources :

Example 11 with ServiceNameEditor

use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method startService.

/**
 * サービスの開始処理を行う。<p>
 *
 * @exception Exception 開始処理に失敗した場合
 */
public void startService() throws Exception {
    metricsInfos.clear();
    if (keyAndCategoryServiceNameMapping != null && keyAndCategoryServiceNameMapping.size() != 0) {
        final ServiceNameEditor nameEditor = new ServiceNameEditor();
        nameEditor.setServiceManagerName(getServiceManagerName());
        final Iterator keys = keyAndCategoryServiceNameMapping.keySet().iterator();
        while (keys.hasNext()) {
            final String key = (String) keys.next();
            final String nameStr = keyAndCategoryServiceNameMapping.getProperty(key);
            nameEditor.setAsText(nameStr);
            final ServiceName name = (ServiceName) nameEditor.getValue();
            final Category category = (Category) ServiceManagerFactory.getServiceObject(name);
            keyAndCategoryMap.put(key, category);
        }
    }
    if (categoryServiceName != null) {
        metricsCategory = (Category) ServiceManagerFactory.getServiceObject(categoryServiceName);
    }
    if ((keyAndCategoryMap != null && keyAndCategoryMap.size() != 0) || metricsCategory != null) {
        writerDaemon = new Daemon(this);
        writerDaemon.setName("Nimbus MetricsWriteDaemon " + getServiceNameObject());
        writerDaemon.start();
    }
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor) Category(jp.ossc.nimbus.service.writer.Category) Daemon(jp.ossc.nimbus.daemon.Daemon) ServiceName(jp.ossc.nimbus.core.ServiceName) Iterator(java.util.Iterator)

Example 12 with ServiceNameEditor

use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.

the class NimbusLogFactory method getInstance.

/**
 * 指定されたキーに対応するLogインスタンスを取得する。<p>
 *
 * @param key キー情報
 * @return Logインスタンス
 */
private Log getInstance(final Object key) {
    if (logInstances.containsKey(key)) {
        return (Log) logInstances.get(key);
    }
    if (deafultLogFactory == null) {
        deafultLogFactory = createDefaultLogFactory();
    }
    LogWrapper log = null;
    if (logFactory != null) {
        if (key instanceof Class) {
            log = new LogWrapper(logFactory.getInstance((Class) key), deafultLogFactory.getInstance((Class) key));
        } else {
            log = new LogWrapper(logFactory.getInstance((String) key), deafultLogFactory.getInstance((String) key));
        }
        logInstances.put(key, log);
        return log;
    }
    String factoryName = System.getProperty(FACTORY_NAME_PROPERTY);
    if (factoryName == null) {
        factoryName = (String) getAttribute(FACTORY_NAME_PROPERTY);
    }
    if (factoryName == null) {
        if (key instanceof Class) {
            log = new LogWrapper(deafultLogFactory.getInstance((Class) key));
        } else {
            log = new LogWrapper(deafultLogFactory.getInstance((String) key));
        }
        logInstances.put(key, log);
        return log;
    }
    final ServiceNameEditor editor = new ServiceNameEditor();
    editor.setAsText(factoryName);
    final ServiceName name = (ServiceName) editor.getValue();
    LogWrapper tmpLog = null;
    if (key instanceof Class) {
        tmpLog = new LogWrapper(deafultLogFactory.getInstance((Class) key));
    } else {
        tmpLog = new LogWrapper(deafultLogFactory.getInstance((String) key));
    }
    log = tmpLog;
    logInstances.put(key, log);
    final String managerName = name.getServiceManagerName();
    final String serviceName = name.getServiceName();
    if (!ServiceManagerFactory.isRegisteredManager(managerName)) {
        waitRegistrationManager(managerName, serviceName);
        return log;
    }
    final ServiceManager manager = ServiceManagerFactory.findManager(managerName);
    if (!manager.isRegisteredService(serviceName)) {
        waitRegistrationService(manager, serviceName);
        return log;
    }
    final Service service = manager.getService(serviceName);
    waitStartService(service);
    return log;
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor) Log(org.apache.commons.logging.Log)

Example 13 with ServiceNameEditor

use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.

the class ServiceNameMetaData method importXML.

/**
 * サービス名を表す要素のElementをパースして、自分自身の初期化を行う。<p>
 *
 * @param element サービス名を表す要素のElement
 * @exception DeploymentException サービス名を表す要素の解析に失敗した場合
 */
public void importXML(Element element) throws DeploymentException {
    super.importXML(element);
    tagName = element.getTagName();
    managerName = getOptionalAttribute(element, MANAGER_NAME_ATTRIBUTE_NAME, managerName == null ? ServiceManager.DEFAULT_NAME : managerName);
    String content = getElementContent(element);
    if (content != null && content.length() != 0) {
        if (content != null) {
            // システムプロパティの置換
            content = Utility.replaceSystemProperty(content);
            final MetaData parent = getParent();
            if (parent != null && parent instanceof ObjectMetaData) {
                ObjectMetaData objData = (ObjectMetaData) parent;
                if (objData.getServiceLoader() != null) {
                    // サービスローダ構成プロパティの置換
                    content = Utility.replaceServiceLoderConfig(content, objData.getServiceLoader().getConfig());
                }
            }
            if (parent != null && parent instanceof ServiceMetaData) {
                ServiceMetaData serviceData = (ServiceMetaData) parent;
                if (serviceData.getManager() != null) {
                    // マネージャプロパティの置換
                    content = Utility.replaceManagerProperty(serviceData.getManager(), content);
                }
            }
            // サーバプロパティの置換
            content = Utility.replaceServerProperty(content);
        }
        if (content.indexOf('#') != -1) {
            final ServiceNameEditor editor = new ServiceNameEditor();
            editor.setServiceManagerName(managerName);
            editor.setAsText(content);
            final ServiceName editName = (ServiceName) editor.getValue();
            if (!editName.getServiceManagerName().equals(managerName)) {
                managerName = editName.getServiceManagerName();
            }
            serviceName = editName.getServiceName();
        } else {
            serviceName = content;
        }
    } else {
        throw new DeploymentException("Content of '" + tagName + "' element must not be null.");
    }
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor)

Example 14 with ServiceNameEditor

use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.

the class ServiceMetaData method applyTemplate.

/**
 * テンプレートを適用したメタデータを生成する。<p>
 *
 * @param loader ServiceLoader
 * @return テンプレート適用後のメタデータ
 * @exception ServiceNotFoundException テンプレートとして指定されているサービスメタデータが見つからない場合
 */
public ServiceMetaData applyTemplate(ServiceLoader loader) throws ServiceNotFoundException {
    if (getTemplateName() == null) {
        return this;
    }
    ServiceNameEditor editor = new ServiceNameEditor();
    if (getManager() != null) {
        editor.setServiceManagerName(getManager().getName());
    }
    editor.setAsText(getTemplateName());
    ServiceName temlateServiceName = (ServiceName) editor.getValue();
    ServiceMetaData templateData = null;
    if (loader != null) {
        templateData = loader.getServiceMetaData(temlateServiceName.getServiceManagerName(), temlateServiceName.getServiceName());
    }
    if (templateData == null) {
        templateData = ServiceManagerFactory.getServiceMetaData(temlateServiceName);
    }
    templateData = templateData.applyTemplate(loader);
    ServiceMetaData result = (ServiceMetaData) clone();
    if (result.constructor == null) {
        result.constructor = templateData.constructor;
    }
    if (templateData.fields.size() != 0) {
        Iterator entries = templateData.fields.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            if (!result.fields.containsKey(entry.getKey())) {
                result.fields.put(entry.getKey(), entry.getValue());
            }
        }
    }
    if (templateData.attributes.size() != 0) {
        Iterator entries = templateData.attributes.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            if (!result.attributes.containsKey(entry.getKey())) {
                result.attributes.put(entry.getKey(), entry.getValue());
            }
        }
    }
    if (templateData.invokes.size() != 0) {
        result.invokes.addAll(templateData.invokes);
    }
    if (result.optionalConfig == null) {
        result.optionalConfig = templateData.optionalConfig;
    }
    if (templateData.depends.size() != 0) {
        result.depends.addAll(templateData.depends);
    }
    return result;
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor)

Example 15 with ServiceNameEditor

use of jp.ossc.nimbus.beans.ServiceNameEditor in project nimbus by nimbus-org.

the class XYPlotFactoryService method createPlot.

// PlotFactoryのJavaDoc
public Plot createPlot(PlotCondition[] plotConditions) throws PlotCreateException {
    // 複数のプロット条件を1つにマージ
    XYPlotConditionImpl xyPlotCondition = mergeXYPlotCondition(plotConditions);
    if (xyPlotCondition == null) {
        return new XYPlot(null, new NumberAxis(), new NumberAxis(), new XYLineAndShapeRenderer(true, false));
    }
    // テンプレートのプロットから値をコピーしたプロット作成
    XYPlot xyPlot = copyXYPlot();
    // データセットリスト
    List dsFactoryList = new ArrayList();
    // 有効なデータセット名を取得
    String[] enableDsNames = xyPlotCondition.getEnableDatasetNames();
    // 設定順のデータセット名を取得
    String[] dsNamesOrder = xyPlotCondition.getDatasetNameOrder();
    // データセット条件に設定されたときのみ適用
    if (dsNamesOrder != null && dsNamesOrder.length > 0) {
        for (int j = 0; j < dsNamesOrder.length; j++) {
            // データセット名
            String dsName = dsNamesOrder[j];
            boolean isEnabled = false;
            if (enableDsNames != null && enableDsNames.length > 0) {
                for (int k = 0; k < enableDsNames.length; k++) {
                    if (dsName.equals(enableDsNames[k])) {
                        isEnabled = true;
                        break;
                    }
                }
                if (isEnabled) {
                    if (dsFactoryMap.containsKey(dsName)) {
                        // 有効なデータセット
                        dsFactoryList.add(dsFactoryMap.get(dsName));
                    }
                }
            }
        }
    } else {
        /*
             * データセット条件にデータセット順序、有効データセット名が
             * 設定されなかった場合は、サービス定義の順序でデータセットを設定
             */
        dsFactoryList.addAll(dsFactoryMap.values());
    }
    for (int j = 0; j < dsFactoryList.size(); j++) {
        DatasetFactory dsFactory = (DatasetFactory) dsFactoryList.get(j);
        String dsName = dsFactory.getName();
        DatasetCondition[] dsConditions = xyPlotCondition.getDatasetConditions();
        Dataset ds = null;
        try {
            ds = dsFactory.createDataset(dsConditions);
        } catch (DatasetCreateException e) {
            // データセット生成失敗
            throw new PlotCreateException(e);
        }
        // サービス名エディタ
        ServiceNameEditor editor = new ServiceNameEditor();
        editor.setServiceManagerName(getServiceManagerName());
        // データセットのループ
        if (ds != null && (ds instanceof XYDataset)) {
            // データセット
            xyPlot.setDataset(j, (XYDataset) ds);
            // このデータセットが所属する横軸名
            if (dsDomainAxisNames != null && dsDomainAxisNames.size() > 0) {
                String domainAxisName = dsDomainAxisNames.getProperty(dsName);
                if (domainAxisName != null && domainAxisIndexMap.containsKey(domainAxisName)) {
                    Integer domainAxisIndex = (Integer) domainAxisIndexMap.get(domainAxisName);
                    xyPlot.mapDatasetToDomainAxis(j, domainAxisIndex.intValue());
                }
            }
            // このデータセットが所属する縦軸名
            if (dsRangeAxisNames != null && dsRangeAxisNames.size() > 0) {
                String rangeAxisName = dsRangeAxisNames.getProperty(dsName);
                if (rangeAxisName != null && rangeAxisIndexMap.containsKey(rangeAxisName)) {
                    Integer rangeAxisIndex = (Integer) rangeAxisIndexMap.get(rangeAxisName);
                    xyPlot.mapDatasetToRangeAxis(j, rangeAxisIndex.intValue());
                }
            }
            // レンダラー
            XYItemRenderer renderer = null;
            if (dsRendererNames != null && dsRendererNames.size() > 0) {
                String rendererNameStr = dsRendererNames.getProperty(dsName);
                editor.setAsText(rendererNameStr);
                ServiceName rendererName = (ServiceName) editor.getValue();
                renderer = (XYItemRenderer) ServiceManagerFactory.getServiceObject(rendererName);
            }
            if (renderer != null) {
                xyPlot.setRenderer(j, renderer);
            } else {
                xyPlot.setRenderer(j, new XYLineAndShapeRenderer(true, false));
            }
        }
    }
    // 横軸
    if (domainAxisServiceNames != null && domainAxisServiceNames.length > 0) {
        for (int j = 0; j < domainAxisServiceNames.length; j++) {
            ValueAxis domainAxis = (ValueAxis) ServiceManagerFactory.getServiceObject(domainAxisServiceNames[j]);
            // 横軸ラベルフォント
            if (xyPlotCondition.getDefaultDomainAxisLabelFontName() != null || xyPlotCondition.getDefaultDomainAxisLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultDomainAxisLabelFontSize() != Integer.MIN_VALUE) {
                domainAxis.setLabelFont(mergeFont(domainAxis.getLabelFont(), xyPlotCondition.getDefaultDomainAxisLabelFontName(), xyPlotCondition.getDefaultDomainAxisLabelFontStyle(), xyPlotCondition.getDefaultDomainAxisLabelFontSize()));
            } else if (xyPlotCondition.getDomainAxisLabelFontName(j) != null || xyPlotCondition.getDomainAxisLabelFontStyle(j) != Integer.MIN_VALUE || xyPlotCondition.getDomainAxisLabelFontSize(j) != Integer.MIN_VALUE) {
                domainAxis.setLabelFont(mergeFont(domainAxis.getLabelFont(), xyPlotCondition.getDomainAxisLabelFontName(j), xyPlotCondition.getDomainAxisLabelFontStyle(j), xyPlotCondition.getDomainAxisLabelFontSize(j)));
            }
            // 横軸Tickラベルフォント
            if (xyPlotCondition.getDefaultDomainAxisTickLabelFontName() != null || xyPlotCondition.getDefaultDomainAxisTickLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultDomainAxisTickLabelFontSize() != Integer.MIN_VALUE) {
                domainAxis.setTickLabelFont(mergeFont(domainAxis.getTickLabelFont(), xyPlotCondition.getDefaultDomainAxisTickLabelFontName(), xyPlotCondition.getDefaultDomainAxisTickLabelFontStyle(), xyPlotCondition.getDefaultDomainAxisTickLabelFontSize()));
            } else if (xyPlotCondition.getDomainAxisTickLabelFontName(j) != null || xyPlotCondition.getDomainAxisTickLabelFontStyle(j) != Integer.MIN_VALUE || xyPlotCondition.getDomainAxisTickLabelFontSize(j) != Integer.MIN_VALUE) {
                domainAxis.setTickLabelFont(mergeFont(domainAxis.getTickLabelFont(), xyPlotCondition.getDomainAxisTickLabelFontName(j), xyPlotCondition.getDomainAxisTickLabelFontStyle(j), xyPlotCondition.getDomainAxisTickLabelFontSize(j)));
            }
            xyPlot.setDomainAxis(j, domainAxis);
        }
    }
    // 縦軸
    if (rangeAxisServiceNames != null && rangeAxisServiceNames.length > 0) {
        for (int j = 0; j < rangeAxisServiceNames.length; j++) {
            ValueAxis rangeAxis = (ValueAxis) ServiceManagerFactory.getServiceObject(rangeAxisServiceNames[j]);
            // 縦軸ラベルフォント
            if (xyPlotCondition.getDefaultRangeAxisLabelFontName() != null || xyPlotCondition.getDefaultRangeAxisLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultRangeAxisLabelFontSize() != Integer.MIN_VALUE) {
                rangeAxis.setLabelFont(mergeFont(rangeAxis.getLabelFont(), xyPlotCondition.getDefaultRangeAxisLabelFontName(), xyPlotCondition.getDefaultRangeAxisLabelFontStyle(), xyPlotCondition.getDefaultRangeAxisLabelFontSize()));
            } else if (xyPlotCondition.getRangeAxisLabelFontName(j) != null || xyPlotCondition.getRangeAxisLabelFontStyle(j) != Integer.MIN_VALUE || xyPlotCondition.getRangeAxisLabelFontSize(j) != Integer.MIN_VALUE) {
                rangeAxis.setLabelFont(mergeFont(rangeAxis.getLabelFont(), xyPlotCondition.getRangeAxisLabelFontName(j), xyPlotCondition.getRangeAxisLabelFontStyle(j), xyPlotCondition.getRangeAxisLabelFontSize(j)));
            }
            // 縦軸Tickラベルフォント
            if (xyPlotCondition.getDefaultRangeAxisTickLabelFontName() != null || xyPlotCondition.getDefaultRangeAxisTickLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultRangeAxisTickLabelFontSize() != Integer.MIN_VALUE) {
                rangeAxis.setTickLabelFont(mergeFont(rangeAxis.getTickLabelFont(), xyPlotCondition.getDefaultRangeAxisTickLabelFontName(), xyPlotCondition.getDefaultRangeAxisTickLabelFontStyle(), xyPlotCondition.getDefaultRangeAxisTickLabelFontSize()));
            } else if (xyPlotCondition.getRangeAxisTickLabelFontName(j) != null || xyPlotCondition.getRangeAxisTickLabelFontStyle(j) != Integer.MIN_VALUE || xyPlotCondition.getRangeAxisTickLabelFontSize(j) != Integer.MIN_VALUE) {
                rangeAxis.setTickLabelFont(mergeFont(rangeAxis.getTickLabelFont(), xyPlotCondition.getRangeAxisTickLabelFontName(j), xyPlotCondition.getRangeAxisTickLabelFontStyle(j), xyPlotCondition.getRangeAxisTickLabelFontSize(j)));
            }
            // 縦軸の可視状態設定
            if (xyPlotCondition.isRangeAxisVisible(j) != null) {
                rangeAxis.setVisible(xyPlotCondition.isRangeAxisVisible(j).booleanValue());
            }
            xyPlot.setRangeAxis(j, rangeAxis);
        }
    }
    if (adjusters != null) {
        // 目盛り調節
        for (int i = 0; i < adjusters.length; i++) {
            adjusters[i].adjust(xyPlot);
        }
    }
    return xyPlot;
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor) NumberAxis(org.jfree.chart.axis.NumberAxis) Dataset(org.jfree.data.general.Dataset) XYDataset(org.jfree.data.xy.XYDataset) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) ArrayList(java.util.ArrayList) XYPlot(org.jfree.chart.plot.XYPlot) ServiceName(jp.ossc.nimbus.core.ServiceName) ValueAxis(org.jfree.chart.axis.ValueAxis) ArrayList(java.util.ArrayList) List(java.util.List) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Aggregations

ServiceNameEditor (jp.ossc.nimbus.beans.ServiceNameEditor)20 ServiceName (jp.ossc.nimbus.core.ServiceName)12 Iterator (java.util.Iterator)4 ServletConfig (javax.servlet.ServletConfig)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 PropertyEditor (java.beans.PropertyEditor)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Method (java.lang.reflect.Method)1