org.apache.sling.models.annotations.Model.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.apache.sling.models.annotations.Model.<init>()方法的一些代码示例,展示了Model.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.<init>()方法的具体详情如下:
包路径:org.apache.sling.models.annotations.Model
类名称:Model
方法名:<init>

Model.<init>介绍

暂无

代码示例

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

/**
 * An exporter for exporting formatted string values
 */
@Model(adaptables = Resource.class)
public class PathReportCellCSVExporter implements ReportCellCSVExporter {

 @Override
 public String getValue(Object result) {
  Resource resource = (Resource) result;
  return resource.getPath();
 }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

/**
 * Model for configuring a query-based report result.
 */
@Model(adaptables = Resource.class)
public interface QueryReportConfig {

 @Inject
 int getPageSize();

 @Inject
 String getQuery();

 @Inject
 String getQueryLanguage();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.launchpad.test-services

@Model(adaptables = SlingHttpServletRequest.class)
public class DummyModel {

  private String message;
  
  @PostConstruct
  public void init() {
    message = "from-sling-model";
  }
  
  public String getMessage() {
    return message;
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.cms.core

/**
 * A model for providing the site-level configuration for the readability
 * insight provider.
 */
@Model(adaptables = Resource.class)
public interface ReadabilitySiteConfig {

  @Inject
  double getMinGradeLevel();

  @Inject
  double getMaxGradeLevel();

}

代码示例来源:origin: Cognifide/APM

@Model(adaptables = Resource.class)
public interface ExampleScriptModel {

  @Inject
  String getContent();

}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

/**
 * An exporter for exporting the containing page
 */
@Model(adaptables = Resource.class)
public class ContainingPageReportCellCSVExporter implements ReportCellCSVExporter {

 @Override
 public String getValue(Object obj) {
  Resource result = (Resource) obj;
  PageManager pageMgr = result.getResourceResolver().adaptTo(PageManager.class);
  Page page = pageMgr.getContainingPage(result);
  return page != null ? page.getPath() : "";
 }

}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

@Model(adaptables = Resource.class)
public interface ExampleScriptModel {

  @Inject
  String getContent();

}

代码示例来源:origin: org.apache.sling/org.apache.sling.cms.core

/**
 * A model for retrieving sites.
 */
@Model(adaptables = Resource.class, adapters = SiteManager.class)
public class SiteManagerImpl implements SiteManager {

  private final Site site;

  public SiteManagerImpl(Resource containingResource) {
    site = SiteImpl.getSite(containingResource);
  }

  public Site getSite() {
    return site;
  }
}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

@Model(adaptables = SlingHttpServletRequest.class)
public class ExecutionModel {

  @Getter
  private final Entry entry;

  @Inject
  public ExecutionModel(@OSGiService History history, SlingHttpServletRequest request) {
    entry = history.find(request.getRequestPathInfo().getSuffix());
  }

}

代码示例来源:origin: sinnerschrader/aem-react

@Model(adaptables = SlingHttpServletRequest.class)
public class CityViewModel {

 @Inject
 private SlingHttpServletRequest request;

 public String getName() {
  Page currentPage = WCMUtils.getComponentContext(request).getPage();
  return currentPage.getTitle();

 }
}

代码示例来源:origin: Cognifide/APM

@Model(adaptables = SlingHttpServletRequest.class)
public class ExecutionModel {

  @Getter
  private final Entry entry;

  @Inject
  public ExecutionModel(@OSGiService History history, SlingHttpServletRequest request) {
    entry = history.find(request.getRequestPathInfo().getSuffix());
  }

}

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.sightly.testing-content

@Model(adaptables = Resource.class)
public class ResourceModel {

  @Inject
  @Named("jcr:title")
  private String title;

  public String getTitle() {
    return title != null ? title : "FAILED";
  }
}

代码示例来源:origin: Cognifide/APM

@Model(adaptables = SlingHttpServletRequest.class)
public class ViewFileModel {

  private static final String FILENAME_PARAMETER_NAME = "filename";

  private static final String FILEPATH_PARAMETER_NAME = "filepath";

  @Getter
  private final String fileName;

  @Getter
  private final String filePath;

  public ViewFileModel(SlingHttpServletRequest request) {
    this.fileName = PropertiesUtil
        .toString(request.getParameter(FILENAME_PARAMETER_NAME), StringUtils.EMPTY);
    this.filePath = PropertiesUtil
        .toString(request.getParameter(FILEPATH_PARAMETER_NAME), StringUtils.EMPTY);
  }
}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

@Model(adaptables = SlingHttpServletRequest.class)
public class ViewFileModel {

  private static final String FILENAME_PARAMETER_NAME = "filename";

  private static final String FILEPATH_PARAMETER_NAME = "filepath";

  @Getter
  private final String fileName;

  @Getter
  private final String filePath;

  public ViewFileModel(SlingHttpServletRequest request) {
    this.fileName = PropertiesUtil
        .toString(request.getParameter(FILENAME_PARAMETER_NAME), StringUtils.EMPTY);
    this.filePath = PropertiesUtil
        .toString(request.getParameter(FILEPATH_PARAMETER_NAME), StringUtils.EMPTY);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.cms.core

/**
 * Model for retrieving the locale information from a resource with the
 * jcr:language property.
 */
@ProviderType
@Model(adaptables = Resource.class)
public class LocaleResource {

  private Locale locale;

  public LocaleResource(Resource resource) {
    this.locale = Locale
        .forLanguageTag(resource.getValueMap().get(JcrConstants.JCR_LANGUAGE, "").replace("_", "-"));
  }

  public Locale getLocale() {
    return locale;
  }
}

代码示例来源:origin: heervisscher/htl-examples

@Model(adaptables=Page.class)
public class MyCustomPage {

  @Self
  private Page page;
  
  private String title;
  
  @PostConstruct
  protected void init() {
    title = "MyProject : " + page.getTitle();
  }
  
  public String getTitle() {
    return title;
  }
  
  public Iterator<Page> getChildPages() {
    return page.listChildren(new PageFilter());
  }
  
}

代码示例来源:origin: heervisscher/htl-examples

@Model(adaptables=SlingHttpServletRequest.class)
public class ProductSettings {

  @Inject @Optional @Default(values="empty")
  public String layout;
  
}

代码示例来源:origin: Adobe-Marketing-Cloud/aem-guides

@Model(
    adaptables = SlingHttpServletRequest.class,
    adapters = SearchFacets.class
)
public class SearchFacetsImpl implements SearchFacets {
  private static final Logger log = LoggerFactory.getLogger(SearchFacetsImpl.class);

  @Self
  private SlingHttpServletRequest request;

  @OSGiService
  private PredicateResolver predicateResolver;

  public List<PredicateGroup> getPredicateGroups() {
    return predicateResolver.getPredicateGroups(request);
  }
}

代码示例来源:origin: heervisscher/htl-examples

@Model(adaptables = Resource.class)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION, selector="pageinfo")
public class TitleExporter {
  
  @Self
  private Resource resource;

  public String getText() {
    return resource.getValueMap().get("jcr:title", "");
  }
  
  public String getResourceType() {
     return resource.getResourceType();
  }
  
  public String getName() {
     return resource.getName();
  }

}

代码示例来源:origin: io.wcm.samples/io.wcm.samples.app

/**
 * Sets "HTTP 403 Forbidden" header if WCM mode is disabled.
 */
@Model(adaptables = SlingHttpServletRequest.class)
public class DenyWcmDisabled {

 @SlingObject
 private SlingHttpServletResponse response;
 @AemObject
 private WCMMode wcmMode;

 @PostConstruct
 private void activate() throws IOException {
  if (wcmMode == WCMMode.DISABLED) {
   response.sendError(HttpServletResponse.SC_FORBIDDEN);
  }
 }

}

相关文章

Model类方法