Skip to content

Instantly share code, notes, and snippets.

@aanchalsikka
aanchalsikka / SampleComponentImpl.java
Created Nov 13, 2017
Sample Component with DS annotations
View SampleComponentImpl.java
package blog.techrevel.component.impl;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Deactivate;
@Component(name = "Sample Component", property = { "testProperty=Hello" })
View MultipleComponentPropertiesImpl.java
package blog.techrevel.component.impl;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Deactivate;
@Component(property = { "testProperty1=Hello", "testProperty2=World" })
View ComponentMultivaluedPropertyImpl.java
package blog.techrevel.component.impl;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
View ConfigurableComponentPorpertiesImpl.java
package blog.techrevel.component.impl;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.osgi.service.metatype.annotations.Option;
import org.slf4j.Logger;
View RemoteConnectionDependency.xml
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr2dav</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr2spi</artifactId>
<version>2.4.0</version>
View RemoteConnectionEmbedDependency.xml
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!-- <Embed-Dependency> artifactId1, artifactId2;inline=true </Embed-Dependency> -->
<Export-Package>
blog.techrevel.service
</Export-Package>
View CurlExecutor.java
package blog.techrevel.api;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.codec.binary.Base64;
View CurlExecutor2.java
package blog.techrevel.api;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CurlExecutor2 {
public static void main(String[] args) {
View Sightly-Including a resource only if it exists-1
<div data-sly-resource="${'/content/techrevel/blog/' @ resourceType='techrevel/components/content/example'}"></div>  
View Sightly-Including a resource only if it exists-2
<div data-sly-test="${properties}">
<!--/* This block will only be rendered, if properties is not empty */-->
</div>