예제 #1
0
  @Override
  public List<String> examine(String name, String versionString) {
    ManageableArtifact artifact;

    try {
      artifact = getArtifactRetriever().getArtifact(name, convertToVersion(versionString));
    } catch (IllegalArgumentException iae) {
      return Arrays.asList(iae.getMessage());
    } catch (InstanceNotFoundException e) {
      return getDoesNotExistMessage(TYPE, name, versionString);
    }

    if (STATE_ACTIVE.equals(artifact.getState())) {
      return super.examine(name, versionString);
    }
    return Arrays.asList(UNABLE_TO_EXAMINE_CONFIGURATION_IN_NON_ACTIVE_STATE);
  }
 private void awaitActive(String type, String name, String version) {
     try {
         ObjectName objectName = new ObjectName("org.eclipse.virgo.kernel:type=Model,artifact-type=" + type + ",name=" + name + ",version=" + version);
         ManageableArtifact artifact = JMX.newMXBeanProxy(this.mBeanServer, objectName, ManageableArtifact.class);
         
         long startTime = System.currentTimeMillis();
         
         while (!"ACTIVE".equals(artifact.getState())) {
             if (System.currentTimeMillis() - startTime > TIMEOUT) {
                 fail("Artifact " + type + " " + name + " " + version + " was not active within " + TIMEOUT + "ms.");
             }
             try {
                 Thread.sleep(50);
             } catch (InterruptedException _) {
             }
         }
     } catch (JMException jme) {
         fail(jme.getMessage());
     }
 }