Domain.xml revision ada1678a4262b208a7b87391f520a7767d25287c
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<apt:template apt:name="Domain"
xmlns:apt="http://www.sun.com/jds/apoc/2004/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oor="http://openoffice.org/2001/registry"
xsi:schemaLocation="http://www.sun.com/jds/apoc/2004/template /consumables/schemas/config/apoc/policytemplate.xsd">
<apt:category apt:name="Domain" apt:label="GlassFish Domain">
<apt:page apt:name="Configuration_Item" apt:label="Domain Configuration">
<apt:section apt:name="Configuration" apt:label="Config Data" >
<apt:property apt:name="ADMINISTRATION_TEXT_TOP"
apt:dataPath=""
apt:type="xs:string">
<apt:prop-value>$ADMINISTRATION_TOP_TEXT</apt:prop-value>
<apt:visual>
<apt:htmlPanel/>
</apt:visual>
</apt:property>
<apt:property apt:name="DOMAIN_NAME"
apt:label="$DOMAIN_NAME_TEXT"
apt:dataPath="Configuration.DOMAIN_NAME"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:columns="15" apt:toolTip="$DOMAIN_NAME_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_PORT"
apt:label="$ADMIN_PORT_TEXT"
apt:dataPath="Configuration.ADMIN_PORT"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:columns="6" apt:toolTip="$ADMIN_PORT_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="HTTP_PORT"
apt:label="$HTTP_PORT_TEXT"
apt:dataPath="Configuration.HTTP_PORT"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:columns="6" apt:toolTip="$HTTP_PORT_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_USER" apt:label="$ADMIN_USER_TEXT"
apt:dataPath="Configuration.ADMIN_USER"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:columns="15" apt:toolTip="$ADMIN_USER_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_PASSWORD" apt:label="$ADMIN_PASSWORD_TEXT"
apt:dataPath="Configuration.ADMIN_PASSWORD"
apt:type="xs:string">
<apt:visual>
<apt:password apt:columns="15" apt:toolTip="$ADMIN_PASSWORD_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_REENTERPASSWORD" apt:label="$ADMIN_REENTERPASSWORD_TEXT"
apt:dataPath="Configuration.ADMIN_PASSWORD_REENTER"
apt:type="xs:string">
<apt:visual>
<apt:password apt:columns="15" apt:toolTip="$ADMIN_PASSWORD_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="CREATE_SERVICE" apt:label=""
apt:dataPath="Configuration.CREATE_SERVICE"
apt:type="xs:boolean">
<apt:prop-value>false</apt:prop-value>
<apt:visual>
<apt:checkBox apt:labelPost="$ADMIN_SERVICE_CHOICE_TEXT" apt:toolTip="$ADMIN_SERVICE_CHOICE_TOOL_TIP"/>
</apt:visual>
<apt:scriptHandler apt:scriptLanguage="beanshell" >
<apt:scriptCode><![CDATA[
theAL = new ActionListener() {
actionPerformed(e) {
option = wizard.getComponentByName(content, "CREATE_SERVICE");
serviceName = wizard.getComponentByName(content, "SERVICE_NAME");
if(option.isSelected()) {
// Currently service related entries are enabled only on w2k and solaris.
if (System.getProperty("os.name").toLowerCase().startsWith("sunos") || System.getProperty("os.name").toLowerCase().startsWith("windows") || System.getProperty("os.name").toLowerCase().startsWith("linux"))
serviceName.setEnabled(true);
}
else {
serviceName.setEnabled(false);
}
}
};
return theAL;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:property>
<apt:property apt:name="SERVICE_NAME" apt:label="$ADMIN_SERVICE_NAME_TEXT"
apt:dataPath="Configuration.SERVICE_NAME"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:columns="15" apt:toolTip="$ADMIN_SERVICE_NAME_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="START_SERVER" apt:label=""
apt:dataPath="Configuration.START_SERVER"
apt:type="xs:boolean">
<apt:prop-value>true</apt:prop-value>
<apt:visual>
<apt:checkBox apt:labelPost="$START_SERVER_CHOICE_TEXT" apt:toolTip="$START_SERVER_CHOICE_TOOL_TIP"/>
</apt:visual>
<apt:scriptHandler apt:scriptLanguage="beanshell" >
<apt:scriptCode><![CDATA[
theAL = new ActionListener() {
actionPerformed(e) {
startOption = wizard.getComponentByName(content, "START_SERVER");
if(startOption.isSelected())
ConfigHelper.setValue("Domain.Configuration.STARTUP_TYPE", "AUTOMATIC");
else
ConfigHelper.setValue("Domain.Configuration.STARTUP_TYPE", "MANUAL");
}
};
return theAL;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:property>
</apt:section>
<apt:scriptHandler apt:scriptLanguage="beanshell">
<apt:scriptCode><![CDATA[
import java.lang.String;
import java.io.*;
import java.net.*;
import org.openinstaller.provider.conf.ConfigHelper;
import org.openinstaller.util.*;
wizard.enableCancel(true);
wizard.enableNext(true);
wizard.enableHelp(true);
/* Helper to determine installation mode */
isSilentMode() {
/* get processing mode */
BusRequest modeReq = new BusRequest("ConfigRequest",
new EngineConfigCommand(EngineConfigCommand.COMMAND.GET_CONFIG, EngineConfigItem.DISPLAY_MODE));
BusResponse modeResp = bus.publishRequest(modeReq, "svc://general/EngineConfig");
String mode = (String)modeResp.getResult();
if ("SILENT".equals(mode)) {
return true;
}
return false;
}
/* Validate Configuration Port */
validateAdminPort(prop) {
if (isSilentMode())
return;
String adminPort = (String)prop.getUnconfirmedValue();
validatePortValues(adminPort);
}
/* Validate HTTP Port */
validateHttpPort(prop) {
if (isSilentMode())
return;
String httpPort = (String)prop.getUnconfirmedValue();
validatePortValues(httpPort);
}
validatePortValues(String inputPort) {
// First check if the port is empty
/*
String inputStatus = (String)ConfigHelper.getValue("Domain.Configuration.STATUS"));
if (inputStatus.equals("ERROR")) {
return;
}
*/
if ((inputPort == null) || inputPort.equals("")) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("NULL_OR_EMPTY_VALUE", new String[]{});
}
// Check for non-numeric values
int intPortNumber = 0;
try {
intPortNumber = Integer.parseInt(inputPort);
}catch(NumberFormatException dummy) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("PORT_NOT_NUMERIC",new String[]{});
}
// Check for out of range values
if (intPortNumber <=0 || intPortNumber > 65535) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("PORT_OUT_OF_RANGE", new String[]{});
}
/*Commented out as ConfigHelper() has bugs..
if (inputPort.equals(theOtherPort)) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("PORTS_HAVE_SAME_VALUE", new String[]{});
}
*/
// Check if the port is free
int retStat = isPortFree(intPortNumber);
if (retStat == -1) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("PORT_OCCUPIED", new String[]{});
}
if (retStat == -2) {
ConfigHelper.setValue("Domain.Configuration.STATUS", "ERROR");
throw new EnhancedException("HOST_NAME_CANNOT_BE_FOUND_WARNING", new String[]{});
}
ConfigHelper.setValue("Domain.Configuration.STATUS", "SUCCESS");
}
// Check if the port is free
isPortFree(int intportNumber) {
// Get the hostname first.
String hostName = getHostName();
if (hostName.equals("null")) {
return -2;
}
// use server socket method on Windows, client socket on other platforms.
if (System.getProperty("os.name").indexOf("Windows")!=-1)
{
if (!isPortFreeServer(null, intportNumber)) {
return -1;
}
}
else
{
if (!isPortFreeClient(hostName, intportNumber)) {
return -1;
}
}
return 0;
}
// Get the current hostname needed to attempt to establish a socket connection.
// Can use "localhost" instead??
getHostName() {
String hostname = null;
try
{
hostname = InetAddress.getLocalHost().getHostName();
}
// Return "null" and handle the rest in the calling method.
catch (UnknownHostException hostError) { return "null"; }
catch (SecurityException securityError) { return "null"; }
return hostname;
}
//Use client socket
isPortFreeClient(String hostName, int port) {
try {
Socket socket = new Socket(hostName, port);
OutputStream os = socket.getOutputStream();
InputStream is = socket.getInputStream();
os.close();
os = null;
is.close();
is = null;
socket.close();
socket = null;
} catch (Exception e) {
return true;
}
return false;
}
//Use server socket
isPortFreeServer(InetAddress addr, int port) {
boolean isPortFree = true;
ServerSocket ss = null;
try {
ss = new ServerSocket(port, 0, addr);
} catch (Exception e) {
isPortFree = false;
} finally {
if (ss != null) {
try {
ss.close();
} catch (Exception e) {
isPortFree = false;
}
}
}
return isPortFree;
}
getComponentByName(aParent, aName) {
if (aParent == null || ! (aParent instanceof Container)) {
return null;
}
Component[] theComponents = ((Container)aParent).getComponents();
for (Component theComp : theComponents) {
if (aName.equals(theComp.getName())) {
return theComp;
}
}
for (Component theComp : theComponents) {
if (theComp instanceof Container) {
Object theCompo = getComponentByName((Container) theComp, aName);
if (theCompo != null) {
return theCompo;
}
}
}
return null;
}
run() {
serviceName = wizard.getComponentByName(content, "SERVICE_NAME");
serviceOption = wizard.getComponentByName(content, "CREATE_SERVICE");
startOption = wizard.getComponentByName(content, "START_SERVER");
ConfigHelper.setValue("Domain.Configuration.STARTUP_TYPE", "AUTOMATIC");
if (System.getProperty("os.name").toLowerCase().startsWith("sunos") || System.getProperty("os.name").toLowerCase().startsWith("windows") || System.getProperty("os.name").toLowerCase().startsWith("linux"))
serviceOption.setEnabled(true);
else
serviceOption.setEnabled(false);
startOption.setSelected(true);
serviceName.setEnabled(false);
wizard.enableNext(true);
wizard.enableCancel(true);
// Enable back only for Advanced installation.
if (ConfigHelper.getStringValue("InstallUserType.Option.USER_TYPE").equals("ADVANCED_USER"))
wizard.enableBack(true);
setFirstTab = wizard.getComponentByName(content, "DOMAIN_NAME");
setFirstTab.requestFocus();
}
return (Runnable)this;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:page>
</apt:category>
</apt:template>