Best way to synchronize in a Singleton

I have this classimport java.util.ArrayList;
import java.util.List;
public class SynchIssues
  private List values = new ArrayList();
  private static final SynchIssues singleton = new SynchIssues();
  public static SynchIssues getInstance()
    return singleton;
  public void addValue(String value)
    synchronized(singleton)
      values.add(value);
  public String getValue(int i)
    synchronized (singleton)
      return (String) values.get(i);
}And i synchronize on the singleton itself , but some collegue uses a different approach
import java.util.ArrayList;
import java.util.List;
public class SynchIssues2
  private List values = new ArrayList();
  private static final SynchIssues2 singleton = new SynchIssues2();
  public static SynchIssues2 getInstance()
    return singleton;
  public synchronized void addValue(String value)
      values.add(value);
  public synchronized String getValue(int i)
      return (String) values.get(i);
}He uses synchronize on the methods in stead of the SIngleton.
What approach is best ?
Are both approaches thread safe ?
Do teh different approaches risk deadlocking when different thread will be accessing the classes ?

What do you need to do exactly? What does "the most thread-safe" mean?
If I read correctly your code samples, the fact that the "shared object" is a singleton is not relevant. Your point seems to be more about a generic issue of "synchronizing access to a shared collection".
Without resorting to bytecode examination, it seems your 3 code samples look equivalent as far as individual add() and get() operations are concerned: each operation is atomic, and only one thread is actually reading/modifying the collection at a given time. In this regard each of these operations can be told "thread-safe".
However it gives absolutely no guarantee about several operations executed in sequence : two threads executing such a sequence would probably see their get() and add() interleaved. This may or may not cause a problem depending on your application (what you do about the data in the collection, and in particular how you react to reaching the end of the list).
If you want this kind of guarantee of per-sequence atomicity (a sequence of, e.g., get() is executed without any other thread modifying the collection in between), you have to make sure each client synchronizes on the collection (or on the singleton, if it's the only wrapper) around the whole block of the sequence:
SynchIssueX singleton = SynchIssueX.getInstance();
// make sure no other thread may read any value before I've added them all:
synchronized (singleton) {
  singleton.add(value1);
  singleton.add(value2);
  singleton.add(value3);
}

Similar Messages

  • Best Way To Synchronize Two Folders Via FTP?

    What's the best way to keep two folders in sync via FTP? Also, why is this site turning German? Will there still be a website in English?

    Allan wrote:
    solarwind wrote:What's the best way to keep two folders in sync via FTP?
    sitecopy in AUR may be helpful (http://aur.archlinux.org/packages.php?ID=11319).  You may also want to look at conduit and multisync-gui in AUR.
    solarwind wrote:Also, why is this site turning German? Will there still be a website in English?
    I hear archlinux.de will be in English as a replacement...
    Thanks for that!
    Also, I sure hope there will be an English site. There are many Germans who know English, but not many non-Germans know German. It was a stupid move to switch to German as an official language.

  • Best way to synchronize multiple FPGAs

    I have multiple PXI-7833R FPGAs and I need all of the AIs to be sampled at the same times (across all FPGAs). As I sample all of the individual AI channels, I buffer the data (write to DMA), scan it and check for a user defined trigger in a different loop. Once I discover this in one channel, I save the data from all FPGAs. In terms of synchronizing the sampling, I had begun, from one FPGA, to send a signal over the PXI trigger line to tell the others to sample, but I assume this does not guarantee synchronization. If I base all of the separate FPGA VIs off of the PXI clock, how do I synchronize the loops to sample at the same clock times?
    Thanks
    Solved!
    Go to Solution.

    Hi,
    Well, if it's not very timecritical you could pass messages through the host, thats right.
    Another way, which is quite hard to implement though, would be to use the other available pxi trigger lines to send messages directly from one FPGA to the other. You would need something like a handshaking, a kind of master who directs which slave is allowed to send, a kind of clock for synchronization and so on.
    I cannot give you detailed information, since I never did that by myself, but I know other projects where this works quite good.
    Maybe another forums user can give you some better advice.
    Thanks,
    Christian

  • Best way to synchronize DR standby database

    Hi,
    My setup consists of 3 database installations in three data centers on aix 6.1 and oracle 11g release 2 Enterprise editions.
    The first data center will host the primary database, while the second data center will act as a hot standby site, hosting the physical standby database in a data guard configuration. This second data center is just a few hundred meters from the primary site and is connected with dark fiber.
    The 3rd site is a DR site located about 300KM from the first two centers, and with a WAN link of speeds around 2Mbps. This third site should act as a disaster recovery site in case there's a natural calamity that destroys the first two sites.
    We purchased full license for the first two sites for oracle. However, for the 3rd site, we're only allowed to open the database for up to 10 days in a year. My question is how can we always bring this 3rd database into sync with the first two. Can we use full backups to recover the database periodically, like every month? Or is there another option of using archivelogs, considering that the database can only be open up to a maximum of 10 days in a year?
    Both the primary and the DR sites have Tivoli server installed complete with the tape libraries and we're suppose to take backups even on the DR site.
    Regards,
    dula

    I think your potential solutions depend in part on the meaning of 'open' and what kind of database set up you have at the third site. If the third site is a Standby Datbase and open means in use for any purpose other than recovery mode then you should be able to start it and apply the logs so the the database is ready should the need arise.
    If open means the database is started and active then all you can really do is install Oracle at the third site and leave it off. In this case what I would do is use the rman duplicate command to build the initial database, start it, test it, and shut it down. Then you transfer your primary database rman backup to the site every day along with copies of the archived redo logs. In the event of a primary/secondary site failure you just need to run an rman restore of the newest backup set then recovery using the copied archive redo logs and you are up and running.
    There will be the time delay equal to the time to run restore and recovery but you can set up the remote diaster site, test it, and be pretty sure it will work without using up your 10 day limit.
    An alternate license arrangement might be to run RAC at the two local data centers and have a Stand by database at the remote site.
    HTH -- Mark D Powell --

  • Best way to synchronize two Centros

    I have a Verizon Centro with many third party programs (ThoughManager, RepliGo, SplashShopper...), but do not use any data services or Microsoft Outlook, etc.  All apps are working just fine and I've had no HotSync problems.  I just bought an unlocked Centro GSM for traveling in Europe.  I want to install the same programs and files on the new GSM and keep both devices synchronized with the same programs, files and data.  I've read the manual, but am still unsure how to proceed.
    The Palm Desktop is already installed, obviously.  Will that version, 6.2.2, be the same for the GSM?
    Do I need to assign a different name to the new device?
    Do I need to HotSync the GSM every time I Hotsync the original device, or can I do this just ahead of traveling?
    Thank you!
    Post relates to: Centro (Verizon)

    Hi, and welcome to the Palm Community Forums.
    Normally with two of the same device is would be a simple matter to just sync them both to the same Hotsync ID. But in this case it might be problematic because your two phones use different network technologies and I don't know if there are, for exampla, system files on one which would FUBAR the other.
    Giving them each a separate name would mean 1) buying a second copy of your third-party applications because the activation codes are usually tied to a unique Hotsync ID and as such, won't activate on a phone with a different name, and; 2) either beaming your data (contacts, calendar, etc.) between the two devices; or 3) using a third-party solution called SyncUc to share databases between two differently named devices.
    Maybe I can ask someone else to look in here and offer their $.02.
    smkranz
    I am a volunteer, and not an HP employee.
    Palm OS ∙ webOS ∙ Android

  • Best way to handle time taking MIS queries!

    Dear all,
    Recently we have developed some MIS reports that execute large queries and process lot of data. These queries almost held the database and user's experience very slow speed.
    What is the best way to handle these heavy duty queries?
    Like having another server for MIS and then what is the best way to synchronize data on daily basis?
    OR
    Creating procedures that execute at night and populate MIS tables and reports using this formulated data?
    Any other better solution please?
    Thanks, Imran

    misterimran wrote:
    Dear all,
    Recently we have developed some MIS reports that execute large queries and process lot of data. These queries almost held the database and user's experience very slow speed.
    What is the best way to handle these heavy duty queries?
    Like having another server for MIS and then what is the best way to synchronize data on daily basis?Based on your requirement, Streams.
    Creating procedures that execute at night and populate MIS tables and reports using this formulated data?I would not recommend this for the maintenance part involved; and also, this is re-inventing the wheel.

  • What is the best way to separate functionality ?

    I have this project where I need to develop a component  for other flash developers to use. The scenario if you are the one who's going to use my "component" is like this:
    1) you create a new project
    2) you load the provided swf (or include the provided swc file) file and use the documented api (using interfaces if loaded as swf) to initiate it (for example just call the initiate function and that's it). What the component does itself is pretty much just adding a start up functionality to the website you are building, which includes: functions which make httpRequests and get data which the website will use, loading modules with fonts/graphic assets. It will also communicate the progress of these to the main application so the flex dev can display the progress to the user. At the end when the component has finished prepearing the assets you'll need for the website it notifies the main application.
    3) And there is where the flex dev start his work using the api provided with the component to access the data he needs.
    So what I want to do is package and keep my component source code compiled (to restrict access to the source code) and provide and easy way for the developers to use it. So I figured there 2 ways of doing that:
    1) compile a module/application swf
    2) complie a swc with a singleton
    I started doing it with module swf when I started wondering if that's the best way to do it. I would be happy if someone could give me any thoughts on this one, pros and cons maybe why should I do that and not the other, hopefully an adobe employee will take a look too. Thanks in advance!

    Actually, can I even compile swc files from flex using framework components like httpRequest and then load them as RSL ?
    *UPDATE:
    Seems like I can make my custom component include it in a library project, export it as swc and include that swc as RSL in my actual Flex project.
    But I'm still not sure which approach is better, using RSL for this case or just a module? Does it make any difference ?
    Also another question that rises in my mind is that if using RSL which class should I extend from, when this component will have no visual representation but should be able to do httpRequests and load modules/applications?
    Message was edited by: FM_Flame

  • Best way to implement application level persistant objects?

    I'm designing a J2EE application and want to create some objects that represent lookup tables in the database. I would like these to be static objects that get created either at application startup or the first time they are called and remain in application scope globally for all users/sessions. These are objects that contain lists used for drop-downs/listboxes. I don't necessarilly want to take up unecessary memory
    and take a performance hit for each session by creating them new for each session. The question is what is the recommended design for this scenario? Should these be implemented as static Stateless Session beans with an application scope? Are there any examples on the best way to do this in J2EE?
    Thanks.

    You can simply (and properly) implement the Singleton pattern. Then multiple threads can all query the cached reference table values in the Singleton. Now, I know, that Singletons and J2EE are supposedly no-no's, but sometimes the easiest and simplest solution really is the best one. Perform the database query at startup in a static initializer. Then ensure that you do not have mutator methods (e.g., removeXXX(), setXXX(), addXXX(), etc.) Only provide accessor/getter methods. If you want to be able to refresh the cache without restarting the server, you will have to think about race conditions. But if you are implementing a vanilla cache, I would go with a Singleton.
    - Saish
    "My karma ran over your dogma." - Anon

  • What is the best way to make music in Logic pro8?

    ok, Im using a Mac, 3 external keyboards,a profire 2626 (audio interface) and a MIDI sport (midi interface). I am wanting to track in the audio from the 3 keyboards as MIDI. I wanted to know what is the best way to do this? Is it required to record the audio and MIDI at the same time? When i do do this, (record MIDI and Audio simultaniously), i get this doubling effect after the loop comes back, because of the MIDI and the Audio tracks combined. Arent you supposed to create some kind of Aux track to avoid this so, you can monitor what you just made so this "doubling effect" isnt heard?...another question. I am experiencing latency and it doesnt make sense. I have a low buffer size (32), but i only experience it when i play the space bar or hit record, not if im just sitting there hitting keys..however, I found a trick to avoid this, but here is where it doesnt make sense. If i go to Settings>Synchronization>MIDI...then set my Transmit MIDI Clock Destination to (ALL)...i hear the Latency wehne i hit space bar or record..But if i deselect All...and choose MIDI Sport Port 1...or port 2....there is no latency when i hit space bar or record.. and this doesnt make sense to me because i have 3 keyboards in Ports 1-3..so why wont the destination work better on All?....ok,,that sums it up ..thanks

    There are many different ways to use Logic. You will develop your own technique as you gain experience with it. The doubling you are experiencing is because the midi track is being sent back into your instrument as you record.. Shut off local control on your keyboard. Or temporarily assign the midi track you are recording to an instrument that is NOT being sent back to the same instrument..
    If you are recording three midi keyboards at once, make sure each one is sending on a different midi channel, also make sure that midi instruments are NOt sending back to your keyboards.
    Getting rid of latency is another problem. I am not familiar with MIDI sport. What you want to do is listen to a LIVE input (coming directly from instrument) - then turn the level down on the corresponding track you are recording into Logic. If your audio interface won't let you do that you must turn the audio buffer down as low as your computer will allow without distortion.

  • Best way to access files at two different locations

    Hey Guys,
    I am in need of some help. We currently have about six macs in our prepress department all accsessing 1 mac mini with three external drives that store all our files. We also work out of those drives, not on our local machines.
    So far this has worked out well for us. However, in the next few weeks we will be opening a new shop about 20 miles away, that will need access to all these same exact files. We are not sure of what the best way to do this is.
    Currently the mac mini we are on does not have osx server just osx. Also we have about 4-5 TB of customer files, and any given file that we are working on or would need access to could be up to 2 GB's.
    We are open to all and any ideas. Obviously the cheaper the better, but please give me any and all ideas so that we can evaluate every option and decide what is best for our company.
    We know that our current state of using external drives on a mac mini in not a realistic solution for ever as eventually our drives will fill up and I think we are out of usb ports to add new ones on.
    Also this cannot be a one time type of fix as once we get this new location set up and established, we plan to replicate it and open up a couple more in the comming years. Also seeing as we already have 4-5 TB of data we need something that is future proof so that as we continue to expand and grow we end up needing a new solution in 5 years.
    Thank you for any and all help you can provided.
    -ey3ball

    @rccharles// Do you know of any software that would duplicate or mirror a sever?
    I do not have personal experience beyond dropbox.
    sync
    SyncTwoFolders simply synchronizes two folders. might be more for client.
    https://www.macupdate.com/app/mac/22644/synctwofolders/
    Unix rsync
      whether it copies mac metadata may depend on what version of X you have.  May depend transfer app you use AFS, NFS, Samba.
    dropbox
    Well, if you want with Dropbox, you could use Dropbox to do the syncing. I think this is the way to go because you would get offsite backup. Not sure i'd try to sync the two servers. Duplicate each server to Dropbox.  Provide read-only access to the other site.
    You could experiment around with two computers and a dropbox account.  See how it works for you.  It's free upto two gigs.
    versioning
    dropbox has versioning build in.  using sometype of version system while necessary was viewed as a PITA by most programmers.  The best system would be an automated on where you didn't have to do anything beyond what you were doing before.  Timemachine, etc.
    dropbox
    also would we just talk to our internet provider about a private fiber channel?
    I think Linc Davis has the idea.
    Router-to-router VPN.
    I was putting the concept out there.

  • Best option to synchroniz​e two applicatio​ns

    I've been developing two CVI applications (call them App_1 and App_2, for example), and I've been looking for the best option to synchronize them. I mean that App_1 must know if App_2 is running or not, and which operation is performing in every moment.
    At the beginning I thought to a network variable (created when App_2 starts and deleted when it stops), but this is not an option because if App_2 crashes the network variable is not deleted, but it exists with the last value. And so App_1 would think that App_2 is running...
    Any suggestion on a better way?
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded

    Since you are already on the way to Network Variable, you could benefit from timestamping the variable you are already using. Refer to NVQuality example project for an example of using timestamping of a NV. This could probably address most of your problems, provided the writer continously update status variable even if no change has occurred. Alternatively, you can add a supplementary variable to use as a whatchdog, i.e. the writer continuously writes some different value and the reader checks it has changed over time.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Repost-Best way of using connection pooling

    I am reposting this, seems best suitable in this category.
    I am using Eclipse 3.1 along with Tomcat 5.0, MySQL 4.1, J2EE1.4. I could set up the JNDI Dataresource connection pooling and tested with small test servlet. Now thinking of having common methods for getting connection / closing / commiting ....etc.
    I wrote following. [Please let me know whether it is correct way of doing it - as i am not very sure]
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    import org.apache.log4j.Logger;
    public final class connectionManager {
         private static Logger logger = Logger.getLogger(common.connectionManager.class);
         public connectionManager() {}
         public static Connection getConn () throws NamingException, SQLException
    //JNDI DataSource connection pooling
              Connection conn = null;
              try{
                   Context initContext = new InitialContext();
                   Context envContext  = (Context)initContext.lookup("java:/comp/env");
                   DataSource ds = (DataSource)envContext.lookup("jdbc/TQ3DB");
                   conn = ds.getConnection();
              }catch (NamingException ne) {
                  new GlobalExceptionHandler(logger, ne);
                   conn = null;
                   throw new NamingException();
              }catch (SQLException e){
                   new GlobalExceptionHandler(logger, e);
                   conn = null;
                   throw new SQLException();
              return conn;
           }//getConnection
         public static void commit(Connection conn) throws SQLException
              conn.commit();
         public static void rollback(Connection conn) throws SQLException
              conn.rollback();
           public static void setAutoCommit(Connection conn, boolean autoCommit)
                                        throws SQLException
                conn.setAutoCommit(autoCommit );
         public static void closeConnection(Connection conn) throws SQLException{
              if (conn != null) {
                   conn.close();
                   conn = null;
         }//closeConnection
         public static void closeResources(ResultSet oRS, PreparedStatement pstmt) throws SQLException
              if (oRS != null) {
                   oRS.close();
                   oRS = null;
              if (pstmt != null) {
                        pstmt.close();
                        pstmt = null;
         } // closeResources
    }//ConnectionManager
    I am having a login form which submits user name and password. I am checking this against the database. Following is the servlet to do that.
    package login;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import common.*;
    public class loginServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {          
              doPost(request, response);
         }//doGet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException,IOException{
              String userId = request.getParameter("userId");
              String password = request.getParameter("password");
              ** call a method to validate the password which will return the
              ** User Name for authorized users and null string for un-authorised.
              String uName = validateUser(userId, password);
              //if uName is null .. user is not authorized.
              if (uName == null){
                   //redirect to jsp page with error message
                  RequestDispatcher rd =
                       getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                  if (rd != null){
                       rd.forward(request,response);
              else{
                   // the user is valid - create a seesion for this user.
                   HttpSession userSession = request.getSession(true);
                   // put the user name session variable.
                   userSession.setAttribute("userName", uName);
                   //redirect to Main menu page
                   RequestDispatcher rd =
                        getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                   if (rd != null){
                        rd.forward(request,response);
         }// end of doPost
         private String validateUser(String userId, String password)
                   throws SQLException{
              String returnVal = null;
              connectionManager cm = new connectionManager();
              Connection conn = null;
              PreparedStatement pstmt = null;
              ResultSet oRS = null;
              try{
                   //get the connection
                   conn = cm.getConn ();
                   //get records from user table for this user id and password
                   String sQry = "SELECT  user_login FROM user "
                             + "where user_login = ? AND user_pwd = ? ";
                   pstmt = conn.prepareStatement(sQry);
                   pstmt.setString(1, userId);
                   pstmt.setString(2, password);
                   oRS = pstmt.executeQuery();
                   //check for record
                   if (oRS.next()) {
                        returnVal = oRS.getString("user_login");
                   }else {returnVal = null;}
                 }catch (Exception e){            
                      returnVal = null;
              }finally{
                   cm.closeResources(oRS, pstmt);
                   cm.closeConnection(conn);
              return returnVal;
    }// end of servlet class
    But i am unable to compile it and i am also getting lots of warnings.
    I am getting error at line
    1)String uName = validateUser(userId, password);
    Unhandled exception type SQLException loginServlet.java TQ3/WEB-INF/src/login line
    Following warnings:
    2)For loginServlet Declaration
    The serializable class DBTest does not declare a static final serialVersionUID field of type long loginServlet.java
    3)The static method getConn() from the type connectionManager should be accessed in a static way
    4)The static method closeResources(ResultSet, PreparedStatement) from the type connectionManager should be accessed in a static way
    5)The static method closeConnection(Connection) from the type connectionManager should be accessed in a static way
    Definitely I am doing it wrong but exactly where? I am having very strong doubt the way i am using connections is not the correct way. Pls help me.
    regards
    Manisha

    I am in a search of best way to use connection pooling. Initially was using simple JDBC call, then modified to JNDI, afterwards tried to have common class. Later came accross the idea of Singleton/Static. I wanted to have a common class which will handle all connection related issues and at the same time give good performance.
    With due respect to all Java Gurus: i got all from web articles/tutorials/java forum etc. There is a long discussion regarding Singlet vs static in this forum. But finally got confused and could not figure out in my case which method shall i make use of, so tried both.
    What I want is somebody pointing out flwas inside my 2 code snippets and guide me about which method shall i adopt in future.
    Static way:
    package common;
    import java.sql.Connection;
    import javax.sql.DataSource;
    import java.sql.SQLException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public final class ConnectionManager_Static {
         private static InitialContext ctx = null;
         private static DataSource ds = null;
         public ConnectionManager_Static(){     }
         //as the staic method is updating static var i am synchonizing it
         private static synchronized void getDatasource () throws NamingException, SQLException
              if (ds == null){
                   ctx = new InitialContext();
                   ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
         //making getConnection() also static as it is not instance specific     
         public static Connection getConnection () throws NamingException, SQLException, Exception
              Connection conn = null;
              try{     
                   if (ds == null) {getDatasource ();}
                   if (ds != null) {
                        conn = ds.getConnection();                 
              }catch (Exception e){
                   throw new Exception("From ConnectionManager_Static",e);
              return conn;
           }//getConnection
    }Singleton:
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    public final class ConnectionManager_Singleton {
             private static ConnectionManager_Singleton INSTANCE = null;
              private DataSource datasource = null;
              // Private constructor for singleton pattern
             private ConnectionManager_Singleton() throws NamingException{
                   Context ctx = new InitialContext();
                   datasource = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
             //synchronized creator for  multi-threading issues
             //another if check to avoid multiple instantiation
             private synchronized static void createInstance() throws NamingException{
                 if (INSTANCE == null) {
                     INSTANCE = new ConnectionManager_Singleton();
             public static ConnectionManager_Singleton getInstance() throws NamingException {
                 if (INSTANCE == null) createInstance();
                 return INSTANCE;
              public Connection getConnection() throws Exception
                   Connection con = null;
                   try{
                        con = datasource.getConnection();
                   }catch(Exception e){
                        throw new Exception("From connection manager singleton ", e);
                   return con;
    }Sorry, It's becoming long.
    Thanaks in advance,
    Manisha

  • Best way to implement conclusion date for service ticket

    Hello Folks,
    I have to fix, part of a crm implementation in a customer, and I was thinking what´s the best way to reimplement/reconfigure the conclusion date (or to do by) in a service order ticket.
    I was checking the crm 5.0 best practices, and I found something related on sla contracts on th efollowing documents:
    C13_BB_ConfigGuide_EN_US
    C26_BB_ConfigGuide_EN_US
    C28_BB_ConfigGuide_EN_US
    But the material is poor. Do somebody have a good idea how to implement this? I´m also using webclient and crm 5.0.
    Tips, documents, and ideas are welcome.
    best regards,
    Luiz David

    Ronald,
    There are numerous ways to do this. I would recommend using the SessionFactory. The SessionFactory makes use of the SessionManager, which holds onto the singleton Server session. You can then acquire client sessions using the oracle.toplink.sessions.Session interface from the SessionFactory. There is no need to hold the SessionFactory in a singleton yourself and you do not need to reference the ClientSession directly either.
    We have introduced this latest approach to simplify coding. It will work in both the web architecture with JSP/Servlets accessing the sessions as well as within an EJB tier (Session/Message Driven beans).
    Doug

  • Best way to implement service in 3-tier webarchitecture

    Hi,
    What would be the best way to implement a service in the following 3-tier TopLink architecture: no ejb and a webclient (jsp/servlets)?
    Currently I have a server session type and a service pojo using a singleton SessionFactory. The service pojo is used by the jsp/servlets.
    Should the service pojo be a singleton? Should a SessionManager be used?
    In the examples on OTN a clientsession is directly acquired in the jsp/servlets.
    Thanks,
    Ronald

    Ronald,
    There are numerous ways to do this. I would recommend using the SessionFactory. The SessionFactory makes use of the SessionManager, which holds onto the singleton Server session. You can then acquire client sessions using the oracle.toplink.sessions.Session interface from the SessionFactory. There is no need to hold the SessionFactory in a singleton yourself and you do not need to reference the ClientSession directly either.
    We have introduced this latest approach to simplify coding. It will work in both the web architecture with JSP/Servlets accessing the sessions as well as within an EJB tier (Session/Message Driven beans).
    Doug

  • Best way in LabVIEW to check if TS execution is complete

    I was wondering if anyone had some thoughts on this.
    What is the best way in LabVIEW to check if a TestStand Execution is complete.  I am currently starting a New Execution in a previous state using the 'Engine->New Execution' method.  Then in my state shown in the attachment, I simply wait in a loop until the execution is Stopped using Execution->Get States.
    I have also noticed the function called 'Execution->WaitForEndEx' but the help documentation indicates:
    " This method is not meant to be used by a user interface or sequence editor, as it does not process UIMessages. Instead, use this method from a step to synchronize with another execution."
    Is WaitForEndEx a better method or should I stay with the current implementation?
    Thanks,
    Paul Holzrichter
    Attachments:
    Execution Complete.JPG ‏63 KB

    Hi Paul.
    You could also use the Application Manager's "EndExecution" event.
    This would prevent you from staying in a loop and waiting for the execution to complete.
    Regards, Guenter

Maybe you are looking for

  • I need to wipe my MacBook Air's hard drive - how can I do it?

    Looking to sell and upgrade and want to be secure!

  • SOAP Receiver Channel error

    Dear PI and SOAP experts: I have been having trouble getting a SOAP Receiver channel working for a webservice. I get the following error in the SOAP receiver channel: SOAP: response message contains an error XIAdapter/PARSING/ADAPTER.SOAP_EXCEPTION -

  • Retention Scenario

    Hi Here we hv a scenario as Retention. Client will order a service to vendor for Rs. 10000/- in this the retention amount is 10% that is Rs 1000/- is the retention money. In the PO we need to mention that. Client will pay to vendor upto Rs 9000/- the

  • Reducing from full screen short cut

    Using Firefox as browser, went to full screen, can't now get back so can't se dock, etc.

  • Saturation: an iPhone app

    Saturation is a simple, free app that allows users to play around with color themes  supplied by Adobe Kuler using custom color visualizers. There are two visualizers in the app right now, and we have plans  to add more in future updates. You can dow