Skip to content

Instantly share code, notes, and snippets.

View dileeph's full-sized avatar

Dileep Hareendran dileeph

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="policy.service.a" immediate="true">
<service>
<provide interface="com.x.policy.service.api.PolicyService"/>
</service>
<implementation class="com.x.policy.service.impl.PolicyServiceImpl"/>
</scr:component>
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="policy.service.client" immediate="true">
<implementation class="com.x.policy.client.PolicyServiceClient"/>
<reference
interface="com.x.policy.service.api.PolicyService"
bind="addPolicyService"
unbind="removePolicyService"
cardinality="1..n"
policy="dynamic"
/**
* Policy client class.
* @author Dileep Hareendran
*
*/
public class PolicyServiceClient {
private Set<PolicyService> services = new HashSet<PolicyService>();
/**
* Hook method called on activation of this service client.
<groupId>com.x</groupId>
<artifactId>policy.service.a</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
==================================
<dependency>
<groupId>com.x</groupId>
<artifactId>policy.service.api</artifactId>
@dileeph
dileeph / non-osgi-dep-depth1
Created May 31, 2017 19:34
non-osgi-dep-depth1
<groupId>com.y</groupId>
<artifactId>non-osgi-dep-depth1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>non-osgi-dep-depth1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@dileeph
dileeph / non-osgi-dep-depth2
Created May 31, 2017 19:35
non-osgi-dep-depth2 pom
<groupId>com.y</groupId>
<artifactId>non-osgi-dep-depth2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>non-osgi-dep-depth2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@dileeph
dileeph / non-osgi-dep-depth3
Created May 31, 2017 19:36
non-osgi-dep-depth3 pom
<groupId>com.y</groupId>
<artifactId>non-osgi-dep-depth3</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>non-osgi-dep-depth3</name>
@dileeph
dileeph / depths java classes.java
Created May 31, 2017 19:38
depths java classes.java
package com.y.d1;
import com.y.d2.Depth2;
public class Depth1 {
public String call(String x){
Depth2 d2 = new Depth2();
return "data service " + d2.call(x);
}
@dileeph
dileeph / PolicyServiceImpl.java
Created May 31, 2017 19:43
update to PolicyServiceImpl
//Modify getName() method as follows
public String getName(){
Depth1 d1 = new Depth1();
return "policywithdep-1.0" + d1.call(" deep call ");
}
@dileeph
dileeph / modifiedclient.java
Created May 31, 2017 20:17
modified client for ComponentContext
/**
* Hook method called on activation of this service client.
* @param context BundleContext
*/
public void activate(ComponentContext context){
System.out.println(" >>> " + context.getProperties().get("cmp.name"));
}
/**