[kepler-users] Actor packaging
Dan Higgins
higgins at nceas.ucsb.edu
Mon Oct 29 10:27:25 PDT 2007
Hi Kenneth,
I have been following your threads but haven't responded because I
usually do not use Eclipse. (I find that for actor developement it is
usually easier to just use ant combined with the JEdit editor). But
several questions have apparently come up that I can comment on.
First of all, the JPython actor was deliberately disabled in Kepler
because it caused great problems with the Kepler startup code. (It
greatly slowed startup due to the large number of jar files that Kepler
uses). That problem may be gone now since we changed the Kepler startup
code, so we may need to revisit the use of the Python actor since
several people have expressed interest in it.)
Secondly, I think you said you were using the Beta3 version of
Kepler. Note that this version is somewhat out-of-date and that the
files that it puts into the .kepler directory are incompatible with
newer versions (ie you have to remove .kepler if you are switch to/from
newer versions). Note that you can work with a new version without
having to rebuild Kepler. If you scroll down the Downloads page on the
Kepler web site, you will find a link named
'www.kepler-project.org/nightly/zip/'. The nightly build of Kepler zips
all of Kepler and all the needed parts of Ptolemy into a single zip
file. It also contains a batch file for launching Kepler that doesn't
require any Environment variables to be set. (Although you may need to
delete the .kepler directory [Yes, I know that is a silly requirement!])
Also, as an indication that we are working on making the addition of
new actors easier, I pasted a copy of an email I sent out on Sept 19
about adding actors by including jar files inside the kar files below.
Note that this capability is NOT in the Beta3 release of Kepler.
Dan Higgins
NCEAS
************
(from an email I sent on 9/19)
Hi All,
Currently, Kepler uses a concept called a 'kar' file for
encapsulating actor information. In the $KEPLER/src/actors/ directory
there are subdirectories for each actor. These subdirectories contain a
MANIFEST file and a MoML (XML) file. This MoML file contains standard
Ptolemy information (such as the java class names) plus some additional
info about semantic types for characterizing the actor and actor ports
(and Kepler actor help info is also stored in this MoML file). The ant
task 'ant buildkarlib' zips the information in these directories into
'kar' files, one for each actor.
Now, the kar files are examined at Kepler startup and information
from the kar file is saved in the Kepler cache and also used build the
Kepler actor tree on the left of the main window. Up to now only the
information in the contained MoML file was cached. [Recently the startup
code was changed to NOT pass the MoML file to the MomlParser until the
actor is dragged to the work area and dropped, thus deferring the
loading of java actor classes.]
The information in the MoML file is all that is needed for
composites, pure MoML actors, and extension actors like those built by
customizing the RExpression actor. Importing a kar file for these types
of actors works fine because the underlying Java classes are already in
the Kepler classpath. For new Java based actors, however, there is a big
problem - the java classes are not known to Kepler!
Well, the original idea for the kar file was to include other
information. Stubs for a number of types of information was included in
the KARCacheObject class when it was originally written. We originally
discussed a custom ClassLoader that would allow classes to be loaded,
unloaded, and versioned. Implementing this turned out to a major task
and was postponed. But recently a means for dynamically adding a class
to the standard classpath was discovered and this allows one to at least
add new classes by including the compiled java classes in the kar file!
Take a look at the $KEPLER/src/actors/ImageJ/ directory for an
example. Two jar files are included in addition to the usual MANIFEST
and MoML xml file. ImageJ.jar contains the Kepler actor java classes.
ij.jar is a library used by the actor. The MANIFEST has been modified to
list these two jars; i.e.
Manifest-Version: 1.4.2
KAR-Version: 1.0
lsid: urn:lsid:kepler-project.org:kar:154:1
Name: ImageJ.xml
lsid: urn:lsid:kepler-project.org:actor:251:1
type: actorMetadata
Name: ImageJ.jar
lsid: urn:lsid:kepler-project.org:jar:251:1
type: jar
Name: ij.jar
lsid: urn:lsid:kepler-project.org:jar:252:1
type: jar
At startup, when the KAR files are scanned (in the KARCacheObject
class), the entries of type 'jar' will be pulled out of the kar and
copied to the $KEPLER/lib/jar/ directory. [Any jars in this directory
are automatically added the classpath the next time Kepler is started.]
The jars will also be dynamically added to the classpath when thay are
copied. This means that IF ALL THE JAVA CLASSES NEEDED BY AN ACTOR ARE
INCLUDED IN THE KAR FILE (in jars), THEN THE KAR FILE IS SELF-CONTAINED!
One simply needs to import a KAR file to add a new java-based actor to
Kepler!
NOTE: Currently, the ij.jar and ImageJ.jar classes are already in CVS.
If you are using ant, remove build/classes/util/ImageJActor.class and
lib/jar/ij.jar to test this dynamic loading. (You will also need to
delete the .kepler directory to force rebuilding the cache.
As always, comments are appreciated.
***********
Dan
Kenneth Evans wrote:
> Shawn,
>
> Thanks for your comments in the "Kepler hosed with bad User Library" thread.
>
>
>
>>> We realize the process is difficult and inconvenient right now.
>>>
>
> No problem. I'm sure it will evolve into what people want and need.
>
> In the meantime, I'm still trying to understand how to package an actor as a
> KAR file. Since I can't build Kepler yet, I can't go that route. I should
> be able to make a KAR file independently, however, and import it into
> Kepler.
>
> I tried that with the HelloWorld tutorial. When I try to import, I get:
>
> Error with the cache: The LSID urn:kepler-project.org:kar:450:1 is already
> in use: LSID urn:lsid:kepler-project.org.kar:450:1 already exists.
>
> The HelloWorld.xml file that gives this result is:
>
> <?xml version="1.0" ?>
> - <entity name="HelloWorld" class="ptolemy.kernel.ComponentEntity">
> <property name="entityId" value="urn:lsid:test:actor:1:1"
> class="org.kepler.moml.NamedObjId" />
> <property name="documentation"
> class="org.kepler.moml.DocumentationAttribute" />
> - <property name="class" value="helloworld.HelloWorld"
> class="ptolemy.kernel.util.StringAttribute">
> <property name="id" value="urn:lsid:test:class:1:1"
> class="ptolemy.kernel.util.StringAttribute" />
> </property>
> - <property name="output" class="org.kepler.moml.PortAttribute">
> <property name="direction" value="output"
> class="ptolemy.kernel.util.StringAttribute" />
> <property name="dataType" value="string"
> class="ptolemy.kernel.util.StringAttribute" />
> <property name="isMultiport" value="false"
> class="ptolemy.kernel.util.StringAttribute" />
> </property>
> <property name="semanticType00"
> value="urn:lsid:localhost:onto:2:1#Constant"
> class="org.kepler.sms.SemanticType" />
> </entity
>
> Maybe the thing to do is ask what should it contain.
>
> (I got this from the tutorial except for my trial-and-error attempts to fix
> the LSID.)
>
> Note that I'm not using "urn:kepler-project.org:kar:450:1" as stated in the
> error message. BTW I Googled for LSID and understand the syntax. I am not
> sure what to use, however, for an LSID for my own stuff and how to do the
> numbering in the next-to-last term. (The last is the revision.)
>
> Thanks again for your help.
>
> -Ken
>
>
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at ecoinformatics.org
> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-users
>
>
--
*******************************************************************
Dan Higgins higgins at nceas.ucsb.edu
http://www.nceas.ucsb.edu/ Ph: 805-893-5127
National Center for Ecological Analysis and Synthesis (NCEAS) Marine Science Building - Room 3405
Santa Barbara, CA 93195
*******************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20071029/4824262a/attachment.html>
More information about the Kepler-users
mailing list