本文整理匯總了Java中org.osgi.service.component.annotations.Component類的典型用法代碼示例。如果您正苦於以下問題:Java Component類的具體用法?Java Component怎麽用?Java Component使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Component類屬於org.osgi.service.component.annotations包,在下文中一共展示了Component類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerExecutorComponent
import org.osgi.service.component.annotations.Component; //導入依賴的package包/類
@SuppressWarnings("Convert2streamapi")
private void registerExecutorComponent(Executor... executors) {
for (Executor executor : executors) {
//register beans
Registry registry = context.getRegistry();
if (registry instanceof PropertyPlaceholderDelegateRegistry) {
registry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
}
SimpleRegistry openexRegistry = (SimpleRegistry) registry;
Set<Map.Entry<String, Object>> beansEntries = executor.beans().entrySet();
for (Map.Entry<String, Object> beansEntry : beansEntries) {
if (!openexRegistry.containsKey(beansEntry.getKey())) {
openexRegistry.put(beansEntry.getKey(), beansEntry.getValue());
}
}
//register components
Set<Map.Entry<String, org.apache.camel.Component>> components = executor.components().entrySet();
for (Map.Entry<String, org.apache.camel.Component> entry : components) {
if (!context.getComponentNames().contains(entry.getKey())) {
context.addComponent(entry.getKey(), entry.getValue());
}
}
}
}
示例2: getAllowedRenditionWidths
import org.osgi.service.component.annotations.Component; //導入依賴的package包/類
/**
* Returns the list of allowed renditions sizes from this component's content policy. If the component doesn't have a content policy,
* then the list will be empty. Rendition widths that are not valid {@link Integer} numbers will be ignored.
*
* @param resourceResolver the request's resource resolver
* @param imageResource the resource identifying the accessed image component
* @return the list of the allowed widths; the list will be <i>empty</i> if the component doesn't have a content policy
*/
private List<Integer> getAllowedRenditionWidths(@Nonnull ResourceResolver resourceResolver, Resource imageResource) {
List<Integer> list = new ArrayList<>();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
if (policyManager != null) {
ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
if (componentManager != null) {
com.day.cq.wcm.api.components.Component component = componentManager.getComponentOfResource(imageResource);
if (component != null && component.isAccessible()) {
String delegatingResourceType =
component.getProperties().get(AbstractImageDelegatingModel.IMAGE_DELEGATE, String.class);
if (StringUtils.isNotEmpty(delegatingResourceType)) {
imageResource = new ImageResourceWrapper(imageResource, delegatingResourceType);
}
}
}
ContentPolicy contentPolicy = policyManager.getPolicy(imageResource);
if (contentPolicy != null) {
String[] allowedRenditionWidths = contentPolicy.getProperties()
.get(com.adobe.cq.wcm.core.components.models.Image.PN_DESIGN_ALLOWED_RENDITION_WIDTHS, new String[0]);
for (String width : allowedRenditionWidths) {
try {
list.add(Integer.parseInt(width));
} catch (NumberFormatException e) {
LOGGER.warn("One of the configured widths ({}) from the {} content policy is not a valid Integer.", width,
contentPolicy.getPath());
return list;
}
}
}
}
return list;
}
示例3: doGet
import org.osgi.service.component.annotations.Component; //導入依賴的package包/類
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
throws ServletException, IOException {
boolean hasImageDelegation = false;
ResourceResolver resourceResolver = request.getResourceResolver();
ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
String suffix = request.getRequestPathInfo().getSuffix();
if (componentManager != null && StringUtils.isNotEmpty(suffix)) {
Resource policiesRootPage = getPoliciesRootPage(resourceResolver, suffix);
if (policiesRootPage != null) {
String resourceType = suffix.substring(policiesRootPage.getPath().length() + 1, suffix.lastIndexOf('/'));
com.day.cq.wcm.api.components.Component component = componentManager.getComponent(resourceType);
if (component != null && component.isAccessible()) {
String imageDelegate = component.getProperties().get(AbstractImageDelegatingModel.IMAGE_DELEGATE, String.class);
if (StringUtils.isNotEmpty(imageDelegate)) {
hasImageDelegation = true;
com.day.cq.wcm.api.components.Component delegate = componentManager.getComponent(imageDelegate);
if (delegate != null && delegate.isAccessible()) {
ExpressionCustomizer customizer = ExpressionCustomizer.from(request);
customizer.setVariable(AbstractImageDelegatingModel.IMAGE_DELEGATE, delegate);
}
}
}
}
}
request.setAttribute(RenderCondition.class.getName(), new SimpleRenderCondition(hasImageDelegation));
}
開發者ID:Adobe-Marketing-Cloud,項目名稱:aem-core-wcm-components,代碼行數:28,代碼來源:ImageDelegateRenderCondition.java