[jboss-cvs] JBossAS SVN: r88682 - in projects/naming/tags: 5.0.3.GA and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 11 19:46:32 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-05-11 19:46:32 -0400 (Mon, 11 May 2009)
New Revision: 88682
Added:
projects/naming/tags/5.0.3.GA/
projects/naming/tags/5.0.3.GA/jnpclient/pom.xml
projects/naming/tags/5.0.3.GA/jnpserver/pom.xml
projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java
projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java
projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
projects/naming/tags/5.0.3.GA/pom.xml
Removed:
projects/naming/tags/5.0.3.GA/jnpclient/pom.xml
projects/naming/tags/5.0.3.GA/jnpserver/pom.xml
projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java
projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java
projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
projects/naming/tags/5.0.3.GA/pom.xml
Log:
[maven-release-plugin] copy for tag 5.0.3.GA
Copied: projects/naming/tags/5.0.3.GA (from rev 88678, projects/naming/branches/Branch_5_0)
Deleted: projects/naming/tags/5.0.3.GA/jnpclient/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/jnpclient/pom.xml 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/jnpclient/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3-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.3.GA/jnpclient/pom.xml (from rev 88681, projects/naming/branches/Branch_5_0/jnpclient/pom.xml)
===================================================================
--- projects/naming/tags/5.0.3.GA/jnpclient/pom.xml (rev 0)
+++ projects/naming/tags/5.0.3.GA/jnpclient/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3.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.3.GA/jnpserver/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/pom.xml 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/jnpserver/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3-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.3.GA/jnpserver/pom.xml (from rev 88681, projects/naming/branches/Branch_5_0/jnpserver/pom.xml)
===================================================================
--- projects/naming/tags/5.0.3.GA/jnpserver/pom.xml (rev 0)
+++ projects/naming/tags/5.0.3.GA/jnpserver/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3.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.3.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.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/server/Main.java 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -1,657 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.rmi.MarshalledObject;
-import java.rmi.Remote;
-import java.rmi.server.RMIClientSocketFactory;
-import java.rmi.server.RMIServerSocketFactory;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.net.ServerSocketFactory;
-
-import org.jboss.logging.Logger;
-import org.jboss.net.sockets.DefaultSocketFactory;
-import org.jboss.util.threadpool.ThreadPool;
-import org.jnp.interfaces.MarshalledValuePair;
-import org.jnp.interfaces.Naming;
-
-/**
- * A main() entry point for running the jnp naming service implementation as
- * a standalone process.
- *
- * @author Rickard Oberg
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class Main implements MainMBean
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
- /** The Naming interface server implementation */
- protected NamingBean theServer;
- protected MarshalledObject serverStub;
- protected boolean isStubExported;
- /** The jnp server socket through which the NamingServer stub is vended */
- protected ServerSocket serverSocket;
- /** An optional custom client socket factory */
- protected RMIClientSocketFactory clientSocketFactory;
- /** An optional custom server socket factory */
- protected RMIServerSocketFactory serverSocketFactory;
- /** An optional custom server socket factory */
- protected ServerSocketFactory jnpServerSocketFactory;
- /** The class name of the optional custom client socket factory */
- protected String clientSocketFactoryName;
- /** The class name of the optional custom server socket factory */
- protected String serverSocketFactoryName;
- /** The class name of the optional custom JNP server socket factory */
- protected String jnpServerSocketFactoryName;
- /** The interface to bind to for the lookup socket. This is useful for
- * multi-homed hosts that want control over which interfaces accept
- * connections */
- protected InetAddress bindAddress;
- /** The interface to bind to for the Naming RMI server */
- protected InetAddress rmiBindAddress;
- /** Should the java.rmi.server.hostname property to rmiBindAddress */
- private boolean enableRmiServerHostname;
- /** The serverSocket listen queue depth */
- protected int backlog = 50;
- /** The jnp protocol listening port. The default is 1099, the same as
- the RMI registry default port. */
- protected int port = 1099;
- /** The RMI port on which the Naming implementation will be exported. The
- default is 0 which means use any available port. */
- protected int rmiPort = 0;
- /** A flag indicating if theServer will be set as the NamingContext.setLocal value */
- protected boolean InstallGlobalService = true;
- /** A flag indicating if theServer will try to use the NamingContext.setLocal value */
- protected boolean UseGlobalService = true;
- protected Logger log;
- /** The thread pool used to handle jnp stub lookup requests */
- private Executor lookupExector;
-
- // Static --------------------------------------------------------
- public static void main(String[] args)
- throws Exception
- {
- new Main().start();
- }
-
- // Constructors --------------------------------------------------
- public Main()
- {
- this("org.jboss.naming.Naming");
- }
- public Main(String categoryName)
- {
- // Load properties from properties file
- try
- {
- ClassLoader loader = getClass().getClassLoader();
- InputStream is = loader.getResourceAsStream("jnp.properties");
- System.getProperties().load(is);
- }
- catch (Exception e)
- {
- // Ignore
- }
-
- // Set configuration from the system properties
- setPort(Integer.getInteger("jnp.port",getPort()).intValue());
- setRmiPort(Integer.getInteger("jnp.rmiPort",getRmiPort()).intValue());
- log = Logger.getLogger(categoryName);
- log.debug("isTraceEnabled: "+log.isTraceEnabled());
- }
-
- // Public --------------------------------------------------------
- public NamingBean getNamingInfo()
- {
- return theServer;
- }
- /**
- * Set the NamingBean/Naming implementation
- * @param info
- */
- public void setNamingInfo(NamingBean info)
- {
- this.theServer = info;
- }
-
- @Deprecated
- public void setLookupPool(ThreadPool lookupPool)
- {
- this.lookupExector = new ThreadPoolToExecutor(lookupPool);
- }
-
- public Executor getLookupExector()
- {
- return lookupExector;
- }
- /**
- * Set the Executor to use for bootstrap socket lookup handling. Note
- * that this must support at least 2 thread to avoid hanging the AcceptHandler
- * accept loop.
- * @param lookupExector - An Executor that supports at least 2 threads
- */
- public void setLookupExector(Executor lookupExector)
- {
- this.lookupExector = lookupExector;
- }
-
- /** Get the call by value flag for jndi lookups.
- *
- * @return true if all lookups are unmarshalled using the caller's TCL,
- * false if in VM lookups return the value by reference.
- */
- public boolean getCallByValue()
- {
- return MarshalledValuePair.getEnableCallByReference() == false;
- }
- /** Set the call by value flag for jndi lookups.
- *
- * @param flag - true if all lookups are unmarshalled using the caller's TCL,
- * false if in VM lookups return the value by reference.
- */
- public void setCallByValue(boolean flag)
- {
- boolean callByValue = ! flag;
- MarshalledValuePair.setEnableCallByReference(callByValue);
- }
-
- public Object getNamingProxy()
- throws Exception
- {
- return serverStub.get();
- }
- public void setNamingProxy(Object proxy)
- throws IOException
- {
- serverStub = new MarshalledObject(proxy);
- }
-
- public void setRmiPort(int p)
- {
- rmiPort = p;
- }
- public int getRmiPort()
- {
- return rmiPort;
- }
-
- public void setPort(int p)
- {
- port = p;
- }
- public int getPort()
- {
- return port;
- }
-
- public String getBindAddress()
- {
- String address = null;
- if( bindAddress != null )
- address = bindAddress.getHostAddress();
- return address;
- }
- public void setBindAddress(String host) throws UnknownHostException
- {
- if( host == null || host.length() == 0 )
- bindAddress = null;
- else
- bindAddress = InetAddress.getByName(host);
- }
-
- public String getRmiBindAddress()
- {
- String address = null;
- if( rmiBindAddress != null )
- address = rmiBindAddress.getHostAddress();
- return address;
- }
- public void setRmiBindAddress(String host) throws UnknownHostException
- {
- if( host == null || host.length() == 0 )
- rmiBindAddress = null;
- else
- rmiBindAddress = InetAddress.getByName(host);
- }
-
- /**
- * Returns a URL suitable for use as a java.naming.provider.url value in
- * a set of naming environment properties; i.e. one that can be used to
- * connect to the lookup socket.
- *
- * @return the URL, or <code>null</code> if no bound lookup socket exists
- */
- public String getBootstrapURL()
- {
- if (serverSocket == null || serverSocket.getInetAddress() == null)
- return null;
-
- // Determine the bootstrap URL
- StringBuilder sb = new StringBuilder("jnp://");
- InetAddress addr = serverSocket.getInetAddress();
- if (addr instanceof Inet6Address)
- {
- sb.append('[');
- sb.append(addr.getHostAddress());
- sb.append(']');
- }
- else
- {
- sb.append(addr.getHostAddress());
- }
- sb.append(':');
- sb.append(port);
- return sb.toString();
- }
-
- public boolean isEnableRmiServerHostname()
- {
- return enableRmiServerHostname;
- }
- public void setEnableRmiServerHostname(boolean enableRmiServerHostname)
- {
- this.enableRmiServerHostname = enableRmiServerHostname;
- }
-
- public int getBacklog()
- {
- return backlog;
- }
- public void setBacklog(int backlog)
- {
- if( backlog <= 0 )
- backlog = 50;
- this.backlog = backlog;
- }
-
- public boolean getInstallGlobalService()
- {
- return InstallGlobalService;
- }
- public void setInstallGlobalService(boolean flag)
- {
- this.InstallGlobalService = flag;
- }
- public boolean getUseGlobalService()
- {
- return UseGlobalService;
- }
- public void setUseGlobalService(boolean flag)
- {
- this.UseGlobalService = flag;
- }
-
- public String getClientSocketFactory()
- {
- return clientSocketFactoryName;
- }
- public void setClientSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException
- {
- this.clientSocketFactoryName = factoryClassName;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class<?> clazz = loader.loadClass(clientSocketFactoryName);
- clientSocketFactory = (RMIClientSocketFactory) clazz.newInstance();
- }
-
- public RMIClientSocketFactory getClientSocketFactoryBean()
- {
- return clientSocketFactory;
- }
- public void setClientSocketFactoryBean(RMIClientSocketFactory factory)
- {
- this.clientSocketFactory = factory;
- }
-
- public String getServerSocketFactory()
- {
- return serverSocketFactoryName;
- }
- public void setServerSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException
- {
- this.serverSocketFactoryName = factoryClassName;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class<?> clazz = loader.loadClass(serverSocketFactoryName);
- serverSocketFactory = (RMIServerSocketFactory) clazz.newInstance();
- }
-
- public RMIServerSocketFactory getServerSocketFactoryBean()
- {
- return serverSocketFactory;
- }
- public void setServerSocketFactoryBean(RMIServerSocketFactory factory)
- {
- this.serverSocketFactory = factory;
- }
-
- public String getJNPServerSocketFactory()
- {
- return jnpServerSocketFactoryName;
- }
- public void setJNPServerSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException
- {
- this.jnpServerSocketFactoryName = factoryClassName;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class<?> clazz = loader.loadClass(jnpServerSocketFactoryName);
- jnpServerSocketFactory = (ServerSocketFactory) clazz.newInstance();
- }
-
- public ServerSocketFactory getJNPServerSocketFactoryBean()
- {
- return jnpServerSocketFactory;
- }
- public void setJNPServerSocketFactoryBean(ServerSocketFactory factory)
- {
- this.jnpServerSocketFactory = factory;
- }
-
- /**
- * Access the
- */
- public Naming getNamingInstance()
- {
- return theServer.getNamingInstance();
- }
-
- public void start()
- throws Exception
- {
- log.debug("Begin start");
- // Set the java.rmi.server.hostname to the bind address if not set
- if(rmiBindAddress != null && System.getProperty("java.rmi.server.hostname") == null)
- System.setProperty("java.rmi.server.hostname", rmiBindAddress.getHostAddress());
-
- // Initialize the custom socket factories with any bind address
- initCustomSocketFactories();
- /* Only export server RMI interface and setup the listening socket if
- the port is >= 0 and an external proxy has not been installed.
- A value < 0 indicates no socket based access
- */
- if( this.serverStub == null && port >= 0 )
- {
- initJnpInvoker();
- }
- // Only bring up the bootstrap listener if there is a naming proxy
- if( this.serverStub != null )
- {
- initBootstrapListener();
- }
- log.debug("End start");
- }
-
- public void stop()
- {
- try
- {
- // Stop listener and unexport the RMI object
- if( serverSocket != null )
- {
- ServerSocket s = serverSocket;
- serverSocket = null;
- s.close();
- }
- if( isStubExported == true )
- UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
- }
- catch (Exception e)
- {
- log.error("Exception during shutdown", e);
- }
- }
-
- /** This code should be moved to a seperate invoker in the org.jboss.naming
- *package.
- */
- protected void initJnpInvoker() throws IOException
- {
- log.debug("Creating NamingServer stub, theServer="+theServer
- +",rmiPort="+rmiPort
- +",clientSocketFactory="+clientSocketFactory
- +",serverSocketFactory="+serverSocketFactory);
- Naming instance = getNamingInstance();
- Remote stub = UnicastRemoteObject.exportObject(instance,
- rmiPort, clientSocketFactory, serverSocketFactory);
- log.debug("NamingServer stub: "+stub);
- serverStub = new MarshalledObject(stub);
- isStubExported = true;
- }
-
- /** Bring up the bootstrap lookup port for obtaining the naming service
- * proxy
- */
- protected void initBootstrapListener()
- {
- // Start listener
- try
- {
- // Get the default ServerSocketFactory is one was not specified
- if( jnpServerSocketFactory == null )
- jnpServerSocketFactory = ServerSocketFactory.getDefault();
- serverSocket = jnpServerSocketFactory.createServerSocket(port, backlog, bindAddress);
- // If an anonymous port was specified get the actual port used
- if( port == 0 )
- port = serverSocket.getLocalPort();
- String msg = "JNDI bootstrap JNP=" + bindAddress + ":" + port
- + ", RMI=" + bindAddress + ":" + rmiPort
- + ", backlog="+backlog;
-
- if (clientSocketFactory == null)
- msg+= ", no client SocketFactory";
- else
- msg+= ", Client SocketFactory="+clientSocketFactory.toString();
-
- if (serverSocketFactory == null)
- msg+= ", no server SocketFactory";
- else
- msg+= ", Server SocketFactory="+serverSocketFactory.toString();
-
- log.debug(msg);
- }
- catch (IOException e)
- {
- log.error("Could not start on port " + port, e);
- }
-
- if( lookupExector == null )
- {
- log.debug("Using default newFixedThreadPool(2)");
- lookupExector = Executors.newFixedThreadPool(2, BootstrapThreadFactory.getInstance());
- }
- AcceptHandler handler = new AcceptHandler();
- lookupExector.execute(handler);
- }
-
- /**
- * Init the clientSocketFactory, serverSocketFactory using the bind address.
- */
- protected void initCustomSocketFactories()
- {
- // Use either the rmiBindAddress or bindAddress for the RMI service
- InetAddress addr = rmiBindAddress != null ? rmiBindAddress : bindAddress;
-
- if( clientSocketFactory != null && addr != null )
- {
- // See if the client socket supports setBindAddress(String)
- try
- {
- Class<?> csfClass = clientSocketFactory.getClass();
- Class<?>[] parameterTypes = {String.class};
- Method m = csfClass.getMethod("setBindAddress", parameterTypes);
- Object[] args = {addr.getHostAddress()};
- m.invoke(clientSocketFactory, args);
- }
- catch (NoSuchMethodException e)
- {
- log.warn("Socket factory does not support setBindAddress(String)");
- // Go with default address
- }
- catch (Exception e)
- {
- log.warn("Failed to setBindAddress="+addr+" on socket factory", e);
- // Go with default address
- }
- }
-
- try
- {
- if (serverSocketFactory == null)
- serverSocketFactory = new DefaultSocketFactory(addr);
- else
- {
- if (addr != null)
- {
- // See if the server socket supports setBindAddress(String)
- try
- {
- Class<?> ssfClass = serverSocketFactory.getClass();
- Class<?>[] parameterTypes = {String.class};
- Method m = ssfClass.getMethod("setBindAddress", parameterTypes);
- Object[] args = {addr.getHostAddress()};
- m.invoke(serverSocketFactory, args);
- }
- catch (NoSuchMethodException e)
- {
- log.warn("Socket factory does not support setBindAddress(String)");
- // Go with default address
- }
- catch (Exception e)
- {
- log.warn("Failed to setBindAddress="+addr+" on socket factory", e);
- // Go with default address
- }
- }
- }
- }
- catch (Exception e)
- {
- log.error("operation failed", e);
- serverSocketFactory = null;
- }
- }
-
- private class AcceptHandler implements Runnable
- {
- public void run()
- {
- boolean trace = log.isTraceEnabled();
- while( serverSocket != null )
- {
- Socket socket = null;
- // Accept a connection
- try
- {
- if( trace )
- log.trace("Enter accept on: "+serverSocket);
- socket = serverSocket.accept();
- if( trace )
- log.trace("Accepted bootstrap client: "+socket);
- BootstrapRequestHandler handler = new BootstrapRequestHandler(socket);
- lookupExector.execute(handler);
- }
- catch (IOException e)
- {
- // Stopped by normal means
- if (serverSocket == null)
- return;
- log.error("Naming accept handler stopping", e);
- }
- catch(Throwable e)
- {
- log.error("Unexpected exception during accept", e);
- }
- }
- }
- }
-
- private class BootstrapRequestHandler implements Runnable
- {
- private Socket socket;
- BootstrapRequestHandler(Socket socket)
- {
- this.socket = socket;
- }
- public void run()
- {
- // Return the naming server stub
- try
- {
- if(log.isTraceEnabled())
- log.trace("BootstrapRequestHandler.run start");
- OutputStream os = socket.getOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(os);
- out.writeObject(serverStub);
- out.close();
- if(log.isTraceEnabled())
- log.trace("BootstrapRequestHandler.run end");
- }
- catch (IOException ex)
- {
- log.debug("Error writing response to " + socket.getInetAddress(), ex);
- }
- finally
- {
- try
- {
- socket.close();
- } catch (IOException e)
- {
- }
- }
- }
- }
- private static class BootstrapThreadFactory implements ThreadFactory
- {
- private static final AtomicInteger tnumber = new AtomicInteger(1);
- static BootstrapThreadFactory instance;
- static synchronized ThreadFactory getInstance()
- {
- if(instance == null)
- instance = new BootstrapThreadFactory();
- return instance;
- }
- public Thread newThread(Runnable r)
- {
- Thread t = new Thread(r, "Naming Bootstrap#"+tnumber.getAndIncrement());
- return t;
- }
- }
-}
Copied: projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java (from rev 88679, projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/server/Main.java)
===================================================================
--- projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java (rev 0)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/Main.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -0,0 +1,670 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.net.ServerSocketFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.net.sockets.DefaultSocketFactory;
+import org.jboss.util.threadpool.ThreadPool;
+import org.jnp.interfaces.MarshalledValuePair;
+import org.jnp.interfaces.Naming;
+
+/**
+ * A main() entry point for running the jnp naming service implementation as
+ * a standalone process.
+ *
+ * @author Rickard Oberg
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class Main implements MainMBean
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ /** The Naming interface server implementation */
+ protected NamingBean theServer;
+ protected MarshalledObject serverStub;
+ protected boolean isStubExported;
+ /** The jnp server socket through which the NamingServer stub is vended */
+ protected ServerSocket serverSocket;
+ /** An optional custom client socket factory */
+ protected RMIClientSocketFactory clientSocketFactory;
+ /** An optional custom server socket factory */
+ protected RMIServerSocketFactory serverSocketFactory;
+ /** An optional custom server socket factory */
+ protected ServerSocketFactory jnpServerSocketFactory;
+ /** The class name of the optional custom client socket factory */
+ protected String clientSocketFactoryName;
+ /** The class name of the optional custom server socket factory */
+ protected String serverSocketFactoryName;
+ /** The class name of the optional custom JNP server socket factory */
+ protected String jnpServerSocketFactoryName;
+ /** The interface to bind to for the lookup socket. This is useful for
+ * multi-homed hosts that want control over which interfaces accept
+ * connections */
+ protected InetAddress bindAddress;
+ /** The interface to bind to for the Naming RMI server */
+ protected InetAddress rmiBindAddress;
+ /** Should the java.rmi.server.hostname property to rmiBindAddress */
+ private boolean enableRmiServerHostname;
+ /** The serverSocket listen queue depth */
+ protected int backlog = 50;
+ /** The jnp protocol listening port. The default is 1099, the same as
+ the RMI registry default port. */
+ protected int port = 1099;
+ /** The RMI port on which the Naming implementation will be exported. The
+ default is 0 which means use any available port. */
+ protected int rmiPort = 0;
+ /** A flag indicating if theServer will be set as the NamingContext.setLocal value */
+ protected boolean InstallGlobalService = true;
+ /** A flag indicating if theServer will try to use the NamingContext.setLocal value */
+ protected boolean UseGlobalService = true;
+ protected Logger log;
+ /** The thread pool used to handle jnp stub lookup requests */
+ private Executor lookupExector;
+ /** The exception seen when creating the lookup listening port */
+ private Exception lookupListenerException;
+
+ // Static --------------------------------------------------------
+ public static void main(String[] args)
+ throws Exception
+ {
+ new Main().start();
+ }
+
+ // Constructors --------------------------------------------------
+ public Main()
+ {
+ this("org.jboss.naming.Naming");
+ }
+ public Main(String categoryName)
+ {
+ // Load properties from properties file
+ try
+ {
+ ClassLoader loader = getClass().getClassLoader();
+ InputStream is = loader.getResourceAsStream("jnp.properties");
+ System.getProperties().load(is);
+ }
+ catch (Exception e)
+ {
+ // Ignore
+ }
+
+ // Set configuration from the system properties
+ setPort(Integer.getInteger("jnp.port",getPort()).intValue());
+ setRmiPort(Integer.getInteger("jnp.rmiPort",getRmiPort()).intValue());
+ log = Logger.getLogger(categoryName);
+ log.debug("isTraceEnabled: "+log.isTraceEnabled());
+ }
+
+ // Public --------------------------------------------------------
+ public NamingBean getNamingInfo()
+ {
+ return theServer;
+ }
+ /**
+ * Set the NamingBean/Naming implementation
+ * @param info
+ */
+ public void setNamingInfo(NamingBean info)
+ {
+ this.theServer = info;
+ }
+
+ @Deprecated
+ public void setLookupPool(ThreadPool lookupPool)
+ {
+ this.lookupExector = new ThreadPoolToExecutor(lookupPool);
+ }
+
+ public Executor getLookupExector()
+ {
+ return lookupExector;
+ }
+ /**
+ * Set the Executor to use for bootstrap socket lookup handling. Note
+ * that this must support at least 2 thread to avoid hanging the AcceptHandler
+ * accept loop.
+ * @param lookupExector - An Executor that supports at least 2 threads
+ */
+ public void setLookupExector(Executor lookupExector)
+ {
+ this.lookupExector = lookupExector;
+ }
+
+ /**
+ * Get any exception seen during the lookup listening port creation
+ * @return
+ */
+ public Exception getLookupListenerException()
+ {
+ return lookupListenerException;
+ }
+
+ /** Get the call by value flag for jndi lookups.
+ *
+ * @return true if all lookups are unmarshalled using the caller's TCL,
+ * false if in VM lookups return the value by reference.
+ */
+ public boolean getCallByValue()
+ {
+ return MarshalledValuePair.getEnableCallByReference() == false;
+ }
+ /** Set the call by value flag for jndi lookups.
+ *
+ * @param flag - true if all lookups are unmarshalled using the caller's TCL,
+ * false if in VM lookups return the value by reference.
+ */
+ public void setCallByValue(boolean flag)
+ {
+ boolean callByValue = ! flag;
+ MarshalledValuePair.setEnableCallByReference(callByValue);
+ }
+
+ public Object getNamingProxy()
+ throws Exception
+ {
+ return serverStub.get();
+ }
+ public void setNamingProxy(Object proxy)
+ throws IOException
+ {
+ serverStub = new MarshalledObject(proxy);
+ }
+
+ public void setRmiPort(int p)
+ {
+ rmiPort = p;
+ }
+ public int getRmiPort()
+ {
+ return rmiPort;
+ }
+
+ public void setPort(int p)
+ {
+ port = p;
+ }
+ public int getPort()
+ {
+ return port;
+ }
+
+ public String getBindAddress()
+ {
+ String address = null;
+ if( bindAddress != null )
+ address = bindAddress.getHostAddress();
+ return address;
+ }
+ public void setBindAddress(String host) throws UnknownHostException
+ {
+ if( host == null || host.length() == 0 )
+ bindAddress = null;
+ else
+ bindAddress = InetAddress.getByName(host);
+ }
+
+ public String getRmiBindAddress()
+ {
+ String address = null;
+ if( rmiBindAddress != null )
+ address = rmiBindAddress.getHostAddress();
+ return address;
+ }
+ public void setRmiBindAddress(String host) throws UnknownHostException
+ {
+ if( host == null || host.length() == 0 )
+ rmiBindAddress = null;
+ else
+ rmiBindAddress = InetAddress.getByName(host);
+ }
+
+ /**
+ * Returns a URL suitable for use as a java.naming.provider.url value in
+ * a set of naming environment properties; i.e. one that can be used to
+ * connect to the lookup socket.
+ *
+ * @return the URL, or <code>null</code> if no bound lookup socket exists
+ */
+ public String getBootstrapURL()
+ {
+ if (serverSocket == null || serverSocket.getInetAddress() == null)
+ return null;
+
+ // Determine the bootstrap URL
+ StringBuilder sb = new StringBuilder("jnp://");
+ InetAddress addr = serverSocket.getInetAddress();
+ if (addr instanceof Inet6Address)
+ {
+ sb.append('[');
+ sb.append(addr.getHostAddress());
+ sb.append(']');
+ }
+ else
+ {
+ sb.append(addr.getHostAddress());
+ }
+ sb.append(':');
+ sb.append(port);
+ return sb.toString();
+ }
+
+ public boolean isEnableRmiServerHostname()
+ {
+ return enableRmiServerHostname;
+ }
+ public void setEnableRmiServerHostname(boolean enableRmiServerHostname)
+ {
+ this.enableRmiServerHostname = enableRmiServerHostname;
+ }
+
+ public int getBacklog()
+ {
+ return backlog;
+ }
+ public void setBacklog(int backlog)
+ {
+ if( backlog <= 0 )
+ backlog = 50;
+ this.backlog = backlog;
+ }
+
+ public boolean getInstallGlobalService()
+ {
+ return InstallGlobalService;
+ }
+ public void setInstallGlobalService(boolean flag)
+ {
+ this.InstallGlobalService = flag;
+ }
+ public boolean getUseGlobalService()
+ {
+ return UseGlobalService;
+ }
+ public void setUseGlobalService(boolean flag)
+ {
+ this.UseGlobalService = flag;
+ }
+
+ public String getClientSocketFactory()
+ {
+ return clientSocketFactoryName;
+ }
+ public void setClientSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException
+ {
+ this.clientSocketFactoryName = factoryClassName;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class<?> clazz = loader.loadClass(clientSocketFactoryName);
+ clientSocketFactory = (RMIClientSocketFactory) clazz.newInstance();
+ }
+
+ public RMIClientSocketFactory getClientSocketFactoryBean()
+ {
+ return clientSocketFactory;
+ }
+ public void setClientSocketFactoryBean(RMIClientSocketFactory factory)
+ {
+ this.clientSocketFactory = factory;
+ }
+
+ public String getServerSocketFactory()
+ {
+ return serverSocketFactoryName;
+ }
+ public void setServerSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException
+ {
+ this.serverSocketFactoryName = factoryClassName;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class<?> clazz = loader.loadClass(serverSocketFactoryName);
+ serverSocketFactory = (RMIServerSocketFactory) clazz.newInstance();
+ }
+
+ public RMIServerSocketFactory getServerSocketFactoryBean()
+ {
+ return serverSocketFactory;
+ }
+ public void setServerSocketFactoryBean(RMIServerSocketFactory factory)
+ {
+ this.serverSocketFactory = factory;
+ }
+
+ public String getJNPServerSocketFactory()
+ {
+ return jnpServerSocketFactoryName;
+ }
+ public void setJNPServerSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException
+ {
+ this.jnpServerSocketFactoryName = factoryClassName;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class<?> clazz = loader.loadClass(jnpServerSocketFactoryName);
+ jnpServerSocketFactory = (ServerSocketFactory) clazz.newInstance();
+ }
+
+ public ServerSocketFactory getJNPServerSocketFactoryBean()
+ {
+ return jnpServerSocketFactory;
+ }
+ public void setJNPServerSocketFactoryBean(ServerSocketFactory factory)
+ {
+ this.jnpServerSocketFactory = factory;
+ }
+
+ /**
+ * Access the
+ */
+ public Naming getNamingInstance()
+ {
+ return theServer.getNamingInstance();
+ }
+
+ public void start()
+ throws Exception
+ {
+ log.debug("Begin start");
+ // Set the java.rmi.server.hostname to the bind address if not set
+ if(rmiBindAddress != null && System.getProperty("java.rmi.server.hostname") == null)
+ System.setProperty("java.rmi.server.hostname", rmiBindAddress.getHostAddress());
+
+ // Initialize the custom socket factories with any bind address
+ initCustomSocketFactories();
+ /* Only export server RMI interface and setup the listening socket if
+ the port is >= 0 and an external proxy has not been installed.
+ A value < 0 indicates no socket based access
+ */
+ if( this.serverStub == null && port >= 0 )
+ {
+ initJnpInvoker();
+ }
+ // Only bring up the bootstrap listener if there is a naming proxy
+ if( this.serverStub != null )
+ {
+ initBootstrapListener();
+ }
+ log.debug("End start");
+ }
+
+ public void stop()
+ {
+ try
+ {
+ // Stop listener and unexport the RMI object
+ if( serverSocket != null )
+ {
+ ServerSocket s = serverSocket;
+ serverSocket = null;
+ s.close();
+ }
+ if( isStubExported == true )
+ UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
+ }
+ catch (Exception e)
+ {
+ log.error("Exception during shutdown", e);
+ }
+ }
+
+ /** This code should be moved to a seperate invoker in the org.jboss.naming
+ *package.
+ */
+ protected void initJnpInvoker() throws IOException
+ {
+ log.debug("Creating NamingServer stub, theServer="+theServer
+ +",rmiPort="+rmiPort
+ +",clientSocketFactory="+clientSocketFactory
+ +",serverSocketFactory="+serverSocketFactory);
+ Naming instance = getNamingInstance();
+ Remote stub = UnicastRemoteObject.exportObject(instance,
+ rmiPort, clientSocketFactory, serverSocketFactory);
+ log.debug("NamingServer stub: "+stub);
+ serverStub = new MarshalledObject(stub);
+ isStubExported = true;
+ }
+
+ /** Bring up the bootstrap lookup port for obtaining the naming service
+ * proxy
+ */
+ protected void initBootstrapListener()
+ {
+ // Start listener
+ try
+ {
+ // Get the default ServerSocketFactory is one was not specified
+ if( jnpServerSocketFactory == null )
+ jnpServerSocketFactory = ServerSocketFactory.getDefault();
+ serverSocket = jnpServerSocketFactory.createServerSocket(port, backlog, bindAddress);
+ // If an anonymous port was specified get the actual port used
+ if( port == 0 )
+ port = serverSocket.getLocalPort();
+ String msg = "JNDI bootstrap JNP=" + bindAddress + ":" + port
+ + ", RMI=" + bindAddress + ":" + rmiPort
+ + ", backlog="+backlog;
+
+ if (clientSocketFactory == null)
+ msg+= ", no client SocketFactory";
+ else
+ msg+= ", Client SocketFactory="+clientSocketFactory.toString();
+
+ if (serverSocketFactory == null)
+ msg+= ", no server SocketFactory";
+ else
+ msg+= ", Server SocketFactory="+serverSocketFactory.toString();
+
+ log.debug(msg);
+ }
+ catch (IOException e)
+ {
+ lookupListenerException = e;
+ log.error("Could not start on port " + port, e);
+ return;
+ }
+
+ if( lookupExector == null )
+ {
+ log.debug("Using default newFixedThreadPool(2)");
+ lookupExector = Executors.newFixedThreadPool(2, BootstrapThreadFactory.getInstance());
+ }
+ AcceptHandler handler = new AcceptHandler();
+ lookupExector.execute(handler);
+ }
+
+ /**
+ * Init the clientSocketFactory, serverSocketFactory using the bind address.
+ */
+ protected void initCustomSocketFactories()
+ {
+ // Use either the rmiBindAddress or bindAddress for the RMI service
+ InetAddress addr = rmiBindAddress != null ? rmiBindAddress : bindAddress;
+
+ if( clientSocketFactory != null && addr != null )
+ {
+ // See if the client socket supports setBindAddress(String)
+ try
+ {
+ Class<?> csfClass = clientSocketFactory.getClass();
+ Class<?>[] parameterTypes = {String.class};
+ Method m = csfClass.getMethod("setBindAddress", parameterTypes);
+ Object[] args = {addr.getHostAddress()};
+ m.invoke(clientSocketFactory, args);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.warn("Socket factory does not support setBindAddress(String)");
+ // Go with default address
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to setBindAddress="+addr+" on socket factory", e);
+ // Go with default address
+ }
+ }
+
+ try
+ {
+ if (serverSocketFactory == null)
+ serverSocketFactory = new DefaultSocketFactory(addr);
+ else
+ {
+ if (addr != null)
+ {
+ // See if the server socket supports setBindAddress(String)
+ try
+ {
+ Class<?> ssfClass = serverSocketFactory.getClass();
+ Class<?>[] parameterTypes = {String.class};
+ Method m = ssfClass.getMethod("setBindAddress", parameterTypes);
+ Object[] args = {addr.getHostAddress()};
+ m.invoke(serverSocketFactory, args);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.warn("Socket factory does not support setBindAddress(String)");
+ // Go with default address
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to setBindAddress="+addr+" on socket factory", e);
+ // Go with default address
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("operation failed", e);
+ serverSocketFactory = null;
+ }
+ }
+
+ private class AcceptHandler implements Runnable
+ {
+ public void run()
+ {
+ boolean trace = log.isTraceEnabled();
+ while( serverSocket != null )
+ {
+ Socket socket = null;
+ // Accept a connection
+ try
+ {
+ if( trace )
+ log.trace("Enter accept on: "+serverSocket);
+ socket = serverSocket.accept();
+ if( trace )
+ log.trace("Accepted bootstrap client: "+socket);
+ BootstrapRequestHandler handler = new BootstrapRequestHandler(socket);
+ lookupExector.execute(handler);
+ }
+ catch (IOException e)
+ {
+ // Stopped by normal means
+ if (serverSocket == null)
+ return;
+ log.error("Naming accept handler stopping", e);
+ }
+ catch(Throwable e)
+ {
+ log.error("Unexpected exception during accept", e);
+ }
+ }
+ }
+ }
+
+ private class BootstrapRequestHandler implements Runnable
+ {
+ private Socket socket;
+ BootstrapRequestHandler(Socket socket)
+ {
+ this.socket = socket;
+ }
+ public void run()
+ {
+ // Return the naming server stub
+ try
+ {
+ if(log.isTraceEnabled())
+ log.trace("BootstrapRequestHandler.run start");
+ OutputStream os = socket.getOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(os);
+ out.writeObject(serverStub);
+ out.close();
+ if(log.isTraceEnabled())
+ log.trace("BootstrapRequestHandler.run end");
+ }
+ catch (IOException ex)
+ {
+ log.debug("Error writing response to " + socket.getInetAddress(), ex);
+ }
+ finally
+ {
+ try
+ {
+ socket.close();
+ } catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+ private static class BootstrapThreadFactory implements ThreadFactory
+ {
+ private static final AtomicInteger tnumber = new AtomicInteger(1);
+ static BootstrapThreadFactory instance;
+ static synchronized ThreadFactory getInstance()
+ {
+ if(instance == null)
+ instance = new BootstrapThreadFactory();
+ return instance;
+ }
+ public Thread newThread(Runnable r)
+ {
+ Thread t = new Thread(r, "Naming Bootstrap#"+tnumber.getAndIncrement());
+ return t;
+ }
+ }
+}
Deleted: projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/server/MainMBean.java 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.server;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.rmi.server.RMIClientSocketFactory;
-import java.rmi.server.RMIServerSocketFactory;
-
-import javax.net.ServerSocketFactory;
-
-/**
- * The Mbean interface for the jnp provider server.
- *
- * @author Rickard Oberg
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface MainMBean extends NamingBean
-{
- // Attributes ---------------------------------------------------
-
- void setRmiPort(int port);
- int getRmiPort();
-
- void setPort(int port);
- int getPort();
-
- void setBindAddress(String host) throws UnknownHostException;
- String getBindAddress();
-
- void setRmiBindAddress(String host) throws UnknownHostException;
- String getRmiBindAddress();
-
- void setBacklog(int backlog);
- int getBacklog();
-
- /**
- * Returns a URL suitable for use as a java.naming.provider.url value in
- * a set of naming environment properties; i.e. one that can be used to
- * connect to the lookup socket.
- *
- * @return the URL, or <code>null</code> if no bound lookup socket exists
- */
- String getBootstrapURL();
-
- public NamingBean getNamingInfo();
- /**
- * Set the NamingBean/Naming implementation
- * @param info
- */
- public void setNamingInfo(NamingBean info);
-
- /**
- * Get the call by value flag for jndi lookups.
- * @return true if all lookups are unmarshalled using the caller's TCL, false if in VM lookups return the value by reference. */
- boolean getCallByValue() ;
-
- /**
- * Set the call by value flag for jndi lookups.
- * @param flag - true if all lookups are unmarshalled using the caller's TCL, false if in VM lookups return the value by reference. */
- void setCallByValue(boolean flag) ;
-
- /** Whether the MainMBean's Naming server will be installed as the NamingContext.setLocal global value */
- void setInstallGlobalService(boolean flag);
- boolean getInstallGlobalService();
-
- /** Get the UseGlobalService which defines whether the MainMBean's
- * Naming server will initialized from the existing NamingContext.setLocal
- * global value.
- *
- * @return true if this should try to use VM global naming service, false otherwise
- */
- public boolean getUseGlobalService();
- /** Set the UseGlobalService which defines whether the MainMBean's
- * Naming server will initialized from the existing NamingContext.setLocal global
- * value. This allows one to export multiple servers via different transports
- * and still share the same underlying naming service.
- *
- * @return true if this should try to use VM global naming service, false otherwise
- */
- public void setUseGlobalService(boolean flag);
-
- /** The RMIClientSocketFactory implementation class */
- void setClientSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException;
- String getClientSocketFactory();
- /** The RMIClientSocketFactory bean */
- public RMIClientSocketFactory getClientSocketFactoryBean();
- public void setClientSocketFactoryBean(RMIClientSocketFactory factory);
-
- /** The RMIServerSocketFactory implementation class */
- void setServerSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException;
- String getServerSocketFactory();
- /** The RMIServerSocketFactory bean */
- public RMIServerSocketFactory getServerSocketFactoryBean();
- public void setServerSocketFactoryBean(RMIServerSocketFactory factory);
-
- /** The JNPServerSocketFactory implementation class */
- ServerSocketFactory getJNPServerSocketFactoryBean();
- void setJNPServerSocketFactoryBean(ServerSocketFactory factory);
- public String getJNPServerSocketFactory();
- void setJNPServerSocketFactory(String factoryClassName)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException;
-
- public Object getNamingProxy()
- throws Exception;
- public void setNamingProxy(Object proxy)
- throws IOException;
-
- // Operations ----------------------------------------------------
-
- public void start() throws Exception;
-
- public void stop() throws Exception;
-
-}
Copied: projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java (from rev 88679, projects/naming/branches/Branch_5_0/jnpserver/src/main/java/org/jnp/server/MainMBean.java)
===================================================================
--- projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java (rev 0)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/main/java/org/jnp/server/MainMBean.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.server;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+
+import javax.net.ServerSocketFactory;
+
+/**
+ * The Mbean interface for the jnp provider server.
+ *
+ * @author Rickard Oberg
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface MainMBean extends NamingBean
+{
+ // Attributes ---------------------------------------------------
+
+ void setRmiPort(int port);
+ int getRmiPort();
+
+ void setPort(int port);
+ int getPort();
+
+ void setBindAddress(String host) throws UnknownHostException;
+ String getBindAddress();
+
+ void setRmiBindAddress(String host) throws UnknownHostException;
+ String getRmiBindAddress();
+
+ void setBacklog(int backlog);
+ int getBacklog();
+
+ /**
+ * Returns a URL suitable for use as a java.naming.provider.url value in
+ * a set of naming environment properties; i.e. one that can be used to
+ * connect to the lookup socket.
+ *
+ * @return the URL, or <code>null</code> if no bound lookup socket exists
+ */
+ String getBootstrapURL();
+
+ public NamingBean getNamingInfo();
+ /**
+ * Set the NamingBean/Naming implementation
+ * @param info
+ */
+ public void setNamingInfo(NamingBean info);
+
+ /**
+ * Get the call by value flag for jndi lookups.
+ * @return true if all lookups are unmarshalled using the caller's TCL, false if in VM lookups return the value by reference. */
+ boolean getCallByValue() ;
+
+ /**
+ * Set the call by value flag for jndi lookups.
+ * @param flag - true if all lookups are unmarshalled using the caller's TCL, false if in VM lookups return the value by reference. */
+ void setCallByValue(boolean flag) ;
+
+ /** Whether the MainMBean's Naming server will be installed as the NamingContext.setLocal global value */
+ void setInstallGlobalService(boolean flag);
+ boolean getInstallGlobalService();
+
+ /** Get the UseGlobalService which defines whether the MainMBean's
+ * Naming server will initialized from the existing NamingContext.setLocal
+ * global value.
+ *
+ * @return true if this should try to use VM global naming service, false otherwise
+ */
+ public boolean getUseGlobalService();
+ /** Set the UseGlobalService which defines whether the MainMBean's
+ * Naming server will initialized from the existing NamingContext.setLocal global
+ * value. This allows one to export multiple servers via different transports
+ * and still share the same underlying naming service.
+ *
+ * @return true if this should try to use VM global naming service, false otherwise
+ */
+ public void setUseGlobalService(boolean flag);
+
+ /** The RMIClientSocketFactory implementation class */
+ void setClientSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException;
+ String getClientSocketFactory();
+ /** The RMIClientSocketFactory bean */
+ public RMIClientSocketFactory getClientSocketFactoryBean();
+ public void setClientSocketFactoryBean(RMIClientSocketFactory factory);
+
+ /** The RMIServerSocketFactory implementation class */
+ void setServerSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException;
+ String getServerSocketFactory();
+ /** The RMIServerSocketFactory bean */
+ public RMIServerSocketFactory getServerSocketFactoryBean();
+ public void setServerSocketFactoryBean(RMIServerSocketFactory factory);
+
+ /** The JNPServerSocketFactory implementation class */
+ ServerSocketFactory getJNPServerSocketFactoryBean();
+ void setJNPServerSocketFactoryBean(ServerSocketFactory factory);
+ public String getJNPServerSocketFactory();
+ void setJNPServerSocketFactory(String factoryClassName)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException;
+
+ /**
+ * Get the externally define Naming proxy instance
+ * @return
+ * @throws Exception
+ */
+ public Object getNamingProxy()
+ throws Exception;
+ public void setNamingProxy(Object proxy)
+ throws IOException;
+
+ /**
+ * Get any exception seen during the lookup listening port creation
+ * @return
+ */
+ public Exception getLookupListenerException();
+
+ // Operations ----------------------------------------------------
+
+ public void start() throws Exception;
+
+ public void stop() throws Exception;
+
+}
Deleted: projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.test;
-
-import java.math.BigInteger;
-import java.net.InetAddress;
-import java.security.Permission;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.spi.InitialContextFactory;
-
-import junit.framework.Test;
-
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.beans.metadata.api.model.InjectOption;
-import org.jboss.naming.JndiPermission;
-import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jnp.interfaces.NamingContext;
-import org.jnp.interfaces.TimedSocketFactory;
-import org.jnp.test.support.QueueSecurityManager;
-
-/**
- * Test bootstraping the naming service using the mc
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class NamingMCUnitTest extends MicrocontainerTest
-{
- public static Test suite()
- {
- return suite(NamingMCUnitTest.class);
- }
- /** */
- private InitialContext ctx;
- private QueueSecurityManager qsm;
- private InitialContextFactory ctxFactory;
-
- /**
- *
- * @param name
- */
- public NamingMCUnitTest(String name)
- {
- super(name, true);
- }
-
- /**
- * Obtain the InitialContext from the InitialContextFactory bean ctx property.
- * Each test expects an InitialContextFactory bean
- * @see org.jboss.naming.NamingContextFactory
- *
- * @param ctx
- */
- @Inject(bean="InitialContextFactory", property="ctx")
- public void setInitialContext(InitialContext ctx)
- {
- this.ctx = ctx;
- }
- @Inject(bean="QueueSecurityManager", option=InjectOption.OPTIONAL)
- public void setQueueSecurityManager(QueueSecurityManager qsm)
- {
- this.qsm = qsm;
- }
- @Inject(bean="InitialContextFactory#3", option=InjectOption.OPTIONAL)
- public void setCtxFactory(InitialContextFactory ctxFactory)
- {
- this.ctxFactory = ctxFactory;
- }
-
- /**
- * Validate that a NamingBeanImpl mc bean is accessible via the
- * LocalOnlyContextFactory
- *
- * @throws Exception
- */
- public void testLocaNamingBeanImpl()
- throws Exception
- {
- assertNotNull(ctx);
- validateCtx(ctx);
- }
- /**
- * Validate that the NamingBeanImpl mc bean is accessible via the
- * InitialContext(env) using the LocalOnlyContextFactory
- * @throws Exception
- */
- public void testLocaNamingBeanImplViaInitialContextFactory()
- throws Exception
- {
- Properties env = new Properties();
- env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
- env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
- InitialContext ic = new InitialContext(env);
- validateCtx(ic);
- }
-
- /**
- * Validate that a SingletonNamingServer mc bean is accessible via the
- * LocalOnlyContextFactory
- *
- * @throws Exception
- */
- public void testSingletonNamingServer()
- throws Exception
- {
- assertNotNull(ctx);
- validateCtx(ctx);
- }
-
- /**
- * Test the org.jnp.server.Main bean that wraps a NamingBean with remote
- * access via an rmi proxy
- *
- * @throws Exception
- */
- public void testMainBean()
- throws Exception
- {
- Properties env = new Properties();
- env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", "localhost:1099");
- env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
- env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "10000");
- env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "10000");
- InitialContext ic = new InitialContext(env);
- validateCtx(ic);
- }
- /**
- * Test the org.jnp.server.Main bean that wraps a NamingBean with remote
- * access via an rmi proxy using custom socket factories
- *
- * @throws Exception
- */
- public void testMainBeanSFs()
- throws Exception
- {
- InetAddress localAddr = InetAddress.getLocalHost();
- getLog().debug("InetAddress.getLocalHost(): "+localAddr);
- Properties env = new Properties();
- env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", "localhost:2099");
- env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
- env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "1000");
- env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "1000");
- InitialContext ic = new InitialContext(env);
- validateCtx(ic);
- }
-
- /**
- * Test two Naming instances with one LocalOnlyContextFactory using
- * the NamingContext.local instance, and the other using the non-global
- * Naming instance that was injected.
- * @throws Exception
- */
- public void testMultipleLocalOnlyContextFactory()
- throws Exception
- {
- // The InitialContextFactory
- assertNotNull(ctx);
- validateCtx(ctx);
-
- // The InitialContextFactory#2
- Properties env = new Properties();
- env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
- env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
- env.setProperty(NamingContext.JNP_NAMING_INSTANCE_NAME, "testLocaNamingBeanImpl#2");
- InitialContext ic = new InitialContext(env);
-
- // Validate the second naming context bindings created by JndiBindings#2
- Integer i2 = (Integer) ic.lookup("ints/2");
- assertEquals("ints/1", new Integer(2), i2);
- String s2 = (String) ic.lookup("strings/2");
- assertEquals("strings/2", "String2", s2);
- BigInteger bi2 = (BigInteger) ic.lookup("bigint/2");
- assertEquals("bigint/2", new BigInteger("987654321"), bi2);
- Properties envp = (Properties) ic.lookup("env-props");
- Properties expected = new Properties();
- expected.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory#2");
- expected.setProperty("java.naming.factory.url", "factory#2");
- assertEquals("env-props", expected, envp);
-
- // The InitialContextFactory#3
- assertNotNull(ctxFactory);
- // Validate the third naming context bindings created by JndiBindings#3
- Context ctx3 = ctxFactory.getInitialContext(null);
- Integer i3 = (Integer) ctx3.lookup("ints/3");
- assertEquals("ints/1", new Integer(3), i3);
- String s3 = (String) ctx3.lookup("strings/3");
- assertEquals("strings/3", "String3", s3);
- BigInteger bi3 = (BigInteger) ctx3.lookup("bigint/3");
- assertEquals("bigint/2", new BigInteger("333333333"), bi3);
- Properties envp3 = (Properties) ctx3.lookup("env-props");
- Properties expected3 = new Properties();
- expected3.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory#3");
- expected3.setProperty("java.naming.factory.url", "factory#3");
- assertEquals("env-props", expected3, envp3);
- }
-
- public void testInjectedSecurityManager()
- throws Exception
- {
- qsm.clearPerms();
-
- HashSet<JndiPermission> expectedPerms = new HashSet<JndiPermission>();
- // expected doOps() permissions
- expectedPerms.add(new JndiPermission("path1", "createSubcontext"));
- expectedPerms.add(new JndiPermission("path1", "lookup"));
- expectedPerms.add(new JndiPermission("path1", "list"));
- expectedPerms.add(new JndiPermission("path1", "listBindings"));
- expectedPerms.add(new JndiPermission("path1/x", "bind"));
- expectedPerms.add(new JndiPermission("path1/x", "rebind"));
- expectedPerms.add(new JndiPermission("path1/x", "unbind"));
- expectedPerms.add(new JndiPermission("path1", "unbind"));
- SecurityUtil.doOps(ctx);
- // expected doBadOps() permissions
- expectedPerms.add(new JndiPermission("path2", "createSubcontext"));
- expectedPerms.add(new JndiPermission("path1x", "createSubcontext"));
- expectedPerms.add(new JndiPermission("path1x", "rebind"));
- expectedPerms.add(new JndiPermission("path1x", "lookup"));
- expectedPerms.add(new JndiPermission("path1x", "list"));
- expectedPerms.add(new JndiPermission("path1x", "listBindings"));
- expectedPerms.add(new JndiPermission("path1x/x", "bind"));
- expectedPerms.add(new JndiPermission("path1x/x", "rebind"));
- expectedPerms.add(new JndiPermission("path1x", "unbind"));
- SecurityUtil.doBadOps(ctx, false);
-
- List<Permission> perms = qsm.getPerms();
- for(Permission p : perms)
- {
- if(p instanceof JndiPermission)
- {
- getLog().info(p);
- assertTrue(p+" is in expectedPerms", expectedPerms.contains(p));
- }
- }
- }
-
- /**
- *
- * @param ic
- * @throws Exception
- */
- protected void validateCtx(InitialContext ic)
- throws Exception
- {
- Integer i1 = (Integer) ic.lookup("ints/1");
- assertEquals("ints/1", new Integer(1), i1);
- String s1 = (String) ic.lookup("strings/1");
- assertEquals("strings/1", "String1", s1);
- BigInteger bi1 = (BigInteger) ic.lookup("bigint/1");
- assertEquals("bigint/1", new BigInteger("123456789"), bi1);
- Properties env = (Properties) ic.lookup("env-props");
- Properties expected = new Properties();
- expected.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
- expected.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
- assertEquals("env-props", expected, env);
- }
-}
Copied: projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java (from rev 88679, projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java)
===================================================================
--- projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java (rev 0)
+++ projects/naming/tags/5.0.3.GA/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java 2009-05-11 23:46:32 UTC (rev 88682)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.test;
+
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.security.Permission;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.spi.InitialContextFactory;
+
+import junit.framework.Test;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.api.model.InjectOption;
+import org.jboss.naming.JndiPermission;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jnp.interfaces.NamingContext;
+import org.jnp.interfaces.TimedSocketFactory;
+import org.jnp.server.MainMBean;
+import org.jnp.test.support.QueueSecurityManager;
+
+/**
+ * Test bootstraping the naming service using the mc
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class NamingMCUnitTest extends MicrocontainerTest
+{
+ public static Test suite()
+ {
+ return suite(NamingMCUnitTest.class);
+ }
+ /** */
+ private InitialContext ctx;
+ private QueueSecurityManager qsm;
+ private InitialContextFactory ctxFactory;
+ private MainMBean main;
+
+ /**
+ *
+ * @param name
+ */
+ public NamingMCUnitTest(String name)
+ {
+ super(name, true);
+ }
+
+ /**
+ * Obtain the InitialContext from the InitialContextFactory bean ctx property.
+ * Each test expects an InitialContextFactory bean
+ * @see org.jboss.naming.NamingContextFactory
+ *
+ * @param ctx
+ */
+ @Inject(bean="InitialContextFactory", property="ctx")
+ public void setInitialContext(InitialContext ctx)
+ {
+ this.ctx = ctx;
+ }
+ @Inject(bean="QueueSecurityManager", option=InjectOption.OPTIONAL)
+ public void setQueueSecurityManager(QueueSecurityManager qsm)
+ {
+ this.qsm = qsm;
+ }
+ @Inject(bean="InitialContextFactory#3", option=InjectOption.OPTIONAL)
+ public void setCtxFactory(InitialContextFactory ctxFactory)
+ {
+ this.ctxFactory = ctxFactory;
+ }
+ @Inject(bean="jboss:service=Naming", option=InjectOption.OPTIONAL)
+ public void setMainMBean(MainMBean main)
+ {
+ this.main = main;
+ }
+
+ /**
+ * Validate that a NamingBeanImpl mc bean is accessible via the
+ * LocalOnlyContextFactory
+ *
+ * @throws Exception
+ */
+ public void testLocaNamingBeanImpl()
+ throws Exception
+ {
+ assertNotNull(ctx);
+ validateCtx(ctx);
+ }
+ /**
+ * Validate that the NamingBeanImpl mc bean is accessible via the
+ * InitialContext(env) using the LocalOnlyContextFactory
+ * @throws Exception
+ */
+ public void testLocaNamingBeanImplViaInitialContextFactory()
+ throws Exception
+ {
+ Properties env = new Properties();
+ env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
+ InitialContext ic = new InitialContext(env);
+ validateCtx(ic);
+ }
+
+ /**
+ * Validate that a SingletonNamingServer mc bean is accessible via the
+ * LocalOnlyContextFactory
+ *
+ * @throws Exception
+ */
+ public void testSingletonNamingServer()
+ throws Exception
+ {
+ assertNotNull(ctx);
+ validateCtx(ctx);
+ }
+
+ /**
+ * Test the org.jnp.server.Main bean that wraps a NamingBean with remote
+ * access via an rmi proxy
+ *
+ * @throws Exception
+ */
+ public void testMainBean()
+ throws Exception
+ {
+ // Validate
+ assertNotNull(main);
+ assertNull("main.getLookupListenerException", main.getLookupListenerException());
+ Properties env = new Properties();
+ env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.setProperty("java.naming.provider.url", "localhost:1099");
+ env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
+ env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "10000");
+ env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "10000");
+ InitialContext ic = new InitialContext(env);
+ validateCtx(ic);
+ }
+ /**
+ * Test the org.jnp.server.Main bean that wraps a NamingBean with remote
+ * access via an rmi proxy using custom socket factories
+ *
+ * @throws Exception
+ */
+ public void testMainBeanSFs()
+ throws Exception
+ {
+ InetAddress localAddr = InetAddress.getLocalHost();
+ getLog().debug("InetAddress.getLocalHost(): "+localAddr);
+ Properties env = new Properties();
+ env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.setProperty("java.naming.provider.url", "localhost:2099");
+ env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
+ env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "1000");
+ env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "1000");
+ InitialContext ic = new InitialContext(env);
+ validateCtx(ic);
+ }
+
+ /**
+ * Test two Naming instances with one LocalOnlyContextFactory using
+ * the NamingContext.local instance, and the other using the non-global
+ * Naming instance that was injected.
+ * @throws Exception
+ */
+ public void testMultipleLocalOnlyContextFactory()
+ throws Exception
+ {
+ // The InitialContextFactory
+ assertNotNull(ctx);
+ validateCtx(ctx);
+
+ // The InitialContextFactory#2
+ Properties env = new Properties();
+ env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
+ env.setProperty(NamingContext.JNP_NAMING_INSTANCE_NAME, "testLocaNamingBeanImpl#2");
+ InitialContext ic = new InitialContext(env);
+
+ // Validate the second naming context bindings created by JndiBindings#2
+ Integer i2 = (Integer) ic.lookup("ints/2");
+ assertEquals("ints/1", new Integer(2), i2);
+ String s2 = (String) ic.lookup("strings/2");
+ assertEquals("strings/2", "String2", s2);
+ BigInteger bi2 = (BigInteger) ic.lookup("bigint/2");
+ assertEquals("bigint/2", new BigInteger("987654321"), bi2);
+ Properties envp = (Properties) ic.lookup("env-props");
+ Properties expected = new Properties();
+ expected.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory#2");
+ expected.setProperty("java.naming.factory.url", "factory#2");
+ assertEquals("env-props", expected, envp);
+
+ // The InitialContextFactory#3
+ assertNotNull(ctxFactory);
+ // Validate the third naming context bindings created by JndiBindings#3
+ Context ctx3 = ctxFactory.getInitialContext(null);
+ Integer i3 = (Integer) ctx3.lookup("ints/3");
+ assertEquals("ints/1", new Integer(3), i3);
+ String s3 = (String) ctx3.lookup("strings/3");
+ assertEquals("strings/3", "String3", s3);
+ BigInteger bi3 = (BigInteger) ctx3.lookup("bigint/3");
+ assertEquals("bigint/2", new BigInteger("333333333"), bi3);
+ Properties envp3 = (Properties) ctx3.lookup("env-props");
+ Properties expected3 = new Properties();
+ expected3.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory#3");
+ expected3.setProperty("java.naming.factory.url", "factory#3");
+ assertEquals("env-props", expected3, envp3);
+ }
+
+ public void testInjectedSecurityManager()
+ throws Exception
+ {
+ qsm.clearPerms();
+
+ HashSet<JndiPermission> expectedPerms = new HashSet<JndiPermission>();
+ // expected doOps() permissions
+ expectedPerms.add(new JndiPermission("path1", "createSubcontext"));
+ expectedPerms.add(new JndiPermission("path1", "lookup"));
+ expectedPerms.add(new JndiPermission("path1", "list"));
+ expectedPerms.add(new JndiPermission("path1", "listBindings"));
+ expectedPerms.add(new JndiPermission("path1/x", "bind"));
+ expectedPerms.add(new JndiPermission("path1/x", "rebind"));
+ expectedPerms.add(new JndiPermission("path1/x", "unbind"));
+ expectedPerms.add(new JndiPermission("path1", "unbind"));
+ SecurityUtil.doOps(ctx);
+ // expected doBadOps() permissions
+ expectedPerms.add(new JndiPermission("path2", "createSubcontext"));
+ expectedPerms.add(new JndiPermission("path1x", "createSubcontext"));
+ expectedPerms.add(new JndiPermission("path1x", "rebind"));
+ expectedPerms.add(new JndiPermission("path1x", "lookup"));
+ expectedPerms.add(new JndiPermission("path1x", "list"));
+ expectedPerms.add(new JndiPermission("path1x", "listBindings"));
+ expectedPerms.add(new JndiPermission("path1x/x", "bind"));
+ expectedPerms.add(new JndiPermission("path1x/x", "rebind"));
+ expectedPerms.add(new JndiPermission("path1x", "unbind"));
+ SecurityUtil.doBadOps(ctx, false);
+
+ List<Permission> perms = qsm.getPerms();
+ for(Permission p : perms)
+ {
+ if(p instanceof JndiPermission)
+ {
+ getLog().info(p);
+ assertTrue(p+" is in expectedPerms", expectedPerms.contains(p));
+ }
+ }
+ }
+
+ /**
+ *
+ * @param ic
+ * @throws Exception
+ */
+ protected void validateCtx(InitialContext ic)
+ throws Exception
+ {
+ Integer i1 = (Integer) ic.lookup("ints/1");
+ assertEquals("ints/1", new Integer(1), i1);
+ String s1 = (String) ic.lookup("strings/1");
+ assertEquals("strings/1", "String1", s1);
+ BigInteger bi1 = (BigInteger) ic.lookup("bigint/1");
+ assertEquals("bigint/1", new BigInteger("123456789"), bi1);
+ Properties env = (Properties) ic.lookup("env-props");
+ Properties expected = new Properties();
+ expected.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ expected.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
+ assertEquals("env-props", expected, env);
+ }
+}
Deleted: projects/naming/tags/5.0.3.GA/pom.xml
===================================================================
--- projects/naming/branches/Branch_5_0/pom.xml 2009-05-11 23:19:27 UTC (rev 88678)
+++ projects/naming/tags/5.0.3.GA/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3-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.3.GA/pom.xml (from rev 88681, projects/naming/branches/Branch_5_0/pom.xml)
===================================================================
--- projects/naming/tags/5.0.3.GA/pom.xml (rev 0)
+++ projects/naming/tags/5.0.3.GA/pom.xml 2009-05-11 23:46:32 UTC (rev 88682)
@@ -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.3.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.3.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