Best Practice: ExecutorService#execute v.s. BlockingQueue

Hello all:
I have a choice to make here.
I am developing a server app. It takes requests from a message broker and use these requests as conditions to fetch data from backend d-base and send back to the broker's topic again.
The idea is simple and straightforward. I construct runnable tasks to do the above job, and I created a cached thread pool (Executors#newCachedThreadPool) , and pass the task to ExecutorService#execute , piece of cake.
the code works fine in testing phase. However I have been obsessed with the idea of using a blocking queue.
In my mind, the implementation using queue is as follows:
- construct runnable tasks as above;
- put the task into the queue;
- create a thread (or a runnable passed to a ExecutorService#execute ), which runs tirelessly (endless loop) to pick the task from the queue and call task#run.
I think the choice is depending on the volumes of the client requests. If that's not too many, a cached thread pool assigning a thread for each request might be appropriate; otherwise, a fixed size threadpool or blocking queue might be preferable?
BTW, what's the difference b/w a fixed thread pool and a blocking queue solution? It seems to me that they have the same effect since the size of both is fixed.
Thanks, John

An ExecutorService has a executor and a threadpool and you submit your task in that pool. Those pool takes a work queue, be it a blockingQueue, or a non blockingQueue or a Synchronous queue, and they are managed by the ExecutorService class. You also specify what kind of pool you are interested in. And then, ES manages both.
You ought not to invoke execute() method on a ES: it returns void! You want some result bearing computation, else you could have used Executor and just invoke execute! If you think about PC design pattern, you need a queue to where the producer places the tasks and consumer consumes from it. That's the idea of queue.
In your case, I'd have avoid using cacheThreadPool as it creates unlimited number of threads. Rather, I'd have used a bounded blocking queue just to be on safer side. Let me know in case you want to discuss more :)

Similar Messages

  • Best Practices for Reprocessing or Reexecuting a mapping

    Hi All
    Please,
    May someone tell me which is the best practice to execute a mapping when it fails?
    How does Oracle Warehouse Builder manage the re execution and re processing of a map from a Source system to staging area tables?
    - Truncate the stage table and start again?
    - Populate an identical error table and reprocess only this table after fixing each Extraction mistake? This to avoid a whole processing when the quantity of mistakes is considerably lower than successful records
    - Has OWB a log table of error records? Can I process over this table?
    - Any valuable link ?
    (The questions applies for mappings between staging area tables and the Warehouse tables too)
    I`m working with DB v 9.2.0.5, and OWB v.10g.
    Thanks in Advance
    LEONARDO QUINTERO RIPPE
    [email protected]
    Technical Consulting

    Roland,
    The doc is linked on [SAP on DB2 for z/OS|SAP on DB2 for z/OS] or access the doc directly [here|https://service.sap.com/~sapidb/011000358700000525542007E] .
    Regards,
    Thomas

  • Best Practice: Executing the same code from different triggers

    Swing supports the idea of Actions, which seems to be an implementation of the "Command" pattern. One can create an instance of an Action implementation and set it to several JComponents, like JButton and JMenuItem. Whenever the button or the menu item is triggered, the action gets executed. So far, so good.
    But there are more triggers in Swing that cannot get configured to trigger an action, namely Drops and pressing the window's [X] Close icon. Certainly these fire events, but they do not automatically trigger actions.
    Certainly one can react to importData(TransferSupport) and windowClosing() by manually calling the action's actionPerformed(ActionEvent) method, but as there is no setAction(Action) method at neither the TransferHandler class nor the WindowAdapter class, the question is: Where to take that Action instance from, and what command name to pass to it's constructor, and what to provide as the event source?
    It just seems like the Action framework has a gap here, as it nicely covers these questions for JComponents, but not for JFrame and JDialog.
    So unless there are JFrame.setDropAction(Action) and JFrame.setCloseAction(Action) methods added to the Swing framework (and I doubt they will get added any time near), my question is whether there have been establed some widely accepted best practices (i. e. something that 75% of the programmers will do, not something ONE programmer always does but just he does). Any Swing expert here answering this?

    The window decorations are handled by the OS. That [X] close button isn't a JButton at all.
    JFrame's and JDialog's, however, do have a root panes. And you can ask the root pane to take over window decorations via JFrame#setDefaultLookAndFeelDecorated(true). JDialog has a similar method. When the root pane takes over window decorations, then the [X] icon is a JButton and you could, in theory, set its action to an Action object.
    The the metal LAF window decorations, however, are ugly (I think at least) and I'm not sure how many programs actually use it.

  • Best practice for a same query against 2 different tables

    Hello all,
    I want to extract info about tablespaces storage, both permanent and temporary. For that I use 2 different cursors that do exactly the same query but against a different table (dba_data_files and dba_temp_files).
    CURSOR permanentTBSStorageInfo (tablespaceName VARCHAR2) IS
    SELECT file_name, bytes, autoextensible, maxbytes, increment_by
    FROM dba_data_files
    WHERE tablespace_name = tablespaceName;
    CURSOR temporaryTBSStorageInfo (tablespaceName VARCHAR2) IS
    SELECT file_name, bytes, autoextensible, maxbytes, increment_by
    FROM dba_temp_files
    WHERE tablespace_name = tablespaceName;
    First I'm bothered that I have to use 2 cursors to execute the same query against 2 different tables. Is there no another way around?
    Then I fetch the results of this cursors in 2 different loops because I didn't find a way to dynamically call the cursors. I am looking for best practice here, knowing that I will do the same parsing against the results of the 2 cursors.
    Thank you,

    Hi
    Check whether the below query is helpful or not
    select      fs.tablespace_name "Tablespace",
         fs.tempspace "Temp MB",
         df.totalspace "Total MB"
         from
         (select
         tablespace_name,
         round(sum(bytes) / 1048576) TotalSpace
         from
         dba_data_files
         group by
         tablespace_name
         ) df,
         (select
         tablespace_name,
         round(sum(bytes) / 1048576) tempSpace
         from
         dba_temp_files
         group by
         tablespace_name
         ) fs
         where
         df.tablespace_name = fs.tablespace_name;
    Thanks

  • Office Web Apps - Best Practice for App Pool Security Account?

    Guys,
    I am finalising my testing of Office Web Apps, and ready to move onto deploying it to my live farm.
    Generally speaking, I put service applications in their own application pool.
    Obviously by doing so this has an overhead on memory and processing, however generally speaking it is best practice from a security perspective when using separate accounts.
    I have to create 3 new service applications in order to deploy Office Web Apps, in my test environment these are using the Default SharePoint app pool. 
    Should I create one application pool for all my office web apps with a fresh service account, or does it make no odds from a security perspective to run them in the default app pool?
    Cheers,
    Conrad
    Conrad Goodman MCITP SA / MCTS: WSS3.0 + MOSS2007

    i run my OWA under it's own service account (spOWA) and use only one app pool.  Just remember that if you go this route, "When
    you create a new application pool, you can specify a security account used by the application pool to be either a predefined Network Service account or a managed account. The account must have db_datareader, db_datawriter, and execute permissions for the content
    databases and the SharePoint configuration database, and be assigned to the db_owner role for the content databases." (http://technet.microsoft.com/en-us/library/ff431687.aspx)

  • Error while running eCATT for Best Practice HR- US

    HI All,
    I am executing BC sets through eCATT for implementing Best Practice of HR for US. While running eCATT i am getting two errors, i am not in a positiong to find out a solution. Can you guys please share your throghts.
    Error messages are as follows:
    1) Error in eCATT command CHEVAR
        Condition not fulfilled
    2) Error in eCATT command ABAP
        LOCAL GENERATION LIMIT 36 SUBPOOL REACHED
    Looking forward to the response
    Thanks & Regards
    Shyam V

    Hi Shyam,
                  I was just wondering if this document may help the query you were looking for
    http://help.sap.com/saphelp_nw04/helpdata/en/43/2f34413f97f323e10000000a155106/frameset.htm
    Hope you decode the error.
    Have a best day ahead.

  • Best practice implementation. What are the steps for this?.

    We had an upgrade from CRM 4 to 7 undertaken by some outfit (name deleted). After the upgrade was complete it would look as though the comapny carried on using the GUI interface rather than the WebUI interface, mainly because that's how CRM 4 worked. Now they would like to use the WebUI interface of CRM 7, as the GUI interface is no longer supported, but are receiving a number of errors when using certain features of teh WebUI. It would look as though a lot of config is missing, especially in the UI Framework area. I can only assume that whichever company performed the upgarde simply skipped this section when upgrading.
    I assume that I could download the best practice install/upgrade (?) and then just execute the section regarding the UI Framework, if such a section exists. bearing in mind that there seems to be a lot of config missing in the UI Framework section, would you recommend the course of action that I have mentioned?.
    Our WebUI Interaction centre is giving errors when we go in and I have been informed that I need to complete the config for:
    Customer Relationship Management->UI Framework->UI Framework Definition->Maintain Runtime Framework Profile
    But as I mentioned, there are lots of other sections in the UI Framework area that are empty and hence the suggestion I made above. Hopwever, I would specifically be interested to hear from anyone who can tell me what the entries are in the view table BSPWDV_RF_PROF_C and possibly the table BSPWDV_CTRL_REPL and BSPWDV_DEF_CC.
    I know this only completes part of the config, but it might be enough so that the WebUI IC can be viewed.
    On another subject, I have just come into this company and if I wanted to see what had been installed how do I go about that. for example, if I wanted to know if there had been an upgrade from 4 to 7 for a particular Industry solution, where do I check this?.
    Jason

    I have been through the following steps:
    Entered this URL http://help.sap.com/bp/initial/index.htm
    Clicked on 'Cross-industry Packages'
    Clicked on 'CRM'
    Clicked on 'Englilsh'
    Then the following page is displayed:
    http://help.sap.com/bp_crm70/CRM_DE/HTML/index.htm displayed
    But now what?. How do I get the Best practice instructions for a CRM implemenation?.
    Jason

  • [SOLVED]xpra + winswitch - best practice due to /etc/X11/xorg.conf.d/*

    Running xpra causes some headaches.
    The application builds fine and installs just perfectly, the troubles comes from the default Xorg configuration is no longer stored in /etc/X11/xorg.conf, it's now stored and read from numerous files under /etc/X11/xorg.conf.d/ where just so happen to be my 5-nvidia.conf.
    Starting xpra via:
    xpra start :100
    Causes:
    X.Org X Server 1.14.3
    Release Date: 2013-09-12
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.11.0-1-ARCH x86_64
    Current Operating System: Linux archie 3.11.2-1-ARCH #1 SMP PREEMPT Fri Sep 27 07:35:36 CEST 2013 x86_64
    Kernel command line: root=/dev/sda1 rw initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux
    Build Date: 13 September 2013 01:28:59PM
    Current version of pixman: 0.30.2
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (++) Log file: "/home/torxed/.xpra/Xorg.:100.log", Time: Thu Oct 3 19:56:30 2013
    (++) Using config file: "/etc/xpra/xorg.conf"
    (==) Using config directory: "/etc/X11/xorg.conf.d"
    setversion 1.4 failed
    Initializing built-in extension Generic Event Extension
    Initializing built-in extension SHAPE
    Initializing built-in extension MIT-SHM
    Initializing built-in extension XInputExtension
    Initializing built-in extension XTEST
    Initializing built-in extension BIG-REQUESTS
    Initializing built-in extension SYNC
    Initializing built-in extension XKEYBOARD
    Initializing built-in extension XC-MISC
    Initializing built-in extension SECURITY
    Initializing built-in extension XINERAMA
    Initializing built-in extension XFIXES
    Initializing built-in extension RENDER
    Initializing built-in extension RANDR
    Initializing built-in extension COMPOSITE
    Initializing built-in extension DAMAGE
    Initializing built-in extension MIT-SCREEN-SAVER
    Initializing built-in extension DOUBLE-BUFFER
    Initializing built-in extension RECORD
    Initializing built-in extension DPMS
    Initializing built-in extension X-Resource
    Initializing built-in extension XVideo
    Initializing built-in extension XVideo-MotionCompensation
    Initializing built-in extension XFree86-VidModeExtension
    Initializing built-in extension XFree86-DGA
    Initializing built-in extension XFree86-DRI
    Initializing built-in extension DRI2
    Loading extension GLX
    (EE)
    Fatal server error:
    (EE) xf86OpenConsole: Cannot open /dev/tty0 (No such file or directory)
    (EE)
    (EE)
    Please consult the The X.Org Foundation support
    at http://wiki.x.org
    for help.
    (EE) Please also check the log file at "/home/torxed/.xpra/Xorg.:100.log" for additional information.
    (EE)
    (EE) Server terminated with error (1). Closing log file.
    2013-10-03 19:56:30,893
    2013-10-03 19:56:30,893 Xvfb command has terminated! xpra cannot continue
    2013-10-03 19:56:30,894
    2013-10-03 19:56:30,895 removing socket /home/torxed/.xpra/archie-100
    tl;dr: 5-nvidia.conf is trying to get loaded after xf86-video-dummy is loaded (which is the default for xpra).
    Now to the question: What's the best practice because there's no information about this issue, and i can't be the only one who's run in to this since the xorg.conf was removed. At the moment I move all my nvidia configs out of the way, start xpra and move them back in. This works for the better part as long as i execute xpra with my own scripts.
    But is there a better way (which doesn't perhaps include recreating xorg.conf since that appears to be something you should walk away from)?
    Last edited by Torxed (2013-10-04 10:29:35)

    Good thinking! (xpra is basically just screen but for x, or a X11 tunnel via SSH).
    After a really quick poking around and remembering that xpra really just uses xorg-server-xvfb and at the very bottom of /etc/xpra/xpra.conf there's a line that says:
    xvfb=xpra_Xdummy -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
    Appending -configdir appears to be working.
    Here are the full steps:
    [torxed@archie ~]$ sudo cp -r /etc/X11/xorg.conf.d /etc/xpra/
    [torxed@archie ~]$ sudo rm /etc/xpra/xorg.conf.d/*nvidia*
    [torxed@archie ~]$ sudo sed -i '$s/$/ -configdir \/etc\/xpra\/xpra.conf.d/' /etc/xpra/xpra.conf
    *nvidia* would have to match your graphic-driver-config that would cause xorg-server-xvbf to crash.
    I'll update the wiki and put a mention on the package about it because this either has to be standard or well known from the start because it really just breaks the package all together.
    Last edited by Torxed (2013-10-04 10:29:09)

  • Best Practice On Taking Count in Bean

    Hi folks,
      Here i'm using Jdev 11.1.1.7.0. where I have a case take count on inserted rows in bean.
    here we go..
    Bean code
    developer way 1:
    button_click(){
    int count = voins.getRowcount();
    developer way 2:
    button_click(){
    int count = iteratorbind.getEstimatedRowcount();
    developer way 1: fetching view object in bean for purpose of taking row count.
      ---developer 1 says that best practice on taking count is using view object 'getRowcount()'.
    Note: developer 1 comment that developer 2 way is worst practice. it's a time taken process
    developer way 2: using iterator getting row count
      ---developer 2 says that for taking count we can use 'estimatedRowcount'.
    Note: developer 2 comment that developer 1 way is worst practice taking view object on bean.
    i.e developer 1 try catch the model layer directly from the code. we can use iterator to do all the stuff.
    which is best practice please suggest me... is there any other practice taking row count in bean.
    thanks.

    Dev way 1)
    A look into the java doc reveals
    Note that this method retrieves all rows from the database then returns the number of rows in the Row Set collection.
    So if your table contains a lot of rows calling getRowCount takes a lot of time and memory.
    Dev way 2)
    Calling getEstimatedRowCount executes a select count(*) from (your query) to get the count. This is fast but the task count may differ if many changes are done on the table. I personally had never a problem with this, but I can't speak for you.
    Timo

  • Best practice for using remote control under limited rights?

    Hi. We are getting ready to take admin rights away from our users and make them standard users. We plan to utilize Zen for most of our in-scope applications so that we can allow users to install supported software. There is usually no problem in that case because Zen can elevate to System access during the install. However, we know that there are applications out there that a user may want to install that is not packaged in Zen. Also, in the event that a system setting needs to be changed, we will have to have a method for supporting this. In either case, the user will call our help desk. Unfortunately, the user will not have enough rights to do the install or system change even if the help desk associate remote control's the PC. What is the best practice to handle this situation in a Netware/Zenworks environment where users only have limited access?
    I was thinking of three possibilities:
    1.) The obivous one is to send a technician over to log in using local admin credentials to install the software or perform the change. (Drawback - not very efficient because a desktop tech would have to get over to the user's PC to perform the work)
    2.) Have the help desk engineer log out of the machine through remote control, log back in as local admin to install the software or perform the change. (Drawback - not very convienant and time consuming.)
    3.) Have the help desk engineer use the "run as" command or even create a Zen application object that could be executed to provide temporary rights for installing software or making system changes. Aaron Margosis of Microsoft writes about this quite a bit in his blog Aaron Margosis' "Non-Admin" WebLog : Table of Contents (Aaron Margosis' Non-Admin WebLog) (Drawback - some software or settings will not work properly using this technique)
    The last one that I didn't list was creating a new application object. I did not factor this one in because this isn't always applicable to system changes and we really don't want to be making app objects for every out of scope app that exists in the user community. We typically only make them for widely used and supported apps.
    Your feedback is appreciated.
    Thanks

    Originally Posted by spond
    Joshbilsky,
    how about
    4) use the remote execute option to remotely launch an app as admin?
    Shaun Pond
    That's probably an option that we will make available. I wasn't sure how some things will work under the SYSTEM context vs local admin.

  • Best practice for select access to users

    Not sure if this is the correct forum to post, if not then let me know where should I post.
    From my understanding this is the best forum to ask this questions.
    Are you aware of any "Best Practice Document" to grant select accesses to users on databases. These users are developers which select data out of database for the investigation and application bug fix.
    From time to time user want more and more access to different tables so that they can do investigation properly.
    Let me know if there exists a best practice document around this space.
    Asked in this forum as this is related to PL/SQL access.

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version.
    >
    Are you aware of any "Best Practice Document" to grant select accesses to users on databases. These users are developers which select data out of database for the investigation and application bug fix.
    From time to time user want more and more access to different tables so that they can do investigation properly.
    Let me know if there exists a best practice document around this space.
    >
    There are many best practices documents about various aspects of security for Oracle DBs but none are specific to developers doing invenstigation.
    Here is the main page for Oracles' OPAC white papers about security.
    http://www.oracletechnetwork-ap.com/topics/201207-Security/resources_whitepaper.cfm
    Take a look at the ones on 'Oracle Identity Management' and on 'Developers and Identity Services'.
    http://www.dbspecialists.com/files/presentations/implementing_oracle_11g_enterprise_user_security.pdf
    This paper by Database Specialists shows how to use Oracle Identity Management to limit access to users such as developers through the use of roles. It shows some examples of users using their own account but having limited privileges based on the role they are given.
    http://www.dbspecialists.com/files/presentations/implementing_oracle_11g_enterprise_user_security.pdf
    And this Oracle White Paper, 'Oracle Database Security Checklist', is a more basic security doc that discusses the entire range of security issues that should be considered for an Oracle Database.
    http://www.oracle.com/technetwork/database/security/twp-security-checklist-database-1-132870.pdf
    You don't mention what environment (PROD/QA/TEST/DEV) you are even talking about or whether the access is to deal with emergency issues or general reproduction and fixing of bugs.
    Many sites create special READONLY roles, eg. READ_ONLY_APP1, and then grant privileges to those roles for tables/objects that application uses. Then that role can be granted to users that need privileges for that application and can be revoked when they no longer need it.
    Some sites prefer creating special READONLY users that have those read only roles. If a user needs access the DBA changes the password and provides the account info to the user. When the user has completed their duties the DBA resets the password to something no one else knows.
    Those special users have auditing on them and the user using them is responsible for all activity recorded in the logs during the time the user has access to that account.
    In general you grant the minimum privileges needed and revoke them when they are no longer needed; generally through the use of roles.
    >
    Asked in this forum as this is related to PL/SQL access.
    >
    Please explain that. Your question was about 'access to different tables'. How does PL/SQL access fit into that?
    The important reason for the difference is that access is easily controlled thru the use of roles but in named PL/SQL blocks roles are disabled. So those special roles and accounts mentioned above are well-suited to allowing developers to query data but are not well-suited if the user needs to execute PL/SQL code belonging to another schema (the app schema).

  • Best practice for mouseless ADF applications

    I am developing an ADF application where the users do not want to use the mouse.
    So I would like to know if there are a best practice for this?
    I am already using the accessKey functionality and subforms defaultCommand
    But I have had problems setting focus to objects on a page like tables. I would like a button to return the focus to the table after it has made the command like delete.
    I have implemented a solution where I have found inspiration several threads and other webpages (see below).
    Is this solution okay?
    Are there any problems with it?
    I would also like to know if there are better pathways to go like
    out of the box solutions,
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/79-global-template-button-strategy-360139.pdf (are there an example implementation?), or
    http://one-size-doesnt-fit-all.blogspot.dk/2010/11/adf-ui-shell-supporting-global-hotkeys.html
    in advance thanks
    Inspiration webpages
    https://blogs.oracle.com/jdevotnharvest/entry/how_to_programmatically_set_focus
    http://technology.amis.nl/2008/01/04/adf-11g-rich-faces-focus-on-field-after-button-press-or-ppr-including-javascript-in-ppr-response-and-clientlisteners-client-side-programming-in-adf-faces-rich-client-components-part-2/
    how to Commit table by writting Java code in Managed Bean?
    Table does not refresh and getting error as UIComponent is Null
    A short description of the solution:
    (jdeveloper version 11.1.1.2.0)
    --- Example where I use onSetFocus in jsff page
    <af:commandButton text="#{hrsusuiBundle.FOCUS}" id="cb10"
    partialSubmit="true" accessKey="f"
    shortDesc="Alt+Shift+F"
    actionListener="#{managedBean_clientUtils.onSetFocus}">
    <af:clientAttribute name="focusField" value="t1"/>
    </af:commandButton>
    --- Examples where I use doTableActionAndSetFocus in jsff page
    --- There have to be a binding in the jsff page to delete, commit and rollback
    <af:commandButton text="#{hrsusuiBundle.DELETE}" id="cb4"
    accessKey="x"
    shortDesc="Alt+Shift+X"
    partialSubmit="true"
    actionListener="#{managedBean_clientUtils.doTableActionAndSetFocus}">
    <af:clientAttribute name="focusField" value="t1"/>
    <af:clientAttribute name="actionField" value="Delete"/>
    </af:commandButton>
    <af:commandButton text="#{hrsusuiBundle.COMMIT}" id="cb5"
    accessKey="s" shortDesc="Alt+Shift+S"
    partialSubmit="true"
    actionListener="#{managedBean_clientUtils.doTableActionAndSetFocus}">
    <af:clientAttribute name="focusField" value="t1"/>
    <af:clientAttribute name="actionField" value="Commit"/>
    </af:commandButton>
    <af:commandButton text="#{hrsusuiBundle.ROLLBACK}" id="cb6"
    accessKey="z" shortDesc="Alt+Shift+Z"
    partialSubmit="true"
    actionListener="#{managedBean_clientUtils.doTableActionAndSetFocus}"
    immediate="true">
    <af:resetActionListener/>
    <af:clientAttribute name="focusField" value="t1"/>
    <af:clientAttribute name="actionField" value="Rollback"/>
    </af:commandButton>
    --- This is the java class I use
    --- It is published in adfc-config.xml as a request scope managedbean
    public class ClientUtils {
    public ClientUtils() {
    public void doTableActionAndSetFocus(ActionEvent event) {
    RichCommandButton rcb = (RichCommandButton)event.getSource();
    String focusOn = (String)rcb.getAttributes().get("focusField");
    String actionToDo = (String)rcb.getAttributes().get("actionField");
    UIComponent component = null;
    String clientId = null;
    component = JSFUtils.findComponentInRoot(focusOn);
    clientId = component.getClientId(JSFUtils.getFacesContext());
    if ( "Delete".equals(actionToDo) || "Commit".equals(actionToDo) || "Rollback".equals(actionToDo) ){
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    OperationBinding operationBinding = bindings.getOperationBinding(actionToDo);
    Object result = operationBinding.execute();
    AdfFacesContext.getCurrentInstance().addPartialTarget(component);
    if (clientId != null) {           
    makeSetFocusJavaScript(clientId);
    public static String onSetFocus(ActionEvent event) {
    RichCommandButton rcb = (RichCommandButton)event.getSource();
    String focusOn = (String)rcb.getAttributes().get("focusField");
    String clientId = null;
    if (focusOn.contains(":")) {
    clientId = focusOn;
    } else {
    clientId = findComponentsClientIdInRoot(focusOn);
    if (clientId != null) {           
    makeSetFocusJavaScript(clientId);
    return null;
    private static void writeJavaScriptToClient(String script) {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks = null;
    erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
    erks.addScript(fctx, script);
    public static void makeSetFocusJavaScript(String clientId) {
    if (clientId != null) {
    StringBuilder script = new StringBuilder();
    //use client id to ensure component is found if located in
    //naming container
    script.append("var textInput = ");
    script.append("AdfPage.PAGE.findComponentByAbsoluteId");
    script.append ("('"+clientId+"');");
    script.append("if(textInput != null){");
    script.append("textInput.focus();");
    script.append("}");
    writeJavaScriptToClient(script.toString());
    public static String findComponentsClientIdInRoot(String id) {
    UIComponent component = null;
    String clientId = null;
    component = JSFUtils.findComponentInRoot(id);
    clientId = component.getClientId(JSFUtils.getFacesContext());
    return clientId;
    }

    Hi,
    I am developing an ADF application where the users do not want to use the mouse. So I would like to know if there are a best practice for this?
    Well HTML (and this is the user interface you see) follows a tab index navigation that you follow with "tab" and "shift+tab". Anything else is a short cut for which you use mnemonics (as you already do) or shortcuts (explained in http://one-size-doesnt-fit-all.blogspot.dk/2010/11/adf-ui-shell-supporting-global-hotkeys.html). There is a distinction to make between non-web environments (which I think you and your users have abackground in) and client desktop environments. Browsers block some keyboard functionality for their own purpose. So you may have to find a list of keys first that work across browsers. Unlike desktop clients, which allow you to "press a button" without the button to take focus, this cannot be done on the web. So you need to be clever here, avoiding buttons at all.
    The following paper is about JavaScript in ADF and explains the basics for what Chris Muir explains in : http://one-size-doesnt-fit-all.blogspot.dk/2010/11/adf-ui-shell-supporting-global-hotkeys.html
    http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf
    It has the outline for how to register short cut keys that perform a specific action (e.g. register ctrl+d to delete the current row you are on, or press F11 to execute a query (similar to Oracle Forms frmres files)). However, be aware that this includes some code you have to write (actually quite some code to be honest).
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/79-global-template-button-strategy-360139.pdf (are there an example implementation?), or
    http://one-size-doesnt-fit-all.blogspot.dk/2010/11/adf-ui-shell-supporting-global-hotkeys.html
    Actually these are implementations as they come with example code for you to use and customize, do they? So what is this question asking for more ? Also note that global buttons don't quite have anything in common with the question you asked. I assume you want to see it as an implementation of the Forms toolbar that operates on the form or table the focus is in. This however does not work for the web as there is nothing that keeps track of which component has a focus and to what iterator (data block) it belongs. This would involve even more coding (though possibly doable)
    Frank

  • Need advise for best practice when using Toplink with external transaction

    Hello;
    Our project is trying to switch from Toplink control transaction to using External transaction so we can make database operation and JMS operation within a single transaction.
    Some of our team try out the Toplink support for external transaction and come up with the following initial recommendation.
    Since we are not familar with using external transaction, I would like member of this forum and experts, to help comment on whether these recommendation are indeed valid or in line with the best practice. And for folks that have done this in their project, what did you do ?
    Any help will be most appreciated.
    Data Access Objects must be enhanced to support reading from a TOPLink unit of work when using an external transaction controller. Developers must consider what impact a global transaction will have on the methods in their data access objects (DAOs).
    The following findSomeObject method is representative of a “finder” in the current implementation of our DAOs. It is not especially designed to execute in the context of a global transaction, nor read from a unit of work.
    public findSomeObject(ILoginUser aUser, Expression queryExpression)
    ClientSession clientSession = getClientSession(aUser);
    SomeObject obj = null;
    try
    ReadObjectQuery readObjectQuery = new ReadObjectQuery(SomeObject.class);
    readObjectQuery.setSelectionCriteria(queryExpression);
    obj = (SomeObject)clientSession.executeQuery(readObjectQuery);
    catch (DatabaseException dbe)
    // throw an appropriate exception
    finally
    clientSession.release();
    if (obj == null)
    // throw an appropriate exception
    return obj;
    However, after making the following changes (in blue) the findSomeObject method will now read from a unit of work while executing in the context of a global transaction.
    public findSomeObject(ILoginUser aUser, Expression queryExpression)
    Session session = getClientSession(aUser);
    SomeObject obj = null;
    try
    ReadObjectQuery readObjectQuery = new ReadObjectQuery(SomeObject.class);
    readObjectQuery.setSelectionCriteria(queryExpression);
    if (TransactionController.getInstance().useExternalTransactionControl())
         session = session.getActiveUnitOfWork();
         readObjectQuery.conformResultsInUnitOfWork(); }
    obj = (SomeObject)session.executeQuery(readObjectQuery);
    catch (DatabaseException dbe)
    // throw an appropriate exception
    finally
    if (TransactionController.getInstance().notUseExternalTransactionControl())
         session.release();
    if (obj == null)
    // throw an appropriate exception
    return obj;
    When getting the TOPLink client session and reading from the unit of work in the context of a global transaction, new objects need to be cached.
    public getUnitOfWork(ILoginUser aUser)
    throws DataAccessException
         ClientSession clientSession = getClientSession(aUser);
         UnitOfWork uow = null;
         if (TransactionController.getInstance().useExternalTransactionControl())
              uow = clientSession.getActiveUnitOfWork();
              uow.setShouldNewObjectsBeCached(true);     }
         else
              uow = clientSession.acquireUnitOfWork();
         return uow;
    }

    As it generally is with this sort of question there is no exact answer.
    The only required update when working with an External Transaction is that getActiveUnitOfWork() is called instead of acquireUnitOfWork() other than that the semantics of the calls and when you use a UnitOfWork is still dependant on the requirements of your application. For instance I noticed that originally the findSomeObject method did not perform a transactional read (no UnitOfWork). Has the requirements for this method changed? If they have not then there is still no need to perform a transactional read, and the method would not need to change.
    As for the requirement that new object be cached this is only required if you are not conforming the transactional queries and adds a slight performance boost for find by primary key queries. In order to use this however, objects must be assigned primary keys by the application before they are registered in the UnitOfWork.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Best practice for encoding and decoding DUT/UUT registers? Class? Cluster? Strings? Bitbanging?

    I am architectecting a LabVIEW system to charactarize silicon devices.  I am trying to decide the best way to enqueue, encode, and decode device commands executed by my test system.
    For example, a ADC or DAC device might come in both I2C and SPI flavors (same part, different interface) and have a large register map which can be represented as register names or the actual binrary value of it's address. 
    I would like my data structure to
    *) be protocol agnostic
    *) have the flexibility to program using either the memonics or hard coded addresses
    *) be agnostic to the hardware which executes the command. (
    *) I would like to enqueue mulitple commands in a row.
    I am thinking a detailed class is my best bet, but are there are examples or best practices already established?

    I agree on the detailed class inherited from a general DUT-class. Especially if you want to mix interfaces you need to keep those as far away from your top vi as possible.
    As to the 4th point i'd implement command-vi's as enque and have a in-class command-queue (or possibly just an array of commands).
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Select One Choice attribute' LoV based on two bind variables, best practice

    Hello there,
    I am in the process of learning the ADF 11g, I have following requirement,
    A page must contain a list of school names which is needed to be fetched based on two parameters, the parameters are student information been inserted in the previous page.
    I have defined a read only view "SchoolNamesViewRO", it's query depends on two bind variables :stdDegree and stdCateg.
    added that RO View as a view accessor to the entity to which the name attribute belongs, and then add LoV for the name attribute using the ReadOnly view,
    added the name attribute as Select One Choice to page2,
    and now I need to pass the values of the bind variables of the ReadOnly view,
    the information needed to be passed as the bind variables is inserted in the previous page, I could have the data as bindings attribute values in the page2 definition
    I have implemented the next two appraoches but both resulted in an empty list :
    * added ExecuteWithParams Action to the bindings of the page and then defined an Invoke Action (set refresh condition) in the executable s, set the default values of the parameters to be the attributes values' input value,
    in the trace I code see that the binding fetches correct values as supposed , but the select list appears empty, does the this execution for the query considered to be connected to the list ?
    * added a method to the ReadOnly view Imp java class to set the bind variables, then I define it as a MethodAction in the bindings , and then create an Invoke action for it , also the select is empty,
    if the query been executed with the passed variables, then why the list is empty? is it reading data from another place than the page!
    and what is the best practice to implement that requirement?
    would the solution be : by setting the default value of the bind variables to be some kind of Expression!
    please notice that query execution had the bound variables ( I see in the trace) are set to the correct values.
    would you give some hints or redirect me to a useful link,
    Thanks in advance
    Regards,

    please give me any example using backing bean .for example
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1">
    <af:form id="f1">
    <af:selectOneChoice label="Label 1" id="soc1" binding="#{Af.l1}"
    autoSubmit="true">
    <af:selectItem label="A" value="1" id="si1"/>
    <af:selectItem label="B" value="2" id="si2"/>
    </af:selectOneChoice>
    <af:selectOneChoice label="Label 2" id="soc2" disabled="#{Af.l1=='2'}"
    partialTriggers="soc1">
    <af:selectItem label="C" value="3" id="si3"/>
    <af:selectItem label="D" value="4" id="si4"/>
    </af:selectOneChoice>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>
    package a;
    import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;
    public class A {
    private RichSelectOneChoice l1;
    public A() {
    public void setL1(RichSelectOneChoice l1) {
    this.l1 = l1;
    public RichSelectOneChoice getL1() {
    return l1;
    is there any mistake

Maybe you are looking for