o instead of Ant conditions to test socket connections and http connections, use Jelly so that properties can be reset each time init is called.
Issue ID: MPAPPSERVER-7 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a32396668d
commit
e44ef24ca6
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 The Apache Software Foundation.
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -284,25 +284,53 @@
|
|||||||
|
|
||||||
<!-- a flag to see if the appserver is started -->
|
<!-- a flag to see if the appserver is started -->
|
||||||
<j:remove var="maven.appserver.started" />
|
<j:remove var="maven.appserver.started" />
|
||||||
<ant:condition property="maven.appserver.started">
|
<j:remove var="failedSocket" />
|
||||||
<ant:and>
|
<j:set var="canHttpConnect" value="true" /><!-- default -->
|
||||||
<ant:socket server="${maven.appserver.host}"
|
<j:if test="${context.getVariable('maven.appserver.test.url') != null}">
|
||||||
port="${maven.appserver.test.socket}" />
|
<!-- override default true above because test url is optional -->
|
||||||
<!-- only use the test url if defined, else just use the socket -->
|
<j:set var="canHttpConnect" value="false" />
|
||||||
<j:if test="${context.getVariable('maven.appserver.test.url') != null}">
|
<!-- test url connection -->
|
||||||
<ant:http url="${maven.appserver.test.url}" />
|
<j:catch var="httpConnectException" >
|
||||||
|
<j:new className="java.net.URL" var="testURL" >
|
||||||
|
<j:arg type="java.lang.String"
|
||||||
|
value="${context.getVariable('maven.appserver.test.url')}" />
|
||||||
|
</j:new>
|
||||||
|
<j:invoke on="${testURL}" method="openConnection" var="testConnection"/>
|
||||||
|
<j:invoke on="${testConnection}" method="getResponseCode" var="testResponse" />
|
||||||
|
<j:if test="${testResponse gt 0 and testResponse lt 400}">
|
||||||
|
<j:set var="canHttpConnect" value="true" />
|
||||||
</j:if>
|
</j:if>
|
||||||
</ant:and>
|
</j:catch>
|
||||||
</ant:condition>
|
<j:if test="${httpConnectException.getCause().getCause().toString().indexOf('MalformedURLException') ge 0}">
|
||||||
|
<exception:appserverTestURLInvalid
|
||||||
|
propname="maven.appserver.test.url"
|
||||||
|
propvalue="${context.getVariable('maven.appserver.test.url')}"
|
||||||
|
cause="${httpConnectException}"/>
|
||||||
|
</j:if>
|
||||||
|
<!-- clean up the objects to prevent leak in long sessions -->
|
||||||
|
<j:remove var="testURL" />
|
||||||
|
<j:remove var="testConnection" />
|
||||||
|
<j:remove var="testResponse" />
|
||||||
|
</j:if>
|
||||||
|
<!-- always test socket -->
|
||||||
|
<j:catch var="failedSocket">
|
||||||
|
<j:new className="java.net.Socket" var="dummy">
|
||||||
|
<j:arg type="java.lang.String"
|
||||||
|
value="${context.getVariable('maven.appserver.host')}" />
|
||||||
|
<j:arg type="int"
|
||||||
|
value="${context.getVariable('maven.appserver.test.socket')}" />
|
||||||
|
</j:new>
|
||||||
|
</j:catch>
|
||||||
|
<j:if test="${failedSocket.getCause() == null and canHttpConnect == 'true'}">
|
||||||
|
<j:set var="maven.appserver.started" value="true" />
|
||||||
|
</j:if>
|
||||||
|
|
||||||
<!-- a flag to see if the appserver is installed -->
|
|
||||||
<j:remove var="maven.appserver.installed" />
|
<j:remove var="maven.appserver.installed" />
|
||||||
<ant:condition property="maven.appserver.installed">
|
<util:available file="${maven.appserver.root}" >
|
||||||
<ant:and>
|
<util:available file="${maven.appserver.dir}" >
|
||||||
<ant:available file="${maven.appserver.root}" type="dir" />
|
<j:set var="maven.appserver.installed" value="true" />
|
||||||
<ant:available file="${maven.appserver.dir}" type="dir" />
|
</util:available>
|
||||||
</ant:and>
|
</util:available>
|
||||||
</ant:condition>
|
|
||||||
|
|
||||||
<j:if test="${context.getVariable('maven.appserver.started') == 'true' and context.getVariable('maven.appserver.installed') == 'true'}">
|
<j:if test="${context.getVariable('maven.appserver.started') == 'true' and context.getVariable('maven.appserver.installed') == 'true'}">
|
||||||
<j:set var="maven.appserver.installedAndStarted" value="true" />
|
<j:set var="maven.appserver.installedAndStarted" value="true" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user