Author: reto
Date: Tue Sep 14 09:39:19 2010
New Revision: 996808

URL: http://svn.apache.org/viewvc?rev=996808&view=rev
Log:
CLEREZZA-278: split utilities for self-registration to a separate subclass, 
added documentation

Added:
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/documentation.nt
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/AbstractRenderlet.scala
Modified:
    
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/PageRenderlet.scala

Added: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/documentation.nt
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/documentation.nt?rev=996808&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/documentation.nt
 (added)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/resources/META-INF/documentation.nt
 Tue Sep 14 09:39:19 2010
@@ -0,0 +1,25 @@
+<bundle:///intro-content-el/0> <http://discobits.org/ontology#infoBit> "The 
Type-Rendering Utilities for Scala allow to write Renderlets in Scala more 
easily. Apart from a having to add a bit of code to produce complete Scala 
classes they provide the same functionality as available in ScalaServerPages, 
additionally the Renderlet can register itself for a specified RDF type and 
rendering mode."^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
+<bundle:///intro-content-el/0> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro-content-el/1> <http://discobits.org/ontology#infoBit> "See 
the ScalaDoc for PageRenderlet and its superclass AbstractRenderlet for usage 
instrcutions. Note that the resulting rendelerlets need to be registered as 
service, in serviceComponents.xml the respective section would look like this: 
\n<pre xmlns=\"http://www.w3.org/1999/xhtml\";>\n&lt;scr:component 
enabled=\"true\" 
name=\"org.example.html.BookFormRenderlet\"&gt;\n\t&lt;implementation 
class=\"org.example.html.BookFormRenderlet\"/&gt;\n\t&lt;service 
servicefactory=\"false\"&gt;\n\t\t&lt;provide 
interface=\"org.apache.clerezza.platform.typerendering.Renderlet\"/&gt;\n\t&lt;/service&gt;\n\t&lt;property
 name=\"service.pid\" 
value=\"org.example.html.BookFormRenderlet\"/&gt;\n\t&lt;reference 
name=\"renderletManager\"\n\tinterface=\"org.apache.clerezza.platform.typerendering.RenderletManager\"\n\tcardinality=\"1..1\"
 policy=\"static\" bind=\"bindRenderletManager\" 
unbind=\"unbindRenderletManager\"/&gt;\n&lt;/
 
scr:component&gt;\n</pre>"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>
 .
+<bundle:///intro-content-el/1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro-content> <http://discobits.org/ontology#contains> 
_:86e4309edd82a6d415338546caff2d551 . 
+<bundle:///intro-content> <http://discobits.org/ontology#contains> 
_:8ced329518dac9ef741f4099548bb8451 . 
+<bundle:///intro-content> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#OrderedContent> .
+<bundle:///intro-title> <http://discobits.org/ontology#infoBit> "Clerezza - 
Platform Type Rendering Utilities for 
Scala"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
+<bundle:///intro-title> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro> <http://clerezza.org/2009/08/documentation#after> 
<bundle://org.apache.clerezza.platform.typerendering.scalaserverpages/intro> .
+<bundle:///intro> <http://discobits.org/ontology#contains> 
_:b7d0232f405805aac4674f5585e011d01 . 
+<bundle:///intro> <http://discobits.org/ontology#contains> 
_:ccd6d577f99d82c53d5323fdbe4b6ba31 . 
+<bundle:///intro> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#TitledContent> .
+_:86e4309edd82a6d415338546caff2d551 <http://discobits.org/ontology#holds> 
<bundle:///intro-content-el/1> . 
+_:86e4309edd82a6d415338546caff2d551 <http://discobits.org/ontology#pos> "1" . 
+_:86e4309edd82a6d415338546caff2d551 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#Entry> . 
+_:8ced329518dac9ef741f4099548bb8451 <http://discobits.org/ontology#holds> 
<bundle:///intro-content-el/0> . 
+_:8ced329518dac9ef741f4099548bb8451 <http://discobits.org/ontology#pos> "0" . 
+_:8ced329518dac9ef741f4099548bb8451 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#Entry> . 
+_:b7d0232f405805aac4674f5585e011d01 <http://discobits.org/ontology#holds> 
<bundle:///intro-content> . 
+_:b7d0232f405805aac4674f5585e011d01 <http://discobits.org/ontology#pos> "1" . 
+_:b7d0232f405805aac4674f5585e011d01 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#Entry> . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 <http://discobits.org/ontology#holds> 
<bundle:///intro-title> . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 <http://discobits.org/ontology#pos> "0" . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://discobits.org/ontology#Entry> . 

Added: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/AbstractRenderlet.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/AbstractRenderlet.scala?rev=996808&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/AbstractRenderlet.scala
 (added)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/AbstractRenderlet.scala
 Tue Sep 14 09:39:19 2010
@@ -0,0 +1,72 @@
+package org.apache.clerezza.platform.typerendering.scala
+
+import java.io.IOException
+import java.io.OutputStream
+import java.net.URI
+import javax.ws.rs.core.MediaType
+import org.apache.clerezza.platform.typerendering.Renderlet.RequestProperties
+import org.apache.clerezza.platform.typerendering._
+import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.rdf.utils.GraphNode
+import org.osgi.service.component.ComponentContext
+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._
+
+/**
+ * This abstract Renderlet is overwritten to support the rendering of a 
+ * particular RDF type in scala.
+ * <br/>
+ * Overwriting classes weill define the method renderedPage(Arguments) to 
deliver
+ * the representation of the resource.
+ * <br/>
+ * There's typically only one instance of a AbstractRenderlet while a new 
instance
+ * of RenderedPage is generated for each request.
+ *
+ * An example of a subclass:
+ *
+ * class BookFormRenderlet extends AbstractRenderlet {
+ *
+ *      override def renderedPage(arguments: RenderedPage.Arguments): 
RenderedPage = {
+ *             new RenderedPage(arguments) {
+ *
+ *                     override def content = <div 
xmlns="http://www.w3.org/1999/xhtml";>
+ *                        ....
+ *                     </div>
+ *             }
+ *      }
+ * }
+ */
+abstract class AbstractRenderlet extends Renderlet {
+
+       def renderedPage(renderingArguments: RenderedPage.Arguments): 
RenderedPage
+
+       def ifx[T](con:  => Boolean)(f: => T) :  T = {
+               if (con) f else null.asInstanceOf[T]
+       }
+
+       val resultDocModifier = 
org.apache.clerezza.platform.typerendering.ResultDocModifier.getInstance();
+
+       @throws(classOf[IOException])
+       override def render(res: GraphNode, context: GraphNode,
+                                       sharedRenderingValues: 
java.util.Map[String, Object],
+                                       renderer: CallbackRenderer ,
+                                       renderingSpecification:  URI,
+                                       mode: String,
+                                       mediaType: MediaType,
+                                       requestProperties: RequestProperties,
+                                       os: OutputStream) = {
+                       if (os == null) {
+                               throw new IllegalArgumentException("Exception!")
+                       }
+                       val renderingSpecificationOption = if 
(renderingSpecification != null) {Some(renderingSpecification)} else {None}
+                       val modeOption = if (mode != null) {Some(mode)} else 
{None}
+                       renderedPage(
+                               RenderedPage.Arguments(res, context, 
sharedRenderingValues, renderer,
+                                                                  
renderingSpecificationOption, modeOption, mediaType, os));
+
+       }
+
+}
+

Modified: 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/PageRenderlet.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/PageRenderlet.scala?rev=996808&r1=996807&r2=996808&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/PageRenderlet.scala
 (original)
+++ 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.typerendering.scala/src/main/scala/org/apache/clerezza/platform/typerendering/scala/PageRenderlet.scala
 Tue Sep 14 09:39:19 2010
@@ -15,22 +15,11 @@ import org.apache.clerezza.rdf.utils._
 import org.apache.clerezza.rdf.scala.utils.Preamble._
 
 /**
- * This abstract Renderlet is overwritten to support the rendering of a 
- * particular RDF type in scala.
- * <br/>
- * Overwriting classes weill define the method renderedPage(Arguments), 
rdfType 
- * and optionally mode.
- * <br/>
- * This class makes sure the renderlet is registered with the renderlet manager
- * when the component is activated.
- * <br/>
- * There's typically only one instance of a PageRenderlet while a new instance
- * of RenderedPage is generated for each request.
- *
+ * This extends AbstractRenderlet with rdfType (abstract) and mode (defaulting 
to
+ * "naked") and provides an activate method registering the class as Renderlet
+ * with the RenderletManager.
  */
-abstract class PageRenderlet extends Renderlet {
-
-       println("constructoing PageRenderlet")
+abstract class PageRenderlet extends AbstractRenderlet {
 
        def renderedPage(renderingArguments: RenderedPage.Arguments): 
RenderedPage
        def rdfType: UriRef
@@ -38,13 +27,6 @@ abstract class PageRenderlet extends Ren
 
        var renderletManager: RenderletManager = null;
 
-       def ifx[T](con:  => Boolean)(f: => T) :  T = {
-               if (con) f else null.asInstanceOf[T]
-       }
-
-       val resultDocModifier = 
org.apache.clerezza.platform.typerendering.ResultDocModifier.getInstance();
-
-
        def activate(context: ComponentContext) = {
                println("activating Page Renderlet "+this.getClass);
                renderletManager.registerRenderlet(this.getClass.getName,
@@ -53,30 +35,6 @@ abstract class PageRenderlet extends Ren
                                MediaType.APPLICATION_XHTML_XML_TYPE, true);
        }
 
-
-
-       @throws(classOf[IOException])
-       override def render(res: GraphNode, context: GraphNode,
-                                       sharedRenderingValues: 
java.util.Map[String, Object],
-                                       renderer: CallbackRenderer ,
-                                       renderingSpecification:  URI,
-                                       mode: String,
-                                       mediaType: MediaType,
-                                       requestProperties: RequestProperties,
-                                       os: OutputStream) = {
-                       if (os == null) {
-                               throw new IllegalArgumentException("Exception!")
-                       }
-                       val renderingSpecificationOption = if 
(renderingSpecification != null) {Some(renderingSpecification)} else {None}
-                       val modeOption = if (mode != null) {Some(mode)} else 
{None}
-                       renderedPage(
-                               RenderedPage.Arguments(res, context, 
sharedRenderingValues, renderer,
-                                                                  
renderingSpecificationOption, modeOption, mediaType, os));
-
-       }
-       
-       
-
        def bindRenderletManager(m: RenderletManager)  = {
                renderletManager = m
        }


Reply via email to