attract attributes typing java plugin for rhapsody - java

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...

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.

GATE SUMMA configuration

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);

Validate Gherkin Feature File

I used IntelliJ to write Cucumber feature files i.e., *.feature files and corresponding step definition files in Java within the IDE. The user experience is great and IDE opens up its IntelliSense showing all valid options for which the step definitions exist. If I write a new step in a scenario or a step that has no corresponding step definition exist already in the Java file, it highlights the step with different colour and similarly if regex don't match. I get informed by this highlighting that something has to be written for this step in Java file or the step is wrong and will not execute.
I need the same functionality on a non developer machine i.e., on a Business Analyst or Product owner machine, where there is no IDE installed but just an editor like Notepad++. I know about the Notepad++ plug-in for Gherkin but it doesn't highlight the step for which step definition is missing in the *.java step definition file. Please suggest any editor or free IDE that has similar plug-in available.
Thanks,
Shany
In case you use JIRA to manage your stories then you can use a JIRA plugin which has Auto-complete, parameter highlight functionality. There are other similar plugins you can browse.

Eclipse-PMD Configure ruleset globally

So i am using the Plugin Eclipse-PMD (http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/) in a shared version control enviroment.
We have multiple smaller projects in the entire project.
Out of the box it seems that this plugin requires individual configuration for every single project.
The way it works it that it searched for a .pmd file in the project and read information from that.
But it's really inconvenient to do that for 10-20 subprojects.
There is a general setting under Preferences -> PMD. But this doesn't seem to apply globally, even if that global checkbox is checked.
What i basically want: I want to configure the plugin to respect a single ruleSet-file in one place.
There is another problem with configuring it subproject-specific: I cannot configure a relative path for the ruleSetFile in the .pmd-file.
The problem with absolute path is that the file is checked into version control ... so with every commit everyone else would have to readjust.
I found this commit: https://github.com/pmd/pmd/pull/36 but i cannot seem to make it work the way it's roughly described.
So, did anyone achieve what i am looking for?
Edit: Actually i cannot even specify any other file that is not ".ruleset" in the .pmd-file as <ruleSetFile> without specifying an absolute path??
The default value for ruleSetFile is ".ruleset". So i thought, analogous to that, i could create a file in the exact same dir, call it fooRules.xml, and specify it via <ruleSetFile>fooRules.xml</ruleSetFile> but it can only find it if put the entire path to fooRules.xml in there?!
Try eclipse-pmd (available in the Eclipse marketplace or via the update site http://www.acanda.ch/eclipse-pmd/release/latest). With eclipse-pmd you can configure your projects to use a single rule set file for several projects. It also stores its path relative to the workspace. You still have to configure each project individually though (for now, this will change in a future release).
To set up eclipse-pmd in the way you described you have to open the project properties of your first project, select the "PMD" property page and add the rule set. Select the rule set type "Workspace" and pick your rule set file.
For every other project you have to open the project's PMD property page where you'll find the previously selected rule set file which simply needs to be checked to activate.
If you set it up this way there will be a .eclipse-pmd file in each project containing the settings. If you check this into your version control system then no one else in your team has to set up anything (apart from installing eclipse-pmd).
Disclaimer: I wrote eclipse-pmd. Mostly because I had the exact same problems as you with the other plugin.
I've been struggling a long time to get this working with PMD for Eclipse. While Eclipse-PMD has this feature built-in, I had some other issues with it (e.g. I think it is not meant to create reports).
The trick was adding the rules to the project as a link.
Create the rule file, e.g. pmd.xml, in the parent folder of the project. Add the file to the projects to be checked, but add it as a reference. Therefore, drag the file from the explorer to the bundle and select:
In the project properties, in the PMD section, check Enable PMD and Apply and Close the settings.
Now close Eclipse. Edit the file with the name .pmd in the project folder by replacing the content with the following:
<?xml version="1.0" encoding="UTF-8"?>
<pmd>
<useProjectRuleSet>true</useProjectRuleSet>
<ruleSetFile>pmd.xml</ruleSetFile>
<includeDerivedFiles>false</includeDerivedFiles>
<violationsAsErrors>true</violationsAsErrors>
<fullBuildEnabled>true</fullBuildEnabled>
</pmd>
Restart Eclipse and right click the project. Select PMD/Check Code. Now, only the violations defined in pmd.xml should be reported.
Configuring PMD only using the GUI does not seem to work for me.

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.

Categories