How to get installData instance in my own java class

107 views
Skip to first unread message

Nanoart

unread,
Mar 1, 2017, 9:15:17 AM3/1/17
to izpack-user
In IzPack 4.x, I used AutomatedInstallData.getInstance() to get installData in my own java classes which were executed by ProcessPanel through "executeclass". This method has gone in IzPack 5.x,  what is the solution? 

Many thanks,

Mike

Prashant Pawar

unread,
Apr 11, 2017, 12:29:33 PM4/11/17
to izpack-user
I am also looking for solution.

- Prashant

René Krell

unread,
Apr 12, 2017, 4:25:01 AM4/12/17
to izpack-user
Hi,

in IzPack 5 there is no global instance for the InstallData, it is held in a container instead. This container is not visible for the executable classes. So far so true.

In case you need to access variable values read-only, the new approach is adding arguments to the class by the nested <arg> element. These arguments can contain references to unresolved variables, which are resolved at runtime.
In particular, this replacement is done in com.izforge.izpack.panels.process.ProcessPanelWorker.ExecutableClass#run.

The definition should look like this:
<executeclass name="my.nice.ExtraClass">
  <arg>${var-to-be-resolved}</arg>
  ...
</executeclass>

It is not possible to access the complete InstallData from an executable class of the ProcessPanel so far.

René


Dne úterý 11. dubna 2017 18:29:33 UTC+2 Prashant Pawar napsal(a):

Prashant Pawar

unread,
Apr 12, 2017, 5:09:42 AM4/12/17
to izpack-user
Thank u very much for quick response.
      Actually i am setting the some of the variables values in executable class based on pack selection. For example. i am installing one component "Test" which user selected in packs panel. so if user select this pack, I want to set the variable ${project.version} value which i am reading from jar manifest file. As we have read only access of variable in executable class in Izpack 5, which approach i can use to resolve this issue.

Thanks
Prashant

René Krell

unread,
Apr 12, 2017, 6:44:25 AM4/12/17
to izpack-user
With IzPack 5, there is no approach with executable classes in ProcessPanel.
Nevertheless, you can implement your own custom InstallerListener, where you get this access this way:

@Override
public void afterPack(Pack pack, int index) {
final InstallData installData = getInstallData();
  ,,,
}

René


Dne středa 12. dubna 2017 11:09:42 UTC+2 Prashant Pawar napsal(a):

Prashant Pawar

unread,
Apr 12, 2017, 6:49:26 AM4/12/17
to izpack-user
Great!. It works. Thanks a lot Rene!!

-Prashant

René Krell

unread,
Apr 12, 2017, 7:06:44 AM4/12/17
to izpack-user
My answer has been somewhat incomplete, there is of course no predefined method getInstallData(). The complete answer can be found here:
https://groups.google.com/d/msg/izpack-user/BTu9vPKnlgk/Ckmt3X0V8jEJ

You can use almost any API type as argument types in the constructor, which get automatically assigned with valid instances from picocontainer.

René


Dne středa 12. dubna 2017 12:49:26 UTC+2 Prashant Pawar napsal(a):

Prashant Pawar

unread,
Apr 12, 2017, 7:10:13 AM4/12/17
to izpack-user
Actually i am using AbstractProgressInstallerListener and which has getInstallData() so i used the same. Should i go with this?
Thanks for clarification.

-Prashant

René Krell

unread,
Apr 12, 2017, 8:27:41 AM4/12/17
to izpack-user
Of course, you can.
Anyway, with the fully featured constructor you might pull in further instances you want to make usage of (for instance for dynamically enhancing language packs etc.).

René


Dne středa 12. dubna 2017 13:10:13 UTC+2 Prashant Pawar napsal(a):

박대현

unread,
Mar 12, 2023, 10:36:56 PM3/12/23
to izpack-user
Hi,
I wanted to get the installData from what conversations written above, but I'm not sure how to fill in the details.
Can you tell me how to write it after or within the code below?

[izpack-user] the AutomatedInstallData.getInstance() method disappeared (google.com)
import com.izforge.izpack.api.data.InstallData;

public class MyListener extends AbstractInstallerListener {

    private final InstallData installData;

    public MyListener(InstallData installData) {
        this.installlData = installData;      
    }

    public InstallData getInstallData() {
        return installData;
    }
}

And Is this the right way to write it in my own process java code?
Actually I don't know IzPack source code structure well

public class HelloWorld {

        MyListener myListener;

public void run(AbstractUIProcessHandler handler, String[] args) {
    installPath = myListener.getInstallData().getInstallPath();
        }
}

2017년 4월 12일 수요일 오후 9시 27분 41초 UTC+9에 renda...@gmail.com님이 작성:
Reply all
Reply to author
Forward
0 new messages