當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractPropertyPlaceholder類代碼示例

本文整理匯總了Java中org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder的典型用法代碼示例。如果您正苦於以下問題:Java AbstractPropertyPlaceholder類的具體用法?Java AbstractPropertyPlaceholder怎麽用?Java AbstractPropertyPlaceholder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractPropertyPlaceholder類屬於org.apache.aries.blueprint.ext包,在下文中一共展示了AbstractPropertyPlaceholder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processMutableBeanMetadata

import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder; //導入依賴的package包/類
private void processMutableBeanMetadata(final MutableBeanMetadata bean) {
    if (restartDependentsOnUpdates && bean.getRuntimeClass() != null
            && AbstractPropertyPlaceholder.class.isAssignableFrom(bean.getRuntimeClass())) {
        LOG.debug("{}: Found PropertyPlaceholder bean: {}, runtime {}", logName(), bean.getId(),
                bean.getRuntimeClass());

        for (BeanProperty prop : bean.getProperties()) {
            if (CM_PERSISTENT_ID_PROPERTY.equals(prop.getName())) {
                if (prop.getValue() instanceof ValueMetadata) {
                    ValueMetadata persistentId = (ValueMetadata)prop.getValue();

                    LOG.debug("{}: Found {} property, value : {}", logName(),
                            CM_PERSISTENT_ID_PROPERTY, persistentId.getStringValue());

                    registerManagedService(persistentId.getStringValue());
                } else {
                    LOG.debug("{}: {} property metadata {} is not instanceof ValueMetadata",
                            logName(), CM_PERSISTENT_ID_PROPERTY, prop.getValue());
                }

                break;
            }
        }
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:26,代碼來源:ComponentProcessor.java

示例2: lookupPropertyPlaceholderIds

import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder; //導入依賴的package包/類
/**
 * Lookup the ids of the Blueprint property placeholder services in the
 * Blueprint container.
 *
 * @return the ids, will be an empty array if none found.
 */
public String[] lookupPropertyPlaceholderIds() {
    List<String> ids = new ArrayList<String>();

    for (Object componentId : container.getComponentIds()) {
        String id = (String) componentId;
        ComponentMetadata meta = container.getComponentMetadata(id);
        if (meta instanceof ExtendedBeanMetadata) {
            Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
            if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
                ids.add(id);
            }
        }
    }

    return ids.toArray(new String[ids.size()]);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:BlueprintPropertiesParser.java

示例3: addPropertyPlaceholder

import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder; //導入依賴的package包/類
/**
 * Adds the given Blueprint property placeholder service with the given id
 *
 * @param id id of the Blueprint property placeholder service to add.
 */
public void addPropertyPlaceholder(String id) {
    Object component = container.getComponentInstance(id);

    if (component instanceof AbstractPropertyPlaceholder) {
        AbstractPropertyPlaceholder placeholder = (AbstractPropertyPlaceholder) component;
        placeholders.add(placeholder);

        log.debug("Adding Blueprint PropertyPlaceholder: {}", id);

        if (method == null) {
            try {
                method = AbstractPropertyPlaceholder.class.getDeclaredMethod("getProperty", String.class);
                method.setAccessible(true);
            } catch (NoSuchMethodException e) {
                throw new IllegalStateException("Cannot add blueprint property placeholder: " + id
                        + " as the method getProperty is not accessible", e);
            }
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:26,代碼來源:BlueprintPropertiesParser.java

示例4: parseProperty

import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder; //導入依賴的package包/類
@Override
public String parseProperty(String key, String value, Properties properties) {
    log.trace("Parsing property key: {} with value: {}", key, value);

    String answer = null;

    // prefer any override properties
    // this logic is special for BlueprintPropertiesParser as we otherwise prefer
    // to use the AbstractPropertyPlaceholder from OSGi blueprint config admins
    // service to lookup otherwise
    if (key != null && propertiesComponent.getOverrideProperties() != null) {
        answer = (String) propertiesComponent.getOverrideProperties().get(key);
    }

    // lookup key in blueprint and return its value
    if (answer == null && key != null) {
        for (AbstractPropertyPlaceholder placeholder : placeholders) {
            boolean isDefault = false;
            if (placeholders.size() > 1) {
                // okay we have multiple placeholders and we want to return the answer that
                // is not the default placeholder if there is multiple keys
                if (placeholder instanceof PropertyPlaceholder) {
                    Map map = ((PropertyPlaceholder) placeholder).getDefaultProperties();
                    isDefault = map != null && map.containsKey(key);
                }
                log.trace("Blueprint property key: {} is part of default properties: {}", key, isDefault);
            }
            
            try {
                String candidate = (String) ObjectHelper.invokeMethod(method, placeholder, key);

                if (candidate != null) {
                    if (answer == null || !isDefault) {
                        log.trace("Blueprint parsed candidate property key: {} as value: {}", key, answer);
                        answer = candidate;
                    }
                }
            } catch (Exception ex) {
                // Here we just catch the exception and try to use other candidate
            }  
        }
        log.debug("Blueprint parsed property key: {} as value: {}", key, answer);
    }
    
    // if there is a delegate then let it parse the current answer as it may be jasypt which
    // need to decrypt values
    if (delegate != null) {
        String delegateAnswer = delegate.parseProperty(key, answer != null ? answer : value, properties);
        if (delegateAnswer != null) {
            answer = delegateAnswer;
            log.debug("Delegate property parser parsed the property key: {} as value: {}", key, answer);
        }
    }
    
    if (answer == null) {
        throw new IllegalArgumentException("Property placeholder key: " + key + " not found");
    }

    log.trace("Returning parsed property key: {} as value: {}", key, answer);
    return answer;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:62,代碼來源:BlueprintPropertiesParser.java


注:本文中的org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。