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();
}
}
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;
}
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.");
}
}
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;
}
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;
}
Aggregations