Package gov.cca

Examples of gov.cca.TypeMap


   * @param properties the XML-ised form of the TypeMap object
   */
  public void setProperties(String properties)
    throws gov.cca.CCAException {
    logger.finest("called");
    TypeMap tMap = services.getProperties();
    TypeUtil.fromXML(properties, tMap);
  }
View Full Code Here


    logger.finest("called for port: " + providesPortName);

    ProvidesPortInfo pInfo = (ProvidesPortInfo) providesPortMap.get(providesPortName);
    if (pInfo != null) {
      synchronized(pInfo) {
  TypeMap pMap = pInfo.getProperties();
  return pMap.getString("cca.portType", "None");
      }
    } else
      throw new PortNotDefinedException("Port " + providesPortName + " not defined");
  }
View Full Code Here

    logger.finest("called for port: " + usesPortName);

    UsesPortInfo uInfo = (UsesPortInfo) usesPortMap.get(usesPortName);
    if (uInfo != null) {
      synchronized(uInfo) {
  TypeMap uMap = uInfo.getProperties();
  return uMap.getString("cca.portType", "None");
      }
    } else
      throw new PortNotDefinedException("Port " + usesPortName + " not defined");
  }
View Full Code Here

      logger.severe("Exception thrown while parsing Component XML", e);
      throw new NonstandardException("Exception while parsing Component XML", e);
    }

    // create a new TypeMap and fill in the values
    TypeMap componentEnv = new TypeMapImpl();
    componentEnv.putString("execHost", cInfo.getInstanceLocation());
    componentEnv.putString("creationProto", cInfo.getCreationProto());

    // check if a valid installation exists for this host/proto
    boolean found = false;
    for (int k = 0; k < executionEnvList.length; k++) {
      ExecutionEnv executionEnv = executionEnvList[k];
      String[] hostName = executionEnv.getHostName();
      String[] creationMech = executionEnv.getCreationProto();

      // check if there is a match for the hostName
      int h;
      for (h = 0; h < hostName.length; h++) {
  if (hostName[h].equals(cInfo.getInstanceLocation())) {
    break;
  }
      }

      // if h equals hostName.length, then skip
      if (h == hostName.length)
  continue;
     
      // check if there is a match for creationProto
      int m;
      for (m = 0; m < creationMech.length; m++) {
  if (creationMech[m].equals(cInfo.getCreationProto())) {
    break;
  }
      }

      // if h equals creationMech.length, then skip
      if (m == creationMech.length)
  continue;
     
      // if we get here, this is a valid installation for this
      // creationProto/execHost pair
      NameValuePair[] nameValuePairList =
  executionEnv.getNameValuePair();
      for (int l = 0; l < nameValuePairList.length; l++) {
  NameValuePair nameValuePair = nameValuePairList[l];
  String nameOfVariable = nameValuePair.getName();
  String value = nameValuePair.getValue();
  componentEnv.putString(nameOfVariable, value);
      }
     
      // found an installation, break here
      found = true;
      break;
    }
   
    // if no valid installation found, throw an Exception
    if (!found) {
      String message = new String ("No valid installation for : " +
           cInfo.getInstanceLocation() + " , " +
           cInfo.getCreationProto());
      logger.severe(message);
      throw new NonstandardException(message);
    }

    // get the name of the class for the component
    String className = componentEnv.getString("className",
               "None");
    if (className.equals("None"))
      throw new NonstandardException("Property className for component not defined");
   
    // notify that this is a migration
    componentEnv.putString("componentHandle", cInfo.getInstanceHandle());
    componentEnv.putBool("isMigrated", true);

    // invoke the Builder Service to create a new instance
    XCATBuilderService builderService = null;
    try {
      builderService = new XCATBuilderServiceImpl(false);
View Full Code Here

       uInfo.getMigrationStatus() +
       "</migrationStatus>");
     
      // copy over the TypeMap object
      sInfoBuffer.append("<properties>");
      TypeMap tMap = uInfo.getProperties();
      String[] mapKeys = tMap.getAllKeys();
      for (int j = 0; j < mapKeys.length; j++) {
  sInfoBuffer.append("<propertiesEntry>");
  sInfoBuffer.append("<key>" +
         mapKeys[j] +
         "</key>");
  sInfoBuffer.append("<type>" +
         TypeUtil.toString(tMap.typeOf(mapKeys[j])) +
         "</type>");
  sInfoBuffer.append("<value>" +
         tMap.getAsString(mapKeys[j]) +
         "</value>");
  sInfoBuffer.append("</propertiesEntry>");
      }
      sInfoBuffer.append("</properties>");
     
      // copy over information from the ConnectionID
      XCATConnectionID connID = uInfo.getConnectionID();
      if (connID != null) {
  sInfoBuffer.append("<connectionID>");
  sInfoBuffer.append("<providerIntfName>" +
         connID.getProviderIntfName() +
         "</providerIntfName>");
  sInfoBuffer.append("<userIntfName>" +
         connID.getUserIntfName() +
         "</userIntfName>");
 
  // fill in the state of the connection
  sInfoBuffer.append("<connectionIDInfo>");
  XCATConnectionInfo xconnInfo = connID.getConnectionInfo();
  sInfoBuffer.append("<providerIDHandle>" +
         xconnInfo.getProviderIDHandle() +
         "</providerIDHandle>");
  sInfoBuffer.append("<userIDHandle>" +
         xconnInfo.getUserIDHandle() +
         "</userIDHandle>");
  sInfoBuffer.append("<providerName>" +
         xconnInfo.getProviderName() +
         "</providerName>");
  sInfoBuffer.append("<userName>" +
         xconnInfo.getUserName() +
         "</userName>");
  sInfoBuffer.append("<providerPortName>" +
         xconnInfo.getProviderPortName() +
         "</providerPortName>");
  sInfoBuffer.append("<userPortName>" +
         xconnInfo.getUserPortName() +
         "</userPortName>");
  sInfoBuffer.append("<providesPortHandle>" +
         xconnInfo.getProvidesPortHandle() +
         "</providesPortHandle>");
  sInfoBuffer.append("</connectionIDInfo>");
  sInfoBuffer.append("</connectionID>");
      }
     
      sInfoBuffer.append("</usesPortRecord>");
      sInfoBuffer.append("</usesPortEntry>");
    }
    sInfoBuffer.append("</usesPortMap>");
   
    // create a list of WS ports
    sInfoBuffer.append("<wsPortMap>");
    Object[] wsKeys = wsPortMap.keySet().toArray();
    // add an entry for every ws port
    for (int i = 0; i < wsKeys.length; i++) {
      // create an entry for each Ws Port
      sInfoBuffer.append("<wsPortEntry>");
      sInfoBuffer.append("<portName>" +
       (String) wsKeys[i] +
       "</portName>");
     
      // copy over information from WSPortInfo to WsPortRecord
      WSPortInfo wInfo = (WSPortInfo) wsPortMap.get(wsKeys[i]);
      sInfoBuffer.append("<wsPortRecord>");
      sInfoBuffer.append("<portName>" +
       wInfo.getPortName() +
       "</portName>");
      sInfoBuffer.append("<portType>" +
       wInfo.getPortType() +
       "</portType>");
      sInfoBuffer.append("<inUse>" +
       false +
       "</inUse>"); // inUse is always false before & after migration
      sInfoBuffer.append("<unregistered>" +
       wInfo.isUnregistered() +
       "</unregistered>");
      if (wInfo.isConnected())
  sInfoBuffer.append("<endPointLocation>" +
         wInfo.getEndPointLocation() +
         "</endPointLocation>");
      // copy over the TypeMap object
      sInfoBuffer.append("<properties>");
      TypeMap tMap = wInfo.getProperties();
      String[] mapKeys = tMap.getAllKeys();
      for (int j = 0; j < mapKeys.length; j++) {
  sInfoBuffer.append("<propertiesEntry>");
  sInfoBuffer.append("<key>" +
         mapKeys[j] +
         "</key>");
  sInfoBuffer.append("<type>" +
         TypeUtil.toString(tMap.typeOf(mapKeys[j])) +
         "</type>");
  sInfoBuffer.append("<value>" +
         tMap.getAsString(mapKeys[j]) +
         "</value>");
  sInfoBuffer.append("</propertiesEntry>");
      }
      sInfoBuffer.append("</properties>");
     
      // end of wsPortRecord
      sInfoBuffer.append("</wsPortRecord>");
      sInfoBuffer.append("</wsPortEntry>");
    }
    sInfoBuffer.append("</wsPortMap>");

    // create a list of provides ports
    sInfoBuffer.append("<providesPortMap>");
    Object[] providerKeys = providesPortMap.keySet().toArray();
    // add an entry for every provides port
    for (int i = 0; i < providerKeys.length; i++) {
      // create a entry for a Provides Port
      sInfoBuffer.append("<providesPortEntry>");
      sInfoBuffer.append("<portName>" +        
       (String) providerKeys[i] +
       "</portName>");
     
      // copy over information from ProvidesPortInfo
      sInfoBuffer.append("<providesPortRecord>");
      ProvidesPortInfo pInfo = (ProvidesPortInfo) providesPortMap.get(providerKeys[i]);
      sInfoBuffer.append("<portName>" +
       pInfo.getPortName() +
       "</portName>");
      sInfoBuffer.append("<portType>" +
       pInfo.getPortType() +
       "</portType>");
      sInfoBuffer.append("<inUse>" +
       pInfo.getInUse() +
       "</inUse>");
      sInfoBuffer.append("<numConnections>" +
       pInfo.getNumConnections() +
       "</numConnections>");
      sInfoBuffer.append("<providesPortHandle>" +
       pInfo.getProvidesPortHandle() +
       "</providesPortHandle>");
      sInfoBuffer.append("<removed>" +
       pInfo.isRemoved() +
       "</removed>");
     
      // copy over the TypeMap object
      sInfoBuffer.append("<properties>");
      TypeMap tMap = pInfo.getProperties();
      String[] mapKeys = tMap.getAllKeys();
      for (int j = 0; j < mapKeys.length; j++) {
  sInfoBuffer.append("<propertiesEntry>");
  sInfoBuffer.append("<key>" +
         mapKeys[j] +
         "</key>");
  sInfoBuffer.append("<type>" +
         TypeUtil.toString(tMap.typeOf(mapKeys[j])) +
         "</type>");
  sInfoBuffer.append("<value>" +
         tMap.getAsString(mapKeys[j]) +
         "</value>");
  sInfoBuffer.append("</propertiesEntry>");
      }
      sInfoBuffer.append("</properties>");
     
View Full Code Here

    break;

        // initialize values
        String portName = null;
        String portType = null;
        TypeMap tMap = createTypeMap();
        boolean inUse = false;
        XCATConnectionID connID = null;
        boolean unregistered = false;
        int migrationStatus = 0;

        if (entryChild.getLocalName().equals("portName")) {
    // get the portName
    portName = (String) entryChild.readNextChild();
        } else { // is a <usesPortRecord/>
    // read all the values for the UsesPortInfo object
    while (true) {
      XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
      if (nextItem == null)
        break;
     
      if (nextItem.getLocalName().equals("portName")) {
        portName = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("portType")) {
        portType = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("properties")) {
        setPropertiesFromXML(nextItem, tMap);
      } else if (nextItem.getLocalName().equals("inUse")) {
        inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      } else if (nextItem.getLocalName().equals("connectionID")) {
        connID = xmlToConnectionID(nextItem);
      } else if (nextItem.getLocalName().equals("unregistered")) {
        unregistered =
          Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      } else { // (nextItem.getLocalName().equals("migrationStatus"))
        migrationStatus = Integer.parseInt((String) nextItem.readNextChild());
      }
    }

    // create a UsesPortInfo entry
    UsesPortInfo uInfo = new UsesPortInfo(portName,
                  portType,
                  tMap);
    uInfo.setInUse(inUse);
    if (unregistered)
      uInfo.unregisterPort();
    uInfo.setMigrationStatus(migrationStatus);
    if (connID != null)
      uInfo.setConnectionID(connID);

    // add this uses port to the HashMap
    usesPortMap.put(portName, uInfo);
        }
      }
    }
  } else if (nextChild.getLocalName().equals("wsPortMap")) {
      // add an entry for every WS port
    while (true) {
      // get the next entry
      XmlPullNode entryNode = (XmlPullNode) nextChild.readNextChild();
      if (entryNode == null)
        break;
     
      // parse every <wsPortEntry/>
      while (true) {
        // get the next child for the wsPortEntry
        XmlPullNode entryChild = (XmlPullNode) entryNode.readNextChild();
        if (entryChild == null)
    break;

        // initialize values
        String portName = null;
        String portType = null;
        TypeMap tMap = createTypeMap();
        boolean inUse = false;
        boolean unregistered = false;
        String endPointLocation = null;

        if (entryChild.getLocalName().equals("portName")) {
    // get the portName
    portName = (String) entryChild.readNextChild();
        } else { // is a <wsPortRecord/>
    // read all the values for the WSPortInfo object
    while (true) {
      XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
      if (nextItem == null)
        break;
     
      if (nextItem.getLocalName().equals("portName")) {
        portName = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("portType")) {
        portType = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("properties")) {
        setPropertiesFromXML(nextItem, tMap);
      } else if (nextItem.getLocalName().equals("inUse")) {
        inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      } else if (nextItem.getLocalName().equals("endPointLocation")) {
        endPointLocation = (String) nextItem.readNextChild();
      } else { // if (nextItem.getLocalName().equals("unregistered")) {
        unregistered =
          Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      }
    }
   
    // create a WSPortInfo entry
    WSPortInfo wInfo = new WSPortInfo(portName,
              portType,
              tMap);
    wInfo.setInUse(inUse);
    if (unregistered)
      wInfo.unregisterPort();
    if (endPointLocation != null)
      wInfo.setEndPointLocation(endPointLocation);

    // add this WS port to the HashMap
    wsPortMap.put(portName, wInfo);
        }
      }
    }
  } else { // (nextChild.getLocalName().equals("providesPortMap"))
    // add an entry for every provides port
    while (true) {
      // get the next entry
      XmlPullNode entryNode = (XmlPullNode) nextChild.readNextChild();
      if (entryNode == null)
        break;
     
      // parse every <providesPortEntry/>
      while (true) {
        // get the next child for the providesPortEntry
        XmlPullNode entryChild = (XmlPullNode) entryNode.readNextChild();
        if (entryChild == null)
    break;
       
        // initialize values
        String portName = null;
        String portType = null;
        TypeMap tMap = createTypeMap();
        boolean inUse = false;
        int numConnections = 0;
        String providesPortHandle = null;
        boolean removed = false;

        if (entryChild.getLocalName().equals("portName")) {
    // get the portName
    portName = (String) entryChild.readNextChild();
        } else { // is a <providesPortRecord/>
    // read all the values for the ProvidesPortInfo object
    while (true) {
      XmlPullNode nextItem = (XmlPullNode) entryChild.readNextChild();
      if (nextItem == null)
        break;
     
      if (nextItem.getLocalName().equals("portName")) {
        portName = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("portType")) {
        portType = (String) nextItem.readNextChild();
      } else if (nextItem.getLocalName().equals("properties")) {
        setPropertiesFromXML(nextItem, tMap);
      } else if (nextItem.getLocalName().equals("inUse")) {
        inUse = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      } else if (nextItem.getLocalName().equals("numConnections")) {
        numConnections = Integer.parseInt((String) nextItem.readNextChild());
      } else if (nextItem.getLocalName().equals("providesPortHandle")) {
        providesPortHandle = (String) nextItem.readNextChild();
      } else { // (nextItem.getLocalName().equals("removed"))
        removed = Boolean.valueOf((String) nextItem.readNextChild()).booleanValue();
      }
    }

    // create a ProvidesPortInfo entry
    ProvidesPortInfo pInfo = new ProvidesPortInfo(portName,
                    portType,
                    tMap,
                    providesPortHandle);
    pInfo.setInUse(inUse);
    pInfo.setNumConnections(numConnections);
    if (removed)
      pInfo.removePort();
   
    // export this port as a grid service
    String portImpl = tMap.getString("cca.portImpl", "None");
    if (portImpl.equals("None"))
      throw new UnexpectedException("Can't find FQN for provides port: " + portName);
    Class portClass = Class.forName(portImpl);
    // assumption here that a void constructor exists
    Object portInstance = portClass.newInstance();
    String intfClassName = tMap.getString("portClass", "None");
    UnicastRemoteObject.exportObject((XCATPort) portInstance,
             new Class[]{Class.forName(intfClassName)});
   
    // add a reference to the Handle Resolver
    String portGSH = pInfo.getProvidesPortHandle();
View Full Code Here

TOP

Related Classes of gov.cca.TypeMap

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.