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

Removed some Felix SCR annotations and replaced with OSGi annotations #3332

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -40,9 +38,12 @@
/**
* Workflow process which mattes an image against a solid background to the specified size.
*/
@Component(metatype = false)
@Service
@Property(name = "process.label", value = "Matte Rendition")

@Component(
service = {WorkflowProcess.class},
property = {
"process.label=Matte Rendition"
})
@SuppressWarnings({"squid:S00115", "checkstyle:localvariablename"})
public final class MatteRenditionProcess extends AbstractRenditionModifyingProcess implements WorkflowProcess {

Expand All @@ -63,11 +64,11 @@ enum HoritzonalPosition {
private static final String SPECIFIER = "matte";

// Disable this feature on AEM as a Cloud Service
@Reference(target="(distribution=classic)")
RequireAem requireAem;
@Reference(target = "(distribution=classic)")
private transient RequireAem requireAem;

@Reference
private WorkflowHelper workflowHelper;
private transient WorkflowHelper workflowHelper;

@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
Expand Down Expand Up @@ -109,28 +110,28 @@ protected Layer processLayer(Layer layer, Rendition rendition, WorkflowSession w

VerticalPosition vpos = VerticalPosition.valueOf(verticalPositionArgument);
switch (vpos) {
case bottom:
topAnchor = newLayer.getHeight() - layer.getHeight();
break;
case middle:
topAnchor = (newLayer.getHeight() - layer.getHeight()) / 2;
break;
default:
topAnchor = 0;
break;
case bottom:
topAnchor = newLayer.getHeight() - layer.getHeight();
break;
case middle:
topAnchor = (newLayer.getHeight() - layer.getHeight()) / 2;
break;
default:
topAnchor = 0;
break;
}

HoritzonalPosition hpos = HoritzonalPosition.valueOf(horizontalPositionArgument);
switch (hpos) {
case right:
leftAnchor = newLayer.getWidth() - layer.getWidth();
break;
case center:
leftAnchor = (newLayer.getWidth() - layer.getWidth()) / 2;
break;
default:
leftAnchor = 0;
break;
case right:
leftAnchor = newLayer.getWidth() - layer.getWidth();
break;
case center:
leftAnchor = (newLayer.getWidth() - layer.getWidth()) / 2;
break;
default:
leftAnchor = 0;
break;
}
newLayer.blit(layer, leftAnchor, topAnchor, layer.getWidth(), layer.getHeight(), 0, 0);
return newLayer;
Expand Down Expand Up @@ -161,7 +162,7 @@ private Integer[] getDimension(String dimensions) {
return d;
}
// default value(s)
return new Integer[] { DEFAULT_WIDTH, DEFAULT_HEIGHT };
return new Integer[]{DEFAULT_WIDTH, DEFAULT_HEIGHT};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
*/
package com.adobe.acs.commons.genericlists.impl;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.adapter.AdapterFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.adobe.acs.commons.genericlists.GenericList;
import com.day.cq.wcm.api.Page;
import org.osgi.service.component.annotations.Component;

@Component
@Service
@Properties({ @Property(name = AdapterFactory.ADAPTABLE_CLASSES, value = "com.day.cq.wcm.api.Page"),
@Property(name = AdapterFactory.ADAPTER_CLASSES, value = "com.adobe.acs.commons.genericlists.GenericList") })
@Component(service = {AdapterFactory.class},
property = {
AdapterFactory.ADAPTABLE_CLASSES + "=com.day.cq.wcm.api.Page",
AdapterFactory.ADAPTER_CLASSES + "=com.adobe.acs.commons.genericlists.GenericList"
})
public class GenericListAdapterFactory implements AdapterFactory {

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.sling.api.SlingHttpServletRequest;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Deactivate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a public abstract class, I recommend leaving the SCR annotation in place here, in addition to the DS annotation, so that consumers using Felix SCR tooling will still find the old annotation in the class file.

import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -59,7 +59,7 @@ public void init(final FilterConfig filterConfig) throws ServletException {
@Override
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
final FilterChain filterChain) throws IOException, ServletException {

if (!this.accepts(servletRequest, servletResponse)) {
filterChain.doFilter(servletRequest, servletResponse);
return;
Expand All @@ -78,11 +78,11 @@ public final void doFilter(final ServletRequest servletRequest, final ServletRes
// Get contents
final String originalContents = originalResponse.getBufferedServletOutput().getWriteMethod() == ResponseWriteMethod.WRITER ? originalResponse.getBufferedServletOutput().getBufferedString() : null;

if (originalContents != null
if (originalContents != null
&& StringUtils.contains(response.getContentType(), "html")) {

final int injectionIndex = getInjectIndex(originalContents);

if (injectionIndex != -1) {
// prevent the captured response from being given out a 2nd time via the implicit close()
originalResponse.setFlushBufferOnClose(false);
Expand Down Expand Up @@ -113,7 +113,7 @@ public void destroy() {

@SuppressWarnings("squid:S3923")
protected boolean accepts(final ServletRequest servletRequest,
final ServletResponse servletResponse) {
final ServletResponse servletResponse) {

if (!(servletRequest instanceof HttpServletRequest)
|| !(servletResponse instanceof HttpServletResponse)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
/**
* Http Injectors.
*/
@org.osgi.annotation.versioning.Version("2.1.2")
@org.osgi.annotation.versioning.Version("2.1.3")
package com.adobe.acs.commons.http.injectors;
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
package com.adobe.acs.commons.httpcache.rule.impl;

import com.adobe.acs.commons.httpcache.rule.AbstractHttpCacheHandlingRule;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import com.adobe.acs.commons.httpcache.rule.HttpCacheHandlingRule;
import org.apache.sling.api.SlingHttpServletRequest;
import org.osgi.service.component.annotations.Component;

/**
* ACS AEM Commons - HTTP Cache - Rule: Cache only request http method is GET.
*
* <p>
* Process only Http GET requests.
*/
@Component
@Service
@Component(service = {HttpCacheHandlingRule.class})
public class CacheOnlyGetRequest extends AbstractHttpCacheHandlingRule {
private static final String HTTP_GET_METHOD = "GET";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,20 @@

import com.adobe.acs.commons.images.ImageTransformer;
import com.day.image.Layer;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* ACS AEM Commons - Image Transformer - Greyscale
*/
@Component
@Properties({
@Property(
name = ImageTransformer.PROP_TYPE,
value = GreyscaleImageTransformerImpl.TYPE
)
})
@Service

@Component(
service = {ImageTransformer.class},
property = {
ImageTransformer.PROP_TYPE + "=" + GreyscaleImageTransformerImpl.TYPE
})
public class GreyscaleImageTransformerImpl implements ImageTransformer {
private static final Logger log = LoggerFactory.getLogger(GreyscaleImageTransformerImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@
import com.adobe.acs.commons.images.ImageTransformer;
import com.day.image.Layer;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,16 +36,12 @@
* percentage (e.g. "50%").
* Rounding is one of "round" (using Math.round), "up" (using Math.ceil), or "down" (using Math.floor)
* "round" being the default
*
*/
@Component
@Properties({
@Property(
name = ImageTransformer.PROP_TYPE,
value = ScaleImageTransformerImpl.TYPE
)
})
@Service
@Component(
service = {ImageTransformer.class},
property = {
ImageTransformer.PROP_TYPE + "=" + ScaleImageTransformerImpl.TYPE
})
public class ScaleImageTransformerImpl implements ImageTransformer {
private static final Logger log = LoggerFactory.getLogger(ScaleImageTransformerImpl.class);

Expand All @@ -60,7 +53,7 @@ public class ScaleImageTransformerImpl implements ImageTransformer {
private static final String ROUND_UP = "up";
private static final String ROUND_DOWN = "down";

@Reference(target = "(" + ImageTransformer.PROP_TYPE + "=" + ResizeImageTransformerImpl.TYPE +")")
@Reference(target = "(" + ImageTransformer.PROP_TYPE + "=" + ResizeImageTransformerImpl.TYPE + ")")
ImageTransformer resizeImageTransformer;

@Override
Expand Down Expand Up @@ -106,8 +99,8 @@ public final Layer transform(Layer layer, final ValueMap properties) {
// Invoke the ResizeImageTransformer with the new values

final ValueMap params = new ValueMapDecorator(new HashMap<String, Object>());
params.put(ResizeImageTransformerImpl.KEY_WIDTH, (int)newWidth);
params.put(ResizeImageTransformerImpl.KEY_HEIGHT, (int)newHeight);
params.put(ResizeImageTransformerImpl.KEY_WIDTH, (int) newWidth);
params.put(ResizeImageTransformerImpl.KEY_HEIGHT, (int) newHeight);

layer = resizeImageTransformer.transform(layer, params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@
package com.adobe.acs.commons.mcp.impl.processes;

import com.adobe.acs.commons.mcp.ProcessDefinitionFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;

/**
*
*/
@Component
@Service(ProcessDefinitionFactory.class)
@Component(service = {ProcessDefinitionFactory.class})
public class DataImporterFactory extends ProcessDefinitionFactory<DataImporter> {
@Override
public String getName() {
Expand All @@ -35,5 +30,5 @@ public String getName() {
@Override
protected DataImporter createProcessDefinitionInstance() {
return new DataImporter();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

import com.adobe.acs.commons.mcp.AdministratorsOnlyProcessDefinitionFactory;
import com.adobe.acs.commons.mcp.ProcessDefinitionFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;

@Component
@Service(ProcessDefinitionFactory.class)
@Component(service = {ProcessDefinitionFactory.class})
public class ProcessCleanupFactory extends AdministratorsOnlyProcessDefinitionFactory<ProcessCleanup> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@
import com.adobe.acs.commons.mcp.ProcessDefinitionFactory;
import com.adobe.acs.commons.util.RequireAem;
import com.day.cq.replication.Replicator;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
@Service(ProcessDefinitionFactory.class)

@Component(service = {ProcessDefinitionFactory.class})
public class TreeReplicationFactory extends ProcessDefinitionFactory<TreeReplication> {

// Disable this feature on AEM as a Cloud Service
@Reference(target="(distribution=classic)")
RequireAem requireAem;
@Reference(target = "(distribution=classic)")
transient RequireAem requireAem;

@Reference
Replicator replicator;
transient Replicator replicator;


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@
import com.adobe.acs.commons.mcp.ProcessDefinitionFactory;
import com.adobe.acs.commons.util.RequireAem;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.mime.MimeTypeService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
@Service(ProcessDefinitionFactory.class)
@Component(service = {ProcessDefinitionFactory.class})
public class FileAssetIngestorFactory extends AuthorizedGroupProcessDefinitionFactory<FileAssetIngestor> {

// Disable this feature on AEM as a Cloud Service
@Reference(target="(distribution=classic)")
RequireAem requireAem;
@Reference(target = "(distribution=classic)")
transient RequireAem requireAem;

@Reference
MimeTypeService mimetypeService;
transient MimeTypeService mimetypeService;

@Override
public String getName() {
Expand All @@ -46,7 +44,7 @@ public String getName() {
public FileAssetIngestor createProcessDefinitionInstance() {
return new FileAssetIngestor(mimetypeService);
}

@Override
protected final String[] getAuthorizedGroups() {
return AssetIngestor.AUTHORIZED_GROUPS;
Expand Down
Loading
Loading