Search in sources :

Example 11 with MessageRecordFactory

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

the class DefaultServiceLoaderService method loadService.

// ServiceLoaderのJavaDoc
public void loadService(String managerName, String serviceName) throws DeploymentException {
    final ServiceMetaData serviceData = getServiceMetaData(managerName, serviceName);
    if (serviceData == null) {
        final MessageRecordFactory message = getMessageRecordFactory();
        throw new DeploymentException(message.findEmbedMessage(SVCL_00035, new Object[] { managerName, serviceName }));
    }
    deployServiceMetaData(serviceData);
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 12 with MessageRecordFactory

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

the class DefaultServiceLoaderService method checkDepends.

private void checkDepends(Map refServices, ServiceNameMetaData dependsData) throws DeploymentException {
    if (dependsData == null) {
        return;
    }
    final String depManagerName = dependsData.getManagerName();
    final String depServiceName = dependsData.getServiceName();
    if (refServices.containsKey(depManagerName)) {
        final Map services = (Map) refServices.get(depManagerName);
        if (services.containsKey(depServiceName)) {
            return;
        }
    }
    final MessageRecordFactory message = getMessageRecordFactory();
    throw new DeploymentException(message.findEmbedMessage(SVCL_00036, new Object[] { depManagerName, depServiceName }));
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 13 with MessageRecordFactory

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

the class DefaultServiceLoaderService method loadServerMetaData.

/**
 * サービス定義を読み込み、サービス定義&lt;server&gt;要素メタデータを構築する。<p>
 * ここでは、以下の処理を行う。<br>
 * <ol>
 *   <li>指定されたストリームからサービス定義XMLを読み込み、パースする。</li>
 *   <li>パースしたサービス定義XMLから、{@link ServerMetaData}を生成する。ServerMetaDataの生成の過程で、各要素に対応するメタデータも生成される。</li>
 * </ol>
 *
 * @param is サービス定義入力ストリーム
 * @exception ParserConfigurationException XMLパーサの生成に失敗した場合
 * @exception IOException {@link #setServiceURL(URL)}で設定されたURLにサービス定義XMLが見つからない場合
 * @exception SAXException サービス定義XMLのパースに失敗した場合
 * @exception DeploymentException サービス定義の設定に誤りがある場合
 */
public ServerMetaData loadServerMetaData(InputStream is) throws IOException, ParserConfigurationException, SAXException, DeploymentException {
    final InputSource inputSource = new InputSource(is);
    final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    domFactory.setValidating(isValidate());
    final DocumentBuilder builder = domFactory.newDocumentBuilder();
    final NimbusEntityResolver resolver = new NimbusEntityResolver();
    builder.setEntityResolver(resolver);
    final MyErrorHandler handler = new MyErrorHandler();
    builder.setErrorHandler(handler);
    final Document doc = builder.parse(inputSource);
    if (handler.isError()) {
        final MessageRecordFactory message = getMessageRecordFactory();
        throw new DeploymentException(message.findEmbedMessage(SVCL_00033, serviceURL));
    }
    final ServerMetaData serverData = new ServerMetaData(this, serviceURL);
    final DocumentType docType = doc.getDoctype();
    if (docType != null) {
        serverData.setDocType("<!DOCTYPE " + docType.getName() + " PUBLIC \"" + docType.getPublicId() + "\" \"" + docType.getSystemId() + "\">");
    }
    if (inputSource.getEncoding() != null) {
        serverData.setEncoding(inputSource.getEncoding());
    }
    serverData.importXML(doc.getDocumentElement());
    final Properties props = serverData.getProperties();
    final Object[] propKeys = props.keySet().toArray();
    for (int i = 0; i < propKeys.length; i++) {
        final String propKey = (String) propKeys[i];
        String prop = props.getProperty(propKey);
        // システムプロパティの置換
        prop = Utility.replaceSystemProperty(prop);
        // サービスローダ構成プロパティの置換
        prop = Utility.replaceServiceLoderConfig(prop, getConfig());
        // サーバプロパティの置換
        prop = Utility.replaceServerProperty(prop);
        ServiceManagerFactory.setProperty(propKey, prop);
    }
    return serverData;
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 14 with MessageRecordFactory

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

the class DefaultServiceManagerService method isMatchingState.

private boolean isMatchingState(Service service, int state, boolean isInit) throws IllegalStateException {
    final int serviceState = service.getState();
    ServiceMetaData serviceData = null;
    try {
        serviceData = ServiceManagerFactory.getServiceMetaData(service.getServiceManagerName(), service.getServiceName());
    } catch (ServiceNotFoundException e) {
    }
    if (state < STARTED && serviceData != null && isInit && serviceData.getInitStateValue() < state) {
        return true;
    }
    switch(state) {
        case CREATING:
        case CREATED:
            return serviceState == CREATED || serviceState == STARTING || serviceState == STARTED;
        case STARTING:
        case STARTED:
            return serviceState == STARTED;
        case STOPPING:
        case STOPPED:
            return serviceState == STOPPED || serviceState == DESTROYING || serviceState == DESTROYED;
        case DESTROYING:
        case DESTROYED:
            return serviceState == DESTROYED;
        default:
            final MessageRecordFactory message = getMessageRecordFactory();
            throw new IllegalStateException(message.findEmbedMessage(SVCM_00011, new Object[] { getServiceName(), name, STATES[state], STATES[serviceState] }));
    }
}
Also used : MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory)

Example 15 with MessageRecordFactory

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

the class DefaultCommonsLogFactoryService method getInstance.

// CommonsLogFactoryのJavaDoc
public Log getInstance(String name) throws LogConfigurationException {
    if (logInstances == null) {
        final MessageRecordFactory message = getMessageRecordFactory();
        throw new LogConfigurationException(message.findMessage(DCLF_00001));
    }
    if (logInstances.containsKey(name)) {
        return (Log) logInstances.get(name);
    }
    final CommonsLog log = new CommonsLog(name);
    logInstances.put(name, log);
    if (!enabledClientSet.isEmpty()) {
        log.setEnabled(containsEnabledClient(log));
    }
    return log;
}
Also used : Log(org.apache.commons.logging.Log) MessageRecordFactory(jp.ossc.nimbus.service.message.MessageRecordFactory) LogConfigurationException(org.apache.commons.logging.LogConfigurationException)

Aggregations

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