i want to tidy up my extension code(Java extension). So i thought i put similar things in a class and access them thru this.
My project is made out of a main-class which extends SFSExtension and contains the init() start-function.
Now i created a new class itemUtil-class which extends main-class so i have access to sfsAPI() and so on... (i dont take extends SFSExtension cause this forces me to create a second init()-function that i dont want.)
Then i tried to access that class.
First i made a reference in main:
Code: Select all
public class Main extends SFSExtension {
ItemUtil handleItemUtil = new ItemUtil();
@Override
public void init() {
//........
In the code above is a bug. This "ItemUtil handleItemUtil = new ItemUtil();" lets the server crash.
To access from other points in my projekt i do (Only for showing purposes...):
Code: Select all
ItemUtil handleItemUtil = ((Main)getParentExtension()).handleItemUtil;
handleItemUtil.TestFunction();
itemUtil-class:
Code: Select all
public class ItemUtil extends Main {
public void TestFunction() {
}
}
How can i do it the right way? What i want is to outsource some code in files.
regards.