Index: tika-bundle/pom.xml
===================================================================
--- tika-bundle/pom.xml	(revision 1590555)
+++ tika-bundle/pom.xml	(working copy)
@@ -41,7 +41,7 @@
   <url>http://tika.apache.org/</url>
 
   <properties>
-    <pax.exam.version>2.2.0</pax.exam.version>
+    <pax.exam.version>3.5.0</pax.exam.version>
   </properties>
 
   <dependencies>
@@ -69,6 +69,23 @@
       <artifactId>pax-exam-junit4</artifactId>
       <version>${pax.exam.version}</version>
       <scope>test</scope>
+      <exclusions>
+	      <!-- 
+	      	avoid inmport of org.osgi.core already provided by 
+	      	org.apache.felix:org.apache.felix.framework:4.4.0!
+	      	Tree:
+	      	+- org.ops4j.pax.exam:pax-exam-junit4:jar:3.5.0:test
+			|  +- org.ops4j.pax.exam:pax-exam-spi:jar:3.5.0:test
+			|  |  +- org.ops4j.base:ops4j-base-spi:jar:1.4.0:test
+			|  |  \- org.ops4j.pax.tinybundles:tinybundles:jar:2.0.0:test
+			|  |     \- biz.aQute.bnd:bndlib:jar:2.1.0:test
+			|  |        \- org.osgi:org.osgi.core:jar:4.2.0:test
+	      	-->
+      	<exclusion>
+      		<groupId>org.osgi</groupId>
+      		<artifactId>org.osgi.core</artifactId>
+      	</exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
@@ -79,7 +96,7 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
-      <version>4.0.1</version>
+      <version>4.4.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -89,9 +106,15 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+      <scope>test</scope>
+	</dependency>
+    <dependency>
       <groupId>org.ops4j.pax.url</groupId>
       <artifactId>pax-url-aether</artifactId>
-      <version>1.3.3</version>
+      <version>2.0.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>
Index: tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java
===================================================================
--- tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java	(revision 1590555)
+++ tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java	(working copy)
@@ -17,9 +17,11 @@
 package org.apache.tika.bundle;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.ops4j.pax.exam.CoreOptions.bundle;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -27,33 +29,58 @@
 import java.io.InputStream;
 import java.net.URISyntaxException;
 
+import javax.inject.Inject;
+
 import org.apache.tika.Tika;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.exception.TikaException;
 import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
 import org.apache.tika.parser.ParseContext;
 import org.apache.tika.parser.Parser;
 import org.apache.tika.sax.BodyContentHandler;
+import org.junit.Assert;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
 
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
 public class BundleIT {
 
+	private static final String[] SYS_PKG = new String[]{
+        "javax.servlet",
+        "javax.servlet.http"
+	} 
+	;
+	
     private final File TARGET = new File("target");
+  
+    @Inject
+    private BundleContext bc;
 
     @Configuration
     public Option[] configuration() throws IOException, URISyntaxException {
         File base = new File(TARGET, "test-bundles");
         return CoreOptions.options(
+        		systemPackages(SYS_PKG),
                 junitBundles(),
                 bundle(new File(base, "tika-core.jar").toURI().toURL().toString()),
                 bundle(new File(base, "tika-bundle.jar").toURI().toURL().toString()));
     }
  
-    //@Test
-    public void testTikaBundle(BundleContext bc) throws Exception {
+    @Test
+    public void testTikaBundle() throws Exception {
         Tika tika = new Tika();
 
         // Simple type detection
@@ -64,11 +91,46 @@
         String xml = tika.parseToString(new File("pom.xml"));
         assertTrue(xml.contains("tika-bundle"));
 
+        testParser(tika.getParser());
+    }
+
+    @Test
+    public void testRegisteredServices() throws Exception {
+    	ServiceReference detectorRef = bc.getServiceReference(Detector.class.getName());
+    	assertNotNull("Detector serice is not referenced as OSGI service", detectorRef);
+    	Detector detector = (Detector)bc.getService(detectorRef);
+    	assertNotNull("Unable to get Detector Service for "+detectorRef+"!",detector);
+    	
+        Metadata metadata = new Metadata();
+        metadata.set(Metadata.RESOURCE_NAME_KEY, "test.txt");
+    	Assert.assertEquals(MediaType.TEXT_PLAIN, detector.detect(null, metadata));
+    	
+    	metadata = new Metadata();
+        metadata.set(Metadata.RESOURCE_NAME_KEY, "test.pdf");
+    	Assert.assertEquals(new MediaType("application","pdf"), detector.detect(null, metadata));
+    	
+    	ServiceReference parserRef = bc.getServiceReference(Parser.class.getName());
+    	assertNotNull("Parser serice is not referenced as OSGI service", detectorRef);
+    	Parser parser = (Parser)bc.getService(parserRef);
+    	assertNotNull("Unable to get Parser Service for "+parserRef+"!",parser);
+    	
+    	testParser(parser);
+    }
+    
+    /**
+     * internally used by the {@link #testTikaBundle()} and 
+     * {@link #testRegisteredServices()} to test the functionality of
+     * the {@link Parser} running within an OSGI environment
+     * @param parser the parser to test
+     * @throws IOException
+     * @throws SAXException
+     * @throws TikaException
+     */
+	private void testParser(Parser parser) throws IOException, SAXException, TikaException {
+		Assert.assertNotNull(parser);
         // Package extraction
         ContentHandler handler = new BodyContentHandler();
-
-        Parser parser = tika.getParser();
-        ParseContext context = new ParseContext();
+		ParseContext context = new ParseContext();
         context.set(Parser.class, parser);
 
         InputStream stream =
@@ -80,6 +142,7 @@
         }
 
         String content = handler.toString();
+
         assertTrue(content.contains("testEXCEL.xls"));
         assertTrue(content.contains("Sample Excel Worksheet"));
         assertTrue(content.contains("testHTML.html"));
@@ -98,6 +161,6 @@
         assertTrue(content.contains("This is a sample Microsoft Word Document"));
         assertTrue(content.contains("testXML.xml"));
         assertTrue(content.contains("Rida Benjelloun"));
-    }
-
+	}
+    
 }
Index: tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java
===================================================================
--- tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java	(revision 1590555)
+++ tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java	(working copy)
@@ -18,8 +18,10 @@
 
 import java.util.Properties;
 
+import org.apache.tika.config.TikaConfig;
 import org.apache.tika.detect.DefaultDetector;
 import org.apache.tika.detect.Detector;
+import org.apache.tika.parser.AutoDetectParser;
 import org.apache.tika.parser.DefaultParser;
 import org.apache.tika.parser.Parser;
 import org.osgi.framework.BundleActivator;
@@ -33,13 +35,14 @@
     private ServiceRegistration parserService;
 
     public void start(BundleContext context) throws Exception {
+    	TikaConfig config = new TikaConfig(Activator.class.getClassLoader());
         detectorService = context.registerService(
                 Detector.class.getName(),
-                new DefaultDetector(Activator.class.getClassLoader()),
+                config.getDetector(),
                 new Properties());
         parserService = context.registerService(
                 Parser.class.getName(),
-                new DefaultParser(Activator.class.getClassLoader()),
+                new AutoDetectParser(config),
                 new Properties());
     }
 
