JBossWeb SVN: r1438 - branches/2.1.x/webapps/docs.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-14 10:43:09 -0400 (Wed, 14 Apr 2010)
New Revision: 1438
Modified:
branches/2.1.x/webapps/docs/changelog.xml
Log:
- Fix changelog.
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2010-04-14 13:48:47 UTC (rev 1437)
+++ branches/2.1.x/webapps/docs/changelog.xml 2010-04-14 14:43:09 UTC (rev 1438)
@@ -16,6 +16,16 @@
<body>
+<section name="JBoss Web 2.1.8.GA (remm)">
+ <subsection name="Coyote">
+ <changelog>
+ <fix>
+ <jira>165</jira>: Correct fix for <bug>42727</bug>. (remm)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 2.1.7.GA (remm)">
<subsection name="General">
<changelog>
@@ -33,9 +43,6 @@
<jira>153</jira>: <bug>43839</bug>
Parent context cookie overwriting URL encoded cookie. (markt/mmillson)
</fix>
- <fix>
- <jira>165</jira>: Correct fix for <bug>42727</bug>. (remm)
- </fix>
</changelog>
</subsection>
<subsection name="Jasper">
15 years, 9 months
JBossWeb SVN: r1437 - in branches/2.1.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-14 09:48:47 -0400 (Wed, 14 Apr 2010)
New Revision: 1437
Modified:
branches/2.1.x/java/org/apache/catalina/connector/CoyoteReader.java
branches/2.1.x/webapps/docs/changelog.xml
Log:
- JBWEB-165: Fix oops.
Modified: branches/2.1.x/java/org/apache/catalina/connector/CoyoteReader.java
===================================================================
--- branches/2.1.x/java/org/apache/catalina/connector/CoyoteReader.java 2010-04-14 13:48:02 UTC (rev 1436)
+++ branches/2.1.x/java/org/apache/catalina/connector/CoyoteReader.java 2010-04-14 13:48:47 UTC (rev 1437)
@@ -156,8 +156,8 @@
mark(MAX_LINE_LENGTH);
while ((pos < MAX_LINE_LENGTH) && (end < 0)) {
int nRead = read(lineBuffer, pos, MAX_LINE_LENGTH - pos);
- if (nRead < 0 && aggregator == null) {
- if (pos == 0) {
+ if (nRead < 0) {
+ if (pos == 0 && aggregator == null) {
return null;
}
end = pos;
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2010-04-14 13:48:02 UTC (rev 1436)
+++ branches/2.1.x/webapps/docs/changelog.xml 2010-04-14 13:48:47 UTC (rev 1437)
@@ -29,9 +29,13 @@
<fix>
Fix incomplete write logic in APR. (jfclere)
</fix>
- <fix> <jboss-jira>JBWEB-153</jboss-jira> <bug>43839</bug>
+ <fix>
+ <jira>153</jira>: <bug>43839</bug>
Parent context cookie overwriting URL encoded cookie. (markt/mmillson)
</fix>
+ <fix>
+ <jira>165</jira>: Correct fix for <bug>42727</bug>. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
15 years, 9 months
JBossWeb SVN: r1436 - branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-14 09:48:02 -0400 (Wed, 14 Apr 2010)
New Revision: 1436
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/CoyoteReader.java
Log:
- JBWEB-165.
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/CoyoteReader.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/CoyoteReader.java 2010-04-14 13:34:47 UTC (rev 1435)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/CoyoteReader.java 2010-04-14 13:48:02 UTC (rev 1436)
@@ -134,7 +134,6 @@
ib.reset();
}
-
public String readLine()
throws IOException {
@@ -153,7 +152,7 @@
while ((pos < MAX_LINE_LENGTH) && (end < 0)) {
int nRead = read(lineBuffer, pos, MAX_LINE_LENGTH - pos);
if (nRead < 0) {
- if (pos == 0) {
+ if (pos == 0 && aggregator == null) {
return null;
}
end = pos;
@@ -204,5 +203,4 @@
}
-
}
15 years, 9 months
JBossWeb SVN: r1435 - in trunk: java/org/apache/catalina/session and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-14 09:34:47 -0400 (Wed, 14 Apr 2010)
New Revision: 1435
Modified:
trunk/java/org/apache/catalina/connector/CoyoteReader.java
trunk/java/org/apache/catalina/session/StandardManager.java
trunk/webapps/docs/changelog.xml
Log:
- JBWEB-165: Ooops.
- Port patch.
Modified: trunk/java/org/apache/catalina/connector/CoyoteReader.java
===================================================================
--- trunk/java/org/apache/catalina/connector/CoyoteReader.java 2010-04-12 11:05:36 UTC (rev 1434)
+++ trunk/java/org/apache/catalina/connector/CoyoteReader.java 2010-04-14 13:34:47 UTC (rev 1435)
@@ -156,8 +156,8 @@
mark(MAX_LINE_LENGTH);
while ((pos < MAX_LINE_LENGTH) && (end < 0)) {
int nRead = read(lineBuffer, pos, MAX_LINE_LENGTH - pos);
- if (nRead < 0 && aggregator == null) {
- if (pos == 0) {
+ if (nRead < 0) {
+ if (pos == 0 && aggregator == null) {
return null;
}
end = pos;
Modified: trunk/java/org/apache/catalina/session/StandardManager.java
===================================================================
--- trunk/java/org/apache/catalina/session/StandardManager.java 2010-04-12 11:05:36 UTC (rev 1434)
+++ trunk/java/org/apache/catalina/session/StandardManager.java 2010-04-14 13:34:47 UTC (rev 1435)
@@ -393,9 +393,11 @@
StandardSession session = getNewSession();
session.readObjectData(ois);
session.setManager(this);
- sessions.put(session.getIdInternal(), session);
- session.activate();
- sessionCounter++;
+ if (session.isValidInternal()) {
+ sessions.put(session.getIdInternal(), session);
+ session.activate();
+ sessionCounter++;
+ }
}
} catch (ClassNotFoundException e) {
log.error(sm.getString("standardManager.loading.cnfe", e), e);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-04-12 11:05:36 UTC (rev 1434)
+++ trunk/webapps/docs/changelog.xml 2010-04-14 13:34:47 UTC (rev 1435)
@@ -22,6 +22,9 @@
<update>
More standalone code removal. (remm)
</update>
+ <fix>
+ <jira>165</jira>: Correct fix for <bug>42727</bug>. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
15 years, 9 months
JBossWeb SVN: r1434 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-12 07:05:36 -0400 (Mon, 12 Apr 2010)
New Revision: 1434
Modified:
trunk/java/org/apache/el/parser/ELParser.jjt
trunk/java/org/apache/el/parser/ELParserTokenManager.java
trunk/webapps/docs/changelog.xml
Log:
- Port minor EL parsing fix.
Modified: trunk/java/org/apache/el/parser/ELParser.jjt
===================================================================
--- trunk/java/org/apache/el/parser/ELParser.jjt 2010-04-08 22:33:40 UTC (rev 1433)
+++ trunk/java/org/apache/el/parser/ELParser.jjt 2010-04-12 11:05:36 UTC (rev 1434)
@@ -374,7 +374,7 @@
*/
< LITERAL_EXPRESSION:
( (~["$", "#", "\\"])* "\\" (["$", "#"])?
- | (~["$", "#"])* (["$", "#"] ~["{"])
+ | (~["$", "#"])* (["$", "#"] ~["{", "$", "#"])
| (~["$", "#"])+
)+
| "$"
Modified: trunk/java/org/apache/el/parser/ELParserTokenManager.java
===================================================================
--- trunk/java/org/apache/el/parser/ELParserTokenManager.java 2010-04-08 22:33:40 UTC (rev 1433)
+++ trunk/java/org/apache/el/parser/ELParserTokenManager.java 2010-04-12 11:05:36 UTC (rev 1434)
@@ -128,6 +128,8 @@
jjCheckNAdd(5);
break;
case 5:
+ if ((0xffffffe7ffffffffL & l) == 0L)
+ break;
if (kind > 1)
kind = 1;
jjCheckNAddStates(5, 8);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-04-08 22:33:40 UTC (rev 1433)
+++ trunk/webapps/docs/changelog.xml 2010-04-12 11:05:36 UTC (rev 1434)
@@ -24,6 +24,13 @@
</update>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>49081</bug>: EL parsing fix. (markt)
+ </fix>
+ </changelog>
+ </subsection>
</section>
<section name="JBoss Web 3.0.0.Beta4 (remm)">
15 years, 9 months
JBossWeb SVN: r1433 - in trunk: java/org/apache/catalina/core and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-08 18:33:40 -0400 (Thu, 08 Apr 2010)
New Revision: 1433
Removed:
trunk/java/org/apache/catalina/mbeans-descriptors.xml
Modified:
trunk/java/org/apache/catalina/Globals.java
trunk/java/org/apache/catalina/Host.java
trunk/java/org/apache/catalina/Loader.java
trunk/java/org/apache/catalina/Server.java
trunk/java/org/apache/catalina/core/StandardHost.java
trunk/java/org/apache/catalina/core/StandardServer.java
trunk/java/org/apache/catalina/startup/Catalina.java
trunk/java/org/apache/catalina/startup/Embedded.java
trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
trunk/webapps/docs/changelog.xml
Log:
- More standalone code removal.
- Add back two util methods used in AS.
Modified: trunk/java/org/apache/catalina/Globals.java
===================================================================
--- trunk/java/org/apache/catalina/Globals.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/Globals.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -356,40 +356,4 @@
(System.getSecurityManager() != null);
- /**
- * The folder used for JAR overlays.
- */
- public static final String OVERLAY_PATH =
- System.getProperty("org.apache.catalina.OVERLAY_PATH", "/META-INF/resources");
-
-
- /**
- * The path used for web fragments.
- */
- public static final String WEB_FRAGMENT_PATH =
- System.getProperty("org.apache.catalina.WEB_FRAGMENT_PATH", "/META-INF/web-fragment.xml");
-
-
- /**
- * The path used for the ServletContainerInitializer service.
- */
- public static final String SERVLET_CONTAINER_INITIALIZER_SERVICE_PATH =
- System.getProperty("org.apache.catalina.SERVLET_CONTAINER_INITIALIZER_SERVICE_PATH",
- "/META-INF/services/javax.servlet.ServletContainerInitializer");
-
-
- /**
- * The master flag which controls XML validation.
- */
- public static final boolean XML_VALIDATION =
- Boolean.valueOf(System.getProperty("org.apache.catalina.XML_VALIDATION", "false")).booleanValue();
-
-
- /**
- * The master flag which controls namespace awareness when parsing XML.
- */
- public static final boolean XML_NAMESPACE_AWARE =
- Boolean.valueOf(System.getProperty("org.apache.catalina.XML_NAMESPACE_AWARE", "false")).booleanValue();
-
-
}
Modified: trunk/java/org/apache/catalina/Host.java
===================================================================
--- trunk/java/org/apache/catalina/Host.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/Host.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -136,15 +136,6 @@
/**
- * Return the Context that would be used to process the specified
- * host-relative request URI, if any; otherwise return <code>null</code>.
- *
- * @param uri Request URI to be mapped
- */
- public Context map(String uri);
-
-
- /**
* Remove the specified alias name from the aliases for this Host.
*
* @param alias Alias name to be removed
Modified: trunk/java/org/apache/catalina/Loader.java
===================================================================
--- trunk/java/org/apache/catalina/Loader.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/Loader.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -88,22 +88,6 @@
/**
- * Return the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- */
- public boolean getDelegate();
-
-
- /**
- * Set the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- *
- * @param delegate The new flag
- */
- public void setDelegate(boolean delegate);
-
-
- /**
* Return descriptive information about this Loader implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
@@ -111,31 +95,10 @@
public String getInfo();
- /**
- * Return the reloadable flag for this Loader.
- */
- public boolean getReloadable();
-
-
- /**
- * Set the reloadable flag for this Loader.
- *
- * @param reloadable The new reloadable flag
- */
- public void setReloadable(boolean reloadable);
-
-
// --------------------------------------------------------- Public Methods
/**
- * Return the set of loader repositories defined for this class loader.
- * If none are defined, a zero-length array is returned.
- */
- public String[] findLoaderRepositories();
-
-
- /**
* Add a property change listener to this component.
*
* @param listener The listener to add
@@ -152,20 +115,6 @@
/**
- * Return the set of repositories defined for this class loader.
- * If none are defined, a zero-length array is returned.
- */
- public String[] findRepositories();
-
-
- /**
- * Has the internal repository associated with this Loader been modified,
- * such that the loaded classes should be reloaded?
- */
- public boolean modified();
-
-
- /**
* Remove a property change listener from this component.
*
* @param listener The listener to remove
Modified: trunk/java/org/apache/catalina/Server.java
===================================================================
--- trunk/java/org/apache/catalina/Server.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/Server.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -58,48 +58,6 @@
public String getInfo();
- /**
- * Return the port number we listen to for shutdown commands.
- */
- public int getPort();
-
-
- /**
- * Set the port number we listen to for shutdown commands.
- *
- * @param port The new port number
- */
- public void setPort(int port);
-
-
- /**
- * Return the address on which we listen to for shutdown commands.
- */
- public String getAddress();
-
-
- /**
- * Set the address on which we listen to for shutdown commands.
- *
- * @param address The new address
- */
- public void setAddress(String address);
-
-
- /**
- * Return the shutdown command string we are waiting for.
- */
- public String getShutdown();
-
-
- /**
- * Set the shutdown command we are waiting for.
- *
- * @param shutdown The new shutdown command
- */
- public void setShutdown(String shutdown);
-
-
// --------------------------------------------------------- Public Methods
@@ -112,12 +70,6 @@
/**
- * Wait until a proper shutdown command is received, then return.
- */
- public void await();
-
-
- /**
* Return the specified Service (if it exists); otherwise return
* <code>null</code>.
*
Modified: trunk/java/org/apache/catalina/core/StandardHost.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardHost.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/core/StandardHost.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -358,55 +358,6 @@
/**
- * Return the Context that would be used to process the specified
- * host-relative request URI, if any; otherwise return <code>null</code>.
- *
- * @param uri Request URI to be mapped
- */
- public Context map(String uri) {
-
- if (log.isDebugEnabled())
- log.debug("Mapping request URI '" + uri + "'");
- if (uri == null)
- return (null);
-
- // Match on the longest possible context path prefix
- if (log.isTraceEnabled())
- log.trace(" Trying the longest context path prefix");
- Context context = null;
- String mapuri = uri;
- while (true) {
- context = (Context) findChild(mapuri);
- if (context != null)
- break;
- int slash = mapuri.lastIndexOf('/');
- if (slash < 0)
- break;
- mapuri = mapuri.substring(0, slash);
- }
-
- // If no Context matches, select the default Context
- if (context == null) {
- if (log.isTraceEnabled())
- log.trace(" Trying the default context");
- context = (Context) findChild("");
- }
-
- // Complain if no Context has been selected
- if (context == null) {
- log.error(sm.getString("standardHost.mappingError", uri));
- return (null);
- }
-
- // Return the mapped Context (if any)
- if (log.isDebugEnabled())
- log.debug(" Mapped to context '" + context.getPath() + "'");
- return (context);
-
- }
-
-
- /**
* Remove the specified alias name from the aliases for this Host.
*
* @param alias Alias name to be removed
Modified: trunk/java/org/apache/catalina/core/StandardServer.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardServer.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/core/StandardServer.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -21,19 +21,11 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.security.AccessControlException;
-import java.util.Random;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.apache.catalina.Context;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
@@ -88,36 +80,12 @@
/**
- * The port number on which we wait for shutdown commands.
- */
- private int port = 8005;
-
- /**
- * The address on which we wait for shutdown commands.
- */
- private String address = "localhost";
-
-
- /**
- * A random number generator that is <strong>only</strong> used if
- * the shutdown command string is longer than 1024 characters.
- */
- private Random random = null;
-
-
- /**
* The set of Services associated with this Server.
*/
private Service services[] = new Service[0];
/**
- * The shutdown command string we are looking for.
- */
- private String shutdown = "SHUTDOWN";
-
-
- /**
* The string manager for this package.
*/
private static final StringManager sm =
@@ -141,7 +109,6 @@
*/
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
- private boolean stopAwait = false;
// ------------------------------------------------------------- Properties
@@ -166,71 +133,7 @@
return ServerInfo.getServerInfo();
}
- /**
- * Return the port number we listen to for shutdown commands.
- */
- public int getPort() {
- return (this.port);
-
- }
-
-
- /**
- * Set the port number we listen to for shutdown commands.
- *
- * @param port The new port number
- */
- public void setPort(int port) {
-
- this.port = port;
-
- }
-
-
- /**
- * Return the address on which we listen to for shutdown commands.
- */
- public String getAddress() {
-
- return (this.address);
-
- }
-
-
- /**
- * Set the address on which we listen to for shutdown commands.
- *
- * @param address The new address
- */
- public void setAddress(String address) {
-
- this.address = address;
-
- }
-
- /**
- * Return the shutdown command string we are waiting for.
- */
- public String getShutdown() {
-
- return (this.shutdown);
-
- }
-
-
- /**
- * Set the shutdown command we are waiting for.
- *
- * @param shutdown The new shutdown command
- */
- public void setShutdown(String shutdown) {
-
- this.shutdown = shutdown;
-
- }
-
-
// --------------------------------------------------------- Server Methods
@@ -271,113 +174,7 @@
}
- public void stopAwait() {
- stopAwait=true;
- }
-
/**
- * Wait until a proper shutdown command is received, then return.
- * This keeps the main thread alive - the thread pool listening for http
- * connections is daemon threads.
- */
- public void await() {
- // Negative values - don't wait on port - tomcat is embedded or we just don't like ports
- if( port == -2 ) {
- // undocumented yet - for embedding apps that are around, alive.
- return;
- }
- if( port==-1 ) {
- while( true ) {
- try {
- Thread.sleep(10000);
- } catch( InterruptedException ex ) {
- }
- if( stopAwait ) return;
- }
- }
-
- // Set up a server socket to wait on
- ServerSocket serverSocket = null;
- try {
- serverSocket =
- new ServerSocket(port, 1,
- InetAddress.getByName(address));
- } catch (IOException e) {
- log.error("StandardServer.await: create[" + address
- + ":" + port
- + "]: ", e);
- System.exit(1);
- }
-
- // Loop waiting for a connection and a valid command
- while (true) {
-
- // Wait for the next connection
- Socket socket = null;
- InputStream stream = null;
- try {
- socket = serverSocket.accept();
- socket.setSoTimeout(10 * 1000); // Ten seconds
- stream = socket.getInputStream();
- } catch (AccessControlException ace) {
- log.warn("StandardServer.accept security exception: "
- + ace.getMessage(), ace);
- continue;
- } catch (IOException e) {
- log.error("StandardServer.await: accept: ", e);
- System.exit(1);
- }
-
- // Read a set of characters from the socket
- StringBuilder command = new StringBuilder();
- int expected = 1024; // Cut off to avoid DoS attack
- while (expected < shutdown.length()) {
- if (random == null)
- random = new Random();
- expected += (random.nextInt() % 1024);
- }
- while (expected > 0) {
- int ch = -1;
- try {
- ch = stream.read();
- } catch (IOException e) {
- log.warn("StandardServer.await: read: ", e);
- ch = -1;
- }
- if (ch < 32) // Control character or EOF terminates loop
- break;
- command.append((char) ch);
- expected--;
- }
-
- // Close the socket now that we are done with it
- try {
- socket.close();
- } catch (IOException e) {
- ;
- }
-
- // Match against our command string
- boolean match = command.toString().equals(shutdown);
- if (match) {
- break;
- } else
- log.warn("StandardServer.await: Invalid command '" +
- command.toString() + "' received");
-
- }
-
- // Close the server socket and return
- try {
- serverSocket.close();
- } catch (IOException e) {
- ;
- }
-
- }
-
-
- /**
* Return the specified Service (if it exists); otherwise return
* <code>null</code>.
*
@@ -492,71 +289,10 @@
* Return a String representation of this component.
*/
public String toString() {
-
- StringBuilder sb = new StringBuilder("StandardServer[");
- sb.append(getPort());
- sb.append("]");
- return (sb.toString());
-
+ return ("StandardServer[]");
}
- /**
- * Write the configuration information for this entire <code>Server</code>
- * out to the server.xml configuration file.
- *
- * @exception javax.management.InstanceNotFoundException if the managed resource object
- * cannot be found
- * @exception javax.management.MBeanException if the initializer of the object throws
- * an exception, or persistence is not supported
- * @exception javax.management.RuntimeOperationsException if an exception is reported
- * by the persistence mechanism
- */
- public synchronized void storeConfig() throws Exception {
-
- ObjectName sname = null;
- try {
- sname = new ObjectName("Catalina:type=StoreConfig");
- if(mserver.isRegistered(sname)) {
- mserver.invoke(sname, "storeConfig", null, null);
- } else
- log.error("StoreConfig mbean not registered" + sname);
- } catch (Throwable t) {
- log.error(t);
- }
-
- }
-
-
- /**
- * Write the configuration information for <code>Context</code>
- * out to the specified configuration file.
- *
- * @exception javax.management.InstanceNotFoundException if the managed resource object
- * cannot be found
- * @exception javax.management.MBeanException if the initializer of the object throws
- * an exception, or persistence is not supported
- * @exception javax.management.RuntimeOperationsException if an exception is reported
- * by the persistence mechanism
- */
- public synchronized void storeContext(Context context) throws Exception {
-
- ObjectName sname = null;
- try {
- sname = new ObjectName("Catalina:type=StoreConfig");
- if(mserver.isRegistered(sname)) {
- mserver.invoke(sname, "store",
- new Object[] {context},
- new String [] { "java.lang.String"});
- } else
- log.error("StoreConfig mbean not registered" + sname);
- } catch (Throwable t) {
- log.error(t);
- }
-
- }
-
-
// ------------------------------------------------------ Lifecycle Methods
@@ -662,9 +398,6 @@
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
- if (port == -1)
- stopAwait();
-
}
public void init() throws Exception {
Deleted: trunk/java/org/apache/catalina/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/mbeans-descriptors.xml 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/mbeans-descriptors.xml 2010-04-08 22:33:40 UTC (rev 1433)
@@ -1,150 +0,0 @@
-<?xml version="1.0"?>
-<mbeans-descriptors>
-
- <mbean name="Group"
- className="org.apache.catalina.mbeans.GroupMBean"
- description="Group from a user database"
- domain="Users"
- group="Group"
- type="org.apache.catalina.Group">
-
- <attribute name="description"
- description="Description of this group"
- type="java.lang.String"/>
-
- <attribute name="groupname"
- description="Group name of this group"
- type="java.lang.String"/>
-
- <attribute name="roles"
- description="MBean Names of roles for this group"
- type="[Ljava.lang.String;"
- writeable="false"/>
-
- <attribute name="users"
- description="MBean Names of user members of this group"
- type="[Ljava.lang.String;"
- writeable="false"/>
-
- <operation name="addRole"
- description="Add a new authorized role for this group"
- impact="ACTION"
- returnType="void">
- <parameter name="role"
- description="Role to be added"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeRole"
- description="Remove an old authorized role for this group"
- impact="ACTION"
- returnType="void">
- <parameter name="role"
- description="Role to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeRoles"
- description="Remove all authorized roles for this group"
- impact="ACTION"
- returnType="void">
- </operation>
-
- </mbean>
-
- <mbean name="Role"
- className="org.apache.catalina.mbeans.RoleMBean"
- description="Security role from a user database"
- domain="Users"
- group="Role"
- type="org.apache.catalina.Role">
-
- <attribute name="description"
- description="Description of this role"
- type="java.lang.String"/>
-
- <attribute name="rolename"
- description="Role name of this role"
- type="java.lang.String"/>
-
- </mbean>
-
- <mbean name="User"
- className="org.apache.catalina.mbeans.UserMBean"
- description="User from a user database"
- domain="Users"
- group="User"
- type="org.apache.catalina.User">
-
- <attribute name="fullName"
- description="Full name of this user"
- type="java.lang.String"/>
-
- <attribute name="groups"
- description="MBean Names of groups this user is a member of"
- type="[Ljava.lang.String;"/>
-
- <attribute name="password"
- description="Password of this user"
- type="java.lang.String"/>
-
- <attribute name="roles"
- description="MBean Names of roles for this user"
- type="[Ljava.lang.String;"
- writeable="false"/>
-
- <attribute name="username"
- description="User name of this user"
- type="java.lang.String"/>
-
- <operation name="addGroup"
- description="Add a new group membership for this user"
- impact="ACTION"
- returnType="void">
- <parameter name="groupname"
- description="Group name of the new group"
- type="java.lang.String"/>
- </operation>
-
- <operation name="addRole"
- description="Add a new authorized role for this user"
- impact="ACTION"
- returnType="void">
- <parameter name="role"
- description="Role to be added"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeGroup"
- description="Remove an old group membership for this user"
- impact="ACTION"
- returnType="void">
- <parameter name="groupname"
- description="Group name of the old group"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeGroups"
- description="Remove all group memberships for this user"
- impact="ACTION"
- returnType="void">
- </operation>
-
- <operation name="removeRole"
- description="Remove an old authorized role for this user"
- impact="ACTION"
- returnType="void">
- <parameter name="role"
- description="Role to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeRoles"
- description="Remove all authorized roles for this user"
- impact="ACTION"
- returnType="void">
- </operation>
-
- </mbean>
-
-</mbeans-descriptors>
Modified: trunk/java/org/apache/catalina/startup/Catalina.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Catalina.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/startup/Catalina.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -19,30 +19,14 @@
package org.apache.catalina.startup;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.Socket;
-
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Server;
/**
- * Startup/Shutdown shell program for Catalina. The following command line
- * options are recognized:
- * <ul>
- * <li><b>-config {pathname}</b> - Set the pathname of the configuration file
- * to be processed. If a relative path is specified, it will be
- * interpreted as relative to the directory pathname specified by the
- * "catalina.base" system property. [conf/server.xml]
- * <li><b>-help</b> - Display usage information.
- * <li><b>-stop</b> - Stop the currently running instance of Catalina.
- * </u>
+ * Wrapper impl of Embedded.
*
- * Should do the same thing as Embedded, but using a server.xml file.
- *
* @author Craig R. McClanahan
* @author Remy Maucherat
* @version $Revision$ $Date$
@@ -55,19 +39,6 @@
/**
- * Pathname to the server configuration file.
- */
- protected String configFile = "conf/server.xml";
-
- // XXX Should be moved to embedded
- /**
- * The shared extensions class loader for this server.
- */
- protected ClassLoader parentClassLoader =
- Catalina.class.getClassLoader();
-
-
- /**
* The server component we are starting or stopping
*/
protected Server server = null;
@@ -85,247 +56,27 @@
protected boolean stopping = false;
- /**
- * Use shutdown hook flag.
- */
- protected boolean useShutdownHook = true;
-
-
- /**
- * Shutdown hook.
- */
- protected Thread shutdownHook = null;
-
-
// ------------------------------------------------------------- Properties
- public void setConfig(String file) {
- configFile = file;
+ public Server getServer() {
+ return server;
}
-
- public void setConfigFile(String file) {
- configFile = file;
- }
-
-
- public String getConfigFile() {
- return configFile;
- }
-
-
- public void setUseShutdownHook(boolean useShutdownHook) {
- this.useShutdownHook = useShutdownHook;
- }
-
-
- public boolean getUseShutdownHook() {
- return useShutdownHook;
- }
-
-
- /**
- * Set the shared extensions class loader.
- *
- * @param parentClassLoader The shared extensions class loader.
- */
- public void setParentClassLoader(ClassLoader parentClassLoader) {
-
- this.parentClassLoader = parentClassLoader;
-
- }
-
-
- /**
- * Set the server instance we are configuring.
- *
- * @param server The new server
- */
public void setServer(Server server) {
-
this.server = server;
-
}
- // ----------------------------------------------------------- Main Program
-
- /**
- * The application main program.
- *
- * @param args Command line arguments
- */
- public static void main(String args[]) {
- (new Catalina()).process(args);
- }
-
-
- /**
- * The instance main program.
- *
- * @param args Command line arguments
- */
- public void process(String args[]) {
-
- setAwait(true);
- try {
- if (arguments(args)) {
- if (starting) {
- load(args);
- start();
- } else if (stopping) {
- stopServer();
- }
- }
- } catch (Exception e) {
- e.printStackTrace(System.out);
- }
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Process the specified command line arguments, and return
- * <code>true</code> if we should continue processing; otherwise
- * return <code>false</code>.
- *
- * @param args Command line arguments to process
- */
- protected boolean arguments(String args[]) {
-
- boolean isConfig = false;
-
- if (args.length < 1) {
- usage();
- return (false);
- }
-
- for (int i = 0; i < args.length; i++) {
- if (isConfig) {
- configFile = args[i];
- isConfig = false;
- } else if (args[i].equals("-config")) {
- isConfig = true;
- } else if (args[i].equals("-nonaming")) {
- setUseNaming( false );
- } else if (args[i].equals("-help")) {
- usage();
- return (false);
- } else if (args[i].equals("start")) {
- starting = true;
- stopping = false;
- } else if (args[i].equals("stop")) {
- starting = false;
- stopping = true;
- } else {
- usage();
- return (false);
- }
- }
-
- return (true);
-
- }
-
-
- /**
- * Return a File object representing our configuration file.
- */
- protected File configFile() {
-
- File file = new File(configFile);
- if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), configFile);
- return (file);
-
- }
-
-
- public void stopServer() {
- stopServer(null);
- }
-
- public void stopServer(String[] arguments) {
-
- if (arguments != null) {
- arguments(arguments);
- }
-
- // Stop the existing server
- if (server.getPort() < 0) {
- return;
- }
- try {
- Socket socket = new Socket(server.getAddress(), server.getPort());
- OutputStream stream = socket.getOutputStream();
- String shutdown = server.getShutdown();
- for (int i = 0; i < shutdown.length(); i++)
- stream.write(shutdown.charAt(i));
- stream.flush();
- stream.close();
- socket.close();
- } catch (IOException e) {
- log.error("Catalina.stop: ", e);
- System.exit(1);
- }
-
- }
-
-
- /**
- * Start a new server instance.
- */
- public void load() {
-
- // Stream redirection
- initStreams();
-
- // Start the new server
- if (server instanceof Lifecycle) {
- try {
- server.initialize();
- } catch (LifecycleException e) {
- log.error("Catalina.start", e);
- }
- }
-
- }
-
-
- /*
- * Load using arguments
- */
- public void load(String args[]) {
-
- try {
- if (arguments(args))
- load();
- } catch (Exception e) {
- e.printStackTrace(System.out);
- }
- }
-
public void create() {
-
}
public void destroy() {
-
}
/**
* Start a new server instance.
*/
public void start() {
-
- if (server == null) {
- load();
- }
-
- long t1 = System.nanoTime();
-
// Start the new server
if (server instanceof Lifecycle) {
try {
@@ -334,29 +85,6 @@
log.error("Catalina.start: ", e);
}
}
-
- long t2 = System.nanoTime();
- if (log.isDebugEnabled())
- log.debug("Server startup in " + ((t2 - t1) / 1000000) + " ms");
-
- try {
- // Register shutdown hook
- if (useShutdownHook) {
- if (shutdownHook == null) {
- shutdownHook = new CatalinaShutdownHook();
- }
- Runtime.getRuntime().addShutdownHook(shutdownHook);
- }
- } catch (Throwable t) {
- // This will fail on JDK 1.2. Ignoring, as Tomcat can run
- // fine without the shutdown hook.
- }
-
- if (await) {
- await();
- stop();
- }
-
}
@@ -365,17 +93,6 @@
*/
public void stop() {
- try {
- // Remove the ShutdownHook first so that server.stop()
- // doesn't get invoked twice
- if (useShutdownHook) {
- Runtime.getRuntime().removeShutdownHook(shutdownHook);
- }
- } catch (Throwable t) {
- // This will fail on JDK 1.2. Ignoring, as Tomcat can run
- // fine without the shutdown hook.
- }
-
// Shut down the server
if (server instanceof Lifecycle) {
try {
@@ -388,48 +105,6 @@
}
- /**
- * Await and shutdown.
- */
- public void await() {
-
- server.await();
-
- }
-
-
- /**
- * Print usage information for this application.
- */
- protected void usage() {
-
- System.out.println
- ("usage: java org.apache.catalina.startup.Catalina"
- + " [ -config {pathname} ]"
- + " [ -nonaming ] { start | stop }");
-
- }
-
-
- // --------------------------------------- CatalinaShutdownHook Inner Class
-
- // XXX Should be moved to embedded !
- /**
- * Shutdown hook which will perform a clean shutdown of Catalina if needed.
- */
- protected class CatalinaShutdownHook extends Thread {
-
- public void run() {
-
- if (server != null) {
- Catalina.this.stop();
- }
-
- }
-
- }
-
-
private static org.jboss.logging.Logger log=
org.jboss.logging.Logger.getLogger( Catalina.class );
Modified: trunk/java/org/apache/catalina/startup/Embedded.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Embedded.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/catalina/startup/Embedded.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -41,7 +41,6 @@
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.log.SystemLogHandler;
import org.jboss.logging.Logger;
@@ -131,18 +130,6 @@
/**
- * Is naming enabled ?
- */
- protected boolean useNaming = true;
-
-
- /**
- * Is standard streams redirection enabled ?
- */
- protected boolean redirectStreams = true;
-
-
- /**
* The set of Engines that have been deployed in this server. Normally
* there will only be one.
*/
@@ -187,66 +174,10 @@
*/
protected boolean started = false;
- /**
- * Use await.
- */
- protected boolean await = false;
-
-
// ------------------------------------------------------------- Properties
/**
- * Return true if naming is enabled.
- */
- public boolean isUseNaming() {
-
- return (this.useNaming);
-
- }
-
-
- /**
- * Enables or disables naming support.
- *
- * @param useNaming The new use naming value
- */
- public void setUseNaming(boolean useNaming) {
-
- boolean oldUseNaming = this.useNaming;
- this.useNaming = useNaming;
- support.firePropertyChange("useNaming", new Boolean(oldUseNaming),
- new Boolean(this.useNaming));
-
- }
-
-
- /**
- * Return true if redirction of standard streams is enabled.
- */
- public boolean isRedirectStreams() {
-
- return (this.redirectStreams);
-
- }
-
-
- /**
- * Enables or disables naming support.
- *
- * @param useNaming The new use naming value
- */
- public void setRedirectStreams(boolean redirectStreams) {
-
- boolean oldRedirectStreams = this.redirectStreams;
- this.redirectStreams = redirectStreams;
- support.firePropertyChange("redirectStreams", new Boolean(oldRedirectStreams),
- new Boolean(this.redirectStreams));
-
- }
-
-
- /**
* Return the default Realm for our Containers.
*/
public Realm getRealm() {
@@ -269,14 +200,6 @@
}
- public void setAwait(boolean b) {
- await = b;
- }
-
- public boolean isAwait() {
- return await;
- }
-
public void setCatalinaHome( String s ) {
System.setProperty( "catalina.home", s);
}
@@ -848,19 +771,6 @@
}
- // ------------------------------------------------------ Protected Methods
-
-
- protected void initStreams() {
- if (redirectStreams) {
- // Replace System.out and System.err with a custom PrintStream
- SystemLogHandler systemlog = new SystemLogHandler(System.out);
- System.setOut(systemlog);
- System.setErr(systemlog);
- }
- }
-
-
// -------------------------------------------------------- Private Methods
/**
Modified: trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
===================================================================
--- trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2010-04-08 22:33:40 UTC (rev 1433)
@@ -214,6 +214,56 @@
return null;
}
+ public static Object callMethod1(Object target, String methodN,
+ Object param1, String typeParam1, ClassLoader cl) throws Exception {
+ if (target == null || param1 == null) {
+ d("Assert: Illegal params " + target + " " + param1);
+ }
+ if (dbg > 0)
+ d("callMethod1 " + target.getClass().getName() + " "
+ + param1.getClass().getName() + " " + typeParam1);
+
+ Class params[] = new Class[1];
+ if (typeParam1 == null)
+ params[0] = param1.getClass();
+ else
+ params[0] = cl.loadClass(typeParam1);
+ Method m = findMethod(target.getClass(), methodN, params);
+ if (m == null)
+ throw new NoSuchMethodException(target.getClass().getName() + " "
+ + methodN);
+ return m.invoke(target, new Object[] { param1 });
+ }
+
+ public static Method findMethod(Class c, String name, Class params[]) {
+ Method methods[] = c.getMethods();
+ if (methods == null)
+ return null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(name)) {
+ Class methodParams[] = methods[i].getParameterTypes();
+ if (methodParams == null)
+ if (params == null || params.length == 0)
+ return methods[i];
+ if (params == null)
+ if (methodParams == null || methodParams.length == 0)
+ return methods[i];
+ if (params.length != methodParams.length)
+ continue;
+ boolean found = true;
+ for (int j = 0; j < params.length; j++) {
+ if (params[j] != methodParams[j]) {
+ found = false;
+ break;
+ }
+ }
+ if (found)
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
/**
* Reverse of Introspector.decapitalize
*/
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-04-07 23:15:04 UTC (rev 1432)
+++ trunk/webapps/docs/changelog.xml 2010-04-08 22:33:40 UTC (rev 1433)
@@ -16,6 +16,16 @@
<body>
+<section name="JBoss Web 3.0.0.Beta5 (remm)">
+ <subsection name="Catalina">
+ <changelog>
+ <update>
+ More standalone code removal. (remm)
+ </update>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 3.0.0.Beta4 (remm)">
<subsection name="Catalina">
<changelog>
15 years, 9 months
JBossWeb SVN: r1432 - trunk/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-07 19:15:04 -0400 (Wed, 07 Apr 2010)
New Revision: 1432
Modified:
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Oops, forgot to call after with the new event ...
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-04-05 14:26:16 UTC (rev 1431)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-04-07 23:15:04 UTC (rev 1432)
@@ -297,6 +297,8 @@
}
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
} catch (ClientAbortException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
@@ -506,6 +508,8 @@
}
}
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
} catch (ClientAbortException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
15 years, 9 months
JBossWeb SVN: r1431 - trunk/java/org/apache/tomcat/util.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-05 10:26:16 -0400 (Mon, 05 Apr 2010)
New Revision: 1431
Modified:
trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
Log:
- Remove dead code.
Modified: trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
===================================================================
--- trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2010-04-05 14:15:03 UTC (rev 1430)
+++ trunk/java/org/apache/tomcat/util/IntrospectionUtils.java 2010-04-05 14:26:16 UTC (rev 1431)
@@ -17,23 +17,16 @@
package org.apache.tomcat.util;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.net.UnknownHostException;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.util.Vector;
// Depends: JDK1.1
/**
* Utils for introspection and reflection
+ * Note: For the complete legacy version, see JBoss Web 2.1
*/
public final class IntrospectionUtils {
@@ -42,218 +35,6 @@
org.jboss.logging.Logger.getLogger( IntrospectionUtils.class );
/**
- * Call execute() - any ant-like task should work
- */
- public static void execute(Object proxy, String method) throws Exception {
- Method executeM = null;
- Class c = proxy.getClass();
- Class params[] = new Class[0];
- // params[0]=args.getClass();
- executeM = findMethod(c, method, params);
- if (executeM == null) {
- throw new RuntimeException("No execute in " + proxy.getClass());
- }
- executeM.invoke(proxy, (Object[]) null);//new Object[] { args });
- }
-
- /**
- * Call void setAttribute( String ,Object )
- */
- public static void setAttribute(Object proxy, String n, Object v)
- throws Exception {
- if (proxy instanceof AttributeHolder) {
- ((AttributeHolder) proxy).setAttribute(n, v);
- return;
- }
-
- Method executeM = null;
- Class c = proxy.getClass();
- Class params[] = new Class[2];
- params[0] = String.class;
- params[1] = Object.class;
- executeM = findMethod(c, "setAttribute", params);
- if (executeM == null) {
- if (log.isDebugEnabled())
- log.debug("No setAttribute in " + proxy.getClass());
- return;
- }
- if (false)
- if (log.isDebugEnabled())
- log.debug("Setting " + n + "=" + v + " in " + proxy);
- executeM.invoke(proxy, new Object[] { n, v });
- return;
- }
-
- /**
- * Call void getAttribute( String )
- */
- public static Object getAttribute(Object proxy, String n) throws Exception {
- Method executeM = null;
- Class c = proxy.getClass();
- Class params[] = new Class[1];
- params[0] = String.class;
- executeM = findMethod(c, "getAttribute", params);
- if (executeM == null) {
- if (log.isDebugEnabled())
- log.debug("No getAttribute in " + proxy.getClass());
- return null;
- }
- return executeM.invoke(proxy, new Object[] { n });
- }
-
- /**
- * Construct a URLClassLoader. Will compile and work in JDK1.1 too.
- */
- public static ClassLoader getURLClassLoader(URL urls[], ClassLoader parent) {
- try {
- Class urlCL = Class.forName("java.net.URLClassLoader");
- Class paramT[] = new Class[2];
- paramT[0] = urls.getClass();
- paramT[1] = ClassLoader.class;
- Method m = findMethod(urlCL, "newInstance", paramT);
- if (m == null)
- return null;
-
- ClassLoader cl = (ClassLoader) m.invoke(urlCL, new Object[] { urls,
- parent });
- return cl;
- } catch (ClassNotFoundException ex) {
- // jdk1.1
- return null;
- } catch (Exception ex) {
- ex.printStackTrace();
- return null;
- }
- }
-
- public static String guessInstall(String installSysProp,
- String homeSysProp, String jarName) {
- return guessInstall(installSysProp, homeSysProp, jarName, null);
- }
-
- /**
- * Guess a product install/home by analyzing the class path. It works for
- * product using the pattern: lib/executable.jar or if executable.jar is
- * included in classpath by a shell script. ( java -jar also works )
- *
- * Insures both "install" and "home" System properties are set. If either or
- * both System properties are unset, "install" and "home" will be set to the
- * same value. This value will be the other System property that is set, or
- * the guessed value if neither is set.
- */
- public static String guessInstall(String installSysProp,
- String homeSysProp, String jarName, String classFile) {
- String install = null;
- String home = null;
-
- if (installSysProp != null)
- install = System.getProperty(installSysProp);
-
- if (homeSysProp != null)
- home = System.getProperty(homeSysProp);
-
- if (install != null) {
- if (home == null)
- System.getProperties().put(homeSysProp, install);
- return install;
- }
-
- // Find the directory where jarName.jar is located
-
- String cpath = System.getProperty("java.class.path");
- String pathSep = System.getProperty("path.separator");
- StringTokenizer st = new StringTokenizer(cpath, pathSep);
- while (st.hasMoreTokens()) {
- String path = st.nextToken();
- // log( "path " + path );
- if (path.endsWith(jarName)) {
- home = path.substring(0, path.length() - jarName.length());
- try {
- if ("".equals(home)) {
- home = new File("./").getCanonicalPath();
- } else if (home.endsWith(File.separator)) {
- home = home.substring(0, home.length() - 1);
- }
- File f = new File(home);
- String parentDir = f.getParent();
- if (parentDir == null)
- parentDir = home; // unix style
- File f1 = new File(parentDir);
- install = f1.getCanonicalPath();
- if (installSysProp != null)
- System.getProperties().put(installSysProp, install);
- if (home == null && homeSysProp != null)
- System.getProperties().put(homeSysProp, install);
- return install;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- } else {
- String fname = path + (path.endsWith("/") ? "" : "/")
- + classFile;
- if (new File(fname).exists()) {
- try {
- File f = new File(path);
- String parentDir = f.getParent();
- if (parentDir == null)
- parentDir = path; // unix style
- File f1 = new File(parentDir);
- install = f1.getCanonicalPath();
- if (installSysProp != null)
- System.getProperties().put(installSysProp, install);
- if (home == null && homeSysProp != null)
- System.getProperties().put(homeSysProp, install);
- return install;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
- }
-
- // if install directory can't be found, use home as the default
- if (home != null) {
- System.getProperties().put(installSysProp, home);
- return home;
- }
-
- return null;
- }
-
- /**
- * Debug method, display the classpath
- */
- public static void displayClassPath(String msg, URL[] cp) {
- if (log.isDebugEnabled()) {
- log.debug(msg);
- for (int i = 0; i < cp.length; i++) {
- log.debug(cp[i].getFile());
- }
- }
- }
-
- public static String PATH_SEPARATOR = System.getProperty("path.separator");
-
- /**
- * Adds classpath entries from a vector of URL's to the "tc_path_add" System
- * property. This System property lists the classpath entries common to web
- * applications. This System property is currently used by Jasper when its
- * JSP servlet compiles the Java file for a JSP.
- */
- public static String classPathAdd(URL urls[], String cp) {
- if (urls == null)
- return cp;
-
- for (int i = 0; i < urls.length; i++) {
- if (cp != null)
- cp += PATH_SEPARATOR + urls[i].getFile();
- else
- cp = urls[i].getFile();
- }
- return cp;
- }
-
- /**
* Find a method with the right name If found, call the method ( if param is
* int or boolean we'll convert value to the right type before) - that means
* you can have setDebug(1).
@@ -265,7 +46,7 @@
String setter = "set" + capitalize(name);
try {
- Method methods[] = findMethods(o.getClass());
+ Method methods[] = o.getClass().getMethods();
Method setPropertyMethodVoid = null;
Method setPropertyMethodBool = null;
@@ -385,7 +166,7 @@
String isGetter = "is" + capitalize(name);
try {
- Method methods[] = findMethods(o.getClass());
+ Method methods[] = o.getClass().getMethods();
Method getPropertyMethod = null;
// First, the ideal case - a getFoo() method
@@ -433,113 +214,7 @@
return null;
}
- /**
- */
- public static void setProperty(Object o, String name) {
- String setter = "set" + capitalize(name);
- try {
- Method methods[] = findMethods(o.getClass());
- Method setPropertyMethod = null;
- // find setFoo() method
- for (int i = 0; i < methods.length; i++) {
- Class paramT[] = methods[i].getParameterTypes();
- if (setter.equals(methods[i].getName()) && paramT.length == 0) {
- methods[i].invoke(o, new Object[] {});
- return;
- }
- }
- } catch (Exception ex1) {
- if (dbg > 0)
- d("Exception for " + o.getClass() + " " + name);
- if (dbg > 1)
- ex1.printStackTrace();
- }
- }
-
/**
- * Replace ${NAME} with the property value
- *
- * @deprecated Use the explicit method
- */
- public static String replaceProperties(String value, Object getter) {
- if (getter instanceof Hashtable)
- return replaceProperties(value, (Hashtable) getter, null);
-
- if (getter instanceof PropertySource) {
- PropertySource src[] = new PropertySource[] { (PropertySource) getter };
- return replaceProperties(value, null, src);
- }
- return value;
- }
-
- /**
- * Replace ${NAME} with the property value
- */
- public static String replaceProperties(String value, Hashtable staticProp,
- PropertySource dynamicProp[]) {
- if (value.indexOf("$") < 0) {
- return value;
- }
- StringBuilder sb = new StringBuilder();
- int prev = 0;
- // assert value!=nil
- int pos;
- while ((pos = value.indexOf("$", prev)) >= 0) {
- if (pos > 0) {
- sb.append(value.substring(prev, pos));
- }
- if (pos == (value.length() - 1)) {
- sb.append('$');
- prev = pos + 1;
- } else if (value.charAt(pos + 1) != '{') {
- sb.append('$');
- prev = pos + 1; // XXX
- } else {
- int endName = value.indexOf('}', pos);
- if (endName < 0) {
- sb.append(value.substring(pos));
- prev = value.length();
- continue;
- }
- int endName2 = value.indexOf(':', pos);
- String n = null;
- String d = null;
- if (endName2 > 0 && endName2 < endName) {
- n = value.substring(pos + 2, endName2);
- d = value.substring(endName2 + 1, endName);
- } else {
- n = value.substring(pos + 2, endName);
- }
- String v = null;
- if (staticProp != null) {
- v = (String) ((Hashtable) staticProp).get(n);
- }
- if (v == null && dynamicProp != null) {
- for (int i = 0; i < dynamicProp.length; i++) {
- v = dynamicProp[i].getProperty(n);
- if (v != null) {
- break;
- }
- }
- }
- if (v == null) {
- if (d == null) {
- v = "${" + n + "}";
- } else {
- v = d;
- }
- }
-
- sb.append(v);
- prev = endName + 1;
- }
- }
- if (prev < value.length())
- sb.append(value.substring(prev));
- return sb.toString();
- }
-
- /**
* Reverse of Introspector.decapitalize
*/
public static String capitalize(String name) {
@@ -560,466 +235,6 @@
return new String(chars);
}
- // -------------------- Class path tools --------------------
-
- /**
- * Add all the jar files in a dir to the classpath, represented as a Vector
- * of URLs.
- */
- public static void addToClassPath(Vector cpV, String dir) {
- try {
- String cpComp[] = getFilesByExt(dir, ".jar");
- if (cpComp != null) {
- int jarCount = cpComp.length;
- for (int i = 0; i < jarCount; i++) {
- URL url = getURL(dir, cpComp[i]);
- if (url != null)
- cpV.addElement(url);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public static void addToolsJar(Vector v) {
- try {
- // Add tools.jar in any case
- File f = new File(System.getProperty("java.home")
- + "/../lib/tools.jar");
-
- if (!f.exists()) {
- // On some systems java.home gets set to the root of jdk.
- // That's a bug, but we can work around and be nice.
- f = new File(System.getProperty("java.home") + "/lib/tools.jar");
- if (f.exists()) {
- if (log.isDebugEnabled())
- log.debug("Detected strange java.home value "
- + System.getProperty("java.home")
- + ", it should point to jre");
- }
- }
- URL url = new URL("file", "", f.getAbsolutePath());
-
- v.addElement(url);
- } catch (MalformedURLException ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * Return all files with a given extension in a dir
- */
- public static String[] getFilesByExt(String ld, String ext) {
- File dir = new File(ld);
- String[] names = null;
- final String lext = ext;
- if (dir.isDirectory()) {
- names = dir.list(new FilenameFilter() {
- public boolean accept(File d, String name) {
- if (name.endsWith(lext)) {
- return true;
- }
- return false;
- }
- });
- }
- return names;
- }
-
- /**
- * Construct a file url from a file, using a base dir
- */
- public static URL getURL(String base, String file) {
- try {
- File baseF = new File(base);
- File f = new File(baseF, file);
- String path = f.getCanonicalPath();
- if (f.isDirectory()) {
- path += "/";
- }
- if (!f.exists())
- return null;
- return new URL("file", "", path);
- } catch (Exception ex) {
- ex.printStackTrace();
- return null;
- }
- }
-
- /**
- * Add elements from the classpath <i>cp </i> to a Vector <i>jars </i> as
- * file URLs (We use Vector for JDK 1.1 compat).
- * <p>
- *
- * @param jars The jar list
- * @param cp a String classpath of directory or jar file elements
- * separated by path.separator delimiters.
- * @throws IOException If an I/O error occurs
- * @throws MalformedURLException Doh ;)
- */
- public static void addJarsFromClassPath(Vector jars, String cp)
- throws IOException, MalformedURLException {
- String sep = System.getProperty("path.separator");
- String token;
- StringTokenizer st;
- if (cp != null) {
- st = new StringTokenizer(cp, sep);
- while (st.hasMoreTokens()) {
- File f = new File(st.nextToken());
- String path = f.getCanonicalPath();
- if (f.isDirectory()) {
- path += "/";
- }
- URL url = new URL("file", "", path);
- if (!jars.contains(url)) {
- jars.addElement(url);
- }
- }
- }
- }
-
- /**
- * Return a URL[] that can be used to construct a class loader
- */
- public static URL[] getClassPath(Vector v) {
- URL[] urls = new URL[v.size()];
- for (int i = 0; i < v.size(); i++) {
- urls[i] = (URL) v.elementAt(i);
- }
- return urls;
- }
-
- /**
- * Construct a URL classpath from files in a directory, a cpath property,
- * and tools.jar.
- */
- public static URL[] getClassPath(String dir, String cpath,
- String cpathProp, boolean addTools) throws IOException,
- MalformedURLException {
- Vector jarsV = new Vector();
- if (dir != null) {
- // Add dir/classes first, if it exists
- URL url = getURL(dir, "classes");
- if (url != null)
- jarsV.addElement(url);
- addToClassPath(jarsV, dir);
- }
-
- if (cpath != null)
- addJarsFromClassPath(jarsV, cpath);
-
- if (cpathProp != null) {
- String cpath1 = System.getProperty(cpathProp);
- addJarsFromClassPath(jarsV, cpath1);
- }
-
- if (addTools)
- addToolsJar(jarsV);
-
- return getClassPath(jarsV);
- }
-
- // -------------------- Mapping command line params to setters
-
- public static boolean processArgs(Object proxy, String args[])
- throws Exception {
- String args0[] = null;
- if (null != findMethod(proxy.getClass(), "getOptions1", new Class[] {})) {
- args0 = (String[]) callMethod0(proxy, "getOptions1");
- }
-
- if (args0 == null) {
- //args0=findVoidSetters(proxy.getClass());
- args0 = findBooleanSetters(proxy.getClass());
- }
- Hashtable h = null;
- if (null != findMethod(proxy.getClass(), "getOptionAliases",
- new Class[] {})) {
- h = (Hashtable) callMethod0(proxy, "getOptionAliases");
- }
- return processArgs(proxy, args, args0, null, h);
- }
-
- public static boolean processArgs(Object proxy, String args[],
- String args0[], String args1[], Hashtable aliases) throws Exception {
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.startsWith("-"))
- arg = arg.substring(1);
- if (aliases != null && aliases.get(arg) != null)
- arg = (String) aliases.get(arg);
-
- if (args0 != null) {
- boolean set = false;
- for (int j = 0; j < args0.length; j++) {
- if (args0[j].equalsIgnoreCase(arg)) {
- setProperty(proxy, args0[j], "true");
- set = true;
- break;
- }
- }
- if (set)
- continue;
- }
- if (args1 != null) {
- for (int j = 0; j < args1.length; j++) {
- if (args1[j].equalsIgnoreCase(arg)) {
- i++;
- if (i >= args.length)
- return false;
- setProperty(proxy, arg, args[i]);
- break;
- }
- }
- } else {
- // if args1 is not specified,assume all other options have param
- i++;
- if (i >= args.length)
- return false;
- setProperty(proxy, arg, args[i]);
- }
-
- }
- return true;
- }
-
- // -------------------- other utils --------------------
- public static void clear() {
- objectMethods.clear();
- }
-
- public static String[] findVoidSetters(Class c) {
- Method m[] = findMethods(c);
- if (m == null)
- return null;
- Vector v = new Vector();
- for (int i = 0; i < m.length; i++) {
- if (m[i].getName().startsWith("set")
- && m[i].getParameterTypes().length == 0) {
- String arg = m[i].getName().substring(3);
- v.addElement(unCapitalize(arg));
- }
- }
- String s[] = new String[v.size()];
- for (int i = 0; i < s.length; i++) {
- s[i] = (String) v.elementAt(i);
- }
- return s;
- }
-
- public static String[] findBooleanSetters(Class c) {
- Method m[] = findMethods(c);
- if (m == null)
- return null;
- Vector v = new Vector();
- for (int i = 0; i < m.length; i++) {
- if (m[i].getName().startsWith("set")
- && m[i].getParameterTypes().length == 1
- && "boolean".equalsIgnoreCase(m[i].getParameterTypes()[0]
- .getName())) {
- String arg = m[i].getName().substring(3);
- v.addElement(unCapitalize(arg));
- }
- }
- String s[] = new String[v.size()];
- for (int i = 0; i < s.length; i++) {
- s[i] = (String) v.elementAt(i);
- }
- return s;
- }
-
- static Hashtable objectMethods = new Hashtable();
-
- public static Method[] findMethods(Class c) {
- Method methods[] = (Method[]) objectMethods.get(c);
- if (methods != null)
- return methods;
-
- methods = c.getMethods();
- objectMethods.put(c, methods);
- return methods;
- }
-
- public static Method findMethod(Class c, String name, Class params[]) {
- Method methods[] = findMethods(c);
- if (methods == null)
- return null;
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().equals(name)) {
- Class methodParams[] = methods[i].getParameterTypes();
- if (methodParams == null)
- if (params == null || params.length == 0)
- return methods[i];
- if (params == null)
- if (methodParams == null || methodParams.length == 0)
- return methods[i];
- if (params.length != methodParams.length)
- continue;
- boolean found = true;
- for (int j = 0; j < params.length; j++) {
- if (params[j] != methodParams[j]) {
- found = false;
- break;
- }
- }
- if (found)
- return methods[i];
- }
- }
- return null;
- }
-
- /** Test if the object implements a particular
- * method
- */
- public static boolean hasHook(Object obj, String methodN) {
- try {
- Method myMethods[] = findMethods(obj.getClass());
- for (int i = 0; i < myMethods.length; i++) {
- if (methodN.equals(myMethods[i].getName())) {
- // check if it's overriden
- Class declaring = myMethods[i].getDeclaringClass();
- Class parentOfDeclaring = declaring.getSuperclass();
- // this works only if the base class doesn't extend
- // another class.
-
- // if the method is declared in a top level class
- // like BaseInterceptor parent is Object, otherwise
- // parent is BaseInterceptor or an intermediate class
- if (!"java.lang.Object".equals(parentOfDeclaring.getName())) {
- return true;
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
- public static void callMain(Class c, String args[]) throws Exception {
- Class p[] = new Class[1];
- p[0] = args.getClass();
- Method m = c.getMethod("main", p);
- m.invoke(c, new Object[] { args });
- }
-
- public static Object callMethod1(Object target, String methodN,
- Object param1, String typeParam1, ClassLoader cl) throws Exception {
- if (target == null || param1 == null) {
- d("Assert: Illegal params " + target + " " + param1);
- }
- if (dbg > 0)
- d("callMethod1 " + target.getClass().getName() + " "
- + param1.getClass().getName() + " " + typeParam1);
-
- Class params[] = new Class[1];
- if (typeParam1 == null)
- params[0] = param1.getClass();
- else
- params[0] = cl.loadClass(typeParam1);
- Method m = findMethod(target.getClass(), methodN, params);
- if (m == null)
- throw new NoSuchMethodException(target.getClass().getName() + " "
- + methodN);
- return m.invoke(target, new Object[] { param1 });
- }
-
- public static Object callMethod0(Object target, String methodN)
- throws Exception {
- if (target == null) {
- d("Assert: Illegal params " + target);
- return null;
- }
- if (dbg > 0)
- d("callMethod0 " + target.getClass().getName() + "." + methodN);
-
- Class params[] = new Class[0];
- Method m = findMethod(target.getClass(), methodN, params);
- if (m == null)
- throw new NoSuchMethodException(target.getClass().getName() + " "
- + methodN);
- return m.invoke(target, emptyArray);
- }
-
- static Object[] emptyArray = new Object[] {};
-
- public static Object callMethodN(Object target, String methodN,
- Object params[], Class typeParams[]) throws Exception {
- Method m = null;
- m = findMethod(target.getClass(), methodN, typeParams);
- if (m == null) {
- d("Can't find method " + methodN + " in " + target + " CLASS "
- + target.getClass());
- return null;
- }
- Object o = m.invoke(target, params);
-
- if (dbg > 0) {
- // debug
- StringBuilder sb = new StringBuilder();
- sb.append("" + target.getClass().getName() + "." + methodN + "( ");
- for (int i = 0; i < params.length; i++) {
- if (i > 0)
- sb.append(", ");
- sb.append(params[i]);
- }
- sb.append(")");
- d(sb.toString());
- }
- return o;
- }
-
- public static Object convert(String object, Class paramType) {
- Object result = null;
- if ("java.lang.String".equals(paramType.getName())) {
- result = object;
- } else if ("java.lang.Integer".equals(paramType.getName())
- || "int".equals(paramType.getName())) {
- try {
- result = new Integer(object);
- } catch (NumberFormatException ex) {
- }
- // Try a setFoo ( boolean )
- } else if ("java.lang.Boolean".equals(paramType.getName())
- || "boolean".equals(paramType.getName())) {
- result = new Boolean(object);
-
- // Try a setFoo ( InetAddress )
- } else if ("java.net.InetAddress".equals(paramType
- .getName())) {
- try {
- result = InetAddress.getByName(object);
- } catch (UnknownHostException exc) {
- d("Unable to resolve host name:" + object);
- }
-
- // Unknown type
- } else {
- d("Unknown type " + paramType.getName());
- }
- if (result == null) {
- throw new IllegalArgumentException("Can't convert argument: " + object);
- }
- return result;
- }
-
- // -------------------- Get property --------------------
- // This provides a layer of abstraction
-
- public static interface PropertySource {
-
- public String getProperty(String key);
-
- }
-
- public static interface AttributeHolder {
-
- public void setAttribute(String key, Object o);
-
- }
-
// debug --------------------
static final int dbg = 0;
15 years, 9 months
JBossWeb SVN: r1430 - trunk/java/org/apache/tomcat/util/net.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-04-05 10:15:03 -0400 (Mon, 05 Apr 2010)
New Revision: 1430
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
Log:
- If 0, don't default to no timeout.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-04-02 15:20:58 UTC (rev 1429)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-04-05 14:15:03 UTC (rev 1430)
@@ -1497,7 +1497,7 @@
*/
public void add(long socket) {
int timeout = keepAliveTimeout;
- if (timeout < 0) {
+ if (timeout <= 0) {
timeout = soTimeout;
}
if (timeout <= 0) {
15 years, 9 months