public void connect()
      throws IllegalArgumentException, UnknownHostException, AlreadyConnectedException {
    try {
      // connect to server
      server.connect();

    } catch (final JIException e) {
      System.out.println(
          String.format("%08X: %s", e.getErrorCode(), server.getErrorMessage(e.getErrorCode())));
    }
  }
 @Override
 protected void launch(EC2Computer computer, TaskListener listener, Instance inst)
     throws AmazonClientException, IOException, InterruptedException {
   int processedTime = 0;
   JIException exception = null;
   // TODO 自動生成されたメソッド・スタブ
   this.host = getHostName(computer);
   while (TIMEOUT > processedTime) {
     try {
       wmiLaunch(computer, listener);
       return;
     } catch (JIException e) {
       listener.getLogger().println("Waiting for DCOM to come up. Sleeping " + WAIT);
       Thread.sleep(WAIT * 1000);
       processedTime += WAIT * 1000;
       exception = e;
     }
   }
   // if not return, then print error.
   if (exception.getErrorCode() == 5) {
     // access denied error
     exception.printStackTrace(
         listener.error(Messages.ManagedWindowsServiceLauncher_AccessDenied()));
   } else {
     exception.printStackTrace(listener.error(exception.getMessage()));
   }
 }
Пример #3
0
  /**
   * Gets an item of the set.
   *
   * @param itemName The name of the item to get.
   * @return The item with the specified name.
   * @throws Exception When an error occurs.
   */
  public T getItem(final String itemName) throws Exception {
    try {
      // Invoke the Item method.
      Object[] inParams = new Object[] {new JIString(itemName), new Integer(0)};
      final JIVariant[] results = super.objectDispatcher.callMethodA("Item", inParams);
      final IJIComObject prop = results[0].getObjectAsComObject();
      final IJIDispatch dispatch = (IJIDispatch) JIObjectFactory.narrowObject(prop);

      // Create a new SWbemSetItem from the result.
      final Constructor<T> ctor = this.clazz.getConstructor(IJIDispatch.class, SWbemServices.class);
      final T item = ctor.newInstance(dispatch, this.service);

      // Return the SWbemSetItem.
      return item;
    } catch (JIException e) {
      if (e.getErrorCode() == 0x80020009) {
        return null;
      } else {
        throw e;
      }
    }
  }
Пример #4
0
  private void readPacket(NetworkDataRepresentation ndr, boolean fromCallback) {

    if (session == null) {
      throw new IllegalStateException(
          "Programming Error ! Session not attached with this call ! ... Please rectify ! ");
    }

    int index = 0;

    outparams = outParams.toArray();

    if (JISystem.getLogger().isLoggable(Level.FINEST)) {
      String str = "";
      for (int i = 0; i < outparams.length; i++) {
        str = str + "Out Param:[" + i + "]" + outparams[i] + "\n";
      }

      JISystem.getLogger().finest(str);
    }

    ArrayList comObjects = new ArrayList();
    Map additionalData = new HashMap();
    additionalData.put(CURRENTSESSION, session);
    additionalData.put(COMOBJECTS, comObjects);
    ArrayList results = new ArrayList();
    // user has nothing to return.
    if (outparams != null && outparams.length > 0) {
      while (index < outparams.length) {
        List listOfDefferedPointers = new ArrayList();
        results.add(
            JIMarshalUnMarshalHelper.deSerialize(
                ndr,
                outparams[index],
                listOfDefferedPointers,
                ((Integer) outparamFlags.get(index)).intValue(),
                additionalData));
        int x = 0;

        while (x < listOfDefferedPointers.size()) {

          ArrayList newList = new ArrayList();
          JIPointer replacement =
              (JIPointer)
                  JIMarshalUnMarshalHelper.deSerialize(
                      ndr,
                      (JIPointer) listOfDefferedPointers.get(x),
                      newList,
                      ((Integer) outparamFlags.get(index)).intValue(),
                      additionalData);
          ((JIPointer) listOfDefferedPointers.get(x))
              .replaceSelfWithNewPointer(
                  replacement); // this should replace the value in the original place.
          x++;
          listOfDefferedPointers.addAll(x, newList);
        }
        index++;
      }

      // now create the right COM Objects, it is required here only and no place else.
      for (int i = 0; i < comObjects.size(); i++) {
        JIComObjectImpl comObjectImpl = (JIComObjectImpl) comObjects.get(i);
        try {
          IJIComObject comObject = null;
          if (fromCallback) {
            // this is a new IP , so make a new JIComServer for this.
            JISession newsession = JISession.createSession(session);
            newsession.setGlobalSocketTimeout(session.getGlobalSocketTimeout());
            newsession.useSessionSecurity(session.isSessionSecurityEnabled());
            newsession.useNTLMv2(session.isNTLMv2Enabled());
            JIComServer comServer =
                new JIComServer(newsession, comObjectImpl.internal_getInterfacePointer(), null);
            comObject = comServer.getInstance();
            JIFrameworkHelper.link2Sessions(session, newsession);
          } else {
            if (comObjectImpl.internal_getInterfacePointer().isCustomObjRef()) {
              continue;
            }
            comObject =
                JIFrameworkHelper.instantiateComObject2(
                    session, comObjectImpl.internal_getInterfacePointer());
          }

          comObjectImpl.replaceMembers(comObject);
          JIFrameworkHelper.addComObjectToSession(
              comObjectImpl.getAssociatedSession(), comObjectImpl);
          // Why did I put this here. We should do an addRef regardless of whether we give a pointer
          // to COM or it gives us one.
          //					if (!fromCallback)
          {
            comObjectImpl.addRef();
          }

        } catch (JIException e) {
          JISystem.getLogger().throwing("JICallBuilder", "readPacket", e);
          throw new JIRuntimeException(e.getErrorCode());
        }
        // replace the members of the original com objects by the completed ones.
      }

      comObjects.clear();
    }

    outparams = results.toArray();
    executed = true;
  }