You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ha...@apache.org on 2002/03/11 11:04:56 UTC
cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test SocketClientTestJNDI.java
hammant 02/03/11 02:04:56
Modified: altrmi PROPOSAL tests.xml
altrmi/src/java/org/apache/commons/altrmi/client/impl/naming
DefaultAltrmiContext.java
Added: altrmi/src/java/org/apache/commons/altrmi/test
SocketClientTestJNDI.java
Log:
Working JNDI test based on Vinay's example code
Revision Changes Path
1.14 +2 -2 jakarta-commons-sandbox/altrmi/PROPOSAL
Index: PROPOSAL
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/PROPOSAL,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- PROPOSAL 18 Feb 2002 21:40:28 -0000 1.13
+++ PROPOSAL 11 Mar 2002 10:04:55 -0000 1.14
@@ -26,12 +26,12 @@
- Piped with same VM / ObjectStream
- Direct within same VM
- Plain sockets / custom message streaming
+ - JNDI Done.
- SOAP (planned)
- Might require additional undynamic "toWSDL()" step.
- CORBA (planned)
- Might require additional undynamic "toIDL()" step.
- - JMS (planned)
- - JNDI (planned)
+ - JMS (planned)
- UDP (planned)
3) Speed
1.9 +6 -1 jakarta-commons-sandbox/altrmi/tests.xml
Index: tests.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/tests.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- tests.xml 9 Mar 2002 06:29:35 -0000 1.8
+++ tests.xml 11 Mar 2002 10:04:55 -0000 1.9
@@ -3,7 +3,7 @@
<!--
"Alt (to) RMI" component of the Jakarta Commons Subproject
- $Id: tests.xml,v 1.8 2002/03/09 06:29:35 hammant Exp $
+ $Id: tests.xml,v 1.9 2002/03/11 10:04:55 hammant Exp $
-->
@@ -153,6 +153,11 @@
</java>
</target>
+ <target name="socket-jndi-client" depends="generate" description="Socket client using JNDI">
+ <java classname="org.apache.commons.altrmi.test.SocketClientTestJNDI" fork="true">
+ <classpath refid="testA.classpath"/>
+ </java>
+ </target>
<target name="pipeda" depends="generate" description="Pipe Server and Client (ObjectStream, client side classes)">
<java classname="org.apache.commons.altrmi.test.PipeTest" fork="true">
1.3 +15 -3 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/naming/DefaultAltrmiContext.java
Index: DefaultAltrmiContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/naming/DefaultAltrmiContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultAltrmiContext.java 11 Mar 2002 09:15:16 -0000 1.2
+++ DefaultAltrmiContext.java 11 Mar 2002 10:04:55 -0000 1.3
@@ -29,7 +29,7 @@
*
*
* @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class DefaultAltrmiContext implements Context {
@@ -56,14 +56,26 @@
String beanDetails = null;
proxyDetails = (String) env.get("proxy.type");
- beanDetails = (String) env.get("bean.type");
-
if (proxyDetails == null) {
proxyDetails = "S";
+ } else if (proxyDetails.equals("ClientSideClasses")) {
+ proxyDetails = "C";
+ } else if (proxyDetails.equals("ServerSideClasses")) {
+ proxyDetails = "S";
+ } else {
+ throw new NamingException("proxy.type should be 'ClientSideClasses' or 'ServerSideClasses', you specified " + proxyDetails);
}
+ beanDetails = (String) env.get("bean.type");
+
if (beanDetails == null) {
beanDetails = "NBO";
+ } else if (beanDetails.equals("NotBeanOnly")) {
+ beanDetails = "NBO";
+ } else if (beanDetails.equals("BeanOnly")) {
+ beanDetails = "BO";
+ } else {
+ throw new NamingException("proxy.type should be 'BeanOnly' or 'NotBeanOnly', you specified " + beanDetails);
}
try {
1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/SocketClientTestJNDI.java
Index: SocketClientTestJNDI.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.commons.altrmi.test;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import java.util.Hashtable;
/**
* Class SocketClientTestJNDI
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class SocketClientTestJNDI {
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception {
System.out.println("Stream over Socket Client, via JNDI");
// JNDI lookup. Note there are no imports of Altrmi classes in this test.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.commons.altrmi.client.impl.naming.DefaultAltrmiInitialContextFactory");
env.put(Context.PROVIDER_URL, "altrmi://localhost:1235/SocketCustomStream");
env.put("proxy.type", "ClientSideClasses");
env.put("bean.type", "NotBeanOnly");
Context ctx = new InitialContext(env);
//list
System.out.println("Listing Published Objects At Server...");
NamingEnumeration listOfPublishedObjectsOnServer = ctx.list("all");
int i = 0;
while (listOfPublishedObjectsOnServer.hasMore()) {
System.out.println("..[" + i + "]:" + listOfPublishedObjectsOnServer.next());
++i;
}
TestInterface ti = (TestInterface) ctx.lookup("Hello");
new TestClient(ti);
ctx.close();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>