Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace @Inject annotation with the specific ones #2441

Merged
merged 12 commits into from
Dec 29, 2023
Merged
Binary file added bundles/core/jacoco.exec
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
package com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.models.factory.ModelFactory;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class PageImageThumbnail {
@SlingObject
private ResourceResolver resourceResolver;

@Inject
@OSGiService
private ModelFactory modelFactory;

private String alt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -77,45 +79,36 @@ public class ClientLibrariesImpl implements ClientLibraries {
@Self
private SlingHttpServletRequest request;

@Inject
@Named(OPTION_RESOURCE_TYPES)
@ScriptVariable(name=OPTION_RESOURCE_TYPES)
Object resourceTypes;

@Inject
@Named(OPTION_FILTER_REGEX)
@ScriptVariable(name=OPTION_FILTER_REGEX)
String filterRegex;

@Inject
@Named(OPTION_INHERITED)
@ScriptVariable(name=OPTION_INHERITED)
@Default(booleanValues = OPTION_INHERITED_DEFAULT)
boolean inherited;

@Inject
@Named(OPTION_CATEGORIES)
@ScriptVariable(name=OPTION_CATEGORIES)
private Object categories;

@Inject
@Named(OPTION_ASYNC)
@ScriptVariable(name=OPTION_ASYNC)
@Nullable
private boolean async;

@Inject
@Named(OPTION_DEFER)
@ScriptVariable(name=OPTION_DEFER)
@Nullable
private boolean defer;

@Inject
@Named(OPTION_CROSSORIGIN)
@ScriptVariable(name=OPTION_CROSSORIGIN)
@Nullable
private String crossorigin;

@Inject
@Named(OPTION_ONLOAD)
@ScriptVariable(name=OPTION_ONLOAD)
@Nullable
private String onload;

@Inject
@Named(OPTION_MEDIA)
@ScriptVariable(name=OPTION_MEDIA)
@Nullable
private String media;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.regex.Pattern;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;

import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -35,6 +34,8 @@
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;

import com.adobe.cq.wcm.core.components.internal.Utils;
import com.adobe.cq.wcm.core.components.models.ComponentFiles;
Expand All @@ -56,16 +57,13 @@ public class ComponentFilesImpl implements ComponentFiles {
*/
public static final String COMPONENTS_SERVICE = "components-service";

@Inject
@Named(OPTION_RESOURCE_TYPES)
@ScriptVariable(name=OPTION_RESOURCE_TYPES)
Object resourceTypes;

@Inject
@Named(OPTION_FILTER_REGEX)
@ScriptVariable(name=OPTION_FILTER_REGEX)
String filterRegex;

@Inject
@Named(OPTION_INHERITED)
@ScriptVariable(name=OPTION_INHERITED)
@Default(booleanValues = OPTION_INHERITED_DEFAULT)
boolean inherited;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.List;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -28,6 +27,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -73,10 +73,10 @@ public class EmbedImpl extends AbstractComponentImpl implements Embed {
@Nullable
private Style currentStyle;

@Inject @Optional
@OSGiService @Optional
private List<UrlProcessor> urlProcessors;

@Inject
@ScriptVariable
private Resource resource;

private Type embedType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.wcm.core.components.internal.models.v1;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import static com.day.cq.commons.jcr.JcrConstants.JCR_CONTENT;
import static com.day.cq.commons.jcr.JcrConstants.JCR_MIMETYPE;

import java.util.Calendar;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.util.Text;
import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -41,7 +40,6 @@
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Source;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
Expand All @@ -53,9 +51,9 @@
import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.wcm.core.components.commons.link.Link;
import com.adobe.cq.wcm.core.components.commons.link.LinkManager;
import com.adobe.cq.wcm.core.components.internal.Utils;
import com.adobe.cq.wcm.core.components.internal.helper.image.AssetDeliveryHelper;
import com.adobe.cq.wcm.core.components.commons.link.LinkManager;
import com.adobe.cq.wcm.core.components.internal.servlets.AdaptiveImageServlet;
import com.adobe.cq.wcm.core.components.models.Image;
import com.adobe.cq.wcm.core.components.models.datalayer.ImageData;
Expand All @@ -74,9 +72,6 @@
import com.day.cq.wcm.api.designer.Style;
import com.fasterxml.jackson.annotation.JsonIgnore;

import static com.day.cq.commons.jcr.JcrConstants.JCR_CONTENT;
import static com.day.cq.commons.jcr.JcrConstants.JCR_MIMETYPE;

@Model(adaptables = SlingHttpServletRequest.class, adapters = {Image.class, ComponentExporter.class}, resourceType = ImageImpl.RESOURCE_TYPE)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class ImageImpl extends AbstractComponentImpl implements Image {
Expand All @@ -100,8 +95,7 @@ public class ImageImpl extends AbstractComponentImpl implements Image {
@ScriptVariable
protected Style currentStyle;

@Inject
@Source("osgi-services")
@OSGiService
protected MimeTypeService mimeTypeService;

@OSGiService(injectionStrategy = InjectionStrategy.OPTIONAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl;
import org.apache.commons.lang3.ArrayUtils;
Expand All @@ -40,6 +39,7 @@
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.factory.ModelFactory;
Expand Down Expand Up @@ -90,10 +90,10 @@ public class PageImpl extends AbstractComponentImpl implements Page {
@JsonIgnore
protected ResourceResolver resolver;

@Inject
@OSGiService
private ModelFactory modelFactory;

@Inject
@OSGiService
private SlingModelFilter slingModelFilter;

@Self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.adobe.cq.wcm.core.components.internal.models.v1;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonObjectBuilder;

Expand All @@ -28,6 +27,7 @@
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -82,7 +82,7 @@ public class PdfViewerImpl extends AbstractComponentImpl implements PdfViewer {
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private boolean dockPageControls;

@Inject
@ScriptVariable
private Resource resource;

private PdfViewerCaConfig caConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.wcm.core.components.internal.models.v1;

import javax.inject.Inject;

import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -25,6 +23,7 @@
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -51,7 +50,7 @@ public class TextImpl extends AbstractComponentImpl implements Text {
@Default(booleanValues = false)
private boolean textIsRich;

@Inject
@ScriptVariable
private Resource resource;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Optional;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -31,6 +30,7 @@
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
Expand Down Expand Up @@ -75,13 +75,13 @@ public class ContentFragmentImpl extends AbstractComponentImpl implements Conten
@Self(injectionStrategy = InjectionStrategy.REQUIRED)
private SlingHttpServletRequest slingHttpServletRequest;

@Inject
@OSGiService
private FragmentRenderService renderService;

@Inject
@OSGiService
private ContentTypeConverter contentTypeConverter;

@Inject
@OSGiService
private ModelFactory modelFactory;

@SlingObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.*;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.jcr.Session;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -29,6 +28,7 @@
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
Expand Down Expand Up @@ -76,7 +76,7 @@ public class ContentFragmentListImpl extends AbstractComponentImpl implements Co
@Self(injectionStrategy = InjectionStrategy.REQUIRED)
private SlingHttpServletRequest slingHttpServletRequest;

@Inject
@OSGiService
private ContentTypeConverter contentTypeConverter;

@SlingObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package com.adobe.cq.wcm.core.components.internal.models.v1.form;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
Expand Down Expand Up @@ -61,7 +61,7 @@ public class TextImpl extends AbstractFieldImpl implements Text, ComponentExport
@ScriptVariable
private Resource resource;

@Inject
@OSGiService
private FormStructureHelperFactory formStructureHelperFactory;

private String[] prefillValues;
Expand Down
Loading