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/10 10:40:18 UTC

cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/naming DefaultAltrmiContext.java DefaultAltrmiInitialContextFactory.java AltrmiContext.java

hammant     02/03/10 01:40:18

  Modified:    altrmi/src/java/org/apache/commons/altrmi/client/impl
                        DefaultInterfaceLookupFactory.java
  Added:       altrmi/src/java/org/apache/commons/altrmi/client/impl/naming
                        DefaultAltrmiContext.java
                        DefaultAltrmiInitialContextFactory.java
  Removed:     altrmi/src/java/org/apache/commons/altrmi/client/impl/naming
                        AltrmiContext.java
  Log:
  Start of JNDI by Vinay
  
  Revision  Changes    Path
  1.3       +9 -1      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/DefaultInterfaceLookupFactory.java
  
  Index: DefaultInterfaceLookupFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/DefaultInterfaceLookupFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultInterfaceLookupFactory.java	6 Mar 2002 16:11:02 -0000	1.2
  +++ DefaultInterfaceLookupFactory.java	10 Mar 2002 09:40:18 -0000	1.3
  @@ -20,9 +20,17 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class DefaultInterfaceLookupFactory extends AbstractInterfaceLookupFactory {
  +
  +    public static final String[] SUPPORTEDSTREAMS = new String[] {
  +        "SocketObjectStream",
  +        "SocketCustomStream",
  +        "RMI"
  +    };
  +
  +
   
       /**
        * Constructor DefaultInterfaceLookupFactory
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/naming/DefaultAltrmiContext.java
  
  Index: DefaultAltrmiContext.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.client.impl.naming;
  
  
  
  import java.util.Hashtable;
  
  import javax.naming.Context;
  import javax.naming.Name;
  import javax.naming.NameParser;
  import javax.naming.NamingEnumeration;
  import javax.naming.NamingException;
  
  import org.apache.commons.altrmi.client.AltrmiInterfaceLookup;
  import org.apache.commons.altrmi.client.AltrmiInterfaceLookupFactory;
  import org.apache.commons.altrmi.client.impl.DefaultInterfaceLookupFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  
  
  /**
   * Class DefaultAltrmiContext
   *
   *
   * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultAltrmiContext implements Context {
  
      AltrmiInterfaceLookupFactory altrmiInterfaceLookupFactory =
          new DefaultInterfaceLookupFactory();
      AltrmiInterfaceLookup altrmiInterfaceLookup = null;
  
      /**
       * Constructor DefaultAltrmiContext
       *
       *
       * @param host
       * @param port
       * @param transportStream
       * @param env
       *
       * @throws NamingException
       *
       */
      DefaultAltrmiContext(String host, String port, String transportStream, Hashtable env)
              throws NamingException {
  
          String proxyDetails = null;
          String beanDetails = null;
  
          proxyDetails = (String) env.get("proxy.type");
          beanDetails = (String) env.get("bean.type");
  
          if (proxyDetails == null) {
              proxyDetails = "S";
          }
  
          if (beanDetails == null) {
              beanDetails = "NBO";
          }
  
          try {
              System.out.println("iurl[" + transportStream + ":" + host + ":" + port + ":"
                                 + proxyDetails + ":" + beanDetails + "]");
  
              altrmiInterfaceLookup =
                  altrmiInterfaceLookupFactory.getAltrmiInterfaceLookup(transportStream + ":"
                                                                        + host + ":" + port + ":"
                                                                        + proxyDetails + ":"
                                                                        + beanDetails);
          } catch (AltrmiConnectionException ace) {
              ace.printStackTrace();
  
              throw new NamingException(ace.getMessage());
          }
      }
  
      /**
       * Method lookup
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object lookup(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method lookup
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object lookup(String name) throws NamingException {
  
          try {
              return altrmiInterfaceLookup.lookup(name);
          } catch (AltrmiConnectionException ace) {
              ace.printStackTrace();
  
              throw new NamingException(ace.getMessage());
          }
      }
  
      /**
       * Method bind
       *
       *
       * @param name
       * @param obj
       *
       * @throws NamingException
       *
       */
      public void bind(Name name, Object obj) throws NamingException {}
  
      /**
       * Method bind
       *
       *
       * @param name
       * @param obj
       *
       * @throws NamingException
       *
       */
      public void bind(String name, Object obj) throws NamingException {}
  
      /**
       * Method rebind
       *
       *
       * @param name
       * @param obj
       *
       * @throws NamingException
       *
       */
      public void rebind(Name name, Object obj) throws NamingException {}
  
      /**
       * Method rebind
       *
       *
       * @param name
       * @param obj
       *
       * @throws NamingException
       *
       */
      public void rebind(String name, Object obj) throws NamingException {}
  
      /**
       * Method unbind
       *
       *
       * @param name
       *
       * @throws NamingException
       *
       */
      public void unbind(Name name) throws NamingException {}
  
      /**
       * Method unbind
       *
       *
       * @param name
       *
       * @throws NamingException
       *
       */
      public void unbind(String name) throws NamingException {}
  
      /**
       * Method rename
       *
       *
       * @param oldName
       * @param newName
       *
       * @throws NamingException
       *
       */
      public void rename(Name oldName, Name newName) throws NamingException {}
  
      /**
       * Method rename
       *
       *
       * @param oldName
       * @param newName
       *
       * @throws NamingException
       *
       */
      public void rename(String oldName, String newName) throws NamingException {}
  
      /**
       * Method list
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NamingEnumeration list(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method list
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NamingEnumeration list(String name) throws NamingException {
  
          final String[] names = altrmiInterfaceLookup.list();
  
          return new NamingEnumeration() {
  
              int size = names.length;
              int index = 0;
  
              public void close() {}
  
              public boolean hasMore() {
                  return index < names.length;
              }
  
              public Object next() {
                  return names[index++];
              }
  
              public boolean hasMoreElements() {
                  return hasMore();
              }
  
              public Object nextElement() {
                  return next();
              }
          };
      }
  
      /**
       * Method listBindings
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NamingEnumeration listBindings(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method listBindings
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NamingEnumeration listBindings(String name) throws NamingException {
          return null;
      }
  
      /**
       * Method destroySubcontext
       *
       *
       * @param name
       *
       * @throws NamingException
       *
       */
      public void destroySubcontext(Name name) throws NamingException {}
  
      /**
       * Method destroySubcontext
       *
       *
       * @param name
       *
       * @throws NamingException
       *
       */
      public void destroySubcontext(String name) throws NamingException {}
  
      /**
       * Method createSubcontext
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Context createSubcontext(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method createSubcontext
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Context createSubcontext(String name) throws NamingException {
          return null;
      }
  
      /**
       * Method lookupLink
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object lookupLink(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method lookupLink
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object lookupLink(String name) throws NamingException {
          return null;
      }
  
      /**
       * Method getNameParser
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NameParser getNameParser(Name name) throws NamingException {
          return null;
      }
  
      /**
       * Method getNameParser
       *
       *
       * @param name
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public NameParser getNameParser(String name) throws NamingException {
          return null;
      }
  
      /**
       * Method composeName
       *
       *
       * @param name
       * @param prefix
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Name composeName(Name name, Name prefix) throws NamingException {
          return null;
      }
  
      /**
       * Method composeName
       *
       *
       * @param name
       * @param prefix
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public String composeName(String name, String prefix) throws NamingException {
          return null;
      }
  
      /**
       * Method addToEnvironment
       *
       *
       * @param propName
       * @param propVal
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object addToEnvironment(String propName, Object propVal) throws NamingException {
          return null;
      }
  
      /**
       * Method removeFromEnvironment
       *
       *
       * @param propName
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Object removeFromEnvironment(String propName) throws NamingException {
          return null;
      }
  
      /**
       * Method getEnvironment
       *
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public Hashtable getEnvironment() throws NamingException {
          return null;
      }
  
      /**
       * Method close
       *
       *
       * @throws NamingException
       *
       */
      public void close() throws NamingException {
          altrmiInterfaceLookup.close();
      }
  
      /**
       * Method getNameInNamespace
       *
       *
       * @return
       *
       * @throws NamingException
       *
       */
      public String getNameInNamespace() throws NamingException {
          return null;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/naming/DefaultAltrmiInitialContextFactory.java
  
  Index: DefaultAltrmiInitialContextFactory.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.client.impl.naming;
  
  
  
  import java.util.Hashtable;
  
  import javax.naming.Context;
  import javax.naming.NamingException;
  import javax.naming.spi.InitialContextFactory;
  
  import org.apache.commons.altrmi.client.impl.DefaultInterfaceLookupFactory;
  
  
  /**
   * Class DefaultAltrmiInitialContextFactory
   *
   *
   * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultAltrmiInitialContextFactory implements InitialContextFactory {
  
      /**
       * Method getInitialContext
       *
       *
       * @param env
       *
       * @return
       *
       * @throws NamingException
       *
       * @see InitialContextFactory#getInitialContext(Hashtable)
       *
       */
      public Context getInitialContext(Hashtable env) throws NamingException {
  
          String transportStream = "";
          String s_url = (String) env.get(Context.PROVIDER_URL);
          int index = -1;
  
          index = (s_url.lastIndexOf("\\") > s_url.lastIndexOf("/"))
                  ? s_url.lastIndexOf("\\") : s_url.lastIndexOf("/");
          transportStream = s_url.substring(index + 1);
  
          System.out.println("transportStream[" + transportStream + "]");
  
          for (int i = 0; i < DefaultInterfaceLookupFactory.SUPPORTEDSTREAMS.length; i++) {
              if (transportStream
                      .equalsIgnoreCase(DefaultInterfaceLookupFactory.SUPPORTEDSTREAMS[i])) {
                  String host = s_url.substring(s_url.indexOf(":") + 3, s_url.lastIndexOf(":"));
                  String port = s_url.substring(s_url.lastIndexOf(":") + 1, index);
  
                  return new DefaultAltrmiContext(host, port, transportStream, env);
              }
          }
  
          throw new NamingException("TransportStream[" + transportStream + "] not supported");
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>