GATE SUMMA configuration - java

I am trying to use the GATE SUMMA from the java. I am trying to run the files included in the tutorial. I have downloaded both ANNIE and SUMMA plugins seperately. What I dont understand is this part in the configuration.
Gate.init();
// you have to register the plugins from GATE you want to use
Gate.getCreoleRegister().addDirectory(new URL("file:///"+anniePluginDir));
// you have to register the SUMMA plugin to have access to its resources
Gate.getCreoleRegister().addDirectory(new URL("file:///"+summaPluginDir));
// now create your controller
What does this mean you have to register the plugins from GATE you want to use
Even providing an plugin path throws and error
The method addDirectory(URL) is undefined for the type CreoleRegister
I see that Creole is a type of configuration management under GATE framework. Do I need to have an xml file created for that?
The full class file is as shown on the Gist ()

Do I need to have an xml file created for that?
Yes,
Gate.getCreoleRegister().addDirectory(URL)
Registers a GATE plugin directory, which has to contain the creole.xml file.
ANNIE plugin directory is a part of common GATE installation (see $GATE_HOME\plugins\ANNIE dir).
I don't know about SUMMA, but I guess it also have such a directory somewhere...
But
The method addDirectory(URL) is undefined for the type CreoleRegister
means that your code was created for a different version of GATE. Apparently, your current version of GATE doesn't have the addDirectory(URL) method. I think it was replaced by
CreoleRegister.registerDirectories(URL) method in the current GATE (ver. 8.x series).

Adding to what #dedek said. The actual code is
URL ANNIEcreoleURL = new URL("resources/plugins/ANNIE");
Gate.getCreoleRegister().registerDirectories(ANNIEcreoleURL);

Related

Java library : Gate Creole ResourceInstantiationException

I am using GATE library and am getting the error
gate.creole.ResourceInstantiationException: Couldn't get resource data for com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2.
You may need first to load the plugin that contains your resource.
For example, to create a gate.creole.tokeniser.DefaultTokeniser
you need first to load the ANNIE plugin.
Go to the menu File->Manage CREOLE plugins or use the method
Gate.getCreoleRegister().registerDirectories(pluginDirectoryURL).
I am initialised my plugins folder and also have added the following line
Gate.getCreoleRegister().registerDirectories(new URL("file:///home/latest/plugins/ANNIE"));
and folder ANNIE contains the file cerole.xml
as told here
why am I still getting the error?
Thank you
You have to register any plugin you are using.
The class
com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2
is a GATE processing resource from a very old version of gateplugin-stringannotation .
So except ANNIE, you have to register the directory of this plugin as well.

attract attributes typing java plugin for rhapsody

I need to write a java plugin will draw on the attributes using the rhapsody . What do you recommend for that. Where should I start ? Previously I did not write plug-ins.
First place to start is to look at the samples provided by IBM. You can find them (on Windows 7, version 7.5.3 of Rhapsody) in:
C:\Users\\IBM\Rational\Rhapsody\7.5.3\Samples\ExtensibilitySamples
There are 3 types you can create:
1. A plugin (what you are asking about)
2. A Check plugin (ties into the model check sub-system)
3. Event callback plugin (don't know much about this one)
I've written 1 and 2.
There should be a how-to document in and around that directory area that walks you through creating a simple plugin. If not, it probably is available in the Rhapsody help (from within the tool)
Basically, you write your Java plugin to conform to a specific interface that IBM provides(com.telelogic.rhapsody.core.RPUserPlugin), create a .hep file that describes the details of that, and then drop the .hep file into the .rpy folder of your project. You then create a new profile in your model with the same name as your .hep file and that should link to the .hep information.
A sample .hep file looks like this:
[Helpers]
numberOfElements=1
#REM: Tranformer Generation plug-in
name1=Generate Transformers
JavaMainClass1=sida.jni.transformerplugin.TransformerPlugin
JavaClassPath1=..\TransformerPlugin\DefaultConfig
isPlugin1=1
isVisible1=1
DLLServerCompatible1=1
Take special note of the numbers added to the end of the attribute names:
ex. isPlugin1, isVisible1
You will want to match that to the name# attribute in the file.
Then make sure your java plugin class files are on the classpath or (better yet), co-located to your .rpy folder. For example, our plugins sit in a folder right next to (at the same level as) our .rpy folder.
If all goes well, you should see an initialization string spit out in the Rhapsody console window for the plugin.
Hope this gets you started...

How to get jar class is coming from

I am currently working on an API for a server software so users can extend my software by programming plugins for it instead of modifying the software themselves, and allow other users without programming knowledge to easily change the software by adding these plugins. So far, everything is working fine. But, I am running into a problem with configuration.
You see, each plugin has a plugin.yml file stored with these 4 attributes:
Main: The main class is stored here
Name: This is where the plugin name is stored
Version: This is where the plugin version is stored
Author: This is where the plugin author is stored
Now, in order for the plugin to print something to the console, they use a function called: this.getServer().getLogger().info("MESSAGE); (They extend another class for plugins, thats why they use "this" instead of another class to log)
But, I do not have any idea on how to get which plugin is which when they are calling the function. I have a ArrayList of PluginSessions which event handlers use to cycle through to run Event Functions.
My solution is to get the jar from which a class is being called so I can then get the plugin.yml from there. But, I have NO idea on how to get that, I have tried using Class.forName(); and some other code. But because the class is non-existent within the jar/project running the code, It will throw a ClassNotFoundException.
Does anyone here know how to get the jar from which a class is coming from without using Class.forName()? Thanks! -Trent
Take a look at Class.getResource.
If you call MyClass.getResource("plugin.yml") (or "/plugin.yml" with leading slash, I forget) you get back a file URL pointing to the plugin.yml file in the same jar as MyClass. (Or null if the path is wrong or the jar doesn't contain a "plugin.yml" file.) You can then open an InputStream to that resource. In a plugin framework you may want to use myPluginInstance.getClass().getResource.
Assuming jar for 'PluginSessions' is already added in you classpath by eclipse then you can try the following trick -
Select/highlight PluginSessions by double clicking on it
Now press CTRL+SHIFT+T
A dialog named Open Type is appeared. Here you found from where the PluginSessions class is coming from. If you have more than one jar containing PluginSessions class than you have a list of them.
To benefited from this CTRL+SHIFT+T trick you need to add all of your jar need by the project to be added in your classpath.

Controlling the order of how JARs are loaded in the classpath

I'm using GWT 2.4 with gquery-dnd-bundle 1.0.4 so that I can construct trees with drag-and-drop nodes. I've bumped into an annoying bug (http://code.google.com/p/gwtquery-plugins/issues/detail?id=6). The gist of it is I need to guarantee that the file "gquery-dnd-bundle-1.0.4.jar" gets loaded by the classloader at runtime before the gwt-servlet.jar file in my WEB-INF/lib directory.
How can I guarantee this?
I'm using Eclipse Indigo with a GWT Web Application project if that is useful.
Here's the exact error I'm seeing
[ERROR] [draganddroptree] - Errors in 'jar:file:/C:/Documents%20and%20Settings/E18538/workspace/DragAndDropTree/war/WEB-INF/lib/gquery-dnd-bundle-1.0.4.jar!/gwtquery/plugins/droppable/client/gwt/DragAndDropCellTree.java'
[ERROR] [draganddroptree] - Line 24: The type com.google.gwt.user.cellview.client.CellTreeNodeView is not visible
[ERROR] [draganddroptree] - Line 86: CellTreeNodeView cannot be resolved to a type
[ERROR] [draganddroptree] - Line 87: The constructor DragAndDropCellTreeNodeView<T>(DragAndDropCellTree, CellTreeNodeView<?>, TreeViewModel.NodeInfo<T>, Element, T) refers to the missing type CellTreeNodeView
[ERROR] [draganddroptree] - Unable to load module entry point class com.cme.draganddroptree.client.DragAndDropTree (see associated exception for details)
[ERROR] [draganddroptree] - Failed to load module 'draganddroptree' from user agent 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' at localhost:4490
You cannot arrange the loading of your "WEB-INF/lib" JAR's in any kind of deterministic order. The only surefire workaround I can think of is to place the lower-priority JAR file in a directory that is scanned prior to "WEB-INF/lib".
For example, if you are using Tomcat, then you could:
Place the "gwt-servlet.jar" file in the "$CATALINA_BASE/lib" directory.
Keep the "gquery-dnd-bundle-1.0.4.jar" file inside your WAR.
This way, "gwt-servlet.jar" will be loaded into the CLASSPATH first, and "gquery-dnd-bundle-1.0.4.jar" will be loaded second... overwriting any conflicting classes from "gwt-servlet.jar".
If you are using some other app server, then the server-level "lib" directory will be different... but the basic idea is that the lower-priority JAR needs to go into the app server's "lib", while the higher-priority JAR needs to stay in the webapp's "lib".
Not the cleanest situation in the world, but it will guarantee the result you want.
UPDATE: You know, after thinking about it and re-reading the Tomcat docs more carefully, I may actually have this backward. You may need to put "gquery-dnd-bundle-1.0.4.jar" in your app server "lib", and "gwt-servlet.jar" in your webapp's "lib". If you try my suggestion and find that it works for you with one approach over the other, let me know and I'll edit my answer to be more precise.
To solve this bug you should have gquery-dnd-bundle-1.0.4.jar set before GWT in your classpath. Using Eclipse in your project properties go to Java Build Path / Order an export and make sure gquery lib is before GWT.
Anyway you may have another problem as gquery-dnd-bundle-1.0.4.jar is compatible with GWT 2.3.x and you are using GWT 2.4. Until a new release of dnd-bundle you can use the enhance-plugin-1.0.2.jar (contains the DND bundle) and gwtquery-1.1.0-SNAPSHOT.jar.
You should look also at the native drag and drop support added in GWT 2.4. Documentation is scarce, but I found this example (you can drag templates from the right and drop them in the task details), and the relevant source code. (info from this post)

How do I conditionally include or exclude a file from an archetype when project is generated?

I'm creating Maven 2 archetypes for our project (Weld). I would like to be able to control which files are placed into the generated project based on the value of a property that is defined during archetype:generate. For instance, I foresee the following prompt:
Define value for groupId: : com.example
Define value for artifactId: : myproject
Define value for package: com.example: :
Define value for includeGradleSupport: : y
Based on the value of includeGradleSupport, I want to include (or not include) the build.gradle file in the generated project. If the user does not want Gradle support, I don't want to clutter up the generated project with unnecessary files.
Another example is that I might need to provide a Jetty web fragment (to activate a listener perhaps) if the user wants Jetty support.
It's all about customization of the project based on what the developer intends to use. While I could create a whole other archetype, sometimes the changes are so slight that it would be easier to include/exclude a file.
Is there a way to control this behavior using the archetype-metadata.xml descriptor?
I personally would move the parts that can be removed/added on user request and put the into different maven profiles so u can build different part using different profiles
I can have a look into what coding it would take to enable this in the archetype plugin.
I think the primary vehicle to do this today would be to conditionally produce two different archetype artifacts during the original build. The archetype user would then explicitly use yourarchetype-withthing or yourarchetype-withoutthing.
I know this isn't perfectly what you are after and I agree that what you are asking for is a sensible use case.
While I could create a whole other archetype, sometimes the changes are so slight that it would be easier to include/exclude a file.
This sentence made me think...
It seems like you have a default project structure.
Let's suppose it is big, has many files. Of course, you don't want to duplicate the logic and the files in a different archetype.
Now sometimes, a project has an additional behavior (related to Gradle).
This sound a typical use-case for another archetype that does not start from nothing, but that comes after the first one. I've seen several examples of such archetypes on the web. The developper triggers this archetype only if the project needs Graddle. :-)
So I suggest : create your Graddle archetype, that adds only the files relevant to Graddle.
Thanks for the info Dan !
I just looked at looked at archetype plugin source code, and http://jira.codehaus.org/browse/ARCHETYPE-58 doesn't appear to have resolved this issue.
Just created http://jira.codehaus.org/browse/ARCHETYPE-424 to track it.

Categories