Is it possible to make service requests synchronous in adobe flex
Christophe Herreman Christophe Herreman Naveen Naveen 1. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Validator mx.
Hide Inherited Public Properties. Show Inherited Public Properties. Value that indicates how to handle multiple calls to the same service. Custom HTTP headers to be sent to the third party endpoint. Flag indicating whether the operation should keep its last call result for later access.
This property is set usually by framework code which wants to modify the behavior of a service invocation without modifying the way in which the service is called externally. Object of name-value pairs used as parameters to the URL. Provides access to the request timeout in seconds for sent messages. The TargetFactory. The handler will be called with the TargetTypeInfo and any fault that occurred during the processing of the request:.
In addition to the services described previously, the MPCUI framework provides a number of other services that are an integral part of the Target object oracle.
You can construct other target instances for associated targets. In either case, use the following methods to obtain additional information for these targets through the MPCUI service layer. For any instance of the Target class, you can call the getTargetInfo method to retrieve the target properties associated with that target instance.
The returned target information populates the properties of the Target instance including: guid , catProperties , typeMetaVer , time zoneRegion , and so on. When calling the getTargetInfo method, you must provide a handler. This handler will be called when the targetInfo service returns.
It is passed the fully populated Target instance and a fault object that is set to include any errors that occurred during the processing of the request to retrieve target properties:.
Use the target. This method is called and passed an array of association types and a handler that is called with the list of associated targets. Refer to the API documentation for a full description of the types of the objects returned by this method:. The metric metadata information is retrieved by calling the Target.
This is useful when attempting to troubleshoot slow pages or to identify the amount of time spent processing the request in the Management server. It is included in the project directories if you are using the Demo Sample as a template. The Activity Tracing dialog displays the set of pages accessed in the current session, and below each page the set of requests made to the Management Server.
Expand or collapse the dialog using the controls in the upper right-hand corner. In the details pane, click Show Item Details to view the body of the request and response messages sent between your application and the Management server. The MPCUI framework supports a limited subset of intervals 15, 30, 60, 90 seconds so that requests can be grouped together to avoid a large number of requests to the Management Server. The MPCUI framework starts and stops the polling of these requests automatically as each page or dialog appears or is removed goes out of scope.
In addition to the batching of polling requests, the MPCUI framework provides the ability to explicitly batch requests made at runtime from activity page or dialog controllers. Batching of requests is a good practice as it avoids additional round trips to the Management Server which slows the performance of your UI pages and adds additional overhead to the Management Server. For service requests you make from your controller. Example is extracted from the HomePageController.
Note the instances of page. All requests made in this way will be performed over a single pass to the Management Server. You can use batch requests elsewhere in controller code by creating a MultiServiceRequestor batch request and passing it to each request made. For example, suppose that in response to a button click in the page, two requests will be made to the Management Server to retrieve information.
They could each be made separately resulting in two trips to the server as shown in Example :. Alternatively, you can combine the batch requests into a single batch request avoiding the additional round trip to the Management server as shown in Example :.
When the plug-in UI requires information about Software Library entities, it can search using different criteria, including name, status, maturity level, or entity attributes. The desired entities can be filtered by specifying the query criteria using the SearchField enumeration.
A list of EntityInfo objects that represent an entity revision that match the query criteria is returned. If any error has occurred, it will be set in ListSwlibEntitiesResult. One of the more powerful aspects of the MPCUI framework is the ability to provide access to administrative features through a UI customized to that purpose.
The framework supports the processing of administrative tasks through the Enterprise Manager job system and Web services that provide access to the job system. The job service allows any job that is registered with the plug-in target type to be submitted for processing. The service does not support the ability to submit system job types at this time.
Scheduling of jobs through the job service supports a limited set of the scheduling options supported by the job system. The job schedule supports the following options:. As with other services, the Adobe Flex framework issues requests asynchronously. This requires that a handler is provided that will be called when the request has completed or failed.
When submitting a job, the result handler is called and passed a JobExecution object. This object contains the processing context for the job that was submitted, and can be used to retrieve the status of the job and operate on the job stop or delete it. When a job is run in this way using the submit method , the job is submitted for processing and the service returns immediately.
Therefore, the status of the job may change from submitted to running, and then to complete and the client must check the status periodically. The job service also provides a way to submit a job for immediate processing and will wait synchronously until the job execution completes, fails or reaches a timeout.
The client handler will not be called until this state is reached. The Task interface is a simplified way of submitting a job for immediate processing, without requiring all of the additional settings associated with the Job. In the case of a synchronous job, the status of the job is available immediately from the result passed to the handler; however, it should be checked to see if it equals JobStatus.
If so, then the request reached the specified timeout and the caller must treat the job execution as if it were submitted asynchronously. After a job has been submitted, there are several APIs available to get the status of the job and the details of each step including job output. Currently, there is no service provided that allows a client to search for a job execution. Getting the job status for a submitted job requires service request, and therefore requires a handler to be called with the result and possibly a fault if the request processing fails.
In addition to the status of the job, the job step details can be retrieved. Use the JobExecution object that is passed to the submit handler, to retrieve step output details as well as the job status. If the job has failed or if the step has not completed, then no data will be returned. In the case of a synchronous job execution, the handler for the Job. In the case of an asynchronous job execution, the handler for the Job.
Each call requires a request to the server:. If a job is submitted asynchronously Job. This indicates that the job is still running, and you might want to check the status of the job again at a later point.
The easiest thing from a code perspective is to expose a UI element that the user interacts with to cause the application to check the status of the job. When the user clicks the button or link, it calls the JobExecution. If the required interaction pattern is that the UI remains active while the job is running in the background, and periodically updating the UI with information about the status of the job, then the MPCUI provides a job API to perform period checking of the job status.
Each update calls a handler to provide the caller with the opportunity to process the current status and update the UI with that information. For jobs that are submitted using the Job. It is the third parameter and it defaults to false:. Using a job to perform administrative tasks is the most flexible approach in terms of scheduling and control start, interrupt, or stop , but does come with the additional overhead of managing the task being processed. For simple tasks that do not require control over schedule and that are expected to be performed quickly, use the RemoteOp service.
This service allows the execution of a script packaged with the plug-in to be executed directly through the Management Agent. Packaging Scripts for Remote Operation. Subsequent parameters are included as required for the script being run.
To run the remote operation, the RemoteOp. This handler has the following signature:. If the remote operation failed to be communicated to the Management Agent, then the fault parameter will include the details of that error. If the remote operation was processed, then the fault will be null and the remoteOp parameter supplied. Check the remoteOp parameter status because it can indicate an error status returned during command execution on the Management Agent.
Example shows this check being performed. The Enterprise Manager credentials model supports three different modes for performing operations that require credentials:. Specific credentials are set for a target or all targets of a particular type.
In this mode, the user does not select a set of credentials or provide credential values. Sets of credentials are created for a target or all targets of a particular type, and each set is assigned a name.
In this mode, the user is presented with a list of named sets and can select the set that they would use to perform the operation. MPCUI provides the facilities for retrieving credential information about a particular target. The services can return information only that the current user is privileged to see.
This ensures that there is no unauthorized access to secure information. It also requires that you must handle a situation where credential information might not be available to the user accessing the MPCUI code. To check if a target has preferred credentials set for it, call the CheckPreferredCredsService.
The service returns a CheckPreferredCredsResult object, which indicates whether global applying to all target instances of the type or instance applying only to the single target instance credentials are available:. You can retrieve the named credentials sets available for a particular target and:.
The following code requests all named sets for two different credentials types for the current target, and calls the credSetResultHandler handler with the result:. The results handler can then consume the named sets return as appropriate in this example, constructing a data source for display in a table :.
This section discusses passing preferred credentials and named set credentials to jobs and remote operations. If the task job or operation to be performed attempts to use preferred credentials, then the credentials parameter passed to the task is omitted.
Both the job and remote operation services will attempt to perform the task using preferred credentials. If no preferred credentials are set, then an error will be returned. To specify that a named set be used to perform a task, the credentials are passed in a JobCredential for jobs and an OpCredential for remote operations. In both cases, the credentials object includes the following four properties that must be set:.
This usage specifies which credentials types are required and where they are applied during job execution. This is one of the properties of the CredentialSet class, which holds named credential sets. For more information, Section 9.
MPCUI provides a credentials region that may be included in a page to allow the end user to interact with the Enterprise Manager credentials subsystem to view the set of credentials available and to select preferred, named, or override credentials when performing a task job or remote operation.
From the page controller associated with the page, retrieve the settings applied by the end user to this region:. Example Retrieving Selected Credential Information. In Example , note that the mode determines if the user selected preferred, named, or override credentials.
Depending on the mode, the named set can be retrieved CredentialsRegion. The Target class provides the ability to retrieve and set the monitoring credentials for the current target. To retrieve the monitoring credentials, an instance of the Target class is required and the getMonitoringCredentials function is called, passing the results handler that will receive the credential meta data including the monitoring credentials set:.
To set the monitoring credentials, the credentials fields according to the credential type specified for monitoring credentials. This is defined in your target metadata. The session state service provides the ability to store global state associated with the Flex application. This is useful for cases where state should be maintained for the current user, even as they move between pages outside of the Flex application that defines the custom UI.
For example, if the user modifies the state of the home page and then navigates to the "All Metrics" page, and then upon returning to the home page you wish to restore the state of the page as the user left it.
Because the user has left the pages that make up the Flex application, it is necessary to store the state required on the server-side session established for this user session and not within the Flex application itself.
To set the session state, call the EmUser. The session attributes contain an array of SessionAttribute objects, each of which has a corresponding name-value pair for the attributes stored. To retrieve the session state, use the corresponding EmUser. This function will retrieve the session state requested by passing a list of SessionAttributes and a handler that will be called with the result.
This will be the same SessionAttributes, populated with the data retrieved from the session:. For example, to create a layout of three rows, each occupying one third of the height of the page, then enter the following in the MXML file:. The Enterprise Manager UI style guides recommends that you organize the information on the page into regions. A region is a visual box with a title that can be expanded and collapsed. For example, in Example , each of the rows could be split up into separate regions rather than more vertical containers:.
Example results in a display similar to Figure You can use each of the regions to contain other UI components such as tables and charts to display meaningful information.
For more detailed examples, see the examples in the Demo Sample included in the Extensibility Development Kit. The Region component is an empty container within which you can display any number of components to construct your UI. MPCUI supplies several packaged regions that can be included in your page with a single simple tag. The availability region displays the availability of the target for the period specified in the AvailabiltyRegion tag daySpan property.
It shows a segmented bar that shows details of the target availability such as outages over that same period:.
The incidents region shows the set of open incidents for the current target and all related targets. It provides the option to filter the list of displayed incidents. For information about reusable credentials UI components, see Section 9. MPCUI supports three chart components. All chart components have integral support for displaying metric information by specifying the metric properties. Additionally, you can construct your own data for the chart using information obtained from other services including SQLDataService and map it to the charts using the dataProvider property.
The following examples and documentation for each chart type are a brief summary of the various options available for each chart.
For a complete description of each chart's properties, refer to the API documentation. For examples of how these charts work at runtime, see the Demo Sample included in the Extensibility Development Kit. Typically, the line chart displays information over time often referred to as a time-series chart. Therefore, it lends itself to the display of metric information either historically or in real-time. The chart includes properties for specifying the metricName and metricColumns an array that should be shown in the chart and a timePeriod property that can be set to show historical data or real-time sampled data.
In addition to specifying metrics to be plotted using the line chart, you can create your own data source that is used by the chart to display data. For example, data obtained through the SQL data service or some other means such as by using the polling service and then creating the data samples to be added to the chart. In the following example, the page includes a chart with the chartDataSource mapped to an item in the page model that is constructed in the page controller.
All charts can include a legend that displays the items shown in the chart. Use the following example to position the legend in one of four locations top, bottom, left, right.
The area chart is similar to the line chart and has the same attributes. It displays data in the same way as LineChart. The showCumulativeLine property controls the display of an area chart.
Otherwise, the area chart overlays the fill areas for each series included in the chart. The bar chart exposes the same properties as the column chart both for visible attributes and for specifying control over the data source:. The groupBy property available for bar and column charts enables you to organize data by key or by column. The default by column applies when the data set does not include keys. For example, assume you have the following data set where the User column is treated as the key to the data:.
In Example , the groupBy property is set to byColumn. This creates two groups of columns, one for each data column, with all three keys appearing in each group as displayed in Figure In Example , the groupBy property is set to byKey. This creates three groups, one for each key, with both columns the data items appearing in each group as displayed in Figure The column chart is a vertical bar chart and exposes the same properties as the bar chart both for visible attributes and for specifying control over the data source:.
In the following example, the code constructs a pie chart by specifying the metric name and metric columns. The MPCUI framework performs the necessary requests to obtain information from the Management Server and populates the values in the chart. The following sections describe the different methods of defining tables, providing examples of each method. You do not have to specify the headerText attributes for the columns because it will be filled with the metric column labels.
You can override these labels if required. In Example , the data for the table is loaded in the controller, and mapped to the page model processInfoData item.
The processInfoData is an array of objects of any type. The dataField property specified for each column identifies the public property that will be displayed in each column. In this case, the dataField name will also be used as the headerText. You can supply the headerText property to override this label. The rows currently selected in the table can be obtained by looking at the selectedRows property of the table. This property is an array of selected rows, where each row is a Dictionary object that contains data in the row keyed by the column name.
If the row is based on a custom data source, then the row will be whatever object was mapped into the table data source. If the table is set to allow single selection, then the selectedRows array includes a single entry only or none if no row is selected.
When you construct a dialog, typically you require an MXML class only, extending the oracle. Dialog class. To make a dialog available to be displayed using the invokeActivity method, you must register it as an activity as part of the Integration class.
In Example , note the following:. It must be unique across all activities included in the application. If you do not define inputParams as part of the dialog definition, then any input data required by the dialog such as any custom properties would have to be set in ActionScript and the dialog shown using the Dialog. If the dialog includes some state that is required when the dialog closes, then a close handler can be passed to the invokeActivity method.
This handler is called with the CloseEvent. This handler identifies which button was pressed to close the dialog and retrieves the dialog object itself to retrieve information from it. In Example , the metricDialogClosed function is passed to invokeActivity. When the dialog closes, the method is called and passed a CloseEvent. From this event, the currentTarget property contains the dialog itself, and the detail property indicates which button was pressed to close the dialog.
The train allows the definition of a multi-step UI, with next and previous buttons to navigate between each step. The train is typically used in cases where the user is going to create or modify an entity that has a large number of attributes that can be organized into categories.
The train must be registered with the integration class, and includes a controller that extends TrainController and a page class for each step in the train and extends TrainStepPage.
Each step train step page can have its own controller class. Because each step is a page with a controller, the layout, management of data and response to events within the step is exactly the same as any other page in the application. For more information about the Page class, see Section 9. The train step controller can access the train itself by referencing the TrainStepPage.
Use this to access other information maintained within the train object or its model. Example provides a definition of train and Figure shows the train. The train controller is used to managed state kept across all pages in the train and respond to changes in the train movement between steps and respond to the train completing when the user clicks either the Finish or Cancel button.
State may be maintained in the Train model using the Train. This property is a dynamic property that can be used to hold any information appropriate to the train. Individual pages can store their own state in their own model properties and may also access information stored in the train model.
Each train step controller can implement the init and destroy methods that are called when the step starts or stops. The step can do either of the following:. The train controller can also be called when the train ends Finish or Cancel by adding a listener function for the train done event:. The listener trainDone in Example can inspect the train state and determine if processing should continue or not.
It can choose to direct control to some other activity page or can set the train back to another step:. Example Defining Actions at the End of the Train. The InfoDisplay and InfoItem classes allow you to display a set of label-value pairs in a group with the labels right-aligned and the values left-aligned. Each entry InfoItem in the display specifies a label, value, optional icon, destination, or click property.
The destination or click properties cause the value to appear as a link. You can set destination to either of the following:. URL object constructed in the controller see HomePage.
You can specify the click handler instead of the destination and set it to a function within the controller that will be called when the item is clicked by the user.
In addition to the ability to define custom renderers for table columns, headers, and other UI elements using the capabilities provided by the Flex framework, the MPCUI framework also provides several built-in renderers that can be used to display custom icons in a table or for an InfoItem.
These renderers are also useful for meta-data only implementations where it is not possible to create controller code to implement a renderer. These built-in renderers show an icon in place of a text value, either in a Table or InfoItem component. The renderer is specified by using the "appModel. For example, the following code would result in an icon being displayed next to the value on the InfoItem and will show a check mark, warning, or error icon depending on the value displayed in the InfoItem:.
The second parameter, "bean" specifies the input parameter for the check mark renderer. This parameter will be different and in some cases optional depending on the renderer selected. Refer to the API documentation for details regarding what each renderer requires for input parameters. If you specify the url and a non-default destination, your destination in the services-config.
Specifies whether to use the Flex proxy service. If you do not specify true to proxy requests though the Flex server, you must ensure that the player can reach the target URL. You also cannot use destinations defined in the services-config. ActionScript function used to decode a service result from XML. If it is not defined the default XMLDecoder is used to do the work.
The function referenced by the xmlDecode property must take a flash. XMLNode object as a parameter and should return an Object. It can return any type of object, but it must return something. Returning null or undefined causes a fault. ActionScript function used to encode a service request as XML. XMLNode object. The xmlEncode property takes an Object and should return a flash. In this case, the XMLNode object can be a flash. Returning the wrong type of object causes a fault.
Cancels the last service invocation or an invokation with the specified ID. Even though the network operation may still continue, no result or fault event is dispatched.
If omitted, the last service invocation is canceled. Sets the result property of the invoker to null. This is useful when the result is a large object that is no longer being used. Otherwise, set to false.
The default value is true. Disconnects the service's network connection. This method does not wait for outstanding network operations to complete. Logs the user out of the destination. Logging out of a destination applies to everything connected using the same channel as specified in the server configuration. For example, if you're connected over the my-rtmp channel and you log out using one of your RPC components, anything that was connected over my-rtmp is logged out.
Note: Adobe recommends that you use the mx. The parameters are optional, but if specified should be an Object containing name-value pairs or an XML object depending on the contentType.
Sets the credentials for the destination accessed by the service. The credentials are applied to all services connected over the same ChannelSet. Note that services that use a proxy to a remote destination will need to call the setRemoteCredentials method instead.
0コメント