-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mcculls
committed
May 18, 2010
1 parent
6278cb8
commit 04adaec
Showing
176 changed files
with
6,804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
chapter01/greeting-example/lifecycle/org.foo.hello.client/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
|
9 changes: 9 additions & 0 deletions
9
chapter01/greeting-example/lifecycle/org.foo.hello.client/build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
9 changes: 9 additions & 0 deletions
9
...er01/greeting-example/lifecycle/org.foo.hello.client/src/org/foo/hello/client/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
chapter01/greeting-example/lifecycle/org.foo.hello.main/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
chapter01/greeting-example/lifecycle/org.foo.hello.main/build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
38 changes: 38 additions & 0 deletions
38
chapter01/greeting-example/lifecycle/org.foo.hello.main/src/org/foo/hello/main/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
chapter01/greeting-example/lifecycle/org.foo.hello/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
15 changes: 15 additions & 0 deletions
15
chapter01/greeting-example/lifecycle/org.foo.hello/src/org/foo/hello/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
chapter01/greeting-example/lifecycle/org.foo.hello/src/org/foo/hello/Greeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + "!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
chapter01/greeting-example/modularity/org.foo.hello.client/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
|
9 changes: 9 additions & 0 deletions
9
chapter01/greeting-example/modularity/org.foo.hello.client/build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
9 changes: 9 additions & 0 deletions
9
...r01/greeting-example/modularity/org.foo.hello.client/src/org/foo/hello/client/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
chapter01/greeting-example/modularity/org.foo.hello.main/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
chapter01/greeting-example/modularity/org.foo.hello.main/build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
36 changes: 36 additions & 0 deletions
36
chapter01/greeting-example/modularity/org.foo.hello.main/src/org/foo/hello/main/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
chapter01/greeting-example/modularity/org.foo.hello/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
7
chapter01/greeting-example/modularity/org.foo.hello/build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
chapter01/greeting-example/modularity/org.foo.hello/src/org/foo/hello/Greeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + "!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.