Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/ieb/open-experiments.git
Browse files Browse the repository at this point in the history
  • Loading branch information
reciva-at committed Apr 3, 2009
2 parents ef3e287 + e7eef2c commit ec98ee1
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 54 deletions.
4 changes: 4 additions & 0 deletions slingtests/osgikernel/bundles/guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!--
<dependency> <groupId>javax.jcr</groupId> <artifactId>jcr</artifactId> </dependency>
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import org.osgi.framework.BundleContext;
import org.sakaiproject.kernel.api.configuration.ConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

Expand All @@ -30,6 +32,8 @@
*/
public abstract class AbstractOsgiModule extends AbstractModule {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOsgiModule.class);

/**
* {@inheritDoc}
* @see com.google.inject.AbstractModule#configure()
Expand All @@ -41,6 +45,8 @@ protected void configure() {
Map<String, String> config = configurationService.getProperties();
if (config != null) {
Names.bindProperties(this.binder(), config);
} else {
LOGGER.warn("No Configuration Properties found");
}
}

Expand Down
26 changes: 14 additions & 12 deletions slingtests/osgikernel/bundles/guiceuser/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
<!--
Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements. See the NOTICE file distributed with this work for additional information regarding
copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
Expand All @@ -9,7 +9,8 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
the License for the specific language governing permissions and limitations under the License.
-->
<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/maven-v4_0_0.xsd">
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sakaiproject.kernel2.osgi</groupId>
Expand All @@ -34,10 +35,7 @@
<instructions>
<Bundle-Category> sakai-kernel </Bundle-Category>
<Bundle-Activator>org.sakaiproject.kernel2.osgi.guiceuser.GuiceUser</Bundle-Activator>
<Import-Package>
com.google.inject.cglib.reflect,
*
</Import-Package>
<Import-Package> com.google.inject.cglib.reflect, * </Import-Package>
</instructions>
</configuration>
</plugin>
Expand All @@ -53,12 +51,16 @@
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
<scope>provided</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@
import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceF;
import org.sakaiproject.kernel2.osgi.guiceuser.impl.FProvider;
import org.sakaiproject.kernel2.osgi.guiceuser.impl.InjectableC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GuiceUser implements BundleActivator {

private static final Logger LOGGER = LoggerFactory.getLogger(GuiceUser.class);

public void start(BundleContext arg0) throws Exception {
System.out.println("Fetching injector");
LOGGER.info("Fetching injector");
Injector injector = Guice.createInjector(new TestModule());
System.err.println("Fetching Injectable instance");
LOGGER.info("Fetching Injectable instance");
injector.getInstance(InjectableC.class);
System.err.println("Print test 1");
LOGGER.info("Print test 1");
InterfaceD d = injector.getInstance(InterfaceD.class);
d.printHello();
InterfaceE e = injector.getInstance(InterfaceE.class);
System.err.println("Print test 2");
LOGGER.info("Print test 2");
e.printHelloViaD();
Provider<InterfaceF> fprovider = injector.getInstance(FProvider.class);
System.err.println("Print test 3");
LOGGER.info("Print test 3");
fprovider.get().printViaE();
}

public void stop(BundleContext arg0) throws Exception {
System.out.println("Stopping");
LOGGER.info("Stopping");
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.sakaiproject.kernel2.osgi.guiceuser.impl;

import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceB;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConcreteB implements InterfaceB {

private static final Logger LOGGER = LoggerFactory.getLogger(ConcreteB.class);

public void printString(String string) {
new Exception().printStackTrace();
System.out.println(string);
Exception e = new Exception("Traceback, not an exception");
LOGGER.info(string,e);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceB;
import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceD;
import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConcreteE implements InterfaceE {

private static final Logger LOGGER = LoggerFactory.getLogger(ConcreteE.class);
private InterfaceD d;

@Inject
Expand All @@ -24,7 +27,7 @@ public void printHelloViaD()

public void doPrint(InterfaceA a, InterfaceB b)
{
System.err.println("Printing from e");
LOGGER.info("Printing from e");
b.printString(a.getHelloWorld());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceE;
import org.sakaiproject.kernel2.osgi.guiceuser.api.InterfaceF;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FProvider implements Provider<InterfaceF> {

protected static final Logger LOGGER = LoggerFactory.getLogger(FProvider.class);
private InterfaceE e;

@Inject
Expand All @@ -21,7 +24,7 @@ public InterfaceF get() {
{

public void printViaE() {
System.err.println("Provided F printing via e via d");
LOGGER.info("Provided F printing via e via d");
FProvider.this.getE().printHelloViaD();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Listens for configuration changes.
*/
public interface ConfigutationListener {
public interface ConfigurationListener {
/**
* @param config the new configuration
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public interface ConfigurationService {
/**
* @param listener the listener to add.
*/
void addListener(ConfigutationListener listener);
void addListener(ConfigurationListener listener);

/**
* @param listener the listener to remove.
*/
void removeListener(ConfigutationListener listener);
void removeListener(ConfigurationListener listener);
}
Loading

0 comments on commit ec98ee1

Please sign in to comment.