Package jade.mtp

Examples of jade.mtp.MTPException


      else if(s.toLowerCase().startsWith("corbaloc:"))
  initFromURL(s, BIG_ENDIAN);
      else if(s.toLowerCase().startsWith("corbaname:"))
  initFromNS(s);
      else
  throw new MTPException("Invalid string prefix");
    }
View Full Code Here


      else if(s.startsWith(":")) {
  // Remove implicit IIOP specification
  s = s.substring(1);
      }
      else
  throw new MTPException("Invalid 'corbaloc' URL: neither 'iiop:' nor ':' was specified.");

      buildIOR(s, FIPA_2000_TYPE_ID, endianness);

    }
View Full Code Here

    if(tok.equals(".")) { // An (id, kind) pair
      tok = lexer.nextToken();
      nc.kind = tok;
    }
    else if(!tok.equals("/")) // No separator other than '.' or '/' is allowed
      throw new MTPException("Ill-formed path into the Naming Service: Unknown separator.");
  }

  // Get the object reference stored into the naming service...
  NameComponent[] path = (NameComponent[])name.toArray(new NameComponent[name.size()]);
  o = ctx.resolve(path);

  // Stringify it and use the resulting IOR to initialize yourself
        String realIOR = orb.object_to_string(o);
  initFromIOR(realIOR);

      }
      catch(NoSuchElementException nsee) {
  throw new MTPException("Ill-formed path into the Naming Service.", nsee);
      }
      catch(UserException ue) {
  throw new MTPException("CORBA Naming Service user exception.", ue);
      }
      catch(SystemException se) {
  throw new MTPException("CORBA Naming Service system exception.", se);
      }
     

    }
View Full Code Here

    break;
  case LITTLE_ENDIAN:
    codecStrategy = new LittleEndianCodec(hexString);
    break;
  default:
    throw new MTPException("Invalid endianness specifier");
  }

  try {
    // Read 'string type_id' field
    String typeID = codecStrategy.readString();
    if(!typeID.equalsIgnoreCase(typeName))
      throw new MTPException("Invalid type ID" + typeID);
  }
  catch (Exception e) { // all exceptions are converted into MTPException
    throw new MTPException("Invalid type ID");
  }

  // Read 'sequence<TaggedProfile> profiles' field
  // Read sequence length
  int seqLen = codecStrategy.readLong();
  for(int i = 0; i < seqLen; i++) {
    // Read 'ProfileId tag' field
    int tag = codecStrategy.readLong();
    byte[] profile = codecStrategy.readOctetSequence();
    if(tag == TAG_INTERNET_IOP) {
      // Process IIOP profile
      CDRCodec profileBodyCodec;
      switch(profile[0]) {
      case BIG_ENDIAN:
        profileBodyCodec = new BigEndianCodec(profile);
        break;
      case LITTLE_ENDIAN:
        profileBodyCodec = new LittleEndianCodec(profile);
        break;
      default:
        throw new MTPException("Invalid endianness specifier");
      }

      // Read IIOP version
      byte versionMajor = profileBodyCodec.readOctet();
      byte versionMinor = profileBodyCodec.readOctet();
      if(versionMajor != 1)
        throw new MTPException("IIOP version not supported");

      try {
        // Read 'string host' field
        host = profileBodyCodec.readString();
      }
      catch (Exception e) {
        throw new MTPException("Invalid host string");
      }

      // Read 'unsigned short port' field
      port = profileBodyCodec.readShort();

      // Read 'sequence<octet> object_key' field and convert it
      // into a String object
      byte[] keyBuffer = profileBodyCodec.readOctetSequence();
      ByteArrayOutputStream buf = new ByteArrayOutputStream();

      // Escape every forbidden character, as for RFC 2396 (URI: Generic Syntax)
      for(int ii = 0; ii < keyBuffer.length; ii++) {
        byte b = keyBuffer[ii];
        if(isUnreservedURIChar(b)) {
    // Write the character 'as is'
    buf.write(b);
        }
        else {
    // Escape it using '%'
    buf.write(ASCII_PERCENT);
    buf.write(HEX[(b & 0xF0) >> 4]); // High nibble
    buf.write(HEX[b & 0x0F]); // Low nibble
        }
      }

      objectKey = buf.toString("US-ASCII");
      codecStrategy = null;

    }
  }
      }
      catch (Exception e) { // all exceptions are converted into MTPException
  throw new MTPException(e.getMessage());
      }
    }
View Full Code Here

    private void buildIOR(String s, String typeName, short endianness) throws MTPException {
      int colonPos = s.indexOf(':');
      int slashPos = s.indexOf('/');
      int poundPos = s.indexOf('#');
      if((colonPos == -1) || (slashPos == -1))
  throw new MTPException("Invalid URL string");

      host = s.substring(0, colonPos);
      port = Short.parseShort(s.substring(colonPos + 1, slashPos));
      if(poundPos == -1) {
  objectKey = s.substring(slashPos + 1, s.length());
  anchor = "";
      }
      else {
  objectKey = s.substring(slashPos + 1, poundPos);
  anchor = s.substring(poundPos + 1, s.length());
      }

      switch(endianness) {
      case BIG_ENDIAN:
  codecStrategy = new BigEndianCodec(new byte[0]);
  break;
      case LITTLE_ENDIAN:
  codecStrategy = new LittleEndianCodec(new byte[0]);
  break;
      default:
  throw new MTPException("Invalid endianness specifier");
      }

      codecStrategy.writeString(typeName);

      // Write '1' as profiles sequence length
      codecStrategy.writeLong(1);

      codecStrategy.writeLong(TAG_INTERNET_IOP);
      CDRCodec profileBodyCodec;
      switch(endianness) {
      case BIG_ENDIAN:
  profileBodyCodec = new BigEndianCodec(new byte[0]);
  break;
      case LITTLE_ENDIAN:
  profileBodyCodec = new LittleEndianCodec(new byte[0]);
  break;
      default:
  throw new MTPException("Invalid endianness specifier");
      }

      // Write IIOP 1.0 profile to auxiliary CDR codec
      profileBodyCodec.writeOctet(IIOP_MAJOR);
      profileBodyCodec.writeOctet(IIOP_MINOR);
View Full Code Here

      parser = (XMLReader)Class.forName(parserClass).newInstance();
      parser.setContentHandler(this);
      parser.setErrorHandler(this);
    }
    catch(Exception e) {
      throw new MTPException(e.toString());
    }
  }
View Full Code Here

    {
      parser.parse(new InputSource(in));
      return env;
    }
    catch (Exception ex) {
      throw new MTPException(ex.getMessage());
    }
  }
View Full Code Here

    public void route(Envelope env, byte[] payload, AID receiver, String address) throws MTPException {
      try {
        slice.routeOut(env, payload, receiver, address);
      }
      catch(IMTPException imtpe) {
        throw new MTPException("Container unreachable during routing", imtpe);
      }
    }
View Full Code Here

TOP

Related Classes of jade.mtp.MTPException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.