Author: donsez
Date: Mon Aug 20 15:00:10 2007
New Revision: 567846
URL: http://svn.apache.org/viewvc?rev=567846&view=rev
Log:
add the class ManagedServiceImpl.java providing a wrapper to the
MavenURLStreamHandlerService in order to dynamically import the package
org.osgi.service.cm
Added:
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java
(with props)
Modified:
felix/sandbox/donsez/urlhandler.maven/pom.xml
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/MavenURLStreamHandlerService.java
felix/sandbox/donsez/urlhandler.maven/src/site/script.txt
Modified: felix/sandbox/donsez/urlhandler.maven/pom.xml
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/urlhandler.maven/pom.xml?rev=567846&r1=567845&r2=567846&view=diff
==============================================================================
--- felix/sandbox/donsez/urlhandler.maven/pom.xml (original)
+++ felix/sandbox/donsez/urlhandler.maven/pom.xml Mon Aug 20 15:00:10 2007
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -16,34 +17,36 @@
specific language governing permissions and limitations
under the License.
-->
-<project>
+<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">
<properties>
<repositoryLocation>http://www.apache.org/~donsez/dev/felix/</repositoryLocation>
<description>provides a URLHandler to located bundle jarfiles
in a local (or remote) Maven repository</description>
- </properties>
+ </properties>
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>felix</artifactId>
- <version>0.9.0-incubator-SNAPSHOT</version>
+ <version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
+
<packaging>bundle</packaging>
<name>Apache Felix Maven URLHandler</name>
<artifactId>org.apache.felix.sandbox.urlhandler.maven</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
<description>${description}</description>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>${pom.version}</version>
+ <version>1.0.0</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.osgi.compendium</artifactId>
- <version>${pom.version}</version>
+ <version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
@@ -67,6 +70,7 @@
<!-- docs in
http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html and
http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html -->
<Import-Package>*</Import-Package>
+ <DynamicImport-Package>org.osgi.service.cm</DynamicImport-Package>
<Private-Package>${pom.artifactId},org.apache.felix.sandbox.util</Private-Package>
<Export-Service>org.osgi.service.url.URLStreamHandlerService,org.osgi.service.cm.ManagedService</Export-Service>
@@ -107,20 +111,4 @@
</plugins>
</reporting>
- <!--
- <repositories>
- <repository>
- <id>apache.m2.incubator</id>
- <name>Apache M2 Incubator Repository</name>
- <url>http://people.apache.org/repo/m2-incubating-repository/</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>apache.m2.incubator</id>
- <name>Apache M2 Incubator Repository</name>
- <url>http://people.apache.org/repo/m2-incubating-repository/</url>
- </pluginRepository>
- </pluginRepositories>
- -->
</project>
Added:
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java?rev=567846&view=auto
==============================================================================
---
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java
(added)
+++
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java
Mon Aug 20 15:00:10 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on 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.
+ */
+package org.apache.felix.sandbox.urlhandler.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.apache.felix.sandbox.util.MavenCompliantVersion;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.url.AbstractURLStreamHandlerService;
+import org.osgi.service.url.URLConstants;
+import org.osgi.service.url.URLStreamHandlerService;
+
+/**
+ * this class provides a wrapper to the MavenURLStreamHandlerService in order
to dynamically import the package org.osgi.service.cm.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ */
+
+public class ManagedServiceImpl
+ implements BundleActivator, ManagedService
+{
+ private BundleContext m_bundleContext;
+ private ServiceRegistration m_serviceRegistration;
+ private MavenURLStreamHandlerService m_mavenURLStreamHandlerService;
+
+ public ManagedServiceImpl(MavenURLStreamHandlerService
mavenURLStreamHandlerService){
+ this.m_mavenURLStreamHandlerService=mavenURLStreamHandlerService;
+ }
+
+ /**
+ * @see
org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ m_bundleContext=context;
+ Dictionary registrationProperties = new Hashtable();
+ registrationProperties.put(Constants.SERVICE_PID,
"org.apache.felix.sandbox.urlhandler.maven");
+ m_serviceRegistration=context.registerService(
+ new String[] {
+ ManagedService.class.getName()
+ }, this, registrationProperties);
+ }
+
+ /**
+ * @see
org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception
+ {
+ m_serviceRegistration.unregister();
+ }
+
+ /**
+ * update the configuration
+ */
+ public void updated(Dictionary configurationProperties) throws
ConfigurationException {
+ m_mavenURLStreamHandlerService.updated(configurationProperties);
+ }
+}
\ No newline at end of file
Propchange:
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/ManagedServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/MavenURLStreamHandlerService.java
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/MavenURLStreamHandlerService.java?rev=567846&r1=567845&r2=567846&view=diff
==============================================================================
---
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/MavenURLStreamHandlerService.java
(original)
+++
felix/sandbox/donsez/urlhandler.maven/src/main/java/org/apache/felix/sandbox/urlhandler/maven/MavenURLStreamHandlerService.java
Mon Aug 20 15:00:10 2007
@@ -20,6 +20,7 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -34,8 +35,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
import org.osgi.service.url.AbstractURLStreamHandlerService;
import org.osgi.service.url.URLConstants;
import org.osgi.service.url.URLStreamHandlerService;
@@ -46,7 +45,7 @@
*/
public class MavenURLStreamHandlerService extends
AbstractURLStreamHandlerService
- implements BundleActivator, ManagedService
+ implements BundleActivator
{
public static String MAVEN_URL_HANDLER_PROTOCOL="mvn";
public static String
DEFAULT_MAVEN_REPOSITORY_ROOTDIR_CONFIG_PROP_NAME="defaultMavenRepositoryRootDir";
@@ -55,6 +54,9 @@
private BundleContext m_bundleContext;
private ServiceRegistration m_serviceRegistration;
+
+ private BundleActivator m_managedService;
+
/**
* initialize the default Maven repository root dir
@@ -75,12 +77,19 @@
m_bundleContext=context;
Dictionary registrationProperties = new Hashtable();
registrationProperties.put(URLConstants.URL_HANDLER_PROTOCOL, new
String[] { MAVEN_URL_HANDLER_PROTOCOL });
- registrationProperties.put(Constants.SERVICE_PID,
"org.apache.felix.sandbox.urlhandler.maven");
m_serviceRegistration=context.registerService(
new String[] {
- URLStreamHandlerService.class.getName(),
- ManagedService.class.getName()
+ URLStreamHandlerService.class.getName()
}, this, registrationProperties);
+
+ try {
+ Class
clazzMS=this.getClass().getClassLoader().loadClass("org.apache.felix.sandbox.urlhandler.maven.ManagedServiceImpl");
+ Constructor constructor=clazzMS.getConstructor(new Class[]{
this.getClass() });
+ m_managedService=(BundleActivator) constructor.newInstance(new
Object[] {this});
+ m_managedService.start(context);
+ } catch(ClassNotFoundException e){
+ } catch (java.lang.NoClassDefFoundError e) {
+ }
}
/**
@@ -88,6 +97,7 @@
*/
public void stop(BundleContext context) throws Exception
{
+ m_managedService.stop(context);
m_serviceRegistration.unregister();
}
@@ -231,7 +241,7 @@
/**
* update the value of the default repository root dir
*/
- public void updated(Dictionary configurationProperties) throws
ConfigurationException {
+ public void updated(Dictionary configurationProperties) {
String s=(String)
configurationProperties.get(DEFAULT_MAVEN_REPOSITORY_ROOTDIR_CONFIG_PROP_NAME);
if(s!=null) m_defaultMavenRepositoryRootDir=s;
}
Modified: felix/sandbox/donsez/urlhandler.maven/src/site/script.txt
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/urlhandler.maven/src/site/script.txt?rev=567846&r1=567845&r2=567846&view=diff
==============================================================================
--- felix/sandbox/donsez/urlhandler.maven/src/site/script.txt (original)
+++ felix/sandbox/donsez/urlhandler.maven/src/site/script.txt Mon Aug 20
15:00:10 2007
@@ -1,13 +1,20 @@
-start
file:C:\Docume~1\Donsez\.m2\repository\org\apache\felix\org.apache.felix.sandbox.urlhandler.maven\0.9.0-incubator-SNAPSHOT\org.apache.felix.sandbox.urlhandler.maven-0.9.0-incubator-SNAPSHOT.jar
+start
file:C:\Docume~1\Donsez\.m2\repository\org\apache\felix\org.apache.felix.sandbox.urlhandler.maven\0.1.0-SNAPSHOT\org.apache.felix.sandbox.urlhandler.maven-0.1.0-SNAPSHOT.jar
services 4
start mvn:org.apache.felix:org.osgi.core:[EMAIL
PROTECTED]://repo1.maven.org/maven2
start mvn:org.apache.felix:javax.servlet
start mvn:org.apache.felix:org.osgi.compendium:1.0.0
+
+stop 4
+start 4
+services 4
+echo mvn:org.apache.felix:org.apache.felix.sandbox.urlhandler.maven can be
managed
+
start mvn:org.apache.felix:org.apache.felix.scr
start mvn:org.apache.felix:org.apache.felix.eventadmin
start mvn:org.apache.felix:org.apache.felix.wireadmin
+
update 5
refresh