Skip to content

Instantly share code, notes, and snippets.

View dileeph's full-sized avatar

Dileep Hareendran dileeph

View GitHub Profile
/**
* 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.
<?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"
<?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.api" immediate="false">
<service>
<provide interface="com.x.policy.service.api.PolicyService"/>
</service>
</scr:component>
<!-- at top -->
<groupId>com.x</groupId>
<artifactId>policy.service.a</artifactId>
<version>3.0.0</version>
<packaging>bundle</packaging>
<!-- in dependencies -->
<dependencies>
<!-- at top, note packaging type changed -->
<groupId>com.x</groupId>
<artifactId>policy.service.api</artifactId>
<version>3.0.0</version>
<packaging>bundle</packaging>
==================================
<!-- inside build tag, replace maven jar plugin with this -->
<plugin>
<!-- at the top , note packaging is changed from jar to bundle-->
<groupId>com.x</groupId>
<artifactId>policy.client</artifactId>
<version>3.0.0</version>
<packaging>bundle</packaging>
===================================
<!-- inside dependencies -->
Bundle-Name: Policy.Service.A
Bundle-SymbolicName: Policy.Service.A
Bundle-Description: policy service for Insurer A
Bundle-Version: 1.0.0
Bundle-Activator: com.x.policy.Activator
Import-Package: org.osgi.framework, com.x.policy.service.api;version="1.0.0"
<groupId>com.x</groupId>
<artifactId>policy.client</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
==================================
<dependency>
<groupId>com.x</groupId>
<artifactId>policy.service.api</artifactId>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.x</groupId>
<artifactId>policy.service.api</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>policy.service.api</name>