You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2011/03/12 02:54:44 UTC

svn commit: r1080841 - in /incubator/clerezza/trunk/parent: ./ osgi.services/ osgi.services/src/main/resources/OSGI-INF/ osgi.services/src/main/scala/org/apache/clerezza/osgi/ osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ osgi.service...

Author: reto
Date: Sat Mar 12 01:54:43 2011
New Revision: 1080841

URL: http://svn.apache.org/viewvc?rev=1080841&view=rev
Log:
CLEREZZA-458: extracted services dsl to own project

Added:
    incubator/clerezza/trunk/parent/osgi.services/
      - copied from r1080060, incubator/clerezza/trunk/parent/shell/
    incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/
    incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/
    incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala
Removed:
    incubator/clerezza/trunk/parent/osgi.services/src/main/resources/OSGI-INF/serviceComponents.xml
    incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/shell/
Modified:
    incubator/clerezza/trunk/parent/osgi.services/pom.xml
    incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/pom.xml
    incubator/clerezza/trunk/parent/pom.xml
    incubator/clerezza/trunk/parent/shell/pom.xml
    incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala

Modified: incubator/clerezza/trunk/parent/osgi.services/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/osgi.services/pom.xml?rev=1080841&r1=1080060&r2=1080841&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/osgi.services/pom.xml (original)
+++ incubator/clerezza/trunk/parent/osgi.services/pom.xml Sat Mar 12 01:54:43 2011
@@ -5,33 +5,17 @@
 		<artifactId>parent</artifactId>
 		<version>0.2-incubating-SNAPSHOT</version>
 	</parent>
-	<artifactId>shell</artifactId>
+	<artifactId>osgi.services</artifactId>
 	<version>0.1-incubating-SNAPSHOT</version>
 	<packaging>bundle</packaging>
-	<name>Clerezza - Shell Service</name>
+	<name>Clerezza - OSGi Services DSL for Scala</name>
+	<description>A Scala DSL to easily access OSGi Services</description>
 	<dependencies>
 		<dependency>
-			<groupId>org.apache.clerezza.scala</groupId>
-			<artifactId>script-engine</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>jline</groupId>
-			<artifactId>jline</artifactId>
-			<version>0.9.94</version>
-		</dependency>
-		<dependency>
-			<groupId>org.scala-lang</groupId>
-			<artifactId>scala-compiler</artifactId>
-		</dependency>
-		<dependency>
 			<groupId>org.scala-lang</groupId>
 			<artifactId>scala-library</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.felix</groupId>
-			<artifactId>org.apache.felix.scr.annotations</artifactId>
-		</dependency>
-		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.compendium</artifactId>
 		</dependency>
@@ -49,9 +33,8 @@
 				<artifactId>maven-bundle-plugin</artifactId>
 				<configuration>
 					<instructions>
-						<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
-						<Export-Package>org.apache.clerezza.shell</Export-Package>
-						<Bundle-SymbolicName>org.apache.clerezza.shell</Bundle-SymbolicName>
+						<Export-Package>org.apache.clerezza.osgi.services</Export-Package>
+						<Bundle-SymbolicName>org.apache.clerezza.osgi.services</Bundle-SymbolicName>
 					</instructions>
 				</configuration>
 			</plugin>

Added: incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala?rev=1080841&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala (added)
+++ incubator/clerezza/trunk/parent/osgi.services/src/main/scala/org/apache/clerezza/osgi/services/ServicesDsl.scala Sat Mar 12 01:54:43 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.clerezza.osgi.services
+
+import org.osgi.framework.BundleContext
+import scala.collection.JavaConversions._
+
+class ServicesDsl(bundleContext: BundleContext) {
+
+	/**
+	 * returns an instance of a service exposing T
+	 */
+	def $[T](implicit m: Manifest[T]): T = {
+		getService(m.erasure.asInstanceOf[Class[T]])
+	}
+
+	private def getService[T](clazz : Class[T]) : T= {
+		val serviceReference = bundleContext.getServiceReference(clazz.getName)
+		if (serviceReference != null) {
+			bundleContext.getService(serviceReference).asInstanceOf[T]
+		} else null.asInstanceOf[T]
+	}
+}

Modified: incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/pom.xml?rev=1080841&r1=1080840&r2=1080841&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/pom.xml (original)
+++ incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/pom.xml Sat Mar 12 01:54:43 2011
@@ -414,6 +414,11 @@
 		</dependency>
 		<dependency>
 			<groupId>org.apache.clerezza</groupId>
+			<artifactId>osgi.services</artifactId>
+			<scope>runtime</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
 			<artifactId>platform.typerendering.core</artifactId>
 			<scope>runtime</scope>
 		</dependency>

Modified: incubator/clerezza/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/pom.xml?rev=1080841&r1=1080840&r2=1080841&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/pom.xml (original)
+++ incubator/clerezza/trunk/parent/pom.xml Sat Mar 12 01:54:43 2011
@@ -1122,6 +1122,11 @@
 			</dependency>
 			<dependency>
 				<groupId>org.apache.clerezza</groupId>
+				<artifactId>osgi.services</artifactId>
+				<version>0.1-incubating-SNAPSHOT</version>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.clerezza</groupId>
 				<artifactId>platform.content.representations</artifactId>
 				<version>0.1-incubating-SNAPSHOT</version>
 			</dependency>

Modified: incubator/clerezza/trunk/parent/shell/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/shell/pom.xml?rev=1080841&r1=1080840&r2=1080841&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/shell/pom.xml (original)
+++ incubator/clerezza/trunk/parent/shell/pom.xml Sat Mar 12 01:54:43 2011
@@ -15,6 +15,10 @@
 			<artifactId>script-engine</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>osgi.services</artifactId>
+		</dependency>
+		<dependency>
 			<groupId>jline</groupId>
 			<artifactId>jline</artifactId>
 			<version>0.9.94</version>

Modified: incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala?rev=1080841&r1=1080840&r2=1080841&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala (original)
+++ incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/OsgiDsl.scala Sat Mar 12 01:54:43 2011
@@ -21,11 +21,13 @@ package org.apache.clerezza.shell
 import java.io.OutputStream
 import java.io.OutputStreamWriter
 import java.io.PrintWriter
+import org.apache.clerezza.osgi.services.ServicesDsl
 import org.osgi.framework.Bundle
 import org.osgi.service.component.ComponentContext
 import scala.collection.JavaConversions._
 
-class OsgiDsl(context: ComponentContext, outputStream: OutputStream) {
+class OsgiDsl(context: ComponentContext, outputStream: OutputStream) 
+		extends ServicesDsl(context.getBundleContext) {
 
 	lazy val out = new PrintWriter(new OutputStreamWriter(outputStream, "utf-8"), true)
 	val bundleContext = context.getBundleContext
@@ -62,15 +64,4 @@ class OsgiDsl(context: ComponentContext,
 	def shutdown {
 		bundleContext.getBundle(0).stop()
 	}
-
-	def $[T](implicit m: Manifest[T]): T = {
-		getService(m.erasure.asInstanceOf[Class[T]])
-	}
-
-	private def getService[T](clazz : Class[T]) : T= {
-		val serviceReference = bundleContext.getServiceReference(clazz.getName)
-		if (serviceReference != null) {
-			bundleContext.getService(serviceReference).asInstanceOf[T]
-		} else null.asInstanceOf[T]
-	}
 }