You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Edward S <su...@gmail.com> on 2007/07/19 19:42:46 UTC

Cocoon Caching

Is there a good document out thr that details how Cocoon Caching works???
The only one that I could find was:
http://cocoon.apache.org/2.0/userdocs/concepts/caching.html

thanks

-Ed.

Re: Cocoon Caching

Posted by Edward S <su...@gmail.com>.
As per the document, I created a cocoon generator and implemented the
CacheableProcessingComponent
interface.

As stated, 2 methods should be implemented:
1] getKey()
2] getValidity()

I created an object, that had all the request parameters along with the URI.
Made that object serializable and set that one as te key.
Similarly, I created another object that implemented SourceValidity and
returned that object from the getValidty method.

However, when I run thru the pipeline... its never adds anything to the
cache neither it returns anything back from the cache.

any thots on where I am going wrong??

-Ed.

Re: Simple Java from flowscript ?

Posted by "Steven D. Majewski" <sd...@virginia.edu>.
I don't see anything obviously wrong with your Java from Javascript  
calls.
Looking at some of my scripts, I see I follow cocoon.senPage() with a  
cocoon.exit() call.
I sort-of recall getting an error without this in some cases, but I  
don't recall what sort of error.

Some other general debugging tips:

   You can run your javascripts using rhino from the shell.
   The cocoon object doesn't exist and there are some other  
environment differences,
	but you can easily test the Date classes:


$ java -jar  /usr/local/java/rhino1_6R5/js.jar
Rhino 1.6 release 5 2006 11 18
js> var d = new java.util.Date();
js> d
Wed Jul 25 15:49:43 EDT 2007
js> d.year
107
js> d.year = 103
103
js> d
Fri Jul 25 15:49:43 EDT 2003
js> d.year = 2003
2003
js> d
Sat Jul 25 15:49:43 EDT 3903
js> ^D


   I see that the year values are actually  - 1900.
   Looking at my java docs, I see that Date.getYear is marked as  
deprecated.
   Perhaps this is a problem if you are running Java 1.6
   ( I'm still using 1.5, so that's just a guess. )


   You might also try adding some cocoon.log.info() calls to write  
debugging info
   to the cocoon log file.


A more complete example is included below at bottom.
( But, as noted, I don't think that is your problem. )
[ Example is a redirector I use to punt around the non-working
    unparsed-entity-uri() in cocoon problem by resolving the
    entities outside of cocoon's SAX event pipeline. ]

-- Steve. 


On Jul 25, 2007, at 3:19 PM, Schmitz, Jeffrey A wrote:

>  Hello,
>    I've tried to call java from my flowscript as shown here:
>
> http://cocoon.apache.org/2.1/userdocs/flow/java.html
>
> However, I get a compilation error when I try to load my webpage.  
> First,
> is there anywhere to see specifics about the compilation error
> encountered?  All it tells me is Compilation produced 1 syntax  
> error on
> line 1.
>
> Also, are there any more complete examples of calling java from
> flowscript?
>
> And finally, any ideas on what may be wrong?
>
> Here's my main flowscript function, which otherwise works until I add
> the java Date stuff:
>
> function main()
> {
>    var d = new java.util.Date();
>    d.year = 2003;    // same effect as d.setYear(2003);
>    getInfo();
>    upload();
>    var uri = neutralInstModel "/" + inputType + "In/" + inputFile +  
> "/"
> + inputType + "In.trans/" + cocoon.continuation.id;
>    cocoon.sendPage(uri);
> }
>

importClass(Packages.org.xml.sax.helpers.DefaultHandler);
importClass(Packages.javax.xml.parsers.SAXParserFactory);

function unparsedEntityHandler( name, publicID, systemID, notat ) {
         this.entities[name] = systemID;
}


function getEntities( filename ) {
         var hnd = { unparsedEntityDecl: unparsedEntityHandler,   
entities: {} };

         var spf = SAXParserFactory.newInstance();
         var p = spf.newSAXParser();
         var a = JavaAdapter( DefaultHandler, hnd );

         var xml = java.io.File( filename );

         p.parse( xml, a );

         return a.entities;

}


function redirector( ) {

         var document = cocoon.request.getParameter( 'document' );
         var entity = cocoon.request.getParameter( 'entity' );

     var ents = getEntities(  cocoon.parameters.context + document );
     cocoon.log.info( ents[entity] );

     cocoon.redirectTo( ents[entity], false );
     cocoon.exit();

}



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Simple Java from flowscript ?

Posted by Tobia Conforto <to...@linux.it>.
Schmitz, Jeffrey A wrote:
> First, is there anywhere to see specifics about the compilation error
> encountered?  All it tells me is Compilation produced 1 syntax error
> on line 1.

Check your cocoon.log file (it's in WEB-INF/logs/ if you didn't change
its location; you can change its location in WEB-INF/logkit.xconf)
Look for the useless error message about "Compilation produced 1 syntax
error" and a couple lines above you will find the real message with
error type, line and column.


> any ideas on what may be wrong?
>
> var uri = neutralInstModel "/" + inputType + "In/" + inputFile + ...
                            ^
:-)


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Simple Java from flowscript ?

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
 Hello,
   I've tried to call java from my flowscript as shown here:

http://cocoon.apache.org/2.1/userdocs/flow/java.html

However, I get a compilation error when I try to load my webpage. First,
is there anywhere to see specifics about the compilation error
encountered?  All it tells me is Compilation produced 1 syntax error on
line 1.

Also, are there any more complete examples of calling java from
flowscript?

And finally, any ideas on what may be wrong?

Here's my main flowscript function, which otherwise works until I add
the java Date stuff: 

function main()
{
   var d = new java.util.Date();
   d.year = 2003;    // same effect as d.setYear(2003);
   getInfo();
   upload();
   var uri = neutralInstModel "/" + inputType + "In/" + inputFile + "/"
+ inputType + "In.trans/" + cocoon.continuation.id;
   cocoon.sendPage(uri);  
}

And here's my flow-interpreters entry in cocoon.xcon:

  <flow-interpreters default="javascript" logger="flow">
    <!-- FOM (Flow Object Model) -->
    <component-instance
class="org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptIn
terpreter" name="javascript">
 
<load-on-startup>resource://org/apache/cocoon/components/flow/javascript
/fom/fom_system.js</load-on-startup>
      <reload-scripts>true</reload-scripts>
      <check-time>4000</check-time>
      <classpath>file:C:/Program Files/Apache Software Foundation/Tomcat
6.0/webapps/SIF/WEB-INF/lib</classpath>
      <!--  <debugger>enabled</debugger> -->  <!-- JavaScript Debugger
support -->
    </component-instance>
  <!--..... Start configuration from 'apples-processor' -->&#13;


  <component-instance
class="org.apache.cocoon.components.flow.apples.ApplesProcessor"
logger="apples" name="apples">
  <!--
 
<load-on-startup>resource://org/apache/cocoon/components/flow/javascript
/fom/fom_system.js</load-on-startup>
      <reload-scripts>true</reload-scripts>
      <check-time>4000</check-time>
      -->
  </component-instance>

<!--..... End configuration from 'apples-processor' -->&#13;
<!--..... Start configuration from 'javaflow' -->&#13;

  <component-instance
class="org.apache.cocoon.components.flow.java.JavaInterpreter"
name="java"/>
<!--..... End configuration from 'javaflow' -->&#13;
</flow-interpreters>


Thanks!
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon Caching

Posted by Niels van Kampenhout <n....@hippo.nl>.
Edward S wrote:
> Is there a good document out thr that details how Cocoon Caching works???
> The only one that I could find was:
> http://cocoon.apache.org/2.0/userdocs/concepts/caching.html

There is a 2.1 version as well [1]. There is also a wiki page [2], for 
what it's worth. For more information you need to dive into the code I'm 
afraid.

Regards,
Niels

[1] http://cocoon.apache.org/2.1/userdocs/concepts/caching.html
[2] http://wiki.apache.org/cocoon/Caching


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org