glassfish.xml revision ada1678a4262b208a7b87391f520a7767d25287c
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
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
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="glassfish"
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="glassfish" apt:label="GlassFishV3">
<apt:page apt:name="Configuration_Item" apt:label="Configuration Settings">
<apt:section apt:name="Administration" apt:label="Administration" >
<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="ANONYMOUS"
apt:label=""
apt:dataPath="Administration.ANONYMOUS"
apt:type="xs:string">
<apt:visual>
<apt:radioButtons apt:toolTip=""/>
</apt:visual>
<apt:constraints>
<apt:enumeration
apt:value="ANONYMOUS"
apt:label="$ANONYMOUS"/>
</apt:constraints>
<apt:scriptHandler apt:scriptLanguage="beanshell" >
<apt:scriptCode><![CDATA[
import org.openinstaller.provider.conf.ConfigHelper;
import org.openinstaller.bus.*;
import org.openinstaller.core.*;
theAL = new ActionListener() {
actionPerformed(e) {
setRegOption("ANONYMOUS");
ValidateCredentials();
}
};
return theAL;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:property>
<apt:property apt:name="NON_ANONYMOUS"
apt:label=""
apt:dataPath="Administration.NON_ANONYMOUS"
apt:type="xs:string">
<apt:visual>
<apt:radioButtons apt:toolTip=""/>
</apt:visual>
<apt:constraints>
<apt:enumeration
apt:value="NON_ANONYMOUS"
apt:label="$NON_ANONYMOUS"/>
</apt:constraints>
<apt:scriptHandler apt:scriptLanguage="beanshell" >
<apt:scriptCode><![CDATA[
import org.openinstaller.provider.conf.ConfigHelper;
theAL = new ActionListener() {
actionPerformed(e) {
setRegOption("NON_ANONYMOUS");
ValidateCredentials();
}
};
return theAL;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:property>
<apt:property apt:name="ADMIN_PORT"
apt:label="Admin Port"
apt:dataPath="Administration.ADMIN_PORT"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:toolTip="$ADMIN_PORT_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="HTTP_PORT"
apt:label="HTTP Port"
apt:dataPath="Administration.HTTP_PORT"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:toolTip="$HTTP_PORT_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_USER" apt:label="Username"
apt:dataPath="Administration.ADMIN_USER"
apt:type="xs:string">
<apt:visual>
<apt:textField apt:toolTip="$ADMIN_USER_TOOL_TIP"/>
</apt:visual>
</apt:property>
<apt:property apt:name="ADMIN_PASSWORD" apt:label="Password"
apt:dataPath="Administration.ADMIN_PASSWORD"
apt:type="xs:string">
<apt:visual>
<apt:password apt:toolTip="$ADMIN_PASSWORD_TOOL_TIP"/>
</apt:visual>
</apt:property>
</apt:section>
<apt:scriptHandler apt:scriptLanguage="beanshell">
<apt:scriptCode><![CDATA[
import java.io.*;
import java.net.*;
import org.openinstaller.provider.conf.ConfigHelper;
import org.openinstaller.util.*;
wizard.enableCancel(true);
wizard.enableNext(true);
wizard.enableBack(true);
ValidateCredentials() {
if (isSilentMode())
return;
String regOption = getRegOption();
usernameTF = getComponentByName(content, "ADMIN_USER");
passwdTF = getComponentByName(content, "ADMIN_PASSWORD");
if ((regOption != null) && regOption.equals("NON_ANONYMOUS")) {
usernameTF.setEnabled(true);
passwdTF.setEnabled(true);
} else {
usernameTF.setEnabled(false);
passwdTF.setEnabled(false);
}
}
/* 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 Administration 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("glassfish.Administration.STATUS"));
if (inputStatus.equals("ERROR")) {
System.out.println("Not validating stuff");
return;
}
*/
if ((inputPort == null) || inputPort.equals("")) {
ConfigHelper.setValue("glassfish.Administration.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("glassfish.Administration.STATUS", "ERROR");
throw new EnhancedException("PORT_NOT_NUMERIC",new String[]{});
}
// Check for out of range values
if (intPortNumber <=0 || intPortNumber > 65535) {
ConfigHelper.setValue("glassfish.Administration.STATUS", "ERROR");
throw new EnhancedException("PORT_OUT_OF_RANGE", new String[]{});
}
/*Commented out as ConfigHelper() has bugs..
if (inputPort.equals(theOtherPort)) {
ConfigHelper.setValue("glassfish.Administration.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("glassfish.Administration.STATUS", "ERROR");
throw new EnhancedException("PORT_OCCUPIED", new String[]{});
}
if (retStat == -2) {
ConfigHelper.setValue("glassfish.Administration.STATUS", "ERROR");
throw new EnhancedException("HOST_NAME_CANNOT_BE_FOUND_WARNING", new String[]{});
}
ConfigHelper.setValue("glassfish.Administration.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;
}
/* Set status trackers */
setRegOption(String s) {
List activeModes = (List)ConfigHelper.getValue("PageFlow.Mode.ACTIVE_MODES_LIST");
if (activeModes.contains("ANONYMOUS")) {
activeModes.remove("ANONYMOUS");
}
if (activeModes.contains("NON_ANONYMOUS")) {
activeModes.remove("NON_ANONYMOUS");
}
activeModes.add(s);
ConfigHelper.setValue("PageFlow.Mode.ACTIVE_MODES_LIST", activeModes);
}
getRegOption() {
String regOption =
return (regOption);
}
run() {
// Group the options.
radio1 = getComponentByName(content, "ANONYMOUS");
radio2 = getComponentByName(content, "NON_ANONYMOUS");
ButtonGroup bg = new ButtonGroup();
bg.add(radio1);
bg.add(radio2);
// Select first radio button when first displayed.
radio1.setSelected(true);
usernameTF = getComponentByName(content, "ADMIN_USER");
passwdTF = getComponentByName(content, "ADMIN_PASSWORD");
usernameTF.setEnabled(false);
passwdTF.setEnabled(false);
radio2.setSelected(false);
wizard.enableNext(true);
wizard.enableCancel(true);
wizard.enableBack(true);
setRegOption("ANONYMOUS");
List activeModes = (List)ConfigHelper.getValue("PageFlow.Mode.ACTIVE_MODES_LIST");
}
return (Runnable)this;
]]></apt:scriptCode>
</apt:scriptHandler>
</apt:page>
</apt:category>
</apt:template>