本文整理汇总了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;
}
}
}
}
示例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()]);
}
示例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);
}
}
}
}
示例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;
}