Search in sources :

Example 6 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class ServiceManagerFactoryServlet method init.

/**
 * サーブレットの初期化を行う。<p>
 * サービス定義のロード及びロード完了チェックを行う。
 *
 * @exception ServletException サーブレットの初期化に失敗した場合
 */
public synchronized void init() throws ServletException {
    ServiceName jsonConverterServiceName = getJSONConverterServiceName();
    if (jsonConverterServiceName == null) {
        jsonConverter = new BeanJSONConverter();
    } else {
        jsonConverter = (BeanJSONConverter) ServiceManagerFactory.getServiceObject(jsonConverterServiceName);
    }
    jsonConverter.setCharacterEncodingToStream("UTF-8");
    jsonConverter.setUnicodeEscape(isUnicodeEscape());
    toStringConverter = new StringStreamConverter(StringStreamConverter.STREAM_TO_STRING);
    toStringConverter.setCharacterEncodingToObject("UTF-8");
    final String[] servicePaths = getServicePaths();
    final boolean isValidate = isValidate();
    if (servicePaths != null && servicePaths.length != 0) {
        for (int i = 0; i < servicePaths.length; i++) {
            ServiceManagerFactory.loadManager(servicePaths[i], true, isValidate);
        }
    }
    if (isCheckLoadManagerCompleted()) {
        final String[] managerNames = getCheckLoadManagerCompletedBy();
        if (managerNames == null || managerNames.length == 0) {
            ServiceManagerFactory.checkLoadManagerCompleted();
        } else {
            for (int i = 0; i < managerNames.length; i++) {
                ServiceManagerFactory.checkLoadManagerCompletedBy(managerNames[i]);
            }
        }
    }
    if (DEFAULT_IGNORE_METHODS != null) {
        ignoreMethodMap = new ClassMappingTree();
        for (int i = 0; i < DEFAULT_IGNORE_METHODS.length; i++) {
            ignoreMethodMap.add(DEFAULT_IGNORE_METHODS[i].getDeclaringClass(), DEFAULT_IGNORE_METHODS[i]);
        }
    }
    final Method[] ignoreMethods = getIgnoreMethods();
    if (ignoreMethods != null && ignoreMethods.length != 0) {
        if (ignoreMethodMap == null) {
            ignoreMethodMap = new ClassMappingTree();
        }
        for (int i = 0; i < ignoreMethods.length; i++) {
            ignoreMethodMap.add(ignoreMethods[i].getDeclaringClass(), ignoreMethods[i]);
        }
    }
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Example 7 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class BeanExchangeConverter method setEnabledPropertyNames.

/**
 * Javaオブジェクト→JSON変換時に出力するプロパティ名を設定する。<p>
 *
 * @param type 対象のクラス
 * @param names プロパティ名の配列
 */
public void setEnabledPropertyNames(Class type, String[] names) {
    if (propertyAccessTypeMap == null) {
        propertyAccessTypeMap = new ClassMappingTree();
    }
    PropertyAccessType pat = (PropertyAccessType) propertyAccessTypeMap.getValueOf(type);
    if (pat == null) {
        pat = new PropertyAccessType();
        propertyAccessTypeMap.add(type, pat);
    }
    if (names == null || names.length == 0) {
        pat.enabledPropertyNames = null;
    } else {
        if (pat.enabledPropertyNames == null) {
            pat.enabledPropertyNames = new HashSet();
        } else {
            pat.enabledPropertyNames.clear();
        }
        for (int i = 0; i < names.length; i++) {
            pat.enabledPropertyNames.add(names[i]);
        }
    }
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree) HashSet(java.util.HashSet)

Example 8 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class BeanJSONConverter method setDisabledPropertyNames.

/**
 * Javaオブジェクト→JSON変換時に出力しないプロパティ名を設定する。<p>
 *
 * @param type 対象のクラス
 * @param names プロパティ名の配列
 */
public void setDisabledPropertyNames(Class type, String[] names) {
    if (propertyAccessTypeMap == null) {
        propertyAccessTypeMap = new ClassMappingTree();
    }
    PropertyAccessType pat = (PropertyAccessType) propertyAccessTypeMap.getValueOf(type);
    if (pat == null) {
        pat = new PropertyAccessType();
        propertyAccessTypeMap.add(type, pat);
    }
    if (names == null || names.length == 0) {
        pat.disabledPropertyNames = null;
    } else {
        if (pat.disabledPropertyNames == null) {
            pat.disabledPropertyNames = new HashSet();
        } else {
            pat.disabledPropertyNames.clear();
        }
        for (int i = 0; i < names.length; i++) {
            pat.disabledPropertyNames.add(names[i]);
        }
    }
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Example 9 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class BeanJSONConverter method setFieldOnly.

/**
 * Javaオブジェクト→JSON変換時にJavaオブジェクトのpublicフィールドのみを対象とするかどうかを設定する。<p>
 * デフォルトは、falseでpublicフィールドのみを対象にはしない。<br>
 *
 * @param type 対象のクラス
 * @param isFieldOnly publicフィールドのみを対象とする場合は、true
 */
public void setFieldOnly(Class type, boolean isFieldOnly) {
    if (propertyAccessTypeMap == null) {
        propertyAccessTypeMap = new ClassMappingTree();
    }
    PropertyAccessType pat = (PropertyAccessType) propertyAccessTypeMap.getValueOf(type);
    if (pat == null) {
        pat = new PropertyAccessType();
        propertyAccessTypeMap.add(type, pat);
    }
    pat.isFieldOnly = isFieldOnly;
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Example 10 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class ExceptionHandlerMappingService method startService.

@Override
public void startService() throws Exception {
    final ClassLoader loader = NimbusClassLoader.getInstance();
    if (exceptionAndHandlerMapping != null) {
        exceptionMapForHandler = new ClassMappingTree();
        final ServiceNameEditor editor = new ServiceNameEditor();
        editor.setServiceManagerName(getServiceManagerName());
        final Iterator exNames = exceptionAndHandlerMapping.keySet().iterator();
        while (exNames.hasNext()) {
            final String exName = (String) exNames.next();
            final Class clazz = Class.forName(exName, true, loader);
            final String name = (String) exceptionAndHandlerMapping.get(exName);
            editor.setAsText(name);
            final ServiceName serviceName = (ServiceName) editor.getValue();
            exceptionMapForHandler.add(clazz, ServiceManagerFactory.getServiceObject(serviceName));
        }
    }
    if (defaultExceptionHandlerServiceName != null) {
        defaultExceptionHandler = (ExceptionHandler) ServiceManagerFactory.getServiceObject(defaultExceptionHandlerServiceName);
    }
}
Also used : ServiceNameEditor(jp.ossc.nimbus.beans.ServiceNameEditor) ServiceName(jp.ossc.nimbus.core.ServiceName) Iterator(java.util.Iterator) NimbusClassLoader(jp.ossc.nimbus.core.NimbusClassLoader) ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Aggregations

ClassMappingTree (jp.ossc.nimbus.util.ClassMappingTree)17 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)1 ServiceNameEditor (jp.ossc.nimbus.beans.ServiceNameEditor)1 NimbusClassLoader (jp.ossc.nimbus.core.NimbusClassLoader)1 ServiceName (jp.ossc.nimbus.core.ServiceName)1