clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1082762 - in /incubator/clerezza/trunk/parent/sourcebundle: ./ src/main/resources/OSGI-INF/ src/main/resources/org/ src/main/resources/org/apache/ src/main/resources/org/apache/clerezza/ src/main/resources/org/apache/clerezza/sourcebundle/...
Date Fri, 18 Mar 2011 00:06:55 GMT
Author: reto
Date: Fri Mar 18 00:06:54 2011
New Revision: 1082762

URL: http://svn.apache.org/viewvc?rev=1082762&view=rev
Log:
CLEREZZA-465: An initial version, supporting creating skeletons with zz>Dev create 'scala_with_activator
in /path/to/some/dir, the actual project prototype has yet to be finished and the naming skeleton/prototype
has to made more consistent

Added:
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/pom.xml
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Activator.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorld.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorldMessageRenderlet.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Ontology.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevDsl.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevShellCustomizer.scala
    incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/UnavailableSkeletonException.scala
Modified:
    incubator/clerezza/trunk/parent/sourcebundle/pom.xml
    incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/OSGI-INF/serviceComponents.xml
    incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/BundleRoot.scala

Modified: incubator/clerezza/trunk/parent/sourcebundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/pom.xml?rev=1082762&r1=1082761&r2=1082762&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/pom.xml (original)
+++ incubator/clerezza/trunk/parent/sourcebundle/pom.xml Fri Mar 18 00:06:54 2011
@@ -44,6 +44,14 @@
 			<artifactId>pax-swissbox-tinybundles</artifactId>
 			<version>1.3.0</version>
 		</dependency>
+        <dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>utils</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>shell</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<sourceDirectory>src/main/scala</sourceDirectory>

Modified: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/OSGI-INF/serviceComponents.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/OSGI-INF/serviceComponents.xml?rev=1082762&r1=1082761&r2=1082762&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/OSGI-INF/serviceComponents.xml
(original)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/OSGI-INF/serviceComponents.xml
Fri Mar 18 00:06:54 2011
@@ -15,4 +15,11 @@
 				cardinality="1..1"
 				bind="bindPackageAdmin" unbind="unbindPackageAdmin"/>
     </scr:component>
+	<scr:component enabled="true"  name="org.apache.clerezza.sourcebundle.DevShellCustomizer">
+        <implementation class="org.apache.clerezza.sourcebundle.DevShellCustomizer"/>
+        <property name="service.pid" value="org.apache.clerezza.sourcebundle.DevShellCustomizer"/>
+		<service servicefactory="false">
+            <provide interface="org.apache.clerezza.shell.ShellCustomizer"/>
+        </service>
+    </scr:component>
 </components>

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/pom.xml?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/pom.xml
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/pom.xml
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.clerezza</groupId>
+		<artifactId>parent</artifactId>
+		<version>0.2-incubating-SNAPSHOT</version>
+	</parent>
+	<artifactId>skeleton</artifactId>
+	<version>0.1-incubating-SNAPSHOT</version>
+	<packaging>bundle</packaging>
+	<name>Clerezza - Project Skeleton</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+		</dependency>
+        <dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>platform.typerendering.core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>platform.typerendering.scala</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>rdf.ontologies</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>rdf.utils</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>rdf.scala.utils</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.clerezza</groupId>
+			<artifactId>osgi.services</artifactId>
+		</dependency>
+        <dependency>
+			<groupId>org.scala-lang</groupId>
+			<artifactId>scala-library</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>javax.ws.rs</groupId>
+			<artifactId>jsr311-api</artifactId>
+        </dependency>
+	</dependencies>
+	<build>
+		<sourceDirectory>src/main/scala</sourceDirectory>
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<configuration>
+					<instructions>
+						<Bundle-activator>skeleton.Activator</Bundle-activator>
+						<Export-Package>skeleton</Export-Package>
+						<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-eclipse-plugin</artifactId>
+				<configuration>
+					<downloadSources>true</downloadSources>
+					<downloadJavadocs>true</downloadJavadocs>
+					<buildcommands>
+						<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
+					</buildcommands>
+					<additionalProjectnatures>
+						<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
+					</additionalProjectnatures>
+					<classpathContainers>
+						<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+						</classpathContainer>
+						<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER
+						</classpathContainer>
+					</classpathContainers>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.scala-tools</groupId>
+				<artifactId>maven-scala-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+</project>
+
+

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Activator.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Activator.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Activator.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Activator.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,43 @@
+package skeleton
+
+import org.osgi.framework.{BundleActivator, BundleContext, ServiceRegistration}
+import scala.collection.JavaConversions.asJavaDictionary
+import org.apache.clerezza.platform.typerendering.{Renderlet, RenderletManager}
+
+/**
+ * Activator for a bundle using Apache Clerezza.
+ */
+class Activator extends BundleActivator {
+
+	var helloWorldRegistration: ServiceRegistration = null
+	var renderletRegistration: ServiceRegistration = null
+	/**
+	 * called when the bundle is started, this method initializes the provided service
+	 */
+	def start(context: BundleContext) {
+		//import org.apache.clerezza.shell.OsgiDsl
+		//val osgiDsl = new OsgiDsl(context, System.out)
+		//import osgiDsl._
+		println("activating...")
+		val args = scala.collection.mutable.Map("javax.ws.rs" -> true)
+		helloWorldRegistration = context.registerService(classOf[Object].getName,
+												  new HelloWorld(), args)
+		val renderlet = new HelloWorldMessageRenderlet
+		val serviceReference = context.getServiceReference(classOf[RenderletManager].getName)
+		renderlet bindRenderletManager context.getService(serviceReference).asInstanceOf[RenderletManager]
+
+		renderletRegistration = context.registerService(classOf[Renderlet].getName,
+												  renderlet, null)
+		println("enjoy!")
+	}
+
+	/**
+	 * called when the bundle is stopped, this method unregisters the provided service
+	 */
+	def stop(context: BundleContext) {
+		helloWorldRegistration.unregister()
+		renderletRegistration.unregister()
+		println("bye")
+	}
+
+}

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorld.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorld.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorld.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorld.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,22 @@
+package skeleton
+
+import javax.ws.rs._
+import org.apache.clerezza.rdf.core.BNode
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph
+import org.apache.clerezza.rdf.ontologies.{DC, RDF}
+import org.apache.clerezza.rdf.utils.GraphNode;
+
+/**
+ * The classical Hello World root resource
+ */
+@Path("hello-world")
+class HelloWorld {
+	@GET def get() = {
+		val resultMGraph = new SimpleMGraph();
+		val graphNode = new GraphNode(new BNode(), resultMGraph);
+		graphNode.addProperty(RDF.`type` , Ontology.HelloWordMessageType);
+		graphNode.addPropertyValue(DC.description,"Hello world");
+		graphNode;
+
+	}
+}

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorldMessageRenderlet.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorldMessageRenderlet.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorldMessageRenderlet.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/HelloWorldMessageRenderlet.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,32 @@
+package skeleton
+
+import javax.ws.rs.core.MediaType
+import org.apache.clerezza.platform.typerendering._
+import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.rdf.utils.GraphNode
+import org.apache.clerezza.rdf.ontologies._
+import org.apache.clerezza.rdf.core._
+import org.apache.clerezza.rdf.utils._
+import org.apache.clerezza.rdf.scala.utils.Preamble._
+import org.apache.clerezza.platform.typerendering.scala._
+
+/**
+ * A Renderlet for HelloWorldMessage
+ */
+class HelloWorldMessageRenderlet extends PageRenderlet {
+
+	val rdfType = Ontology.HelloWordMessageType
+	override def mode = "naked"
+
+	override def renderedPage(arguments: RenderedPage.Arguments): RenderedPage = {
+		new RenderedPage(arguments) {
+			override def content = {
+				resultDocModifier.addStyleSheet("/styles/wall/wall.css")
+				<div xmlns="http://www.w3.org/1999/xhtml" id="tx-content">
+					<h2>Wall</h2>
+				</div>
+			}
+		}
+	}
+
+}

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Ontology.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Ontology.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Ontology.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/resources/org/apache/clerezza/sourcebundle/skeletons/scala_with_activator/src/main/scala/Ontology.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,12 @@
+package skeleton
+
+import org.apache.clerezza.rdf.core.UriRef
+
+object Ontology {
+
+	/**
+	 * The uri for the RDF type of HelloWordMessage
+	 */
+	val HelloWordMessageType = new UriRef("http://example.org/skeleton#HelloWordMessage")
+
+}

Modified: incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/BundleRoot.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/BundleRoot.scala?rev=1082762&r1=1082761&r2=1082762&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/BundleRoot.scala
(original)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/BundleRoot.scala
Fri Mar 18 00:06:54 2011
@@ -19,7 +19,7 @@
 
 package org.apache.clerezza.sourcebundle
 
-import java.io._
+
 import scala.actors.DaemonActor
 import scala.io._
 import org.osgi.framework.Bundle
@@ -32,24 +32,28 @@ import org.apache.clerezza.scala.scripti
 import org.osgi.framework.Constants
 import org.osgi.service.component.ComponentContext
 import org.slf4j.LoggerFactory
-import scala.tools.nsc.io.AbstractFile
-import scala.tools.nsc.io.VirtualDirectory
 import scala.collection.mutable
 import org.osgi.service.packageadmin.PackageAdmin
+import tools.nsc.io.{AbstractFile, VirtualDirectory}
+import java.io.{File, FileInputStream, ByteArrayInputStream}
+import org.apache.clerezza.utils.osgi.BundlePathNode
+import org.wymiwyg.commons.util.dirbrowser.PathNode
 
 /**
  * Provides a service that allows to register directories containing a maven-style project
  * structure to be registered as SourceBundle which is added as OSGi Bundle and regenerated
  * whenever a file is changed.
  *
- * Currently only scala files a compiled.
+ * Currently only scala files are compiled.
  */
 class BundleRoot {
 
-	var compilerService: CompilerService = null
-	var packageAdmin: PackageAdmin = null
+	private var compilerService: CompilerService = null
+	private var packageAdmin: PackageAdmin = null
+
+	private var bundleContext: BundleContext = null
 
-	var bundleContext: BundleContext = null
+	private val skeletonsPath = "org/apache/clerezza/sourcebundle/skeletons"
 
 	val sourceBundles = mutable.ListBuffer[SourceBundle]()
 
@@ -72,16 +76,65 @@ class BundleRoot {
 		for (sb <- sourceBundles) sb.stop()
 	}
 
-  /**
-   * Creates a SourceBundle for the sources in the specified dir
-   */
-	def createSourceBundle(dir: File) = {
+	/**
+	 * adds a SourceBundle for the sources in the specified dir
+	 */
+	def addSourceBundle(dir: File) = {
 		val sourceBundle = new SourceBundle(dir)
 		sourceBundle.start()
 		sourceBundles += sourceBundle
 		sourceBundle
 	}
 
+	@deprecated
+	def createSourceBundle(dir: File) = addSourceBundle(dir)
+
+	/**
+	* list of the available skletons
+	*/
+	def availableSkeletons: Seq[Symbol] = {
+		val skeletonsNode = new BundlePathNode(bundleContext.getBundle, skeletonsPath)
+		for (name <- skeletonsNode.list) yield {
+			Symbol(name.substring(1,name.length-1))
+		}
+	}
+
+	/**
+	 * Creates and adds a new SourceBundle from a skeleton, no existing file is
+	 * replaced
+	 */
+	def createSourceBundle(skeleton: Symbol, dir: File) = {
+		dir.mkdirs
+		val skeletonsNode = new BundlePathNode(bundleContext.getBundle, skeletonsPath)
+		val skeletonNode = skeletonsNode.getSubPath(skeleton.name)
+		if (!skeletonNode.exists) {
+			throw new UnavailableSkeletonException(skeleton, availableSkeletons)
+		}
+		def processFile(p: PathNode, f: File) {
+			if (!f.exists) {
+				val in = scala.io.Source.fromInputStream(p.getInputStream)
+				val out = new java.io.PrintWriter(f)
+				try { in.getLines().foreach(out.println(_)) }
+				finally { out.close }
+			}
+		}
+		def processDir(p: PathNode, f: File) {
+			f.mkdir()
+			for (subPathString <- p.list()) {
+				val subPathNode: PathNode = p.getSubPath(subPathString)
+				val subFile: File = new File(f, subPathString)
+				if (subPathNode.isDirectory) {
+					processDir(subPathNode, subFile)
+				} else {
+					processFile(subPathNode, subFile)
+				}
+			}
+		}
+
+		processDir(skeletonNode, dir)
+		addSourceBundle(dir)
+	}
+
 	def bindCompilerService(cs: CompilerService) {
 		compilerService = cs;
 	}
@@ -137,22 +190,27 @@ class BundleRoot {
 
 			val tinyBundle: TinyBundle = newBundle()
 
-			def compileDir(sourceDir: File) {
-				
+			def compileDir(sourceDir: File): Option[String] = {
+
 				val charArrays = getFilesAsCharArrays(sourceDir)
 				logger.debug("compiling "+charArrays.size+" files")
-				
+
 				val vdPathPrefix = "(memory)"
 				val virtualDirectory = new VirtualDirectory(vdPathPrefix, None)
 				//val wrappedDirectory = VirtualDirectoryWrapper.wrap(virtualDirectory, outputListener)
 
 				val writtenClasses = compilerService.compileToDir(charArrays, virtualDirectory)
 				logger.debug("virtualDirectory "+virtualDirectory.size)
+				var potentialActivator: Option[String] = None
 				for (writtenClass <- writtenClasses) {
 					val fullPath = writtenClass.path
 					val path = fullPath.substring(vdPathPrefix.length+1)
+					if (path.endsWith("Activator.class")) {
+						potentialActivator = Some(path.substring(0, path.lastIndexOf('.')).replace('/', '.'))
+					}
 					tinyBundle.add(path, new ByteArrayInputStream(writtenClass.toByteArray))
 				}
+		    potentialActivator
 			}
 
 			def copyResource(resourcesDir: File) {
@@ -178,10 +236,12 @@ class BundleRoot {
 			tinyBundle.set("Bundle-SymbolicName", symName)
 
 			val scalaSourceDir = new File(dir, "src/main/scala")
-			if (scalaSourceDir.exists) {
+
+			val potentialActivator = if (scalaSourceDir.exists) {
 				compileDir(scalaSourceDir)
 			} else {
 				logger.debug("No source dir "+scalaSourceDir)
+				None
 			}
 			val resourcesDir = new File(dir, "src/main/resources")
 			if (resourcesDir.exists) {
@@ -194,6 +254,10 @@ class BundleRoot {
 				tinyBundle.set("Service-Component", "OSGI-INF/serviceComponents.xml")
 				tinyBundle.set(Constants.EXPORT_PACKAGE, "!OSGI-INF, *" )
 			}
+			potentialActivator match {
+				case Some(s) =>  tinyBundle.set("Bundle-Activator", s)
+				case _ => ;
+			}
 			tinyBundle.set(Constants.IMPORT_PACKAGE, "*" );
 			val in = tinyBundle.build(
 					withBnd()
@@ -206,7 +270,7 @@ class BundleRoot {
 			} else {
 				bundle.update(in)
 			}
-			
+
 		}
 
 		def act() {

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevDsl.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevDsl.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevDsl.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevDsl.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.sourcebundle
+
+import java.io.File
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+import java.io.PrintWriter
+import org.osgi.framework.BundleContext
+import org.apache.clerezza.osgi.services.ServicesDsl
+
+class DevDsl(outputStream: OutputStream, bundleContext: BundleContext) {
+
+	object Dev {
+		private val serviceDsl = new ServicesDsl(bundleContext)
+		import serviceDsl._
+		private lazy val out = new PrintWriter(new OutputStreamWriter(outputStream, "utf-8"), true)
+		
+		def create(skeleton: Symbol) = new Object() {
+			def in(location: String): Unit = try {
+				$[BundleRoot].createSourceBundle(skeleton, new File(location))
+			} catch {
+				case u: UnavailableSkeletonException => {
+					out println "FAILURE: no skeleton "+skeleton+" is available"
+					out println "The following skeletons are available"
+					for (a <- u.available) {
+						out println "  - "+a
+					}
+				}
+			}
+		}
+	}
+
+}

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevShellCustomizer.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevShellCustomizer.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevShellCustomizer.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/DevShellCustomizer.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.sourcebundle
+
+import org.apache.clerezza.shell.Shell
+import org.apache.clerezza.shell.ShellCustomizer
+
+class DevShellCustomizer extends ShellCustomizer {
+	def bindings(e: Shell.Environment): List[(String, String, Any)] = {
+		List(("devDsl", classOf[DevDsl].getName, new DevDsl(e.out,
+						e.componentContext.getBundleContext)))
+	}
+	def imports: List[String] = List("devDsl._")
+}

Added: incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/UnavailableSkeletonException.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/UnavailableSkeletonException.scala?rev=1082762&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/UnavailableSkeletonException.scala
(added)
+++ incubator/clerezza/trunk/parent/sourcebundle/src/main/scala/org/apache/clerezza/sourcebundle/UnavailableSkeletonException.scala
Fri Mar 18 00:06:54 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.sourcebundle
+
+class UnavailableSkeletonException(val requested: Symbol, val available: Seq[Symbol])
+	extends RuntimeException("The Skeleton "+requested.name+" is not avialble") {
+
+}



Mime
View raw message