incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reto Bachmann-Gmuer <r...@apache.org>
Subject request for feedback on platform.typerendering.gui
Date Sun, 27 Mar 2011 11:42:30 GMT
Hello

I'd like to solicit feedback on the module platform.typerendering.gui. The
bundle provides a page to see the list of installed renderlets, this is very
handy to find out which renderlet has to be modified or how a new renderlet
has to be specified to overwrite an existing one.

I tried to implement this utility as easily as possible and now I'd like
some feedback about which compromises are acceptabled an which aren't.

   - No Declarative Services: Rather than DS the project is using an
   activator with the Root-Resource as inline object. This saved me from
   writing XML and bind/unbind methods. The disadvantage of not using DS is
   that component aren't disabled when the services they require go down, but
   when a service is missing this can cause a runtime-exception
   - Ad-Hoc ontology: the Uris for classes and properties are declared in
   scala directly without writing an N3 file
   - No dedicated page template: Template only for the individual renderlets
   descriptions. The page as a whole is renderlet by the default :HeadedPage
   and rdf:List templates

I'm not suggesting this as the default way to make new modules for Clerezza,
but I'd like to discuss if the above compromises are acceptable for a module
like this on which no other project depends, which is not essential for the
working of the platform and with an ontology specific to a very narrow
domain.

Cheers,
reto


On Sun, Mar 27, 2011 at 1:11 PM,  <reto@apache.org> wrote:
> Author: reto
> Date: Sun Mar 27 11:11:11 2011
> New Revision: 1085912
>
> URL: http://svn.apache.org/viewvc?rev=1085912&view=rev
> Log:
> CLEREZZA-460: minimalistic implementation of renderlet-manager gui
>
> Added:
>    incubator/clerezza/trunk/parent/platform.typerendering.gui/   (with
props)
>    incubator/clerezza/trunk/parent/platform.typerendering.gui/pom.xml
>    incubator/clerezza/trunk/parent/platform.typerendering.gui/src/
>    incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/style.css
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Activator.scala
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Ontology.scala
>
 incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/RenderletDescriptionRenderlet.scala
>
> Propchange: incubator/clerezza/trunk/parent/platform.typerendering.gui/
>
------------------------------------------------------------------------------
> --- svn:ignore (added)
> +++ svn:ignore Sun Mar 27 11:11:11 2011
> @@ -0,0 +1 @@
> +target
>
> Added: incubator/clerezza/trunk/parent/platform.typerendering.gui/pom.xml
> URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typerendering.gui/pom.xml?rev=1085912&view=auto
>
==============================================================================
> --- incubator/clerezza/trunk/parent/platform.typerendering.gui/pom.xml
(added)
> +++ incubator/clerezza/trunk/parent/platform.typerendering.gui/pom.xml Sun
Mar 27 11:11:11 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>platform.typerendering.gui</artifactId>
> +       <version>0.1-incubating-SNAPSHOT</version>
> +       <packaging>bundle</packaging>
> +       <name>Clerezza - Platform Typerendering GUI</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/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/style.css
> URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/style.css?rev=1085912&view=auto
>
==============================================================================
> ---
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/style.css
(added)
> +++
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/resources/CLEREZZA-INF/web-resources/styles/renderlets/style.css
Sun Mar 27 11:11:11 2011
> @@ -0,0 +1,17 @@
> +.renderlet {
> +       background-color: lightgray;
> +       border: darkgrey;
> +       border-width: 1px;
> +       border-style: solid;
> +       with: 90%;
> +       vertical-align: middle;
> +       margin-left: 1em;
> +       margin-right: 1em
> +}
> +.entry {
> +       padding-bottom: 1em;
> +}
> +.renderlet .value {
> +       color: darkgreen;
> +}
> +
>
> Added:
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Activator.scala
> URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Activator.scala?rev=1085912&view=auto
>
==============================================================================
> ---
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Activator.scala
(added)
> +++
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Activator.scala
Sun Mar 27 11:11:11 2011
> @@ -0,0 +1,92 @@
> +package org.apache.clerezza.platform.typerendering.gui
> +
> +import org.apache.clerezza.rdf.core.BNode
> +import org.apache.clerezza.rdf.core.impl.SimpleMGraph
> +import org.osgi.framework.{BundleActivator, BundleContext,
ServiceRegistration}
> +import scala.collection.JavaConversions._
> +import org.apache.clerezza.platform.dashboard.GlobalMenuItem
> +import org.apache.clerezza.platform.dashboard.GlobalMenuItemsProvider
> +import org.apache.clerezza.platform.typerendering.{TypeRenderlet,
RenderletManager}
> +import java.util.HashSet
> +import javax.ws.rs._
> +import org.apache.clerezza.rdf.ontologies.{DC, RDF, PLATFORM}
> +import org.apache.clerezza.rdf.utils.GraphNode;
> +import org.apache.clerezza.rdf.scala.utils._
> +
> +/**
> + * Activator for a bundle using Apache Clerezza.
> + */
> +class Activator extends BundleActivator {
> +
> +       private var renderletsOverview: ServiceRegistration = null
> +       private var renderletRegistration, menuProviderRegistration:
ServiceRegistration = null
> +       private var bundleContext: BundleContext = null
> +
> +
> +       final val path = "admin/renderlets/overview"
> +       @Path(path)
> +       object RenderletsOverview {
> +               @GET def get() = {
> +                       val resultMGraph = new SimpleMGraph();
> +                       val preamble = new Preamble(resultMGraph)
> +                       import preamble._
> +                       val resultNode = new GraphNode(new BNode(),
resultMGraph);
> +                       resultNode.addProperty(RDF.`type` ,
Ontology.RenderletOverviewPage);
> +                       resultNode.addProperty(RDF.`type` ,
PLATFORM.HeadedPage);
> +                       resultNode.addProperty(RDF.`type` , RDF.List);
> +                       val renderletList = resultNode.asList;
> +                       for (sr <-
bundleContext.getServiceReferences(classOf[TypeRenderlet].getName, null)) {
> +                               val renderlet =
bundleContext.getService(sr).asInstanceOf[TypeRenderlet]
> +                               val rendRes = new BNode()
> +                               rendRes.addProperty(RDF.`type`,
Ontology.Renderlet);
> +
rendRes.addPropertyValue(Ontology.mediaType,
> +
      renderlet.getMediaType.toString)
> +                               if (renderlet.getModePattern != null)
rendRes.addPropertyValue(Ontology.modePattern,
> +
      renderlet.getModePattern)
> +                               rendRes.addProperty(Ontology.rdfType,
> +
      renderlet.getRdfType)
> +
rendRes.addPropertyValue(Ontology.stringRepresentation,
> +
      renderlet.toString)
> +
rendRes.addPropertyValue(Ontology.providingBundle,
> +
      sr.getBundle.getLocation)
> +                               renderletList.add(rendRes)
> +                       }
> +                       resultNode;
> +               }
> +       }
> +
> +       object MenuProvider extends GlobalMenuItemsProvider {
> +               override def getMenuItems = {
> +                       val result = new HashSet[GlobalMenuItem]();
> +                       result.add(new
GlobalMenuItem("/"+path,"renderlet-overview", "Renderlet Overview", -999,
"Administration"))
> +                       result
> +               }
> +       }
> +
> +       /**
> +        * called when the bundle is started, this method initializes the
provided service
> +        */
> +       def start(context: BundleContext) {
> +               this.bundleContext = context
> +               val args = scala.collection.mutable.Map("javax.ws.rs" ->
true)
> +               renderletsOverview =
context.registerService(classOf[Object].getName,
> +
                               RenderletsOverview, args)
> +               val renderlet = new RenderletDescriptionRenderlet
> +               val serviceReference =
context.getServiceReference(classOf[RenderletManager].getName)
> +               renderletRegistration =
context.registerService(classOf[TypeRenderlet].getName,
> +
                                      renderlet, null)
> +               menuProviderRegistration =
context.registerService(classOf[GlobalMenuItemsProvider].getName,
> +
                                      MenuProvider, null)
> +       }
> +
> +       /**
> +        * called when the bundle is stopped, this method unregisters the
provided service
> +        */
> +       def stop(context: BundleContext) {
> +               renderletsOverview.unregister()
> +               renderletRegistration.unregister()
> +               menuProviderRegistration.unregister()
> +               this.bundleContext = null
> +       }
> +
> +}
>
> Added:
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Ontology.scala
> URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Ontology.scala?rev=1085912&view=auto
>
==============================================================================
> ---
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Ontology.scala
(added)
> +++
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/Ontology.scala
Sun Mar 27 11:11:11 2011
> @@ -0,0 +1,18 @@
> +package org.apache.clerezza.platform.typerendering.gui
> +
> +import org.apache.clerezza.rdf.core.UriRef
> +
> +object Ontology {
> +
> +       private def p(s: String) = new UriRef("
http://clerezza.org/2011/25/renderletgui#"+s)
> +
> +       val RenderletOverviewPage = p("RenderletOverviewPage")
> +       val Renderlet = p("Renderlet")
> +       val renderlet = p("renderlet")
> +       val modePattern = p("modePattern")
> +       val mediaType = p("mediaType")
> +       val rdfType = p("renderedType")
> +       val providingBundle = p("providingBundle")
> +       val stringRepresentation = p("stringRepresentation")
> +
> +}
>
> Added:
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/RenderletDescriptionRenderlet.scala
> URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/RenderletDescriptionRenderlet.scala?rev=1085912&view=auto
>
==============================================================================
> ---
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/RenderletDescriptionRenderlet.scala
(added)
> +++
incubator/clerezza/trunk/parent/platform.typerendering.gui/src/main/scala/RenderletDescriptionRenderlet.scala
Sun Mar 27 11:11:11 2011
> @@ -0,0 +1,39 @@
> +package org.apache.clerezza.platform.typerendering.gui
> +
> +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._
> +import org.apache.clerezza.rdf.ontologies.DC
> +
> +/**
> + * A Renderlet for the descriptions of RenderletDescription
> + */
> +class RenderletDescriptionRenderlet extends SRenderlet {
> +
> +       val getRdfType = Ontology.Renderlet
> +
> +       override def getModePattern = "naked"
> +
> +       override def renderedPage(arguments: XmlResult.Arguments) = {
> +               new XmlResult(arguments) {
> +                       override def content = {
> +                               resultDocModifier.setTitle("Renderlet
Overview")
> +
resultDocModifier.addStyleSheet("/styles/renderlets/style.css")
> +                               <div class="renderlet">
> +                                       <div>Renderlet: <span
class="value">{res/Ontology.stringRepresentation*}</span></div>
> +                                       <div>For type: <span
class="value">{res/Ontology.rdfType*}</span></div>
> +                                       <div>Producing: <span
class="value">{res/Ontology.mediaType*}</span></div>
> +                                       {if
((res/Ontology.modePattern).size > 0) <div>Mode pattern: <span
class="value">{res/Ontology.modePattern*}</span></div>}
> +                                       <div>Provided by: <span
class="value">{res/Ontology.providingBundle*}</span></div>
> +                               </div>
> +                       }
> +               }
> +       }
> +
> +}
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message