How to call one module method into another

I have one module, in which I have created the method.
Now I wanted to call the methods of my module into another module.

Lets pretend this is the module you wrote -

myModule

def foo():
    pass

Then in your other module

import myModule

myModule.foo()

Assuming you are using the scripting modules section.

This is the ā€œModule Developmentā€ category for SDK modules.

For complete access to one moduleā€™s classes and methods from another, you would make the first module a declared dependency of the second module (in module.xml). This will make the second moduleā€™s classloader a child of the first moduleā€™s classloader.

If you cannot do this (some other dependency interferes, perhaps), then you will have to use an indirect access method. If you look at the javadocs for CommonContext, you will see a getModule() method that returns a different moduleā€™s gateway hook. You can use this from your second module to obtain a reference to your first moduleā€™s gateway hook. That hook must expose methods you can use to obtain any other class instances you need.

2 Likes

Whoops, I didnā€™t see the category tag. Ignore what I said.

1 Like