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

updated osgi annotatation in jobs #314

Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 24 additions & 9 deletions core/jobs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@

<dependencies>
<!-- project -->
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

You may get rid of

    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.scr.annotations</artifactId>
    </dependency>

and

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.commons.osgi</artifactId>
    </dependency>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.cognifide.aet</groupId>
<artifactId>communication-api</artifactId>
Expand Down Expand Up @@ -78,10 +90,6 @@
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
Expand All @@ -96,11 +104,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -163,6 +166,18 @@

<build>
<plugins>
<!-- overwrites configuration from parent pom to disable SCR plugin -->
<!-- ToDo: remove me when all felix dependencies are removed -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<executions>
<execution>
<id>generate-scr-descriptor</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
@Service
public class AccessibilityCollectorFactory implements CollectorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
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
public class CookieCollectorFactory implements CollectorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
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
public class JsErrorsCollectorFactory implements CollectorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import com.cognifide.aet.job.api.collector.WebCommunicationWrapper;
import com.cognifide.aet.job.api.exceptions.ParametersException;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;

@Component
@Service
public class OpenPageFactory implements CollectorFactory {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component
@Service
public class ClientSidePerformanceCollectorFactory implements CollectorFactory {

private BundleContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
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(description = "AET Screen Collector Factory", label = "AET Screen Collector Factory")
@Service
@Component(service = CollectorFactory.class)
public class ScreenCollectorFactory implements CollectorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,19 @@
import com.cognifide.aet.job.api.collector.CollectorProperties;
import com.cognifide.aet.job.api.collector.WebCommunicationWrapper;
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.job.common.collectors.source.configuration.SourceCollectorFactoryConf;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
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.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.Designate;

@Component(metatype = true, description = "AET Source Collector Factory", label = "AET Source Collector Factory")
@Service
@Component(service = CollectorFactory.class)
@Designate(ocd = SourceCollectorFactoryConf.class)
public class SourceCollectorFactory implements CollectorFactory {

private static final String SOURCE_COLLECTOR_TIMEOUT_VALUE = "sourceCollectorTimeoutValue";

private static final int DEFAULT_TIMEOUT = 20000;

@Property(name = SOURCE_COLLECTOR_TIMEOUT_VALUE, label = "Timeout value for source collector [ms]", intValue = DEFAULT_TIMEOUT, description = "Timeout value for source collector [ms]")
private int timeoutValue;
SourceCollectorFactoryConf config;

@Reference
private ArtifactsDAO artifactsDAO;
Expand All @@ -53,13 +47,12 @@ public CollectorJob createInstance(CollectorProperties properties, Map<String, S
WebCommunicationWrapper webCommunicationWrapper)
throws ParametersException {
return new SourceCollector(artifactsDAO, properties,
webCommunicationWrapper.getHttpRequestExecutor(), timeoutValue);
webCommunicationWrapper.getHttpRequestExecutor(), config.timeoutValue());
}

@Activate
public void activate(Map properties) {
timeoutValue = PropertiesUtil
.toInteger(properties.get(SOURCE_COLLECTOR_TIMEOUT_VALUE), DEFAULT_TIMEOUT);
public void activate(SourceCollectorFactoryConf config) {
this.config = config;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* AET
*
* Copyright (C) 2013 Cognifide Limited
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.cognifide.aet.job.common.collectors.source.configuration;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "AET Source Collector Factory", description = "AET Source Collector Factory")
public @interface SourceCollectorFactoryConf {

String SOURCE_COLLECTOR_TIMEOUT_VALUE = "sourceCollectorTimeoutValue";

int DEFAULT_TIMEOUT = 20000;

@AttributeDefinition(
name = SOURCE_COLLECTOR_TIMEOUT_VALUE,
description = "Timeout value for source collector [ms]",
type = AttributeType.INTEGER)
int timeoutValue() default DEFAULT_TIMEOUT;
Copy link
Contributor

Choose a reason for hiding this comment

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

With new @AttributeDefinition annotation, the name property is just a human-readable name (i.e. label for the property) - the property name itself is identified by the method name (timeoutValue). So now the method names should be equal to the value of name property on the old @Property annotations - otherwise we'll need to change property names in all karaf configuration files for this component.


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.Map;
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
public class StatusCodesCollectorFactory implements CollectorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class AccessibilityComparatorFactory implements ComparatorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class CookieComparatorFactory implements ComparatorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class JsErrorsComparatorFactory implements ComparatorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class LayoutComparatorFactory implements ComparatorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
import com.cognifide.aet.job.common.comparators.permormance.clientside.parser.ClientSidePerformanceParser;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class ClientSidePerformanceComparatorFactory implements ComparatorFactory {

private final ClientSidePerformanceParser clientSidePerformanceParser = new ClientSidePerformanceParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
import com.cognifide.aet.job.common.comparators.source.diff.DiffParser;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class SourceComparatorFactory implements ComparatorFactory {

@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
import com.cognifide.aet.job.api.exceptions.ParametersException;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class StatusCodesComparatorFactory implements ComparatorFactory {


@Reference
private ArtifactsDAO artifactsDAO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
import com.cognifide.aet.job.common.comparators.w3chtml5.wrapper.NuValidatorWrapper;
import com.cognifide.aet.vs.ArtifactsDAO;
import java.util.List;
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
public class W3cHtml5ComparatorFactory implements ComparatorFactory {

private final W3cHtml5ValidationResultParser resultParser = new W3cHtml5ValidationResultParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import com.cognifide.aet.job.common.collectors.accessibility.AccessibilityIssue;
import java.util.List;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.annotations.Component;

@Component
@Service
public class AccessibilityFilterFactory implements DataFilterFactory {

@Override
Expand Down
Loading