This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: Need to write a custom code rule
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
09:32 AM
Need to write a custom code rule
In my install actions I am using a Modify text file action in order to add some srings to an existing file on the target system. I want to read the file before that and make sure that entry does not exist and only then create the entry. If the property already exists in the file then nothing needs to be done.
I understand I can only do this with a custom rule. I find the documentation to be very poor on custom rules in the Installanywhere help.
Can you please help me with this? Can someone please provide some sort of a code snippet on how I can get started? I really need help on this ASAP.
Thanks,
-Mehjabin
I understand I can only do this with a custom rule. I find the documentation to be very poor on custom rules in the Installanywhere help.
Can you please help me with this? Can someone please provide some sort of a code snippet on how I can get started? I really need help on this ASAP.
Thanks,
-Mehjabin
(7) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
10:57 AM
A general skeleton of the code might look like this:
For a bit more explanation, please see .../CustomCode/Templates/com/acme/CustomCodeRuleTemplate.java inside your InstallAnywhere distribution.
import com.zerog.ia.api.pub.*;You'll need IAClasses.zip on your compiler class path.
public class MyCustomCodeRule extends CustomCodeRule
{
public boolean evaluateRule( )
{
// return true if rule succeeds, false to fail
}
}
For a bit more explanation, please see .../CustomCode/Templates/com/acme/CustomCodeRuleTemplate.java inside your InstallAnywhere distribution.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
10:59 AM
Thanks for the info Robert.
Can you point me to where I can get the API documentation? I did look at the CustomCodeRuleTemplate but what APIs do I use to access the installanywhere variables?
Thanks,
-Mehjabin
Can you point me to where I can get the API documentation? I did look at the CustomCodeRuleTemplate but what APIs do I use to access the installanywhere variables?
Thanks,
-Mehjabin
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
11:03 AM
Please see the API help in the javadoc directory of your IA distribution.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 30, 2008
03:09 PM
The API and the examples are nice, but if my rule is going to be very useful, I need to do an evaluation based on some IA variables. To get the IA variables into my custom rule, I need the CustomCodeRuleProxy class, which (I can tell from the API) takes an argument of type VariableAccess (an interface) in its constructor.
It would be really helpful if someone could provide an example of how to get the IA variables into the custom rule code - i.e. how to use the CustomCodeRuleProxy class (it would have been even better if they just included this in the example in Templates...).
It would be really helpful if someone could provide an example of how to get the IA variables into the custom rule code - i.e. how to use the CustomCodeRuleProxy class (it would have been even better if they just included this in the example in Templates...).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 30, 2008
03:27 PM
Actually, CustomCodeRuleTemplate.java should have commented-out examples of using ruleProxy.getValue and ruleProxy.substitute to get variable values in custom rule code...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 01, 2008
03:18 PM
Yes, this true. After taking another look at the API I noticed there is a protected attribute ruleProxy in the superclass we're extending, so just use that.
Ex:
ruleProxy.substitute("someVariable");
There is no need to create your own proxy object, this is already done for us. Still the documentation for custom code is a little sparse, especially in the manual.
Ex:
ruleProxy.substitute("someVariable");
There is no need to create your own proxy object, this is already done for us. Still the documentation for custom code is a little sparse, especially in the manual.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 02, 2008
01:32 AM
In your IA installation folder there is a javadoc subfolder containing all the API specific documentation. Have you checked that?