/*
(non-Javadoc)
@see net.roboconf.target.api.TargetHandler
#createMachine(net.roboconf.target.api.TargetHandlerParameters)
514370
@Override
	public String createMachine( TargetHandlerParameters parameters ) throws TargetException {

		this.logger.fine( "Creating a new machine." );
		Map<String,String> targetProperties = parameters.getTargetProperties();
		final String providerId = targetProperties.get( PROVIDER_ID );
		ComputeService computeService = jcloudContext( targetProperties );

		// For IaaS, we only expect root instance names to be passed
		if( InstanceHelpers.countInstances( parameters.getScopedInstancePath()) > 1 )
			throw new TargetException( "Only root instances can be passed in arguments." );

		String rootInstanceName = InstanceHelpers.findRootInstancePath( parameters.getScopedInstancePath());
		String machineId = null;
		try {
			// Create a template from an image and a flavor/hardware
			Image image = null;
			String imageName = targetProperties.get( IMAGE_NAME );
			for( Image i : computeService.listImages()) {
				if( i.getName().equalsIgnoreCase( imageName )) {
					image = i;
					break;
				}
			}

			if( image == null )
				throw new TargetException( "No image named '" + imageName + "' was found." );

			Hardware hardware = null;
			String hardwareName = targetProperties.get( HARDWARE_NAME );
			for( Hardware h : computeService.listHardwareProfiles()) {
				if( h.getName().equalsIgnoreCase( hardwareName )) {
					hardware = h;
					break;
				}
			}

			if( hardware == null )
				throw new TargetException( "No hardware named '" + hardwareName + "' was found." );

			Template template = computeService.templateBuilder().fromImage( image ).hardwareId( hardware.getId()).build();
			template.getOptions().securityGroups( targetProperties.get( SECURITY_GROUP ));
			template.getOptions().userMetadata( "Application Name", parameters.getApplicationName());
			template.getOptions().userMetadata( "Root Instance Name", rootInstanceName );
			template.getOptions().userMetadata( "Domain", parameters.getDomain());
			template.getOptions().userMetadata( "Created by", "Roboconf" );

			// Specify our own key pair if the current provider supports it
			String keyPairName = targetProperties.get( KEY_PAIR );
			try {
				if( ! Utils.isEmptyOrWhitespaces( keyPairName )) {
					Method keyPairMethod = template.getOptions().getClass().getMethod( "keyPair", String.class );
					keyPairMethod.invoke( template.getOptions(), keyPairName );
				}

			} catch( Exception e ) {
				throw new TargetException( "Provider: " + providerId + " does not support specifying key pairs.", e );
			}

			String vmName = (parameters.getApplicationName() + "." + rootInstanceName).replaceAll( "\\.|\\s+", "-" );
			Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup( vmName, 1, template );
			machineId = nodes.iterator().next().getId();

		} catch( RunNodesException e ) {
			throw new TargetException( "An error occurred while creating a new node with JClouds on provider " + providerId + ".", e );

		} finally {
			if( computeService != null )
				computeService.getContext().close();
		}

		return machineId;
	}
377171
@Override
    public AddressCompleteMessage createACM(int cic) {
        AddressCompleteMessage acm = createACM();
        CircuitIdentificationCode code = this.parameterFactory.createCircuitIdentificationCode();
        code.setCIC(cic);
        acm.setCircuitIdentificationCode(code);
        return acm;
    }
211810
public MethodMetaArgs createCreateMethod(HandlerMetaDef handlerMetaDef, EventModel em) {

		String p_methodName = handlerMetaDef.getCreateMethod();
		if (p_methodName == null) {
			Debug.logError("[JdonFramework] not configure the createMethod parameter: <createMethod name=XXXXX /> ", module);
		}
		return createCRUDMethodMetaArgs(p_methodName, em);
	}
568734
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String machineId ) throws TargetException {

		this.logger.fine( "Terminating machine '" + machineId + "'." );
		cancelMachineConfigurator( machineId );
		try {
			AmazonEC2 ec2 = createEc2Client( parameters.getTargetProperties());
			TerminateInstancesRequest terminateInstancesRequest = new TerminateInstancesRequest();
			terminateInstancesRequest.withInstanceIds( machineId );
			ec2.terminateInstances( terminateInstancesRequest );

		} catch( Exception e ) {
			this.logger.severe( "An error occurred while terminating a machine on Amazon EC2. " + e.getMessage());
			throw new TargetException( e );
		}
	}
1031890
@Process(actionType = CreateHandler.class)
    public void createHandler(final CreateHandler action, final Dispatcher.Channel channel) {
        operationDelegate.onCreateResource(action.getAddressTemplate(), action.getInstanceName(), action.getNewModel(),
            new CrudOperationDelegate.Callback() {
                @Override
                public void onFailure(AddressTemplate template, String name, Throwable t) {
                    channel.nack(t);
                }

                @Override
                public void onSuccess(AddressTemplate addressTemplate, String name) {
                    lastModifiedInstance = action.getInstanceName();
                    // we must strip the pre-handler-chain suffix to reload a single configuration. 
                    readConfig(action.getAddressTemplate().subTemplate(0, 3), channel);
                }
            });
    }
260172
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String machineId ) throws TargetException {
		try {
			// TODO remove next line when APIs get compatible...
			String postfix = (parameters.getTargetProperties().get(CloudautomationMixins.PROVIDER_ENDPOINT) != null ? "" : "/compute");
			OcciVMUtils.deleteVM( parameters.getTargetProperties().get(SERVER_IP_PORT) + postfix, machineId);
		} catch(TargetException ignore) {
			//ignore
		}
	}
828985
@Override
	public final Object invoke(final String actionName, final Object[] params,
			final String[] signature) throws MBeanException,
			ReflectionException {
		// Get the JmxCommand
		JmxCommand curCmd = null;
		for (JmxCommand cmd : this.cmds) {
			if (cmd.getType().equals(actionName)) {
				curCmd = cmd;
				break;
			}
		}

		final boolean isSync = actionName.startsWith("sync");
		try {
			// initialize arguments for lunching (using Quartz)
			final Map<String, Object> jobDataMap = buildJobDataMap(curCmd, params);

			final Launch<?> launch = Launcher.getLauncher()
					.newLaunch((Class<?>) remoteProgram.getAdapterClass()).addParameters(jobDataMap);
			if (isSync) {
				// Launch and wait until terminated
				launch.synchLaunch();
				return LaunchingMessageKind.ILAUNCH0003.getFormatedMessage(
						remoteProgram.getAdapterClass().getCanonicalName(), launch.getLaunchId(),
						launch.getLaunchResult().getStatusCode(),
						launch.getLaunchResult().getReturnCode());
			} else {
				// Launch and continue
				launch.aSynchLaunch();
				return LaunchingMessageKind.ILAUNCH0002.getFormatedMessage(
						remoteProgram.getAdapterClass().getCanonicalName(), launch.getLaunchId());
			}
		} catch (LaunchException e) {
			LaunchingMessageKind.ELAUNCH0003.format(actionName, e);
		}
		
		return null;
	}
265157
def create_execution_engine():
    
    # Create a target machine representing the host
    target = llvm.Target.from_default_triple()
    target_machine = target.create_target_machine()
    # And an execution engine with an empty backing module
    backing_mod = llvm.parse_assembly("")
    engine = llvm.create_mcjit_compiler(backing_mod, target_machine)
    return engine
1299071
public static Object instanceFromTarget(Object target) throws InstantiationException, IllegalAccessException {
    if (target == null) return null;

    if (target instanceof Class) {
      // Create handler from class
      Class<?> klass = (Class<?>) target;
      return klass.newInstance();
    } else {
      return target;
    }
  }
1190611
@Override
    public void createControlAdapter()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "createControlAdapter");
        controlAdapter = new Alias(messageProcessor, this);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createControlAdapter", controlAdapter);
    }
1066119
function addMachine(name) {
        return co(function*(){
            debug("Adding a new machine with the name '%s'", name);
            let manifest = getManifest();

            if(manifest.machines[name]) {
                debug("Machine already exists");
                throw new Error("Machine already exists");
            }

            manifest.machines[name] = {
                route: "machines/" + name,
                "versions": {
                    "version1": {
                        "route": "machines/" + name + "/versions/version1",
                        "instances": {}
                    }
                }
            };

            let machineDirPath = "machines/" + name;
            let machineVersionsDirPath = machineDirPath + "/versions";
            let version1DirPath = machineVersionsDirPath + "/version1";
            let version1InstancesDirPath = version1DirPath + "/instances";
            let modelFile = version1DirPath + '/model.scxml';
            let infoFile = version1DirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + machineDirPath);
            fs.mkdirSync(repositoryPath + "/" + machineVersionsDirPath);
            fs.mkdirSync(repositoryPath + "/" + version1DirPath);
            fs.mkdirSync(repositoryPath + "/" + version1InstancesDirPath);

            debug("Creating the base.scxml file");
            fs.copySync(__dirname + '/base.scxml', repositoryPath + "/" + modelFile);

            debug("Creating the version info.json file");
            let infoVersion1 = { "isSealed": false };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, infoVersion1);

            debug("Setting the manifest");
            setManifest(manifest);

            yield _commit(null, ["manifest.json", modelFile, infoFile], "Added '" + name + "' machine");
            debug("A new machine with the name '%s' was successfully added", name);
        });
    }
785265
@Override
	public void configureMachine( TargetHandlerParameters parameters, String machineId )
	throws TargetException {
		this.logger.fine( "Configuring machine '" + machineId + "': nothing to configure." );
	}
673956
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String instanceId ) throws TargetException {

		// instanceID is CloudServiceName
		try {
			final AzureProperties azureProperties = buildProperties( parameters.getTargetProperties());
			String baseURL = String.format("https://management.core.windows.net/%s/services", azureProperties.getSubscriptionId());
			String deleteCloudServiceURL = baseURL+"/hostedservices/"+instanceId+"?comp=media";

			// Delete Cloud Service, and also delete all the related things
			int rescodeDeleteCloudService = processDeleteRequest(
					new URL(deleteCloudServiceURL),
					azureProperties.getKeyStoreFile(),
					azureProperties.getKeyStorePassword());		// rescode shoud be 202

			this.logger.info("Response Code: Delete VM: " + rescodeDeleteCloudService);

		} catch( Exception e ) {
			throw new TargetException( e );
		}
	}
442810
public final ControlSilence createNewControlSilence() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlSilence");
    ControlSilence msg = null;
    try {
      msg = new ControlSilenceImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlSilence");
    return msg;
  }
486901
private void createInstance() throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstance");

        ManagedObjectFactory<?> ejbManagedObjectFactory = home.beanMetaData.ivEnterpriseBeanFactory;
        if (ejbManagedObjectFactory != null) {
            createInstanceUsingMOF(ejbManagedObjectFactory);
        } else {
            createInstanceUsingConstructor();
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstance");
    }
105334
protected Object makeModel(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, ModelHandler modelHandler)
			throws Exception {
		Object model = null;
		try {
			String formName = actionMapping.getName();
			if (formName == null)
				throw new Exception("no define the FormName in struts_config.xml");

			ModelMapping modelMapping = modelHandler.getModelMapping();
			String keyName = modelMapping.getKeyName();
			String keyValue = request.getParameter(keyName);
			if (keyValue == null) {
				Debug.logError("[JdonFramework]Need a model's key field : <html:hidden property=MODEL KEY /> in jsp's form! ", module);
			}

			modelManager.removeCache(keyValue);
			Debug.logVerbose("[JdonFramework] no model cache, keyName is " + keyName, module);
			model = modelManager.getModelObject(formName);

		} catch (Exception e) {
			Debug.logError("[JdonFramework] makeModel error: " + e);
			throw new Exception(e);
		}
		return model;
	}
719849
@Override
    public ConnectMessage createCON(int cic) {
        ConnectMessage msg = createCON();
        CircuitIdentificationCode code = this.parameterFactory.createCircuitIdentificationCode();
        code.setCIC(cic);
        msg.setCircuitIdentificationCode(code);
        return msg;
    }