Commits

Micha Kops  committed a386cf9

initial import

  • Participants

Comments (0)

Files changed (16)

+.settings

File hascode-blueprint-bundle/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File hascode-blueprint-bundle/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hascode-blueprint-bundle</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

File hascode-blueprint-bundle/nbactions.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+    <action>
+        <actionName>run</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+    <action>
+        <actionName>debug</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <properties>
+            <vm.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</vm.args>
+            <jpda.listen>true</jpda.listen>
+        </properties>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+    <action>
+        <actionName>profile</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <properties>
+            <vm.args>${profiler.args}</vm.args>
+            <!-- XXX <java jvm="${profiler.java}" ...> -->
+            <profiler.action>profile</profiler.action>
+        </properties>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+</actions>

File hascode-blueprint-bundle/pom.xml

+<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.hascode.tutorial</groupId>
+    <artifactId>hascode-blueprint-bundle</artifactId>
+    <version>0.0.1</version>
+    <packaging>bundle</packaging>
+
+    <name>hascode-blueprint-bundle OSGi Bundle</name>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>1.4.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+        	<groupId>com.hascode.tutorial</groupId>
+        	<artifactId>hascode-osgi-service</artifactId>
+        	<version>0.0.1</version>
+        	<type>bundle</type>
+        	<scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.2.0</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>com.hascode.tutorial.hascode_blueprint_bundle.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>build-for-felix</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>org.apache.felix.main</artifactId>
+                    <version>3.0.7</version>
+                    <scope>provided</scope>
+                </dependency>
+                <!-- To include a shell:
+                <dependency>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>org.apache.felix.gogo.shell</artifactId>
+                    <version>0.6.1</version>
+                </dependency>
+                -->
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <version>1.6</version>
+                        <executions>
+                            <execution>
+                                <id>compile</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <target>
+                                        <pathconvert property="plugins.jars" pathsep="${path.separator}">
+                                            <path refid="maven.runtime.classpath"/>
+                                            <map from="${project.build.directory}${file.separator}classes" to=""/>
+                                        </pathconvert>
+                                        <pathconvert pathsep=" " property="bundles">
+                                            <path path="${plugins.jars}"/>
+                                            <mapper>
+                                                <chainedmapper>
+                                                    <flattenmapper/>
+                                                    <globmapper from="*" to="file:modules/*" casesensitive="no"/>
+                                                </chainedmapper>
+                                            </mapper>
+                                        </pathconvert>
+                                        <propertyfile file="${project.build.directory}/config.properties">
+                                            <entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar"/>
+                                            <entry key="org.osgi.framework.bootdelegation" value="*"/>
+                                        </propertyfile>
+                                        <copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar"/>
+                                    </target>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <version>2.2</version>
+                        <executions>
+                            <execution>
+                                <id>create-executable-jar</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>single</goal>
+                                </goals>
+                                <configuration>
+                                    <descriptors>
+                                        <descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
+                                    </descriptors>
+                                    <finalName>${project.build.finalName}</finalName>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>run-on-felix</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>org.apache.felix.main</artifactId>
+                    <version>3.0.7</version>
+                    <scope>provided</scope>
+                </dependency>
+                <!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed -->
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <version>1.6</version>
+                        <configuration>
+                            <target>
+                                <property name="vm.args" value=""/>
+                                <pathconvert property="plugins.jars" pathsep="${path.separator}">
+                                    <path refid="maven.runtime.classpath"/>
+                                    <map from="${project.build.directory}${file.separator}classes" to=""/>
+                                </pathconvert>
+                                <makeurl property="urls" separator=" ">
+                                    <path path="${plugins.jars}"/>
+                                    <path location="${project.build.directory}/${project.build.finalName}.jar"/>
+                                </makeurl>
+                                <propertyfile file="${project.build.directory}/run.properties">
+                                    <entry key="felix.auto.start" value="${urls}"/>
+                                    <entry key="felix.auto.deploy.action" value="uninstall,install,update,start"/>
+                                    <entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache"/>
+                                    <entry key="org.osgi.framework.bootdelegation" value="*"/>
+                                </propertyfile>
+                                <makeurl property="run.properties.url" file="${project.build.directory}/run.properties"/>
+                                <java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
+                                    <sysproperty key="felix.config.properties" value="${run.properties.url}"/>
+                                    <jvmarg line="${vm.args}"/>
+                                </java>
+                            </target>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

File hascode-blueprint-bundle/src/main/assembly/felix.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>all</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <dependencySets>
+    <dependencySet>
+        <useProjectArtifact>false</useProjectArtifact>
+        <outputDirectory>modules</outputDirectory>
+    </dependencySet>
+  </dependencySets>
+  <files>
+    <file>
+      <source>${project.build.directory}/${project.build.finalName}.jar</source>
+      <outputDirectory>modules</outputDirectory>
+    </file>
+    <file>
+      <source>${project.build.directory}/felix.jar</source>
+      <outputDirectory>bin</outputDirectory>
+    </file>
+    <file>
+      <source>${project.build.directory}/config.properties</source>
+      <outputDirectory>conf</outputDirectory>
+    </file>
+  </files>
+</assembly>

File hascode-blueprint-bundle/src/main/java/com/hascode/tutorial/hascode_blueprint_bundle/Activator.java

+package com.hascode.tutorial.hascode_blueprint_bundle;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import com.hascode.tutorial.hascode_osgi_service.api.SampleService;
+
+public class Activator implements BundleActivator {
+
+	public void start(final BundleContext context) throws Exception {
+		System.out.println("blueprint bundle activator called");
+	}
+
+	public void stop(final BundleContext context) throws Exception {
+	}
+
+	public void onBindService(final SampleService sampleService) {
+		if (sampleService == null) {
+			System.out.println("sample service is null");
+		} else {
+			System.out.println("greet: " + sampleService.getGreeting("bob"));
+		}
+	}
+
+	public void onUnbindService(final SampleService sampleService) {
+		System.out.println("service unbound");
+	}
+}

File hascode-blueprint-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml

+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+	<bean id="bundle-activator" class="com.hascode.tutorial.hascode_blueprint_bundle.Activator"/>
+	
+	<reference id="sampleService" availability="mandatory" activation="eager" interface="com.hascode.tutorial.hascode_osgi_service.api.SampleService">
+		<reference-listener ref="bundle-activator" bind-method="onBindService" unbind-method="onUnbindService"/>
+	</reference>
+</blueprint>

File hascode-osgi-service/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File hascode-osgi-service/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hascode-osgi-service</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

File hascode-osgi-service/nbactions.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+    <action>
+        <actionName>run</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+    <action>
+        <actionName>debug</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <properties>
+            <vm.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</vm.args>
+            <jpda.listen>true</jpda.listen>
+        </properties>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+    <action>
+        <actionName>profile</actionName>
+        <goals>
+            <goal>package</goal>
+            <goal>antrun:run</goal>
+        </goals>
+        <properties>
+            <vm.args>${profiler.args}</vm.args>
+            <!-- XXX <java jvm="${profiler.java}" ...> -->
+            <profiler.action>profile</profiler.action>
+        </properties>
+        <activatedProfiles>
+            <activatedProfile>run-on-felix</activatedProfile>
+        </activatedProfiles>
+    </action>
+</actions>

File hascode-osgi-service/pom.xml

+<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.hascode.tutorial</groupId>
+	<artifactId>hascode-osgi-service</artifactId>
+	<version>0.0.1</version>
+	<packaging>bundle</packaging>
+
+	<name>hascode-osgi-service OSGi Bundle</name>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>1.4.0</version>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>2.2.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Export-Package>com.hascode.tutorial.hascode_osgi_service.api</Export-Package>
+						<Private-Package>com.hascode.tutorial.hascode_osgi_service.*</Private-Package>
+						<Export-Service>com.hascode.tutorial.hascode_osgi_service.api.SampleService</Export-Service>
+						<Bundle-Activator>com.hascode.tutorial.hascode_osgi_service.Activator</Bundle-Activator>
+					</instructions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<profiles>
+		<profile>
+			<id>build-for-felix</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>org.apache.felix.main</artifactId>
+					<version>3.0.7</version>
+					<scope>provided</scope>
+				</dependency>
+				<!-- To include a shell: <dependency> <groupId>org.apache.felix</groupId> 
+					<artifactId>org.apache.felix.gogo.shell</artifactId> <version>0.6.1</version> 
+					</dependency> -->
+			</dependencies>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-antrun-plugin</artifactId>
+						<version>1.6</version>
+						<executions>
+							<execution>
+								<id>compile</id>
+								<phase>package</phase>
+								<goals>
+									<goal>run</goal>
+								</goals>
+								<configuration>
+									<target>
+										<pathconvert property="plugins.jars" pathsep="${path.separator}">
+											<path refid="maven.runtime.classpath" />
+											<map from="${project.build.directory}${file.separator}classes"
+												to="" />
+										</pathconvert>
+										<pathconvert pathsep=" " property="bundles">
+											<path path="${plugins.jars}" />
+											<mapper>
+												<chainedmapper>
+													<flattenmapper />
+													<globmapper from="*" to="file:modules/*"
+														casesensitive="no" />
+												</chainedmapper>
+											</mapper>
+										</pathconvert>
+										<propertyfile file="${project.build.directory}/config.properties">
+											<entry key="felix.auto.start"
+												value="${bundles} file:modules/${project.build.finalName}.jar" />
+											<entry key="org.osgi.framework.bootdelegation" value="*" />
+										</propertyfile>
+										<copy
+											file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}"
+											tofile="${project.build.directory}/felix.jar" />
+									</target>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-assembly-plugin</artifactId>
+						<version>2.2</version>
+						<executions>
+							<execution>
+								<id>create-executable-jar</id>
+								<phase>package</phase>
+								<goals>
+									<goal>single</goal>
+								</goals>
+								<configuration>
+									<descriptors>
+										<descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
+									</descriptors>
+									<finalName>${project.build.finalName}</finalName>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>run-on-felix</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>org.apache.felix.main</artifactId>
+					<version>3.0.7</version>
+					<scope>provided</scope>
+				</dependency>
+				<!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from 
+					Maven since stdin is swallowed -->
+			</dependencies>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-antrun-plugin</artifactId>
+						<version>1.6</version>
+						<configuration>
+							<target>
+								<property name="vm.args" value="" />
+								<pathconvert property="plugins.jars" pathsep="${path.separator}">
+									<path refid="maven.runtime.classpath" />
+									<map from="${project.build.directory}${file.separator}classes"
+										to="" />
+								</pathconvert>
+								<makeurl property="urls" separator=" ">
+									<path path="${plugins.jars}" />
+									<path
+										location="${project.build.directory}/${project.build.finalName}.jar" />
+								</makeurl>
+								<propertyfile file="${project.build.directory}/run.properties">
+									<entry key="felix.auto.start" value="${urls}" />
+									<entry key="felix.auto.deploy.action" value="uninstall,install,update,start" />
+									<entry key="org.osgi.framework.storage"
+										value="${project.build.directory}${file.separator}felix-cache" />
+									<entry key="org.osgi.framework.bootdelegation" value="*" />
+								</propertyfile>
+								<makeurl property="run.properties.url"
+									file="${project.build.directory}/run.properties" />
+								<java fork="true"
+									jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
+									<sysproperty key="felix.config.properties" value="${run.properties.url}" />
+									<jvmarg line="${vm.args}" />
+								</java>
+							</target>
+						</configuration>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+	</profiles>
+</project>

File hascode-osgi-service/src/main/assembly/felix.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>all</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <dependencySets>
+    <dependencySet>
+        <useProjectArtifact>false</useProjectArtifact>
+        <outputDirectory>modules</outputDirectory>
+    </dependencySet>
+  </dependencySets>
+  <files>
+    <file>
+      <source>${project.build.directory}/${project.build.finalName}.jar</source>
+      <outputDirectory>modules</outputDirectory>
+    </file>
+    <file>
+      <source>${project.build.directory}/felix.jar</source>
+      <outputDirectory>bin</outputDirectory>
+    </file>
+    <file>
+      <source>${project.build.directory}/config.properties</source>
+      <outputDirectory>conf</outputDirectory>
+    </file>
+  </files>
+</assembly>

File hascode-osgi-service/src/main/java/com/hascode/tutorial/hascode_osgi_service/Activator.java

+package com.hascode.tutorial.hascode_osgi_service;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import com.hascode.tutorial.hascode_osgi_service.api.SampleService;
+import com.hascode.tutorial.hascode_osgi_service.api.SampleServiceImpl;
+
+public class Activator implements BundleActivator {
+	private ServiceRegistration serviceRegistration;
+
+	public void start(final BundleContext context) throws Exception {
+		serviceRegistration = context.registerService(
+				SampleService.class.getName(), new SampleServiceImpl(), null);
+	}
+
+	public void stop(final BundleContext context) throws Exception {
+		serviceRegistration.unregister();
+	}
+
+}

File hascode-osgi-service/src/main/java/com/hascode/tutorial/hascode_osgi_service/api/SampleService.java

+package com.hascode.tutorial.hascode_osgi_service.api;
+
+public interface SampleService {
+	String getGreeting(final String name);
+}

File hascode-osgi-service/src/main/java/com/hascode/tutorial/hascode_osgi_service/api/SampleServiceImpl.java

+package com.hascode.tutorial.hascode_osgi_service.api;
+
+public class SampleServiceImpl implements SampleService {
+
+	public String getGreeting(final String name) {
+		return "hello, " + name;
+	}
+
+}