Examples of ManagedOperation


Examples of org.jboss.managed.api.ManagedOperation

      assertNotNull(config);

      // This should have a shutdown operation
      Set<ManagedOperation> ops = mc.getOperations();
      MetaType[] signature = {};
      ManagedOperation shutdown = ManagedOperationMatcher.findOperation(ops, "shutdown", signature);
      assertNotNull(shutdown);
      /* Invoke it
      MetaValue[] args = {};
      shutdown.invoke(args);
      */
 
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

            .size());

      // first check that all operations that receive a security domain String are present.
      for (String operationName : opsWithStringParam)
      {
         ManagedOperation operation = operations.get(operationName);
         assertNotNull("Missing expected operation: " + operationName, operation);
         ManagedParameter[] parameters = operation.getParameters();
         assertEquals("Unexpected number of parameters", 1, parameters.length);
         assertEquals("Invalid parameter name", "securityDomain", parameters[0].getName());
         assertEquals("Invalid parameter type", "java.lang.String", parameters[0].getMetaType().getTypeName());
      }

      // now check that the operations that receive a JaasSecurityDomain are present.
      for (String operationName : opsWithDomainParam)
      {
         ManagedOperation operation = operations.get(operationName);
         assertNotNull("Missing expected operation: " + operationName, operation);
         ManagedParameter[] parameters = operation.getParameters();
         assertEquals("Unexpected number of parameters", 1, parameters.length);
         assertEquals("Invalid parameter name", "domain", parameters[0].getName());
         assertEquals("Invalid parameter type", "org.jboss.security.plugins.JaasSecurityDomain", parameters[0]
               .getMetaType().getTypeName());
      }
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

      assertEquals("Unexpected number of operations", noArgsOperations.length + oneArgOperations.length, operations
            .size());
      // first check the methods that don't have any parameter.
      for(String operationName : noArgsOperations)
      {
         ManagedOperation operation = operations.get(operationName);
         assertNotNull("Unexpected operation name: " + operationName, operation);
         ManagedParameter[] parameters = operation.getParameters();
         assertEquals("Unexpected number of parameters", 0, parameters.length);
      }
      // now check the methods that contain a 'secret' parameter.
      for(String operationName : oneArgOperations)
      {
         ManagedOperation operation = operations.get(operationName);
         assertNotNull("Unexpected operation name: " + operationName, operation);
         ManagedParameter[] parameters = operation.getParameters();
         assertEquals("Unexpected number of parameters", 1, parameters.length);
         assertEquals("Invalid parameter name", "secret", parameters[0].getName());
      }
     
      // just the check the second security domain is also available - we don't repeat the tests because the
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

      {
         getLog().debug("name="+mo.getName()+",description="+mo.getDescription()+",impact="+mo.getImpact());
         operations.put(mo.getName(), mo);
      }
     
      ManagedOperation mgdop = operations.get("showHistory");
      assertNotNull("HAPartition has showHistory", mgdop);
      MetaValue result = mgdop.invoke();
      assertNotNull(result);
     
      mgdop = operations.get("showHistoryAsXML");
      assertNotNull("HAPartition has showHistoryAsXML", mgdop);
      result = mgdop.invoke();
      assertNotNull(result);
     
      mgdop = operations.get("getDRMServiceNames");
      assertNotNull("HAPartition has getDRMServiceNames", mgdop);
      result = mgdop.invoke();
      assertTrue(result instanceof CollectionValue);
      MetaValue[] elements = ((CollectionValue) result).getElements();
      assertNotNull(elements);
      boolean found = false;
      for (MetaValue element : elements)
      {
         assertTrue(element instanceof SimpleValue);
         if (HAJNDI.equals(((SimpleValue) element).getValue()))
         {
            found = true;
            break;
         }
      }
      assertTrue(found);
     
      mgdop = operations.get("listDRMContent");     
      assertNotNull("HAPartition has listDRMContent", mgdop);
      result = mgdop.invoke();
      assertTrue(result instanceof SimpleValue);
      Object val = ((SimpleValue) result).getValue();
      assertTrue(val instanceof String);
      assertTrue(((String) val).indexOf(HAJNDI) > -1);
     
      mgdop = operations.get("listDRMContentAsXml");
      assertNotNull("HAPartition has listDRMContentAsXml", mgdop);
      result = mgdop.invoke();
      assertTrue(result instanceof SimpleValue);
      val = ((SimpleValue) result).getValue();
      assertTrue(val instanceof String);
      assertTrue(((String) val).indexOf(HAJNDI) > -1);
     
      mgdop = operations.get("getDRMServiceViewId");
      assertNotNull("HAPartition has getDRMServiceViewId", mgdop)
      MetaValue hajndiparam = SimpleValueSupport.wrap(HAJNDI);
      MetaValue[] hajndiparams = new MetaValue[]{hajndiparam};
      result = mgdop.invoke(hajndiparams);
      assertNotNull(result);
     
      mgdop = operations.get("lookupDRMNodeNames");
      assertNotNull("HAPartition has lookupDRMNodeNames", mgdop);
      result = mgdop.invoke(hajndiparams);
      assertTrue(result instanceof CollectionValue);
      elements = ((CollectionValue) result).getElements();
      assertNotNull(elements);
      assertEquals(2, elements.length);
     
      mgdop = operations.get("isDRMMasterForService");
      assertNotNull("HAPartition has isDRMMasterForService", mgdop);
      result = mgdop.invoke(hajndiparams);
      assertTrue(result instanceof SimpleValue);
      val = ((SimpleValue) result).getValue();
      assertTrue(val instanceof Boolean);
     
      mgdop = operations.get("create");
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

      return dispatcher.get(componentName, propertyName);
   }

   public MetaValue invoke(Long opID, Object componentName, String methodName, MetaValue... param)
   {
      ManagedOperation op = this.registry.getManagedOperation(opID);
      AbstractRuntimeComponentDispatcher.setActiveOperation(op);

      if(param == null)
         param = new MetaValue[0];
     
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

      this.operations.clear();
   }

   public ManagedOperation getManagedOperation(Long opID)
   {
      ManagedOperation op = this.operations.get(opID);
      if(op == null)
         throw new IllegalStateException("operation not found for id " + opID);
      return op;
   }
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

            if (managementOp == null)
               continue;

            try
            {
            ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
            operations.add(op);
            }
            catch(Exception e)
            {
               log.debug("Failed to create ManagedOperation for: "+methodInfo.getName(), e);
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

   public Object invoke(Object componentName, String methodName, MetaValue... param)
   {
      try
      {
         ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
         String[] sig = new String[param.length];
         Object[] args = new Object[param.length];
         if(op != null)
         {
            ManagedParameter[] params = op.getParameters();
            if(params != null &&  params.length == param.length)
            {
               for(int i=0; i < param.length; i++)
               {
                  ManagedParameter mp = params[i];
                  MetaMapper<?> mapper = mp.getTransientAttachment(MetaMapper.class);
                  if(mapper != null)
                     args[i] = mapper.unwrapMetaValue(param[i]);
                  else
                     args[i] = unwrap(param[i]);
                  //
                  sig[i] = mp.getMetaType().getTypeName();
               }
            }
            else
            {
               args = toArguments(param);
               sig = toSignature(param);
            }
         }
         else
         {
            args = toArguments(param);
            sig = toSignature(param);
         }
         // Invoke
         Object value = mbeanServer.invoke(new ObjectName(componentName.toString()), methodName, args, sig);
         MetaValue mvalue = null;
         if (value != null)
         {
            // Look for a return type MetaMapper
            MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
            if (returnTypeMapper != null)
               mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
            else
               mvalue = create(value);
         }
         return mvalue;
      }
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

   public Object invoke(Object componentName, String methodName, MetaValue... param)
   {
      try
      {
         ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
         String[] sig = new String[param.length];
         Object[] args = new Object[param.length];
         if(op != null)
         {
            ManagedParameter[] params = op.getParameters();
            if(params != null &&  params.length == param.length)
            {
               for(int i=0; i < param.length; i++)
               {
                  ManagedParameter mp = params[i];
                  MetaMapper<?> mapper = mp.getTransientAttachment(MetaMapper.class);
                  if(mapper != null)
                     args[i] = mapper.unwrapMetaValue(param[i]);
                  else
                     args[i] = unwrap(param[i]);
                  //
                  sig[i] = mp.getMetaType().getTypeName();
               }              
            }
            else
            {
               args = toArguments(param);
               sig = toSignature(param);
            }
         }
         else
         {
            args = toArguments(param);
            sig = toSignature(param);
         }
         // Invoke
         Object value = bus.invoke(componentName, methodName, args, sig);
         MetaValue mvalue = null;
         if (value != null)
         {
            // Look for a return type MetaMapper
            MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
            if (returnTypeMapper != null)
               mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
            else
               mvalue = create(value);
         }
         return mvalue;
      }
View Full Code Here

Examples of org.jboss.managed.api.ManagedOperation

    }

    protected OperationResult invokeOperation(ManagedComponent managedComponent, String name, Configuration parameters)
        throws Exception {
        OperationDefinition operationDefinition = getOperationDefinition(name);
        ManagedOperation managedOperation = getManagedOperation(managedComponent, operationDefinition);
        // Convert parameters into MetaValue array.
        MetaValue[] parameterMetaValues = ConversionUtils.convertOperationsParametersToMetaValues(managedOperation,
            parameters, operationDefinition);
        // invoke() takes a varargs, so we need to pass an empty array, rather than null.
        MetaValue resultMetaValue = managedOperation.invoke(parameterMetaValues);
        OperationResult result = new OperationResult();
        // Convert result MetaValue to corresponding Property type.
        ConversionUtils.convertManagedOperationResults(managedOperation, resultMetaValue, result.getComplexResults(),
            operationDefinition);
        // If this is a lifecycle operation ask for an avail check
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.