Skip to content

Commit

Permalink
Latest code drop
Browse files Browse the repository at this point in the history
  • Loading branch information
mcculls committed May 18, 2010
1 parent 6278cb8 commit 04adaec
Show file tree
Hide file tree
Showing 176 changed files with 6,804 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chapter01/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<project name="chapter01" default="dist">
<property name="chapter" value="chapter01"/>
<import file="../build.xml"/>
</project>
5 changes: 5 additions & 0 deletions chapter01/greeting-example/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<project name="greeting.example" default="dist">
<import file="../build.xml"/>
<property name="build.cp" value="${felix.jar}"/>
</project>
20 changes: 20 additions & 0 deletions chapter01/greeting-example/lifecycle/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="lifecycle" default="dist">

<property name="version" value="2.0"/>
<dirname property="example.dir" file="${ant.file.lifecycle}"/>
<import file="../build.xml"/>

<target name="provider">
<ant dir="${example.dir}/org.foo.hello" inheritAll="false"/>
</target>

<target name="consumer">
<ant dir="${example.dir}/org.foo.hello.client" inheritAll="false"/>
</target>

<target name="main">
<ant dir="${example.dir}/org.foo.hello.main" inheritAll="false"/>
</target>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#-------------------------------------------------
title=Lifecycle Greeting Example - Consumer
#-------------------------------------------------

module=org.foo.hello.client
custom=true

Private-Package:\
${module}

Import-Package:\
org.foo.hello;version="[2.0,3.0)"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<project name="consumer" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

<target name="compile" depends="provider,common.compile"/>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.foo.hello.client;

import org.foo.hello.Greeting;

public class Client {
static {
Greeting.get().sayHello();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#-------------------------------------------------
title=Lifecycle Greeting Example - Launcher
#-------------------------------------------------

module=org.foo.hello.main
custom=true

25 changes: 25 additions & 0 deletions chapter01/greeting-example/lifecycle/org.foo.hello.main/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<project name="main" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

<target name="compile" depends="consumer,common.compile"/>

<target name="local.dist" depends="compile">
<jar destfile="${example.dir}/main.jar">
<zipfileset src="${felix.jar}"/>
<fileset dir="${build}"/>
<manifest>
<attribute name="Main-Class" value="${module}.Main"/>
</manifest>
</jar>
</target>

<target name="local.pde"/>

<target name="local.clean" depends="common.local.clean">
<delete file="${example.dir}/main.jar"/>
</target>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.foo.hello.main;

import java.util.HashMap;
import java.util.Map;
import org.apache.felix.framework.Felix;
import org.osgi.framework.*;

public class Main {
static Felix m_framework;

public static void main(String[] args) throws Exception {
try {

final Map configMap = new HashMap();
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN, "onFirstInit");
m_framework = new Felix(configMap);
m_framework.init();

final BundleContext context = m_framework.getBundleContext();

Bundle provider = context.installBundle("file:bundles/provider-2.0.jar");
Bundle consumer = context.installBundle("file:bundles/consumer-2.0.jar");

m_framework.start();

provider.start();
consumer.loadClass("org.foo.hello.client.Client").newInstance();
provider.stop();

m_framework.stop();

} catch (Exception ex) {
System.err.println("Error starting program: " + ex);
ex.printStackTrace();
System.exit(0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#-------------------------------------------------
title=Lifecycle Greeting Example - Provider
#-------------------------------------------------

module=org.foo.hello
custom=true

Bundle-Activator: ${module}.Activator

Export-Package:\
${module};version="2.0"

Import-Package:\
org.osgi.framework;version="[1.3,2.0)",\
${module};version="[2.0,3.0)"

7 changes: 7 additions & 0 deletions chapter01/greeting-example/lifecycle/org.foo.hello/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<project name="provider" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.foo.hello;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

public void start(BundleContext ctx) {
Greeting.instance = new Greeting("lifecycle");
}

public void stop(BundleContext ctx) {
Greeting.instance = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.foo.hello;

public class Greeting {
static Greeting instance;

final String m_name;

Greeting(String name) {
m_name = name;
}

public static Greeting get() {
return instance;
}

public void sayHello() {
System.out.println("Hello, " + m_name + "!");
}
}
20 changes: 20 additions & 0 deletions chapter01/greeting-example/modularity/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="modularity" default="dist">

<property name="version" value="1.0"/>
<dirname property="example.dir" file="${ant.file.modularity}"/>
<import file="../build.xml"/>

<target name="provider">
<ant dir="${example.dir}/org.foo.hello" inheritAll="false"/>
</target>

<target name="consumer">
<ant dir="${example.dir}/org.foo.hello.client" inheritAll="false"/>
</target>

<target name="main">
<ant dir="${example.dir}/org.foo.hello.main" inheritAll="false"/>
</target>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#-------------------------------------------------
title=Modularity Greeting Example - Consumer
#-------------------------------------------------

module=org.foo.hello.client
custom=true

Private-Package:\
${module}

Import-Package:\
org.foo.hello;version="[1.0,2.0)"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<project name="consumer" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

<target name="compile" depends="provider,common.compile"/>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.foo.hello.client;

import org.foo.hello.Greeting;

public class Client {
static {
new Greeting("modularity").sayHello();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#-------------------------------------------------
title=Modularity Greeting Example - Launcher
#-------------------------------------------------

module=org.foo.hello.main
custom=true

25 changes: 25 additions & 0 deletions chapter01/greeting-example/modularity/org.foo.hello.main/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<project name="main" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

<target name="compile" depends="consumer,common.compile"/>

<target name="local.dist" depends="compile">
<jar destfile="${example.dir}/main.jar">
<zipfileset src="${felix.jar}"/>
<fileset dir="${build}"/>
<manifest>
<attribute name="Main-Class" value="${module}.Main"/>
</manifest>
</jar>
</target>

<target name="local.pde"/>

<target name="local.clean" depends="common.local.clean">
<delete file="${example.dir}/main.jar"/>
</target>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.foo.hello.main;

import java.util.HashMap;
import java.util.Map;
import org.apache.felix.framework.Felix;
import org.osgi.framework.*;

public class Main {
static Felix m_framework;

public static void main(String[] args) throws Exception {
try {

final Map configMap = new HashMap();
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN, "onFirstInit");
m_framework = new Felix(configMap);
m_framework.init();

final BundleContext context = m_framework.getBundleContext();

Bundle provider = context.installBundle("file:bundles/provider-1.0.jar");
Bundle consumer = context.installBundle("file:bundles/consumer-1.0.jar");

m_framework.start();

consumer.loadClass("org.foo.hello.client.Client").newInstance();

m_framework.stop();

} catch (Exception ex) {
System.err.println("Error starting program: " + ex);
ex.printStackTrace();
System.exit(0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#-------------------------------------------------
title=Modularity Greeting Example - Provider
#-------------------------------------------------

module=org.foo.hello
custom=true

Export-Package:\
${module};version="1.0"

Import-Package:\
${module};version="[1.0,2.0)"

7 changes: 7 additions & 0 deletions chapter01/greeting-example/modularity/org.foo.hello/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<project name="provider" default="dist">

<property file="build.properties"/>
<import file="../build.xml"/>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.foo.hello;

public class Greeting {
final String m_name;

public Greeting(String name) {
m_name = name;
}

public void sayHello() {
System.out.println("Hello, " + m_name + "!");
}
}
20 changes: 20 additions & 0 deletions chapter01/greeting-example/service/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="service" default="dist">

<property name="version" value="3.0"/>
<dirname property="example.dir" file="${ant.file.service}"/>
<import file="../build.xml"/>

<target name="provider">
<ant dir="${example.dir}/org.foo.hello" inheritAll="false"/>
</target>

<target name="consumer">
<ant dir="${example.dir}/org.foo.hello.client" inheritAll="false"/>
</target>

<target name="main">
<ant dir="${example.dir}/org.foo.hello.main" inheritAll="false"/>
</target>

</project>
Loading

0 comments on commit 04adaec

Please sign in to comment.