summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/viewer/Viewer.java
blob: d23a9e11e61b1c3ed9765b82703cd814941ef162 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package org.openslx.runvirt.viewer;

import org.openslx.runvirt.virtualization.LibvirtHypervisor;
import org.openslx.runvirt.virtualization.LibvirtVirtualMachine;
import org.openslx.virtualization.Version;

/**
 * Representation of an viewer for virtual machines running on a host system.
 * 
 * @author Manuel Bentele
 * @version 1.0
 */
public abstract class Viewer
{
	/**
	 * Name of the viewer.
	 */
	private final String name;

	/**
	 * Number of supported displays by the viewer.
	 */
	private final int numSupportedDisplays;

	/**
	 * The virtual machine to display.
	 */
	private final LibvirtVirtualMachine machine;

	/**
	 * Remote (hypervisor) endpoint for the viewer to connect to.
	 */
	private final LibvirtHypervisor hypervisor;

	/**
	 * Creates a new viewer for a Libvirt virtual machine running on a Libvirt hypervisor.
	 * 
	 * @param name textual name of the viewer.
	 * @param numSupportedDisplays number of supported displays by the viewer.
	 * @param machine virtual machine to display.
	 * @param hypervisor remote (hypervisor) endpoint for the viewer to connect to.
	 */
	public Viewer( String name, int numSupportedDisplays, LibvirtVirtualMachine machine, LibvirtHypervisor hypervisor )
	{
		this.name = name;
		this.numSupportedDisplays = numSupportedDisplays;
		this.machine = machine;
		this.hypervisor = hypervisor;
	}

	/**
	 * Returns the name of the viewer.
	 * 
	 * @return name of the viewer.
	 */
	public String getName()
	{
		return this.name;
	}

	/**
	 * Returns the number of supported displays by the viewer.
	 * 
	 * @return number of supported displays by the viewer.
	 */
	public int getNumberOfSupportedDisplays()
	{
		return this.numSupportedDisplays;
	}

	/**
	 * Returns the virtual machine to display.
	 * 
	 * @return virtual machine to display.
	 */
	public LibvirtVirtualMachine getMachine()
	{
		return this.machine;
	}

	/**
	 * Returns the remote (hypervisor) endpoint for the viewer to connect to.
	 * 
	 * @return remote (hypervisor) endpoint for the viewer to connect to.
	 */
	public LibvirtHypervisor getHypervisor()
	{
		return this.hypervisor;
	}

	/**
	 * Displays all virtual machine's displays.
	 * 
	 * @throws ViewerException failed to display all displays of a virtual machine.
	 * 
	 * @apiNote A call to this method blocks until the implemented {@link #render()} process
	 *          terminates.
	 */
	public void display() throws ViewerException
	{
		this.render();
	}

	/**
	 * Returns the version of the viewer.
	 * 
	 * @return version of the viewer.
	 * @throws ViewerException failed to get version of the viewer.
	 */
	public abstract Version getVersion() throws ViewerException;

	/**
	 * Renders the content of all displays from the virtual machine.
	 * 
	 * @throws ViewerException failed to render all displays of a virtual machine.
	 */
	protected abstract void render() throws ViewerException;
}