[jboss-cvs] JBossAS SVN: r83214 - in projects/naming/tags: 5.0.1.GA and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 21 21:53:57 EST 2009
Author: scott.stark at jboss.org
Date: 2009-01-21 21:53:56 -0500 (Wed, 21 Jan 2009)
New Revision: 83214
Added:
projects/naming/tags/5.0.1.GA/
projects/naming/tags/5.0.1.GA/jnpclient/.classpath
projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs
projects/naming/tags/5.0.1.GA/jnpclient/pom.xml
projects/naming/tags/5.0.1.GA/jnpserver/.classpath
projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs
projects/naming/tags/5.0.1.GA/jnpserver/pom.xml
projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java
projects/naming/tags/5.0.1.GA/pom.xml
Removed:
projects/naming/tags/5.0.1.GA/jnpclient/.classpath
projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs
projects/naming/tags/5.0.1.GA/jnpclient/pom.xml
projects/naming/tags/5.0.1.GA/jnpserver/.classpath
projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs
projects/naming/tags/5.0.1.GA/jnpserver/pom.xml
projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java
projects/naming/tags/5.0.1.GA/pom.xml
Log:
[maven-release-plugin] copy for tag 5.0.1.GA
Copied: projects/naming/tags/5.0.1.GA (from rev 83187, projects/naming/branches/Branch_5_0)
Deleted: projects/naming/tags/5.0.1.GA/jnpclient/.classpath
===================================================================
--- projects/naming/branches/Branch_5_0/jnpclient/.classpath 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpclient/.classpath 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,6 +0,0 @@
-<classpath>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.7.GA/jboss-common-core-2.2.7.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.7.GA/jboss-common-core-2.2.7.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
-</classpath>
\ No newline at end of file
Copied: projects/naming/tags/5.0.1.GA/jnpclient/.classpath (from rev 83195, projects/naming/branches/Branch_5_0/jnpclient/.classpath)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpclient/.classpath (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpclient/.classpath 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,6 @@
+<classpath>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+</classpath>
\ No newline at end of file
Deleted: projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/naming/branches/Branch_5_0/jnpclient/.settings/org.eclipse.jdt.core.prefs 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,5 +0,0 @@
-#Tue Nov 18 17:16:09 CET 2008
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.source=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
Copied: projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs (from rev 83195, projects/naming/branches/Branch_5_0/jnpclient/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpclient/.settings/org.eclipse.jdt.core.prefs 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,5 @@
+#Wed Jan 21 17:52:18 PST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Deleted: projects/naming/tags/5.0.1.GA/jnpclient/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/jnpclient/pom.xml 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpclient/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,69 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!-- Parent -->
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4-beta-2</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jnp-client</artifactId>
- <name>JBoss Naming Client</name>
- <version>5.0.1-SNAPSHOT</version>
- <description>The JBoss Naming Client</description>
- <url>http://www.jboss.org</url>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>buildjar</id>
- <phase>package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <jar jarfile="${basedir}/target/jnp-client-${project.version}.jar" update="true" manifest="${basedir}/../jnpserver/src/etc/default.mf">
- <fileset dir="${basedir}/../jnpserver/target/classes">
- <include name="org/jnp/interfaces/**" />
- <include name="org/jnp/server/NamingServer_Stub.class" />
- <include name="org/jboss/naming/**" />
- </fileset>
- <fileset file="${basedir}/../JBossORG-EULA.txt" />
- </jar>
- </tasks>
- </configuration>
- </execution>
- </executions>
- <inherited>true</inherited>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>2.2.10.GA</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>2.0.5.GA</version>
- </dependency>
- <!--
- The jnp-client module depends on the jnpserver module at build time
- in order to copy the classes, but not at runtime.
- <dependency>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jnpserver</artifactId>
- <version>${project.version}</version>
- </dependency>
- -->
- </dependencies>
-</project>
Copied: projects/naming/tags/5.0.1.GA/jnpclient/pom.xml (from rev 83213, projects/naming/branches/Branch_5_0/jnpclient/pom.xml)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpclient/pom.xml (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpclient/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,69 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4-beta-2</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnp-client</artifactId>
+ <name>JBoss Naming Client</name>
+ <version>5.0.1.GA</version>
+ <description>The JBoss Naming Client</description>
+ <url>http://www.jboss.org</url>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>buildjar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <jar jarfile="${basedir}/target/jnp-client-${project.version}.jar" update="true" manifest="${basedir}/../jnpserver/src/etc/default.mf">
+ <fileset dir="${basedir}/../jnpserver/target/classes">
+ <include name="org/jnp/interfaces/**" />
+ <include name="org/jnp/server/NamingServer_Stub.class" />
+ <include name="org/jboss/naming/**" />
+ </fileset>
+ <fileset file="${basedir}/../JBossORG-EULA.txt" />
+ </jar>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ <inherited>true</inherited>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.10.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.5.GA</version>
+ </dependency>
+ <!--
+ The jnp-client module depends on the jnpserver module at build time
+ in order to copy the classes, but not at runtime.
+ <dependency>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnpserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ -->
+ </dependencies>
+</project>
Deleted: projects/naming/tags/5.0.1.GA/jnpserver/.classpath
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/.classpath 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpserver/.classpath 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,30 +0,0 @@
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
- <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.8.GA/jboss-common-core-2.2.8.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.8.GA/jboss-common-core-2.2.8.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR2/jboss-dependency-2.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR2/jboss-dependency-2.0.0.CR2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR2/jboss-kernel-2.0.0.CR2.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR2/jboss-kernel-2.0.0.CR2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR1/jboss-managed-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR1/jboss-managed-2.0.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.CR3/jboss-mdr-2.0.0.CR3.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.0.CR3/jboss-mdr-2.0.0.CR3-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR1/jboss-metatype-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR1/jboss-metatype-2.0.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR13/jbossxb-2.0.0.CR13.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.CR13/jbossxb-2.0.0.CR13-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
-</classpath>
\ No newline at end of file
Copied: projects/naming/tags/5.0.1.GA/jnpserver/.classpath (from rev 83195, projects/naming/branches/Branch_5_0/jnpserver/.classpath)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpserver/.classpath (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpserver/.classpath 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,32 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+ <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.GA/jboss-reflect-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.GA/jboss-reflect-2.0.0.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar" sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/svn/repository.jboss.org/maven2/junit/junit/3.8.2/junit-3.8.2-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+</classpath>
\ No newline at end of file
Deleted: projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/.settings/org.eclipse.jdt.core.prefs 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,5 +0,0 @@
-#Tue Nov 18 17:16:09 CET 2008
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.source=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
Copied: projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs (from rev 83195, projects/naming/branches/Branch_5_0/jnpserver/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpserver/.settings/org.eclipse.jdt.core.prefs 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,5 @@
+#Wed Jan 21 17:52:18 PST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Deleted: projects/naming/tags/5.0.1.GA/jnpserver/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/pom.xml 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpserver/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,99 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!-- Parent -->
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4-beta-2</version>
- </parent>
-
- <version>5.0.1-SNAPSHOT</version>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jnpserver</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Naming Server</name>
- <url>http://www.jboss.org</url>
- <description>The JBoss JNDI Server</description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/naming/branches/Branch_5_0</connection>
- </scm>
- <!-- Properties -->
- <properties>
- <!-- compile dependencies -->
- <version.org.jboss.logging.spi>2.0.5.GA</version.org.jboss.logging.spi>
- <version.org.jboss.common.core>2.2.10.GA</version.org.jboss.common.core>
- <!-- testing dependencies -->
- <version.org.jboss.microcontainer>2.0.0.CR5</version.org.jboss.microcontainer>
- <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
- <version.junit>3.8.2</version.junit>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/client.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rmic-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rmi-compile</id>
- <goals>
- <goal>rmic</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.outputDirectory}</outputDirectory>
- <includes>
- <include>org/jnp/server/NamingServer.class</include>
- </includes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.org.jboss.common.core}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${version.org.jboss.logging.spi}</version>
- </dependency>
-
- <!-- test dependencing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- <version>${version.org.jboss.microcontainer}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>${version.org.jboss.test}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
Copied: projects/naming/tags/5.0.1.GA/jnpserver/pom.xml (from rev 83213, projects/naming/branches/Branch_5_0/jnpserver/pom.xml)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpserver/pom.xml (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpserver/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,99 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4-beta-2</version>
+ </parent>
+
+ <version>5.0.1.GA</version>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnpserver</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Naming Server</name>
+ <url>http://www.jboss.org</url>
+ <description>The JBoss JNDI Server</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/naming/tags/5.0.1.GA</connection>
+ </scm>
+ <!-- Properties -->
+ <properties>
+ <!-- compile dependencies -->
+ <version.org.jboss.logging.spi>2.0.5.GA</version.org.jboss.logging.spi>
+ <version.org.jboss.common.core>2.2.10.GA</version.org.jboss.common.core>
+ <!-- testing dependencies -->
+ <version.org.jboss.microcontainer>2.0.0.CR5</version.org.jboss.microcontainer>
+ <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
+ <version.junit>3.8.2</version.junit>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/client.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rmic-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>rmi-compile</id>
+ <goals>
+ <goal>rmic</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <includes>
+ <include>org/jnp/server/NamingServer.class</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- compile dependencies -->
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.org.jboss.common.core}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.org.jboss.logging.spi}</version>
+ </dependency>
+
+ <!-- test dependencing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.org.jboss.microcontainer}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.org.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Deleted: projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,1840 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jnp.interfaces;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.SerializablePermission;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.ReflectPermission;
-import java.net.DatagramPacket;
-import java.net.InetAddress;
-import java.net.MulticastSocket;
-import java.net.Socket;
-import java.net.InetSocketAddress;
-import java.rmi.ConnectException;
-import java.rmi.MarshalledObject;
-import java.rmi.NoSuchObjectException;
-import java.rmi.RemoteException;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-import javax.naming.Binding;
-import javax.naming.CannotProceedException;
-import javax.naming.CommunicationException;
-import javax.naming.ConfigurationException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.InvalidNameException;
-import javax.naming.LinkRef;
-import javax.naming.Name;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.NotContextException;
-import javax.naming.ContextNotEmptyException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.ServiceUnavailableException;
-import javax.naming.event.EventContext;
-import javax.naming.event.NamingListener;
-import javax.naming.spi.NamingManager;
-import javax.naming.spi.ResolveResult;
-import javax.net.SocketFactory;
-
-import org.jboss.logging.Logger;
-
-/**
- * This class provides the jnp provider Context implementation. It is a Context
- * interface wrapper for a RMI Naming instance that is obtained from either the
- * local server instance or by locating the server given by the
- * Context.PROVIDER_URL value.
- *
- * This class also serves as the jnp url resolution context. jnp style urls
- * passed to the
- * @author oberg
- * @author scott.stark at jboss.org
- * @version $Revision$
- */
-public class NamingContext
- implements EventContext, java.io.Serializable
-{
- // Constants -----------------------------------------------------
- /**
- * @since 1.7
- */
- static final long serialVersionUID = 8906455608484282128L;
- /**
- * The javax.net.SocketFactory impl to use for the bootstrap socket
- */
- public static final String JNP_SOCKET_FACTORY = "jnp.socketFactory";
- /**
- * The local address to bind the connected bootstrap socket to
- */
- public static final String JNP_LOCAL_ADDRESS = "jnp.localAddress";
- /**
- * The local port to bind the connected bootstrap socket to
- */
- public static final String JNP_LOCAL_PORT = "jnp.localPort";
- /**
- * A flag to disable the broadcast discovery queries
- */
- public static final String JNP_DISABLE_DISCOVERY = "jnp.disableDiscovery";
- /**
- * The cluster partition discovery should be restricted to
- */
- public static final String JNP_PARTITION_NAME = "jnp.partitionName";
- /**
- * The multicast IP/address to which the discovery query is sent
- */
- public static final String JNP_DISCOVERY_GROUP = "jnp.discoveryGroup";
- /**
- * The port to which the discovery query is sent
- */
- public static final String JNP_DISCOVERY_PORT = "jnp.discoveryPort";
-
- /** The time-to-live for the multicast discovery packets */
- public static final String JNP_DISCOVERY_TTL = "jnp.discoveryTTL";
-
- /**
- * The time in MS to wait for a discovery query response
- */
- public static final String JNP_DISCOVERY_TIMEOUT = "jnp.discoveryTimeout";
- /**
- * An internal property added by parseNameForScheme if the input name uses a
- * url prefix that was removed during cannonicalization. This is needed to
- * avoid modification of the incoming Name.
- */
- public static final String JNP_PARSED_NAME = "jnp.parsedName";
- /**
- * A flag indicating the style of names passed to NamingManager method.
- * True for api expected relative names, false for absolute names as used
- * historically by the jboss naming implementation.
- */
- public static final String JNP_USE_RELATIVE_NAME = "jnp.useRelativeName";
- /**
- * An integer that controls the number of connection retry attempts will
- * be made on the initial connection to the naming server. This only applies
- * to ConnectException failures. A value <= 1 means that only one attempt
- * will be made.
- */
- public static final String JNP_MAX_RETRIES = "jnp.maxRetries";
- /**
- * The Naming instance to use for the root Context creation
- */
- public static final String JNP_NAMING_INSTANCE = "jnp.namingInstance";
- /**
- * The name to associate with Naming instance to use for the root Context
- */
- public static final String JNP_NAMING_INSTANCE_NAME = "jnp.namingInstanceName";
-
- /**
- * The default discovery multicast information
- */
- public final static String DEFAULT_DISCOVERY_GROUP_ADDRESS = "230.0.0.4";
- public final static int DEFAULT_DISCOVERY_GROUP_PORT = 1102;
- public final static int DEFAULT_DISCOVERY_TIMEOUT = 5000;
-
- /**
- * An obsolete constant replaced by the JNP_MAX_RETRIES value
- */
- public static int MAX_RETRIES = 1;
- /**
- * The JBoss logging interface
- */
- private static Logger log = Logger.getLogger(NamingContext.class);
-
- // Static --------------------------------------------------------
- /** HAJNDI keyed by partition name */
- private static Hashtable haServers = new Hashtable();
- private static RuntimePermission GET_HA_NAMING_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.getHANamingServerForPartition");
- private static RuntimePermission SET_HA_NAMING_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.setHANamingServerForPartition");
- public static void setHANamingServerForPartition(String partitionName, Naming haServer)
- {
- SecurityManager security = System.getSecurityManager();
- if(security != null)
- security.checkPermission(SET_HA_NAMING_SERVER);
- haServers.put(partitionName, haServer);
- }
-
- public static void removeHANamingServerForPartition(String partitionName)
- {
- SecurityManager security = System.getSecurityManager();
- if(security != null)
- security.checkPermission(SET_HA_NAMING_SERVER);
- haServers.remove(partitionName);
- }
-
- public static Naming getHANamingServerForPartition(String partitionName)
- {
- SecurityManager security = System.getSecurityManager();
- if(security != null)
- security.checkPermission(GET_HA_NAMING_SERVER);
- return (Naming) haServers.get(partitionName);
- }
-
- /**
- * The jvm local server used for non-transport access to the naming
- * server
- * @see #checkRef(Hashtable)
- * @see {@linkplain LocalOnlyContextFactory}
- */
- private static Naming localServer;
- private static RuntimePermission GET_LOCAL_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.getLocal");
- private static RuntimePermission SET_LOCAL_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.setLocal");
-
- // Attributes ----------------------------------------------------
- Naming naming;
- Hashtable env;
- Name prefix;
-
- NameParser parser = new NamingParser();
-
- // Static --------------------------------------------------------
-
- // Cache of naming server stubs
- // This is a critical optimization in the case where new InitialContext
- // is performed often. The server stub will be shared between all those
- // calls, which will improve performance.
- // Weak references are used so if no contexts use a particular server
- // it will be removed from the cache.
- static HashMap cachedServers = new HashMap();
-
- static void addServer(String name, Naming server)
- {
- // Add server to map
- synchronized (NamingContext.class)
- {
- cachedServers.put(name, new WeakReference(server));
- }
- }
-
- static Naming getServer(String host, int port, Hashtable serverEnv)
- throws NamingException
- {
- // Check the server cache for a host:port entry
- String hostKey = host + ":" + port;
- WeakReference ref = (WeakReference) cachedServers.get(hostKey);
- Naming server;
- if (ref != null)
- {
- server = (Naming) ref.get();
- if (server != null)
- {
- // JBAS-4622. Ensure the env for the request has the
- // hostKey so we can remove the cache entry if there is a failure
- serverEnv.put("hostKey", hostKey);
- return server;
- }
- }
-
- // Server not found; add it to cache
- try
- {
- SocketFactory factory = loadSocketFactory(serverEnv);
- Socket s;
-
- try
- {
- InetAddress localAddr = null;
- int localPort = 0;
- String localAddrStr = (String) serverEnv.get(JNP_LOCAL_ADDRESS);
- String localPortStr = (String) serverEnv.get(JNP_LOCAL_PORT);
- if (localAddrStr != null)
- localAddr = InetAddress.getByName(localAddrStr);
- if (localPortStr != null)
- localPort = Integer.parseInt(localPortStr);
- s = factory.createSocket(host, port, localAddr, localPort);
- }
- catch (IOException e)
- {
- NamingException ex = new ServiceUnavailableException("Failed to connect to server " + hostKey);
- ex.setRootCause(e);
- throw ex;
- }
-
- // Get stub from naming server
- BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
- ObjectInputStream in = new ObjectInputStream(bis);
- MarshalledObject stub = (MarshalledObject) in.readObject();
- server = (Naming) stub.get();
- s.close();
-
- // Add it to cache
- addServer(hostKey, server);
- serverEnv.put("hostKey", hostKey);
-
- return server;
- }
- catch (IOException e)
- {
- if(log.isTraceEnabled())
- log.trace("Failed to retrieve stub from server " + hostKey, e);
- NamingException ex = new CommunicationException("Failed to retrieve stub from server " + hostKey);
- ex.setRootCause(e);
- throw ex;
- }
- catch (Exception e)
- {
- if(log.isTraceEnabled())
- log.trace("Failed to connect server " + hostKey, e);
- NamingException ex = new CommunicationException("Failed to connect to server " + hostKey);
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- /**
- * Create a SocketFactory based on the JNP_SOCKET_FACTORY property in the
- * given env. If JNP_SOCKET_FACTORY is not specified default to the
- * TimedSocketFactory.
- */
- static SocketFactory loadSocketFactory(Hashtable serverEnv)
- throws ClassNotFoundException, IllegalAccessException,
- InstantiationException, InvocationTargetException
- {
- SocketFactory factory = null;
-
- // Get the socket factory classname
- String socketFactoryName = (String) serverEnv.get(JNP_SOCKET_FACTORY);
- if (socketFactoryName == null ||
- socketFactoryName.equals(TimedSocketFactory.class.getName()))
- {
- factory = new TimedSocketFactory(serverEnv);
- return factory;
- }
-
- /* Create the socket factory. Look for a ctor that accepts a
- Hashtable and if not found use the default ctor.
- */
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class factoryClass = loader.loadClass(socketFactoryName);
- try
- {
- Class[] ctorSig = {Hashtable.class};
- Constructor ctor = factoryClass.getConstructor(ctorSig);
- Object[] ctorArgs = {serverEnv};
- factory = (SocketFactory) ctor.newInstance(ctorArgs);
- }
- catch (NoSuchMethodException e)
- {
- // Use the default ctor
- factory = (SocketFactory) factoryClass.newInstance();
- }
- return factory;
- }
-
- static void removeServer(Hashtable serverEnv)
- {
- String host = "localhost";
- int port = 1099;
-
- // Locate naming service
- if (serverEnv.get(Context.PROVIDER_URL) != null)
- {
- String providerURL = (String) serverEnv.get(Context.PROVIDER_URL);
-
- StringTokenizer tokenizer = new StringTokenizer(providerURL, ", ");
- while (tokenizer.hasMoreElements())
- {
- String url = tokenizer.nextToken();
-
- try
- {
- // Parse the url into a host:port form, stripping any protocol
- Name urlAsName = new NamingParser().parse(url);
- String server = parseNameForScheme(urlAsName, null);
- if (server != null)
- url = server;
- int colon = url.indexOf(':');
- if (colon < 0)
- {
- host = url.trim();
- }
- else
- {
- host = url.substring(0, colon).trim();
- try
- {
- port = Integer.parseInt(url.substring(colon + 1).trim());
- }
- catch (Exception ex)
- {
- // Use default;
- }
- }
-
- // Remove server from map
- synchronized (NamingContext.class)
- {
- cachedServers.remove(host + ":" + port);
- }
- }
- catch (NamingException ignored)
- {
- }
- }
- }
-
- // JBAS-4622. Always do this.
- Object hostKey = serverEnv.remove("hostKey");
- if (hostKey != null)
- {
- synchronized (NamingContext.class)
- {
- cachedServers.remove(hostKey);
- }
- }
- }
-
- /**
- * Called to remove any url scheme atoms and extract the naming service
- * hostname:port information.
- * @param n the name component to the parsed. After returning n will have all
- * scheme related atoms removed.
- * @return the naming service hostname:port information string if name
- * contained the host information.
- */
- static String parseNameForScheme(Name n, Hashtable nameEnv)
- throws InvalidNameException
- {
- String serverInfo = null;
- if (n.size() > 0)
- {
- String scheme = n.get(0);
- int schemeLength = 0;
- if (scheme.startsWith("java:"))
- schemeLength = 5;
- else if (scheme.startsWith("jnp:"))
- schemeLength = 4;
- else if (scheme.startsWith("jnps:"))
- schemeLength = 5;
- else if (scheme.startsWith("jnp-http:"))
- schemeLength = 9;
- else if (scheme.startsWith("jnp-https:"))
- schemeLength = 10;
- if (schemeLength > 0)
- {
- // Make a copy of the name to avoid
- n = (Name) n.clone();
- String suffix = scheme.substring(schemeLength);
- if (suffix.length() == 0)
- {
- // Scheme was "url:/..."
- n.remove(0);
- if (n.size() > 1 && n.get(0).equals(""))
- {
- // Scheme was "url://hostname:port/..."
- // Get hostname:port value for the naming server
- serverInfo = n.get(1);
- n.remove(0);
- n.remove(0);
- // If n is a empty atom remove it or else a '/' will result
- if (n.size() == 1 && n.get(0).length() == 0)
- n.remove(0);
- }
- }
- else
- {
- // Scheme was "url:foo" -> reinsert "foo"
- n.remove(0);
- n.add(0, suffix);
- }
- if (nameEnv != null)
- nameEnv.put(JNP_PARSED_NAME, n);
- }
- }
- return serverInfo;
- }
-
- public static Naming getLocal()
- {
- SecurityManager security = System.getSecurityManager();
- if(security != null)
- security.checkPermission(GET_LOCAL_SERVER);
- return localServer;
- }
- public static void setLocal(Naming server)
- {
- SecurityManager security = System.getSecurityManager();
- if(security != null)
- security.checkPermission(SET_LOCAL_SERVER);
- localServer = server;
- }
-
- // Constructors --------------------------------------------------
- public NamingContext(Hashtable e, Name baseName, Naming server)
- throws NamingException
- {
- if (baseName == null)
- this.prefix = parser.parse("");
- else
- this.prefix = baseName;
-
- if (e != null)
- this.env = (Hashtable) e.clone();
- else
- this.env = new Hashtable();
-
- this.naming = server;
- }
-
- // Public --------------------------------------------------------
- public Naming getNaming()
- {
- return this.naming;
- }
-
- public void setNaming(Naming server)
- {
- this.naming = server;
- }
-
- // Context implementation ----------------------------------------
- public void rebind(String name, Object obj)
- throws NamingException
- {
- rebind(getNameParser(name).parse(name), obj);
- }
-
- public void rebind(Name name, Object obj)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- // Allow state factories to change the stored object
- obj = getStateToBind(obj, name, refEnv);
-
- try
- {
- String className = null;
-
- // Referenceable
- if (obj instanceof Referenceable)
- obj = ((Referenceable) obj).getReference();
-
- if (!(obj instanceof Reference))
- {
- if( obj != null )
- className = obj.getClass().getName();
- obj = createMarshalledValuePair(obj);
- }
- else
- {
- className = ((Reference) obj).getClassName();
- }
- try
- {
- naming.rebind(getAbsoluteName(name), obj, className);
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- naming.rebind(getAbsoluteName(name), obj, className);
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- cctx.rebind(cpe.getRemainingName(), obj);
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public void bind(String name, Object obj)
- throws NamingException
- {
- bind(getNameParser(name).parse(name), obj);
- }
-
- public void bind(Name name, Object obj)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- // Allow state factories to change the stored object
- obj = getStateToBind(obj, name, refEnv);
-
- try
- {
- String className = null;
-
- // Referenceable
- if (obj instanceof Referenceable)
- obj = ((Referenceable) obj).getReference();
-
- if (!(obj instanceof Reference))
- {
- if( obj != null )
- className = obj.getClass().getName();
-
- // Normal object - serialize using a MarshalledValuePair
- obj = createMarshalledValuePair(obj);
- }
- else
- {
- className = ((Reference) obj).getClassName();
- }
- name = getAbsoluteName(name);
-
- try
- {
- naming.bind(name, obj, className);
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- naming.bind(name, obj, className);
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- cctx.bind(cpe.getRemainingName(), obj);
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public Object lookup(String name)
- throws NamingException
- {
- return lookup(getNameParser(name).parse(name));
- }
-
- public Object lookup(Name name)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- // Empty?
- if (name.isEmpty())
- return new NamingContext(refEnv, prefix, naming);
-
- try
- {
- int maxTries = 1;
- try
- {
- String n = (String) refEnv.get(JNP_MAX_RETRIES);
- if( n != null )
- maxTries = Integer.parseInt(n);
- if( maxTries <= 0 )
- maxTries = 1;
- }
- catch(Exception e)
- {
- log.debug("Failed to get JNP_MAX_RETRIES, using 1", e);
- }
- Name n = getAbsoluteName(name);
- Object res = null;
- boolean trace = log.isTraceEnabled();
- for (int i = 0; i < maxTries; i++)
- {
- try
- {
- try
- {
- res = naming.lookup(n);
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- res = naming.lookup(n);
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- // If we got here, we succeeded, so break the loop
- break;
- }
- catch (ConnectException ce)
- {
- int retries = maxTries - i - 1;
- if( trace )
- log.trace("Connect failed, retry count: "+retries, ce);
- // We may overload server so sleep and retry
- if (retries > 0)
- {
- try
- {
- Thread.sleep(1);
- }
- catch (InterruptedException ignored)
- {
- }
- continue;
- }
- // Throw the exception to flush the bad server
- throw ce;
- }
- }
- if (res instanceof MarshalledValuePair)
- {
- MarshalledValuePair mvp = (MarshalledValuePair) res;
- Object storedObj = mvp.get();
- return getObjectInstanceWrapFailure(storedObj, name, refEnv);
- }
- else if (res instanceof MarshalledObject)
- {
- MarshalledObject mo = (MarshalledObject) res;
- return mo.get();
- }
- else if (res instanceof Context)
- {
- // Add env
- Enumeration keys = refEnv.keys();
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
- ((Context) res).addToEnvironment(key, refEnv.get(key));
- }
- return res;
- }
- else if (res instanceof ResolveResult)
- {
- // Dereference partial result
- ResolveResult rr = (ResolveResult) res;
- Object resolveRes = rr.getResolvedObj();
- Object context;
- Object instanceID;
-
- if (resolveRes instanceof LinkRef)
- {
- context = resolveLink(resolveRes, null);
- instanceID = ((LinkRef) resolveRes).getLinkName();
- }
- else
- {
- context = getObjectInstanceWrapFailure(resolveRes, name, refEnv);
- instanceID = context;
- }
-
- if ((context instanceof Context) == false)
- {
- throw new NotContextException(instanceID + " is not a Context");
- }
- Context ncontext = (Context) context;
- return ncontext.lookup(rr.getRemainingName());
- }
- else if (res instanceof LinkRef)
- {
- // Dereference link
- res = resolveLink(res, refEnv);
- }
- else if (res instanceof Reference)
- {
- // Dereference object
- res = getObjectInstanceWrapFailure(res, name, refEnv);
- if (res instanceof LinkRef)
- res = resolveLink(res, refEnv);
- }
-
- return res;
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- return cctx.lookup(cpe.getRemainingName());
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- catch (ClassNotFoundException e)
- {
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public void unbind(String name)
- throws NamingException
- {
- unbind(getNameParser(name).parse(name));
- }
-
-
- public void unbind(Name name)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- try
- {
- try
- {
- naming.unbind(getAbsoluteName(name));
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- naming.unbind(getAbsoluteName(name));
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- cctx.unbind(cpe.getRemainingName());
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public void rename(String oldname, String newname)
- throws NamingException
- {
- rename(getNameParser(oldname).parse(oldname), getNameParser(newname).parse(newname));
- }
-
- public void rename(Name oldName, Name newName)
- throws NamingException
- {
- bind(newName, lookup(oldName));
- unbind(oldName);
- }
-
- public NamingEnumeration list(String name)
- throws NamingException
- {
- return list(getNameParser(name).parse(name));
- }
-
- public NamingEnumeration list(Name name)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- try
- {
- Collection c = null;
- try
- {
- c = naming.list(getAbsoluteName(name));
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- c = naming.list(getAbsoluteName(name));
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- return new NamingEnumerationImpl(c);
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- return cctx.list(cpe.getRemainingName());
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public NamingEnumeration listBindings(String name)
- throws NamingException
- {
- return listBindings(getNameParser(name).parse(name));
- }
-
- public NamingEnumeration listBindings(Name name)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- try
- {
- // Get list
- Collection bindings = null;
- try
- {
- // Get list
- bindings = naming.listBindings(getAbsoluteName(name));
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- bindings = naming.listBindings(getAbsoluteName(name));
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- Collection realBindings = new ArrayList(bindings.size());
-
- // Convert marshalled objects
- Iterator i = bindings.iterator();
- while (i.hasNext())
- {
- Binding binding = (Binding) i.next();
- Object obj = binding.getObject();
- if (obj instanceof MarshalledValuePair)
- {
- try
- {
- obj = ((MarshalledValuePair) obj).get();
- }
- catch (ClassNotFoundException e)
- {
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
- else if (obj instanceof MarshalledObject)
- {
- try
- {
- obj = ((MarshalledObject) obj).get();
- }
- catch (ClassNotFoundException e)
- {
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
- realBindings.add(new Binding(binding.getName(), binding.getClassName(), obj));
- }
-
- // Return transformed list of bindings
- return new NamingEnumerationImpl(realBindings);
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- return cctx.listBindings(cpe.getRemainingName());
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public String composeName(String name, String prefix)
- throws NamingException
- {
- Name result = composeName(parser.parse(name),
- parser.parse(prefix));
- return result.toString();
- }
-
- public Name composeName(Name name, Name prefix)
- throws NamingException
- {
- Name result = (Name) (prefix.clone());
- result.addAll(name);
- return result;
- }
-
- public NameParser getNameParser(String name)
- throws NamingException
- {
- return parser;
- }
-
- public NameParser getNameParser(Name name)
- throws NamingException
- {
- return getNameParser(name.toString());
- }
-
- public Context createSubcontext(String name)
- throws NamingException
- {
- return createSubcontext(getNameParser(name).parse(name));
- }
-
- public Context createSubcontext(Name name)
- throws NamingException
- {
- if (name.size() == 0)
- throw new InvalidNameException("Cannot pass an empty name to createSubcontext");
-
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- try
- {
- name = getAbsoluteName(name);
- try
- {
- return naming.createSubcontext(name);
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- return naming.createSubcontext(name);
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- }
- catch (CannotProceedException cpe)
- {
- cpe.setEnvironment(refEnv);
- Context cctx = NamingManager.getContinuationContext(cpe);
- return cctx.createSubcontext(cpe.getRemainingName());
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- public Object addToEnvironment(String propName, Object propVal)
- throws NamingException
- {
- Object old = env.get(propName);
- env.put(propName, propVal);
- return old;
- }
-
- public Object removeFromEnvironment(String propName)
- throws NamingException
- {
- return env.remove(propName);
- }
-
- public Hashtable getEnvironment()
- throws NamingException
- {
- return env;
- }
-
- public void close()
- throws NamingException
- {
- env = null;
- naming = null;
- }
-
- public String getNameInNamespace()
- throws NamingException
- {
- return prefix.toString();
- }
-
- public void destroySubcontext(String name)
- throws NamingException
- {
- destroySubcontext(getNameParser(name).parse(name));
- }
-
- public void destroySubcontext(Name name)
- throws NamingException
- {
- if (!list(name).hasMore())
- {
- unbind(name);
- }
- else
- throw new ContextNotEmptyException();
- }
-
- public Object lookupLink(String name)
- throws NamingException
- {
- return lookupLink(getNameParser(name).parse(name));
- }
-
- /**
- * Lookup the object referred to by name but don't dereferrence the final
- * component. This really just involves returning the raw value returned by
- * the Naming.lookup() method.
- * @return the raw object bound under name.
- */
- public Object lookupLink(Name name)
- throws NamingException
- {
- Hashtable refEnv = getEnv(name);
- checkRef(refEnv);
- Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
- if (parsedName != null)
- name = parsedName;
-
- if (name.isEmpty())
- return lookup(name);
-
- Object link = null;
- try
- {
- Name n = getAbsoluteName(name);
- try
- {
- link = naming.lookup(n);
- }
- catch (RemoteException re)
- {
- // Check for JBAS-4574.
- if (handleStaleNamingStub(re, refEnv))
- {
- // try again with new naming stub
- link = naming.lookup(n);
- }
- else
- {
- // Not JBAS-4574. Throw exception and let outer logic handle it.
- throw re;
- }
- }
- if (!(link instanceof LinkRef) && link instanceof Reference)
- link = getObjectInstance(link, name, null);
- ;
- }
- catch (IOException e)
- {
- naming = null;
- removeServer(refEnv);
- NamingException ex = new CommunicationException();
- ex.setRootCause(e);
- throw ex;
- }
- catch (Exception e)
- {
- NamingException ex = new NamingException("Could not lookup link");
- ex.setRemainingName(name);
- ex.setRootCause(e);
- throw ex;
- }
- return link;
- }
-
- // Begin EventContext methods
- public void addNamingListener(Name target, int scope, NamingListener l)
- throws NamingException
- {
- if((naming instanceof NamingEvents) == false)
- {
- throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
- }
- NamingEvents next = (NamingEvents) naming;
- try
- {
- next.addNamingListener(this, target, scope, l);
- }
- catch (RemoteException e)
- {
- CommunicationException ce = new CommunicationException("addNamingListener failed");
- ce.initCause(e);
- }
- }
-
- public void addNamingListener(String target, int scope, NamingListener l)
- throws NamingException
- {
- Name targetName = parser.parse(target);
- addNamingListener(targetName, scope, l);
- }
-
- public void removeNamingListener(NamingListener l)
- throws NamingException
- {
- if((naming instanceof NamingEvents) == false)
- {
- throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
- }
- NamingEvents next = (NamingEvents) naming;
- try
- {
- next.removeNamingListener(l);
- }
- catch (RemoteException e)
- {
- CommunicationException ce = new CommunicationException("removeNamingListener failed");
- ce.initCause(e);
- }
- }
-
- public boolean targetMustExist()
- throws NamingException
- {
- if((naming instanceof NamingEvents) == false)
- {
- throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
- }
- NamingEvents next = (NamingEvents) naming;
- boolean targetMustExist = true;
- try
- {
- targetMustExist = next.targetMustExist();
- }
- catch (RemoteException e)
- {
- CommunicationException ce = new CommunicationException("removeNamingListener failed");
- ce.initCause(e);
- }
- return targetMustExist;
- }
- // End EventContext methods
-
- protected Object resolveLink(Object res, Hashtable refEnv)
- throws NamingException
- {
- Object linkResult = null;
- try
- {
- LinkRef link = (LinkRef) res;
- String ref = link.getLinkName();
- if (ref.startsWith("./"))
- linkResult = lookup(ref.substring(2));
- else if (refEnv != null)
- linkResult = new InitialContext(refEnv).lookup(ref);
- else
- linkResult = new InitialContext().lookup(ref);
- }
- catch (Exception e)
- {
- NamingException ex = new NamingException("Could not dereference object");
- ex.setRootCause(e);
- throw ex;
- }
- return linkResult;
- }
-
- // Private -------------------------------------------------------
-
- /**
- * Isolate the creation of the MarshalledValuePair in a privileged block
- * when running under a security manager so the following permissions can
- * be isolated from the caller:
- * RuntimePermission("createClassLoader")
- ReflectPermission("suppressAccessChecks")
- SerializablePermission("enableSubstitution")
- @return the MarshalledValuePair wrapping obj
- */
- private Object createMarshalledValuePair(final Object obj)
- throws IOException
- {
- MarshalledValuePair mvp = null;
- SecurityManager sm = System.getSecurityManager();
- if(sm != null)
- {
- try
- {
- mvp = AccessController.doPrivileged(new PrivilegedExceptionAction<MarshalledValuePair>()
- {
- public MarshalledValuePair run() throws Exception
- {
- return new MarshalledValuePair(obj);
- }
- }
- );
- }
- catch(PrivilegedActionException e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e.getException());
- throw ioe;
- }
- }
- else
- {
- mvp = new MarshalledValuePair(obj);
- }
- return mvp;
- }
-
- /**
- * Determine the form of the name to pass to the NamingManager operations.
- * This is supposed to be a context relative name according to the javaodcs
- * for NamingManager, but historically the absolute name of the target
- * context has been passed in.
- *
- * @param env - the env of NamingContext that op was called on
- * @return true if the legacy and technically incorrect absolute name should
- * be used, false if the context relative name should be used.
- */
- private boolean useAbsoluteName(Hashtable env)
- {
- if (env == null)
- return true;
- String useRelativeName = (String) env.get(JNP_USE_RELATIVE_NAME);
- return Boolean.valueOf(useRelativeName) == Boolean.FALSE;
- }
-
- /**
- * Use the NamingManager.getStateToBind to obtain the actual object to bind
- * into jndi.
- * @param obj - the value passed to bind/rebind
- * @param name - the name passed to bind/rebind
- * @param env - the env of NamingContext that bind/rebind was called on
- * @return the object to bind to the naming server
- * @throws NamingException
- */
- private Object getStateToBind(Object obj, Name name, Hashtable env)
- throws NamingException
- {
- if (useAbsoluteName(env))
- name = getAbsoluteName(name);
- return NamingManager.getStateToBind(obj, name, this, env);
- }
-
- /**
- * Use the NamingManager.getObjectInstance to resolve the raw object obtained
- * from the naming server.
- * @param obj - raw value obtained from the naming server
- * @param name - the name passed to the lookup op
- * @param env - the env of NamingContext that the op was called on
- * @return the fully resolved object
- * @throws Exception
- */
- private Object getObjectInstance(Object obj, Name name, Hashtable env)
- throws Exception
- {
- if (useAbsoluteName(env))
- name = getAbsoluteName(name);
- return NamingManager.getObjectInstance(obj, name, this, env);
- }
-
- /**
- * Resolve the final object and wrap any non-NamingException errors in a
- * NamingException with the cause passed as the root cause.
- * @param obj - raw value obtained from the naming server
- * @param name - the name passed to the lookup op
- * @param env - the env of NamingContext that the op was called on
- * @return the fully resolved object
- * @throws NamingException
- */
- private Object getObjectInstanceWrapFailure(Object obj, Name name, Hashtable env)
- throws NamingException
- {
- try
- {
- return getObjectInstance(obj, name, env);
- }
- catch (NamingException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- NamingException ex = new NamingException("Could not dereference object");
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- /**
- * This methods sends a broadcast message on the network and asks and HA-JNDI
- * server to sent it the HA-JNDI stub
- */
- private Naming discoverServer(Hashtable serverEnv) throws NamingException
- {
- boolean trace = log.isTraceEnabled();
- // Check if discovery should be done
- String disableDiscovery = (String) serverEnv.get(JNP_DISABLE_DISCOVERY);
- if (Boolean.valueOf(disableDiscovery) == Boolean.TRUE)
- {
- if (trace)
- log.trace("Skipping discovery due to disable flag");
- return null;
- }
-
- // we first try to discover the server locally
- //
- String partitionName = (String) serverEnv.get(JNP_PARTITION_NAME);
- Naming server = null;
- if (partitionName != null)
- {
- server = getHANamingServerForPartition(partitionName);
- if (server != null)
- return server;
- }
-
- // We next broadcast a HelloWorld datagram (multicast)
- // Any listening server will answer with its IP address:port in another datagram
- // we will then use this to make a standard "lookup"
- //
- MulticastSocket s = null;
- InetAddress iaGroup = null;
- try
- {
- String group = DEFAULT_DISCOVERY_GROUP_ADDRESS;
- int port = DEFAULT_DISCOVERY_GROUP_PORT;
- int timeout = DEFAULT_DISCOVERY_TIMEOUT;
- int ttl = 16;
-
- String discoveryGroup = (String) serverEnv.get(JNP_DISCOVERY_GROUP);
- if (discoveryGroup != null)
- group = discoveryGroup;
-
- String discoveryTTL = (String) serverEnv.get(JNP_DISCOVERY_TTL);
- if(discoveryTTL != null)
- ttl = Integer.parseInt(discoveryTTL);
-
- String discoveryTimeout = (String) serverEnv.get(JNP_DISCOVERY_TIMEOUT);
- if (discoveryTimeout == null)
- {
- // Check the old property name
- discoveryTimeout = (String) serverEnv.get("DISCOVERY_TIMEOUT");
- }
- if (discoveryTimeout != null && !discoveryTimeout.equals(""))
- timeout = Integer.parseInt(discoveryTimeout);
-
- String discoveryGroupPort = (String) serverEnv.get(JNP_DISCOVERY_PORT);
- if (discoveryGroupPort == null)
- {
- // Check the old property name
- discoveryGroupPort = (String) serverEnv.get("DISCOVERY_GROUP");
- }
- if (discoveryGroupPort != null && !discoveryGroupPort.equals(""))
- {
- int colon = discoveryGroupPort.indexOf(':');
- if (colon < 0)
- {
- // No group given, just the port
- try
- {
- port = Integer.parseInt(discoveryGroupPort);
- }
- catch (Exception ex)
- {
- log.warn("Failed to parse port: " + discoveryGroupPort, ex);
- }
- }
- else
- {
- // The old group:port syntax was given
- group = discoveryGroupPort.substring(0, colon);
- String portStr = discoveryGroupPort.substring(colon + 1);
- try
- {
- port = Integer.parseInt(portStr);
- }
- catch (Exception ex)
- {
- log.warn("Failed to parse port: " + portStr, ex);
- }
- }
- }
-
- iaGroup = InetAddress.getByName(group);
- String localAddrStr = (String) serverEnv.get(JNP_LOCAL_ADDRESS);
- String localPortStr = (String) serverEnv.get(JNP_LOCAL_PORT);
- int localPort = 0;
- if (localPortStr != null)
- localPort = Integer.parseInt(localPortStr);
- if (localAddrStr != null)
- {
- InetSocketAddress localAddr = new InetSocketAddress(localAddrStr, localPort);
- s = new MulticastSocket(localAddr);
- }
- else
- {
- s = new MulticastSocket(localPort);
- }
- s.setSoTimeout(timeout);
- s.setTimeToLive(ttl);
- if(log.isTraceEnabled())
- log.trace("TTL on multicast discovery socket is " + ttl);
- s.joinGroup(iaGroup);
- if (trace)
- log.trace("MulticastSocket: " + s);
- DatagramPacket packet;
- // Send a request optionally restricted to a cluster partition
- StringBuffer data = new StringBuffer("GET_ADDRESS");
- if (partitionName != null)
- data.append(":" + partitionName);
- byte[] buf = data.toString().getBytes();
- packet = new DatagramPacket(buf, buf.length, iaGroup, port);
- if (trace)
- log.trace("Sending discovery packet(" + data + ") to: " + iaGroup + ":" + port);
- s.send(packet);
- // Look for a reply
- // IP address + port number = 128.128.128.128:65535 => (12+3) + 1 + (5) = 21
-
- buf = new byte[50];
- packet = new DatagramPacket(buf, buf.length);
- s.receive(packet);
- String myServer = new String(packet.getData()).trim();
- if (trace)
- log.trace("Received answer packet: " + myServer);
- while (myServer != null && myServer.startsWith("GET_ADDRESS"))
- {
- Arrays.fill(buf, (byte) 0);
- packet.setLength(buf.length);
- s.receive(packet);
- byte[] reply = packet.getData();
- myServer = new String(reply).trim();
- if (trace)
- log.trace("Received answer packet: " + myServer);
- }
- String serverHost;
- int serverPort;
-
- int colon = myServer.indexOf(':');
- if (colon >= 0)
- {
- serverHost = myServer.substring(0, colon);
- serverPort = Integer.valueOf(myServer.substring(colon + 1)).intValue();
- server = getServer(serverHost, serverPort, serverEnv);
- }
- return server;
- }
- catch (IOException e)
- {
- if (trace)
- log.trace("Discovery failed", e);
- NamingException ex = new CommunicationException(e.getMessage());
- ex.setRootCause(e);
- throw ex;
- }
- finally
- {
- try
- {
- if (s != null)
- s.leaveGroup(iaGroup);
- }
- catch (Exception ignore)
- {
- }
- try
- {
- if (s != null)
- s.close();
- }
- catch (Exception ignore)
- {
- }
- }
- }
-
- private void checkRef(Hashtable refEnv)
- throws NamingException
- {
- if (naming == null)
- {
- String host = "localhost";
- int port = 1099;
- Exception serverEx = null;
-
- // Locate first available naming service
- String urls = (String) refEnv.get(Context.PROVIDER_URL);
- if (urls != null && urls.length() > 0)
- {
- StringTokenizer tokenizer = new StringTokenizer(urls, ",");
-
- while (naming == null && tokenizer.hasMoreElements())
- {
- String url = tokenizer.nextToken();
- // Parse the url into a host:port form, stripping any protocol
- Name urlAsName = getNameParser("").parse(url);
- String server = parseNameForScheme(urlAsName, null);
- if (server != null)
- url = server;
- int colon = url.indexOf(':');
- if (colon < 0)
- {
- host = url;
- }
- else
- {
- host = url.substring(0, colon).trim();
- try
- {
- port = Integer.parseInt(url.substring(colon + 1).trim());
- }
- catch (Exception ex)
- {
- // Use default;
- }
- }
- try
- {
- // Get server from cache
- naming = getServer(host, port, refEnv);
- }
- catch (Exception e)
- {
- serverEx = e;
- log.debug("Failed to connect to " + host + ":" + port, e);
- }
- }
-
- // If there is still no
- Exception discoveryFailure = null;
- if (naming == null)
- {
- try
- {
- naming = discoverServer(refEnv);
- }
- catch (Exception e)
- {
- discoveryFailure = e;
- if (serverEx == null)
- serverEx = e;
- }
- if (naming == null)
- {
- StringBuffer buffer = new StringBuffer(50);
- buffer.append("Could not obtain connection to any of these urls: ").append(urls);
- if (discoveryFailure != null)
- buffer.append(" and discovery failed with error: ").append(discoveryFailure);
- CommunicationException ce = new CommunicationException(buffer.toString());
- ce.setRootCause(serverEx);
- throw ce;
- }
- }
- }
- else
- {
- // If we are in a clustering scenario, the client code may request a context
- // for a *specific* HA-JNDI service (i.e. linked to a *specific* partition)
- // EVEN if the lookup is done inside a JBoss VM. For example, a JBoss service
- // may do a lookup on a HA-JNDI service running on another host *without*
- // explicitly providing a PROVIDER_URL but simply by providing a JNP_PARTITON_NAME
- // parameter so that dynamic discovery can be used
- //
- String jnpPartitionName = (String) refEnv.get(JNP_PARTITION_NAME);
- if (jnpPartitionName != null)
- {
- // the client is requesting for a specific partition name
- //
- naming = discoverServer(refEnv);
- if (naming == null)
- throw new ConfigurationException
- ("No valid context could be build for jnp.partitionName=" + jnpPartitionName);
- }
- else
- {
- // Use server in same JVM
- naming = localServer;
-
- if (naming == null)
- {
- naming = discoverServer(refEnv);
- if (naming == null)
- // Local, but no local JNDI provider found!
- throw new ConfigurationException("No valid Context.PROVIDER_URL was found");
- }
- }
- }
- }
- }
-
- private Name getAbsoluteName(Name n)
- throws NamingException
- {
- if (n.isEmpty())
- return composeName(n, prefix);
- else if (n.get(0).toString().equals("")) // Absolute name
- return n.getSuffix(1);
- else // Add prefix
- return composeName(n, prefix);
- }
-
- private Hashtable getEnv(Name n)
- throws InvalidNameException
- {
- Hashtable nameEnv = env;
- env.remove(JNP_PARSED_NAME);
- String serverInfo = parseNameForScheme(n, nameEnv);
- if (serverInfo != null)
- {
- // Set hostname:port value for the naming server
- nameEnv = (Hashtable) env.clone();
- nameEnv.put(Context.PROVIDER_URL, serverInfo);
- }
- return nameEnv;
- }
-
- /**
- * JBAS-4574. Check if the given exception is because the server has
- * been restarted while the cached naming stub hasn't been dgc-ed yet.
- * If yes, we will flush out the naming stub from our cache and
- * acquire a new stub. BW.
- *
- * @param e the exception that may be due to a stale stub
- * @param refEnv the naming environment associated with the failed call
- *
- * @return <code>true</code> if <code>e</code> indicates a stale
- * naming stub and we were able to succesfully flush the
- * cache and acquire a new stub; <code>false</code> otherwise.
- */
- private boolean handleStaleNamingStub(Exception e, Hashtable refEnv)
- {
- if (e instanceof NoSuchObjectException
- || e.getCause() instanceof NoSuchObjectException)
- {
- try
- {
- if( log.isTraceEnabled() )
- {
- log.trace("Call failed with NoSuchObjectException, " +
- "flushing server cache and retrying", e);
- }
- naming = null;
- removeServer(refEnv);
-
- checkRef(refEnv);
-
- return true;
- }
- catch (Exception e1)
- {
- // Just log and return false; let caller continue processing
- // the original exception passed in to this method
- log.error("Caught exception flushing server cache and " +
- "re-establish naming after exception " +
- e.getLocalizedMessage(), e1);
- }
- }
- return false;
- }
-
- // Inner classes -------------------------------------------------
-}
Copied: projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java (from rev 83195, projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java)
===================================================================
--- projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java (rev 0)
+++ projects/naming/tags/5.0.1.GA/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,1880 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.interfaces;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.SerializablePermission;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.ReflectPermission;
+import java.net.DatagramPacket;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.Socket;
+import java.net.InetSocketAddress;
+import java.rmi.ConnectException;
+import java.rmi.MarshalledObject;
+import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.naming.Binding;
+import javax.naming.CannotProceedException;
+import javax.naming.CommunicationException;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.InvalidNameException;
+import javax.naming.LinkRef;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.ContextNotEmptyException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.ServiceUnavailableException;
+import javax.naming.event.EventContext;
+import javax.naming.event.NamingListener;
+import javax.naming.spi.NamingManager;
+import javax.naming.spi.ResolveResult;
+import javax.net.SocketFactory;
+
+import org.jboss.logging.Logger;
+
+/**
+ * This class provides the jnp provider Context implementation. It is a Context
+ * interface wrapper for a RMI Naming instance that is obtained from either the
+ * local server instance or by locating the server given by the
+ * Context.PROVIDER_URL value.
+ *
+ * This class also serves as the jnp url resolution context. jnp style urls
+ * passed to the
+ * @author oberg
+ * @author scott.stark at jboss.org
+ * @version $Revision$
+ */
+public class NamingContext
+ implements EventContext, java.io.Serializable
+{
+ // Constants -----------------------------------------------------
+ /**
+ * @since 1.7
+ */
+ static final long serialVersionUID = 8906455608484282128L;
+ /**
+ * The javax.net.SocketFactory impl to use for the bootstrap socket
+ */
+ public static final String JNP_SOCKET_FACTORY = "jnp.socketFactory";
+ /**
+ * The local address to bind the connected bootstrap socket to
+ */
+ public static final String JNP_LOCAL_ADDRESS = "jnp.localAddress";
+ /**
+ * The local port to bind the connected bootstrap socket to
+ */
+ public static final String JNP_LOCAL_PORT = "jnp.localPort";
+ /**
+ * A flag to disable the broadcast discovery queries
+ */
+ public static final String JNP_DISABLE_DISCOVERY = "jnp.disableDiscovery";
+ /**
+ * The cluster partition discovery should be restricted to
+ */
+ public static final String JNP_PARTITION_NAME = "jnp.partitionName";
+ /**
+ * The multicast IP/address to which the discovery query is sent
+ */
+ public static final String JNP_DISCOVERY_GROUP = "jnp.discoveryGroup";
+ /**
+ * The port to which the discovery query is sent
+ */
+ public static final String JNP_DISCOVERY_PORT = "jnp.discoveryPort";
+
+ /** The time-to-live for the multicast discovery packets */
+ public static final String JNP_DISCOVERY_TTL = "jnp.discoveryTTL";
+
+ /**
+ * The time in MS to wait for a discovery query response
+ */
+ public static final String JNP_DISCOVERY_TIMEOUT = "jnp.discoveryTimeout";
+ /**
+ * An internal property added by parseNameForScheme if the input name uses a
+ * url prefix that was removed during cannonicalization. This is needed to
+ * avoid modification of the incoming Name.
+ */
+ public static final String JNP_PARSED_NAME = "jnp.parsedName";
+ /**
+ * A flag indicating the style of names passed to NamingManager method.
+ * True for api expected relative names, false for absolute names as used
+ * historically by the jboss naming implementation.
+ */
+ public static final String JNP_USE_RELATIVE_NAME = "jnp.useRelativeName";
+ /**
+ * An integer that controls the number of connection retry attempts will
+ * be made on the initial connection to the naming server. This only applies
+ * to ConnectException failures. A value <= 1 means that only one attempt
+ * will be made.
+ */
+ public static final String JNP_MAX_RETRIES = "jnp.maxRetries";
+ /**
+ * The Naming instance to use for the root Context creation
+ */
+ public static final String JNP_NAMING_INSTANCE = "jnp.namingInstance";
+ /**
+ * The name to associate with Naming instance to use for the root Context
+ */
+ public static final String JNP_NAMING_INSTANCE_NAME = "jnp.namingInstanceName";
+
+ /**
+ * The default discovery multicast information
+ */
+ public final static String DEFAULT_DISCOVERY_GROUP_ADDRESS = "230.0.0.4";
+ public final static int DEFAULT_DISCOVERY_GROUP_PORT = 1102;
+ public final static int DEFAULT_DISCOVERY_TIMEOUT = 5000;
+
+ /**
+ * An obsolete constant replaced by the JNP_MAX_RETRIES value
+ */
+ public static int MAX_RETRIES = 1;
+ /**
+ * The JBoss logging interface
+ */
+ private static Logger log = Logger.getLogger(NamingContext.class);
+
+ // Static --------------------------------------------------------
+ /** HAJNDI keyed by partition name */
+ private static Hashtable<String, Naming> haServers = new Hashtable<String, Naming>();
+ private static RuntimePermission GET_HA_NAMING_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.getHANamingServerForPartition");
+ private static RuntimePermission SET_HA_NAMING_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.setHANamingServerForPartition");
+ public static void setHANamingServerForPartition(String partitionName, Naming haServer)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if(security != null)
+ security.checkPermission(SET_HA_NAMING_SERVER);
+ haServers.put(partitionName, haServer);
+ }
+
+ public static void removeHANamingServerForPartition(String partitionName)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if(security != null)
+ security.checkPermission(SET_HA_NAMING_SERVER);
+ haServers.remove(partitionName);
+ }
+
+ public static Naming getHANamingServerForPartition(String partitionName)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if(security != null)
+ security.checkPermission(GET_HA_NAMING_SERVER);
+ return (Naming) haServers.get(partitionName);
+ }
+
+ /**
+ * The jvm local server used for non-transport access to the naming
+ * server
+ * @see #checkRef(Hashtable)
+ * @see {@linkplain LocalOnlyContextFactory}
+ */
+ private static Naming localServer;
+ private static RuntimePermission GET_LOCAL_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.getLocal");
+ private static RuntimePermission SET_LOCAL_SERVER = new RuntimePermission("org.jboss.naming.NamingContext.setLocal");
+ private static int HOST_INDEX = 0;
+ private static int PORT_INDEX = 1;
+
+ // Attributes ----------------------------------------------------
+ Naming naming;
+ Hashtable env;
+ Name prefix;
+
+ NameParser parser = new NamingParser();
+
+ // Static --------------------------------------------------------
+
+ // Cache of naming server stubs
+ // This is a critical optimization in the case where new InitialContext
+ // is performed often. The server stub will be shared between all those
+ // calls, which will improve performance.
+ // Weak references are used so if no contexts use a particular server
+ // it will be removed from the cache.
+ static ConcurrentHashMap<InetSocketAddress, WeakReference<Naming>> cachedServers
+ = new ConcurrentHashMap<InetSocketAddress, WeakReference<Naming>>();
+
+ /**
+ * @deprecated use {@link #addServer(InetSocketAddress, Naming)}
+ * @param name
+ * @param server
+ */
+ static void addServer(String name, Naming server)
+ {
+ Object[] hostAndPort = {name, 0};
+ parseHostPort(name, hostAndPort, 0);
+ String host = (String) hostAndPort[HOST_INDEX];
+ Integer port = (Integer) hostAndPort[PORT_INDEX];
+ InetSocketAddress addr = new InetSocketAddress(host, port);
+ addServer(addr, server);
+ }
+ static void addServer(InetSocketAddress addr, Naming server)
+ {
+ // Add server to map
+ synchronized (NamingContext.class)
+ {
+ WeakReference<Naming> ref = new WeakReference<Naming>(server);
+ cachedServers.put(addr, ref);
+ }
+ }
+
+ static Naming getServer(String host, int port, Hashtable serverEnv)
+ throws NamingException
+ {
+ // Check the server cache for a host:port entry
+ InetSocketAddress key = new InetSocketAddress(host, port);
+ WeakReference<Naming> ref = cachedServers.get(key);
+ Naming server;
+ if (ref != null)
+ {
+ server = (Naming) ref.get();
+ if (server != null)
+ {
+ // JBAS-4622. Ensure the env for the request has the
+ // hostKey so we can remove the cache entry if there is a failure
+ serverEnv.put("hostKey", key);
+ return server;
+ }
+ }
+
+ // Server not found; add it to cache
+ try
+ {
+ SocketFactory factory = loadSocketFactory(serverEnv);
+ Socket s;
+
+ try
+ {
+ InetAddress localAddr = null;
+ int localPort = 0;
+ String localAddrStr = (String) serverEnv.get(JNP_LOCAL_ADDRESS);
+ String localPortStr = (String) serverEnv.get(JNP_LOCAL_PORT);
+ if (localAddrStr != null)
+ localAddr = InetAddress.getByName(localAddrStr);
+ if (localPortStr != null)
+ localPort = Integer.parseInt(localPortStr);
+ s = factory.createSocket(host, port, localAddr, localPort);
+ }
+ catch (IOException e)
+ {
+ NamingException ex = new ServiceUnavailableException("Failed to connect to server " + key);
+ ex.setRootCause(e);
+ throw ex;
+ }
+
+ // Get stub from naming server
+ BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
+ ObjectInputStream in = new ObjectInputStream(bis);
+ MarshalledObject stub = (MarshalledObject) in.readObject();
+ server = (Naming) stub.get();
+ s.close();
+
+ // Add it to cache
+ addServer(key, server);
+ serverEnv.put("hostKey", key);
+
+ return server;
+ }
+ catch (IOException e)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Failed to retrieve stub from server " + key, e);
+ NamingException ex = new CommunicationException("Failed to retrieve stub from server " + key);
+ ex.setRootCause(e);
+ throw ex;
+ }
+ catch (Exception e)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Failed to connect server " + key, e);
+ NamingException ex = new CommunicationException("Failed to connect to server " + key);
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ /**
+ * Create a SocketFactory based on the JNP_SOCKET_FACTORY property in the
+ * given env. If JNP_SOCKET_FACTORY is not specified default to the
+ * TimedSocketFactory.
+ */
+ static SocketFactory loadSocketFactory(Hashtable serverEnv)
+ throws ClassNotFoundException, IllegalAccessException,
+ InstantiationException, InvocationTargetException
+ {
+ SocketFactory factory = null;
+
+ // Get the socket factory classname
+ String socketFactoryName = (String) serverEnv.get(JNP_SOCKET_FACTORY);
+ if (socketFactoryName == null ||
+ socketFactoryName.equals(TimedSocketFactory.class.getName()))
+ {
+ factory = new TimedSocketFactory(serverEnv);
+ return factory;
+ }
+
+ /* Create the socket factory. Look for a ctor that accepts a
+ Hashtable and if not found use the default ctor.
+ */
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class factoryClass = loader.loadClass(socketFactoryName);
+ try
+ {
+ Class[] ctorSig = {Hashtable.class};
+ Constructor ctor = factoryClass.getConstructor(ctorSig);
+ Object[] ctorArgs = {serverEnv};
+ factory = (SocketFactory) ctor.newInstance(ctorArgs);
+ }
+ catch (NoSuchMethodException e)
+ {
+ // Use the default ctor
+ factory = (SocketFactory) factoryClass.newInstance();
+ }
+ return factory;
+ }
+
+ static void removeServer(Hashtable serverEnv)
+ {
+ String host = "localhost";
+ int port = 1099;
+
+ // Locate naming service
+ if (serverEnv.get(Context.PROVIDER_URL) != null)
+ {
+ String providerURL = (String) serverEnv.get(Context.PROVIDER_URL);
+
+ StringTokenizer tokenizer = new StringTokenizer(providerURL, ", ");
+ while (tokenizer.hasMoreElements())
+ {
+ String url = tokenizer.nextToken();
+
+ try
+ {
+ // Parse the url into a host:port form, stripping any protocol
+ Name urlAsName = new NamingParser().parse(url);
+ String server = parseNameForScheme(urlAsName, null);
+ if (server != null)
+ url = server;
+
+ Object[] hostAndPort = {url, 1099};
+ parseHostPort(url, hostAndPort, 1099);
+ host = (String) hostAndPort[HOST_INDEX];
+ port = (Integer) hostAndPort[PORT_INDEX];
+
+ // Remove server from map
+ synchronized (NamingContext.class)
+ {
+ InetSocketAddress key = new InetSocketAddress(host, port);
+ cachedServers.remove(key);
+ }
+ }
+ catch (NamingException ignored)
+ {
+ }
+ }
+ }
+
+ // JBAS-4622. Always do this.
+ Object hostKey = serverEnv.remove("hostKey");
+ if (hostKey != null)
+ {
+ synchronized (NamingContext.class)
+ {
+ cachedServers.remove(hostKey);
+ }
+ }
+ }
+
+ /**
+ * Called to remove any url scheme atoms and extract the naming service
+ * hostname:port information.
+ * @param n the name component to the parsed. After returning n will have all
+ * scheme related atoms removed.
+ * @return the naming service hostname:port information string if name
+ * contained the host information.
+ */
+ static String parseNameForScheme(Name n, Hashtable nameEnv)
+ throws InvalidNameException
+ {
+ String serverInfo = null;
+ if (n.size() > 0)
+ {
+ String scheme = n.get(0);
+ int schemeLength = 0;
+ if (scheme.startsWith("java:"))
+ schemeLength = 5;
+ else if (scheme.startsWith("jnp:"))
+ schemeLength = 4;
+ else if (scheme.startsWith("jnps:"))
+ schemeLength = 5;
+ else if (scheme.startsWith("jnp-http:"))
+ schemeLength = 9;
+ else if (scheme.startsWith("jnp-https:"))
+ schemeLength = 10;
+ if (schemeLength > 0)
+ {
+ // Make a copy of the name to avoid
+ n = (Name) n.clone();
+ String suffix = scheme.substring(schemeLength);
+ if (suffix.length() == 0)
+ {
+ // Scheme was "url:/..."
+ n.remove(0);
+ if (n.size() > 1 && n.get(0).equals(""))
+ {
+ // Scheme was "url://hostname:port/..."
+ // Get hostname:port value for the naming server
+ serverInfo = n.get(1);
+ n.remove(0);
+ n.remove(0);
+ // If n is a empty atom remove it or else a '/' will result
+ if (n.size() == 1 && n.get(0).length() == 0)
+ n.remove(0);
+ }
+ }
+ else
+ {
+ // Scheme was "url:foo" -> reinsert "foo"
+ n.remove(0);
+ n.add(0, suffix);
+ }
+ if (nameEnv != null)
+ nameEnv.put(JNP_PARSED_NAME, n);
+ }
+ }
+ return serverInfo;
+ }
+
+ public static Naming getLocal()
+ {
+ SecurityManager security = System.getSecurityManager();
+ if(security != null)
+ security.checkPermission(GET_LOCAL_SERVER);
+ return localServer;
+ }
+ public static void setLocal(Naming server)
+ {
+ SecurityManager security = System.getSecurityManager();
+ if(security != null)
+ security.checkPermission(SET_LOCAL_SERVER);
+ localServer = server;
+ }
+
+ // Constructors --------------------------------------------------
+ public NamingContext(Hashtable e, Name baseName, Naming server)
+ throws NamingException
+ {
+ if (baseName == null)
+ this.prefix = parser.parse("");
+ else
+ this.prefix = baseName;
+
+ if (e != null)
+ this.env = (Hashtable) e.clone();
+ else
+ this.env = new Hashtable();
+
+ this.naming = server;
+ }
+
+ // Public --------------------------------------------------------
+ public Naming getNaming()
+ {
+ return this.naming;
+ }
+
+ public void setNaming(Naming server)
+ {
+ this.naming = server;
+ }
+
+ // Context implementation ----------------------------------------
+ public void rebind(String name, Object obj)
+ throws NamingException
+ {
+ rebind(getNameParser(name).parse(name), obj);
+ }
+
+ public void rebind(Name name, Object obj)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ // Allow state factories to change the stored object
+ obj = getStateToBind(obj, name, refEnv);
+
+ try
+ {
+ String className = null;
+
+ // Referenceable
+ if (obj instanceof Referenceable)
+ obj = ((Referenceable) obj).getReference();
+
+ if (!(obj instanceof Reference))
+ {
+ if( obj != null )
+ className = obj.getClass().getName();
+ obj = createMarshalledValuePair(obj);
+ }
+ else
+ {
+ className = ((Reference) obj).getClassName();
+ }
+ try
+ {
+ naming.rebind(getAbsoluteName(name), obj, className);
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ naming.rebind(getAbsoluteName(name), obj, className);
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ cctx.rebind(cpe.getRemainingName(), obj);
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public void bind(String name, Object obj)
+ throws NamingException
+ {
+ bind(getNameParser(name).parse(name), obj);
+ }
+
+ public void bind(Name name, Object obj)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ // Allow state factories to change the stored object
+ obj = getStateToBind(obj, name, refEnv);
+
+ try
+ {
+ String className = null;
+
+ // Referenceable
+ if (obj instanceof Referenceable)
+ obj = ((Referenceable) obj).getReference();
+
+ if (!(obj instanceof Reference))
+ {
+ if( obj != null )
+ className = obj.getClass().getName();
+
+ // Normal object - serialize using a MarshalledValuePair
+ obj = createMarshalledValuePair(obj);
+ }
+ else
+ {
+ className = ((Reference) obj).getClassName();
+ }
+ name = getAbsoluteName(name);
+
+ try
+ {
+ naming.bind(name, obj, className);
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ naming.bind(name, obj, className);
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ cctx.bind(cpe.getRemainingName(), obj);
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public Object lookup(String name)
+ throws NamingException
+ {
+ return lookup(getNameParser(name).parse(name));
+ }
+
+ public Object lookup(Name name)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ // Empty?
+ if (name.isEmpty())
+ return new NamingContext(refEnv, prefix, naming);
+
+ try
+ {
+ int maxTries = 1;
+ try
+ {
+ String n = (String) refEnv.get(JNP_MAX_RETRIES);
+ if( n != null )
+ maxTries = Integer.parseInt(n);
+ if( maxTries <= 0 )
+ maxTries = 1;
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to get JNP_MAX_RETRIES, using 1", e);
+ }
+ Name n = getAbsoluteName(name);
+ Object res = null;
+ boolean trace = log.isTraceEnabled();
+ for (int i = 0; i < maxTries; i++)
+ {
+ try
+ {
+ try
+ {
+ res = naming.lookup(n);
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ res = naming.lookup(n);
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ // If we got here, we succeeded, so break the loop
+ break;
+ }
+ catch (ConnectException ce)
+ {
+ int retries = maxTries - i - 1;
+ if( trace )
+ log.trace("Connect failed, retry count: "+retries, ce);
+ // We may overload server so sleep and retry
+ if (retries > 0)
+ {
+ try
+ {
+ Thread.sleep(1);
+ }
+ catch (InterruptedException ignored)
+ {
+ }
+ continue;
+ }
+ // Throw the exception to flush the bad server
+ throw ce;
+ }
+ }
+ if (res instanceof MarshalledValuePair)
+ {
+ MarshalledValuePair mvp = (MarshalledValuePair) res;
+ Object storedObj = mvp.get();
+ return getObjectInstanceWrapFailure(storedObj, name, refEnv);
+ }
+ else if (res instanceof MarshalledObject)
+ {
+ MarshalledObject mo = (MarshalledObject) res;
+ return mo.get();
+ }
+ else if (res instanceof Context)
+ {
+ // Add env
+ Enumeration keys = refEnv.keys();
+ while (keys.hasMoreElements())
+ {
+ String key = (String) keys.nextElement();
+ ((Context) res).addToEnvironment(key, refEnv.get(key));
+ }
+ return res;
+ }
+ else if (res instanceof ResolveResult)
+ {
+ // Dereference partial result
+ ResolveResult rr = (ResolveResult) res;
+ Object resolveRes = rr.getResolvedObj();
+ Object context;
+ Object instanceID;
+
+ if (resolveRes instanceof LinkRef)
+ {
+ context = resolveLink(resolveRes, null);
+ instanceID = ((LinkRef) resolveRes).getLinkName();
+ }
+ else
+ {
+ context = getObjectInstanceWrapFailure(resolveRes, name, refEnv);
+ instanceID = context;
+ }
+
+ if ((context instanceof Context) == false)
+ {
+ throw new NotContextException(instanceID + " is not a Context");
+ }
+ Context ncontext = (Context) context;
+ return ncontext.lookup(rr.getRemainingName());
+ }
+ else if (res instanceof LinkRef)
+ {
+ // Dereference link
+ res = resolveLink(res, refEnv);
+ }
+ else if (res instanceof Reference)
+ {
+ // Dereference object
+ res = getObjectInstanceWrapFailure(res, name, refEnv);
+ if (res instanceof LinkRef)
+ res = resolveLink(res, refEnv);
+ }
+
+ return res;
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ return cctx.lookup(cpe.getRemainingName());
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ catch (ClassNotFoundException e)
+ {
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public void unbind(String name)
+ throws NamingException
+ {
+ unbind(getNameParser(name).parse(name));
+ }
+
+
+ public void unbind(Name name)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ try
+ {
+ try
+ {
+ naming.unbind(getAbsoluteName(name));
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ naming.unbind(getAbsoluteName(name));
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ cctx.unbind(cpe.getRemainingName());
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public void rename(String oldname, String newname)
+ throws NamingException
+ {
+ rename(getNameParser(oldname).parse(oldname), getNameParser(newname).parse(newname));
+ }
+
+ public void rename(Name oldName, Name newName)
+ throws NamingException
+ {
+ bind(newName, lookup(oldName));
+ unbind(oldName);
+ }
+
+ public NamingEnumeration list(String name)
+ throws NamingException
+ {
+ return list(getNameParser(name).parse(name));
+ }
+
+ public NamingEnumeration list(Name name)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ try
+ {
+ Collection c = null;
+ try
+ {
+ c = naming.list(getAbsoluteName(name));
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ c = naming.list(getAbsoluteName(name));
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ return new NamingEnumerationImpl(c);
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ return cctx.list(cpe.getRemainingName());
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public NamingEnumeration listBindings(String name)
+ throws NamingException
+ {
+ return listBindings(getNameParser(name).parse(name));
+ }
+
+ public NamingEnumeration listBindings(Name name)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ try
+ {
+ // Get list
+ Collection bindings = null;
+ try
+ {
+ // Get list
+ bindings = naming.listBindings(getAbsoluteName(name));
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ bindings = naming.listBindings(getAbsoluteName(name));
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ Collection realBindings = new ArrayList(bindings.size());
+
+ // Convert marshalled objects
+ Iterator i = bindings.iterator();
+ while (i.hasNext())
+ {
+ Binding binding = (Binding) i.next();
+ Object obj = binding.getObject();
+ if (obj instanceof MarshalledValuePair)
+ {
+ try
+ {
+ obj = ((MarshalledValuePair) obj).get();
+ }
+ catch (ClassNotFoundException e)
+ {
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+ else if (obj instanceof MarshalledObject)
+ {
+ try
+ {
+ obj = ((MarshalledObject) obj).get();
+ }
+ catch (ClassNotFoundException e)
+ {
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+ realBindings.add(new Binding(binding.getName(), binding.getClassName(), obj));
+ }
+
+ // Return transformed list of bindings
+ return new NamingEnumerationImpl(realBindings);
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ return cctx.listBindings(cpe.getRemainingName());
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public String composeName(String name, String prefix)
+ throws NamingException
+ {
+ Name result = composeName(parser.parse(name),
+ parser.parse(prefix));
+ return result.toString();
+ }
+
+ public Name composeName(Name name, Name prefix)
+ throws NamingException
+ {
+ Name result = (Name) (prefix.clone());
+ result.addAll(name);
+ return result;
+ }
+
+ public NameParser getNameParser(String name)
+ throws NamingException
+ {
+ return parser;
+ }
+
+ public NameParser getNameParser(Name name)
+ throws NamingException
+ {
+ return getNameParser(name.toString());
+ }
+
+ public Context createSubcontext(String name)
+ throws NamingException
+ {
+ return createSubcontext(getNameParser(name).parse(name));
+ }
+
+ public Context createSubcontext(Name name)
+ throws NamingException
+ {
+ if (name.size() == 0)
+ throw new InvalidNameException("Cannot pass an empty name to createSubcontext");
+
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ try
+ {
+ name = getAbsoluteName(name);
+ try
+ {
+ return naming.createSubcontext(name);
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ return naming.createSubcontext(name);
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ }
+ catch (CannotProceedException cpe)
+ {
+ cpe.setEnvironment(refEnv);
+ Context cctx = NamingManager.getContinuationContext(cpe);
+ return cctx.createSubcontext(cpe.getRemainingName());
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ public Object addToEnvironment(String propName, Object propVal)
+ throws NamingException
+ {
+ Object old = env.get(propName);
+ env.put(propName, propVal);
+ return old;
+ }
+
+ public Object removeFromEnvironment(String propName)
+ throws NamingException
+ {
+ return env.remove(propName);
+ }
+
+ public Hashtable getEnvironment()
+ throws NamingException
+ {
+ return env;
+ }
+
+ public void close()
+ throws NamingException
+ {
+ env = null;
+ naming = null;
+ }
+
+ public String getNameInNamespace()
+ throws NamingException
+ {
+ return prefix.toString();
+ }
+
+ public void destroySubcontext(String name)
+ throws NamingException
+ {
+ destroySubcontext(getNameParser(name).parse(name));
+ }
+
+ public void destroySubcontext(Name name)
+ throws NamingException
+ {
+ if (!list(name).hasMore())
+ {
+ unbind(name);
+ }
+ else
+ throw new ContextNotEmptyException();
+ }
+
+ public Object lookupLink(String name)
+ throws NamingException
+ {
+ return lookupLink(getNameParser(name).parse(name));
+ }
+
+ /**
+ * Lookup the object referred to by name but don't dereferrence the final
+ * component. This really just involves returning the raw value returned by
+ * the Naming.lookup() method.
+ * @return the raw object bound under name.
+ */
+ public Object lookupLink(Name name)
+ throws NamingException
+ {
+ Hashtable refEnv = getEnv(name);
+ checkRef(refEnv);
+ Name parsedName = (Name) refEnv.get(JNP_PARSED_NAME);
+ if (parsedName != null)
+ name = parsedName;
+
+ if (name.isEmpty())
+ return lookup(name);
+
+ Object link = null;
+ try
+ {
+ Name n = getAbsoluteName(name);
+ try
+ {
+ link = naming.lookup(n);
+ }
+ catch (RemoteException re)
+ {
+ // Check for JBAS-4574.
+ if (handleStaleNamingStub(re, refEnv))
+ {
+ // try again with new naming stub
+ link = naming.lookup(n);
+ }
+ else
+ {
+ // Not JBAS-4574. Throw exception and let outer logic handle it.
+ throw re;
+ }
+ }
+ if (!(link instanceof LinkRef) && link instanceof Reference)
+ link = getObjectInstance(link, name, null);
+ ;
+ }
+ catch (IOException e)
+ {
+ naming = null;
+ removeServer(refEnv);
+ NamingException ex = new CommunicationException();
+ ex.setRootCause(e);
+ throw ex;
+ }
+ catch (Exception e)
+ {
+ NamingException ex = new NamingException("Could not lookup link");
+ ex.setRemainingName(name);
+ ex.setRootCause(e);
+ throw ex;
+ }
+ return link;
+ }
+
+ // Begin EventContext methods
+ public void addNamingListener(Name target, int scope, NamingListener l)
+ throws NamingException
+ {
+ if((naming instanceof NamingEvents) == false)
+ {
+ throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
+ }
+ NamingEvents next = (NamingEvents) naming;
+ try
+ {
+ next.addNamingListener(this, target, scope, l);
+ }
+ catch (RemoteException e)
+ {
+ CommunicationException ce = new CommunicationException("addNamingListener failed");
+ ce.initCause(e);
+ }
+ }
+
+ public void addNamingListener(String target, int scope, NamingListener l)
+ throws NamingException
+ {
+ Name targetName = parser.parse(target);
+ addNamingListener(targetName, scope, l);
+ }
+
+ public void removeNamingListener(NamingListener l)
+ throws NamingException
+ {
+ if((naming instanceof NamingEvents) == false)
+ {
+ throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
+ }
+ NamingEvents next = (NamingEvents) naming;
+ try
+ {
+ next.removeNamingListener(l);
+ }
+ catch (RemoteException e)
+ {
+ CommunicationException ce = new CommunicationException("removeNamingListener failed");
+ ce.initCause(e);
+ }
+ }
+
+ public boolean targetMustExist()
+ throws NamingException
+ {
+ if((naming instanceof NamingEvents) == false)
+ {
+ throw new UnsupportedOperationException("Naming implementation does not support NamingExt");
+ }
+ NamingEvents next = (NamingEvents) naming;
+ boolean targetMustExist = true;
+ try
+ {
+ targetMustExist = next.targetMustExist();
+ }
+ catch (RemoteException e)
+ {
+ CommunicationException ce = new CommunicationException("removeNamingListener failed");
+ ce.initCause(e);
+ }
+ return targetMustExist;
+ }
+ // End EventContext methods
+
+ protected Object resolveLink(Object res, Hashtable refEnv)
+ throws NamingException
+ {
+ Object linkResult = null;
+ try
+ {
+ LinkRef link = (LinkRef) res;
+ String ref = link.getLinkName();
+ if (ref.startsWith("./"))
+ linkResult = lookup(ref.substring(2));
+ else if (refEnv != null)
+ linkResult = new InitialContext(refEnv).lookup(ref);
+ else
+ linkResult = new InitialContext().lookup(ref);
+ }
+ catch (Exception e)
+ {
+ NamingException ex = new NamingException("Could not dereference object");
+ ex.setRootCause(e);
+ throw ex;
+ }
+ return linkResult;
+ }
+
+ // Private -------------------------------------------------------
+
+ /**
+ * Isolate the creation of the MarshalledValuePair in a privileged block
+ * when running under a security manager so the following permissions can
+ * be isolated from the caller:
+ * RuntimePermission("createClassLoader")
+ ReflectPermission("suppressAccessChecks")
+ SerializablePermission("enableSubstitution")
+ @return the MarshalledValuePair wrapping obj
+ */
+ private Object createMarshalledValuePair(final Object obj)
+ throws IOException
+ {
+ MarshalledValuePair mvp = null;
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ {
+ try
+ {
+ mvp = AccessController.doPrivileged(new PrivilegedExceptionAction<MarshalledValuePair>()
+ {
+ public MarshalledValuePair run() throws Exception
+ {
+ return new MarshalledValuePair(obj);
+ }
+ }
+ );
+ }
+ catch(PrivilegedActionException e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e.getException());
+ throw ioe;
+ }
+ }
+ else
+ {
+ mvp = new MarshalledValuePair(obj);
+ }
+ return mvp;
+ }
+
+ /**
+ * Determine the form of the name to pass to the NamingManager operations.
+ * This is supposed to be a context relative name according to the javaodcs
+ * for NamingManager, but historically the absolute name of the target
+ * context has been passed in.
+ *
+ * @param env - the env of NamingContext that op was called on
+ * @return true if the legacy and technically incorrect absolute name should
+ * be used, false if the context relative name should be used.
+ */
+ private boolean useAbsoluteName(Hashtable env)
+ {
+ if (env == null)
+ return true;
+ String useRelativeName = (String) env.get(JNP_USE_RELATIVE_NAME);
+ return Boolean.valueOf(useRelativeName) == Boolean.FALSE;
+ }
+
+ /**
+ * Use the NamingManager.getStateToBind to obtain the actual object to bind
+ * into jndi.
+ * @param obj - the value passed to bind/rebind
+ * @param name - the name passed to bind/rebind
+ * @param env - the env of NamingContext that bind/rebind was called on
+ * @return the object to bind to the naming server
+ * @throws NamingException
+ */
+ private Object getStateToBind(Object obj, Name name, Hashtable env)
+ throws NamingException
+ {
+ if (useAbsoluteName(env))
+ name = getAbsoluteName(name);
+ return NamingManager.getStateToBind(obj, name, this, env);
+ }
+
+ /**
+ * Use the NamingManager.getObjectInstance to resolve the raw object obtained
+ * from the naming server.
+ * @param obj - raw value obtained from the naming server
+ * @param name - the name passed to the lookup op
+ * @param env - the env of NamingContext that the op was called on
+ * @return the fully resolved object
+ * @throws Exception
+ */
+ private Object getObjectInstance(Object obj, Name name, Hashtable env)
+ throws Exception
+ {
+ if (useAbsoluteName(env))
+ name = getAbsoluteName(name);
+ return NamingManager.getObjectInstance(obj, name, this, env);
+ }
+
+ /**
+ * Resolve the final object and wrap any non-NamingException errors in a
+ * NamingException with the cause passed as the root cause.
+ * @param obj - raw value obtained from the naming server
+ * @param name - the name passed to the lookup op
+ * @param env - the env of NamingContext that the op was called on
+ * @return the fully resolved object
+ * @throws NamingException
+ */
+ private Object getObjectInstanceWrapFailure(Object obj, Name name, Hashtable env)
+ throws NamingException
+ {
+ try
+ {
+ return getObjectInstance(obj, name, env);
+ }
+ catch (NamingException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ NamingException ex = new NamingException("Could not dereference object");
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ /**
+ * This methods sends a broadcast message on the network and asks and HA-JNDI
+ * server to sent it the HA-JNDI stub
+ */
+ private Naming discoverServer(Hashtable serverEnv) throws NamingException
+ {
+ boolean trace = log.isTraceEnabled();
+ // Check if discovery should be done
+ String disableDiscovery = (String) serverEnv.get(JNP_DISABLE_DISCOVERY);
+ if (Boolean.valueOf(disableDiscovery) == Boolean.TRUE)
+ {
+ if (trace)
+ log.trace("Skipping discovery due to disable flag");
+ return null;
+ }
+
+ // we first try to discover the server locally
+ //
+ String partitionName = (String) serverEnv.get(JNP_PARTITION_NAME);
+ Naming server = null;
+ if (partitionName != null)
+ {
+ server = getHANamingServerForPartition(partitionName);
+ if (server != null)
+ return server;
+ }
+
+ // We next broadcast a HelloWorld datagram (multicast)
+ // Any listening server will answer with its IP address:port in another datagram
+ // we will then use this to make a standard "lookup"
+ //
+ MulticastSocket s = null;
+ InetAddress iaGroup = null;
+ try
+ {
+ String group = DEFAULT_DISCOVERY_GROUP_ADDRESS;
+ int port = DEFAULT_DISCOVERY_GROUP_PORT;
+ int timeout = DEFAULT_DISCOVERY_TIMEOUT;
+ int ttl = 16;
+
+ String discoveryGroup = (String) serverEnv.get(JNP_DISCOVERY_GROUP);
+ if (discoveryGroup != null)
+ group = discoveryGroup;
+
+ String discoveryTTL = (String) serverEnv.get(JNP_DISCOVERY_TTL);
+ if(discoveryTTL != null)
+ ttl = Integer.parseInt(discoveryTTL);
+
+ String discoveryTimeout = (String) serverEnv.get(JNP_DISCOVERY_TIMEOUT);
+ if (discoveryTimeout == null)
+ {
+ // Check the old property name
+ discoveryTimeout = (String) serverEnv.get("DISCOVERY_TIMEOUT");
+ }
+ if (discoveryTimeout != null && !discoveryTimeout.equals(""))
+ timeout = Integer.parseInt(discoveryTimeout);
+
+ String discoveryGroupPort = (String) serverEnv.get(JNP_DISCOVERY_PORT);
+ if (discoveryGroupPort == null)
+ {
+ // Check the old property name
+ discoveryGroupPort = (String) serverEnv.get("DISCOVERY_GROUP");
+ }
+ if (discoveryGroupPort != null && !discoveryGroupPort.equals(""))
+ {
+ int colon = discoveryGroupPort.indexOf(':');
+ if (colon < 0)
+ {
+ // No group given, just the port
+ try
+ {
+ port = Integer.parseInt(discoveryGroupPort);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Failed to parse port: " + discoveryGroupPort, ex);
+ }
+ }
+ else
+ {
+ // The old group:port syntax was given
+ group = discoveryGroupPort.substring(0, colon);
+ String portStr = discoveryGroupPort.substring(colon + 1);
+ try
+ {
+ port = Integer.parseInt(portStr);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Failed to parse port: " + portStr, ex);
+ }
+ }
+ }
+
+ iaGroup = InetAddress.getByName(group);
+ String localAddrStr = (String) serverEnv.get(JNP_LOCAL_ADDRESS);
+ String localPortStr = (String) serverEnv.get(JNP_LOCAL_PORT);
+ int localPort = 0;
+ if (localPortStr != null)
+ localPort = Integer.parseInt(localPortStr);
+ if (localAddrStr != null)
+ {
+ InetSocketAddress localAddr = new InetSocketAddress(localAddrStr, localPort);
+ s = new MulticastSocket(localAddr);
+ }
+ else
+ {
+ s = new MulticastSocket(localPort);
+ }
+ s.setSoTimeout(timeout);
+ s.setTimeToLive(ttl);
+ if(log.isTraceEnabled())
+ log.trace("TTL on multicast discovery socket is " + ttl);
+ s.joinGroup(iaGroup);
+ if (trace)
+ log.trace("MulticastSocket: " + s);
+ DatagramPacket packet;
+ // Send a request optionally restricted to a cluster partition
+ StringBuffer data = new StringBuffer("GET_ADDRESS");
+ if (partitionName != null)
+ data.append(":" + partitionName);
+ byte[] buf = data.toString().getBytes();
+ packet = new DatagramPacket(buf, buf.length, iaGroup, port);
+ if (trace)
+ log.trace("Sending discovery packet(" + data + ") to: " + iaGroup + ":" + port);
+ s.send(packet);
+ // Look for a reply
+ // IP address + port number = 128.128.128.128:65535 => (12+3) + 1 + (5) = 21
+
+ buf = new byte[50];
+ packet = new DatagramPacket(buf, buf.length);
+ s.receive(packet);
+ String myServer = new String(packet.getData()).trim();
+ if (trace)
+ log.trace("Received answer packet: " + myServer);
+ while (myServer != null && myServer.startsWith("GET_ADDRESS"))
+ {
+ Arrays.fill(buf, (byte) 0);
+ packet.setLength(buf.length);
+ s.receive(packet);
+ byte[] reply = packet.getData();
+ myServer = new String(reply).trim();
+ if (trace)
+ log.trace("Received answer packet: " + myServer);
+ }
+ String serverHost;
+ int serverPort;
+
+ Object[] hostAndPort = {myServer, 0};
+ parseHostPort(myServer, hostAndPort, DEFAULT_DISCOVERY_GROUP_PORT);
+ serverHost = (String) hostAndPort[HOST_INDEX];
+ serverPort = (Integer) hostAndPort[PORT_INDEX];
+ if (serverHost != null)
+ {
+ server = getServer(serverHost, serverPort, serverEnv);
+ }
+ return server;
+ }
+ catch (IOException e)
+ {
+ if (trace)
+ log.trace("Discovery failed", e);
+ NamingException ex = new CommunicationException(e.getMessage());
+ ex.setRootCause(e);
+ throw ex;
+ }
+ finally
+ {
+ try
+ {
+ if (s != null)
+ s.leaveGroup(iaGroup);
+ }
+ catch (Exception ignore)
+ {
+ }
+ try
+ {
+ if (s != null)
+ s.close();
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ }
+
+ private void checkRef(Hashtable refEnv)
+ throws NamingException
+ {
+ if (naming == null)
+ {
+ String host = "localhost";
+ int port = 1099;
+ Exception serverEx = null;
+
+ // Locate first available naming service
+ String urls = (String) refEnv.get(Context.PROVIDER_URL);
+ if (urls != null && urls.length() > 0)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(urls, ",");
+
+ while (naming == null && tokenizer.hasMoreElements())
+ {
+ String url = tokenizer.nextToken();
+ // Parse the url into a host:port form, stripping any protocol
+ Name urlAsName = getNameParser("").parse(url);
+ String server = parseNameForScheme(urlAsName, null);
+ if (server != null)
+ url = server;
+ //
+ Object[] hostAndPort = {url, 0};
+ parseHostPort(url, hostAndPort, 1099);
+ host = (String) hostAndPort[HOST_INDEX];
+ port = (Integer) hostAndPort[PORT_INDEX];
+ try
+ {
+ // Get server from cache
+ naming = getServer(host, port, refEnv);
+ }
+ catch (Exception e)
+ {
+ serverEx = e;
+ log.debug("Failed to connect to " + host + ":" + port, e);
+ }
+ }
+
+ // If there is still no
+ Exception discoveryFailure = null;
+ if (naming == null)
+ {
+ try
+ {
+ naming = discoverServer(refEnv);
+ }
+ catch (Exception e)
+ {
+ discoveryFailure = e;
+ if (serverEx == null)
+ serverEx = e;
+ }
+ if (naming == null)
+ {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append("Could not obtain connection to any of these urls: ").append(urls);
+ if (discoveryFailure != null)
+ buffer.append(" and discovery failed with error: ").append(discoveryFailure);
+ CommunicationException ce = new CommunicationException(buffer.toString());
+ ce.setRootCause(serverEx);
+ throw ce;
+ }
+ }
+ }
+ else
+ {
+ // If we are in a clustering scenario, the client code may request a context
+ // for a *specific* HA-JNDI service (i.e. linked to a *specific* partition)
+ // EVEN if the lookup is done inside a JBoss VM. For example, a JBoss service
+ // may do a lookup on a HA-JNDI service running on another host *without*
+ // explicitly providing a PROVIDER_URL but simply by providing a JNP_PARTITON_NAME
+ // parameter so that dynamic discovery can be used
+ //
+ String jnpPartitionName = (String) refEnv.get(JNP_PARTITION_NAME);
+ if (jnpPartitionName != null)
+ {
+ // the client is requesting for a specific partition name
+ //
+ naming = discoverServer(refEnv);
+ if (naming == null)
+ throw new ConfigurationException
+ ("No valid context could be build for jnp.partitionName=" + jnpPartitionName);
+ }
+ else
+ {
+ // Use server in same JVM
+ naming = localServer;
+
+ if (naming == null)
+ {
+ naming = discoverServer(refEnv);
+ if (naming == null)
+ // Local, but no local JNDI provider found!
+ throw new ConfigurationException("No valid Context.PROVIDER_URL was found");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Parse a naming provider url for the host/port information
+ * @param url - the naming provider url string to parse
+ * @param output, [0] = the host name/address, [1] = the parsed port as an Integer
+ * @param defaultPort - the default port to return in output[1] if no port
+ * was seen in the url string.
+ * @return the index of the port separator if found, -1 otherwise.
+ */
+ static private int parseHostPort(String url, Object[] output, int defaultPort)
+ {
+ // First look for a @ separating the host and port
+ int colon = url.indexOf('@');
+ if(colon < 0)
+ {
+ // If there are multiple ':' assume its an IPv6 address
+ colon = url.lastIndexOf(':');
+ int firstColon = url.indexOf(':');
+ if(colon > firstColon)
+ colon = -1;
+ }
+
+ if(colon < 0)
+ {
+ output[HOST_INDEX] = url;
+ output[PORT_INDEX] = new Integer(defaultPort);
+ }
+ else
+ {
+ output[HOST_INDEX] = url.substring(0, colon);
+ try
+ {
+ output[PORT_INDEX] = Integer.parseInt(url.substring(colon+1).trim());
+ }
+ catch (Exception ex)
+ {
+ // Use default port
+ output[PORT_INDEX] = new Integer(defaultPort);
+ }
+ }
+ return colon;
+ }
+
+ private Name getAbsoluteName(Name n)
+ throws NamingException
+ {
+ if (n.isEmpty())
+ return composeName(n, prefix);
+ else if (n.get(0).toString().equals("")) // Absolute name
+ return n.getSuffix(1);
+ else // Add prefix
+ return composeName(n, prefix);
+ }
+
+ private Hashtable getEnv(Name n)
+ throws InvalidNameException
+ {
+ Hashtable nameEnv = env;
+ env.remove(JNP_PARSED_NAME);
+ String serverInfo = parseNameForScheme(n, nameEnv);
+ if (serverInfo != null)
+ {
+ // Set hostname:port value for the naming server
+ nameEnv = (Hashtable) env.clone();
+ nameEnv.put(Context.PROVIDER_URL, serverInfo);
+ }
+ return nameEnv;
+ }
+
+ /**
+ * JBAS-4574. Check if the given exception is because the server has
+ * been restarted while the cached naming stub hasn't been dgc-ed yet.
+ * If yes, we will flush out the naming stub from our cache and
+ * acquire a new stub. BW.
+ *
+ * @param e the exception that may be due to a stale stub
+ * @param refEnv the naming environment associated with the failed call
+ *
+ * @return <code>true</code> if <code>e</code> indicates a stale
+ * naming stub and we were able to succesfully flush the
+ * cache and acquire a new stub; <code>false</code> otherwise.
+ */
+ private boolean handleStaleNamingStub(Exception e, Hashtable refEnv)
+ {
+ if (e instanceof NoSuchObjectException
+ || e.getCause() instanceof NoSuchObjectException)
+ {
+ try
+ {
+ if( log.isTraceEnabled() )
+ {
+ log.trace("Call failed with NoSuchObjectException, " +
+ "flushing server cache and retrying", e);
+ }
+ naming = null;
+ removeServer(refEnv);
+
+ checkRef(refEnv);
+
+ return true;
+ }
+ catch (Exception e1)
+ {
+ // Just log and return false; let caller continue processing
+ // the original exception passed in to this method
+ log.error("Caught exception flushing server cache and " +
+ "re-establish naming after exception " +
+ e.getLocalizedMessage(), e1);
+ }
+ }
+ return false;
+ }
+
+ // Inner classes -------------------------------------------------
+}
Deleted: projects/naming/tags/5.0.1.GA/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/pom.xml 2009-01-22 01:29:32 UTC (rev 83187)
+++ projects/naming/tags/5.0.1.GA/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- The parent maven for the jndi naming server project
-
- This pom aggregates the subproject pom
-
- To build this project maven 2 should be installed and in the system path. From the command line
- run "mvn" from the build directory and "install" will be used as the default goal. In order to use
- the "deploy" goal, the mvn.cvs.root should be specified in settings.xml.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>3</version>
- </parent>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jboss-naming-build</artifactId>
- <version>5.0.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Naming Build</name>
- <url>http://www.jboss.com/products/jbossmc</url>
- <description>The JBoss JNDI name server implementation</description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/naming/branches/Branch_5_0</connection>
- </scm>
-
- <modules>
- <module>jnpserver</module>
- <module>jnpclient</module>
- </modules>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-7</version>
- <configuration>
- <tagBase>https://svn.jboss.org/repos/jbossas/projects/naming/tags</tagBase>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
-
Copied: projects/naming/tags/5.0.1.GA/pom.xml (from rev 83213, projects/naming/branches/Branch_5_0/pom.xml)
===================================================================
--- projects/naming/tags/5.0.1.GA/pom.xml (rev 0)
+++ projects/naming/tags/5.0.1.GA/pom.xml 2009-01-22 02:53:56 UTC (rev 83214)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ The parent maven for the jndi naming server project
+
+ This pom aggregates the subproject pom
+
+ To build this project maven 2 should be installed and in the system path. From the command line
+ run "mvn" from the build directory and "install" will be used as the default goal. In order to use
+ the "deploy" goal, the mvn.cvs.root should be specified in settings.xml.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>3</version>
+ </parent>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jboss-naming-build</artifactId>
+ <version>5.0.1.GA</version>
+ <packaging>pom</packaging>
+ <name>JBoss Naming Build</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>The JBoss JNDI name server implementation</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/naming/tags/5.0.1.GA</connection>
+ </scm>
+
+ <modules>
+ <module>jnpserver</module>
+ <module>jnpclient</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/naming/tags</tagBase>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
More information about the jboss-cvs-commits
mailing list