Session Facade and Access to a Non SQL Based Persistent Data Store

Hi,
We are currently using jDeveloper 10.1.3.5 and Oracle Application Server 10.1.3.5. We develop all our applications as Java portlets using Oracle PDK and they are exposed through Oracle Portal.
In our environment, the persistent data is stored on a combination of an Oracle database and a non SQL based persistent data store.
The way we access the non SQL persistent data store is by posting a URL and receiving an XML document back in response. This mechanism is used both for enquiry and update of the persistent store.
We have to create a new XML schema for each entity that we need to access and there are software changes on both our environment (Java) and the non SQL based persistent data store.
In an attempt to shorten development times we are looking to start using ADF faces and EJB3.
We have downloaded the SRDemo tutorial and made it work but there are some challenges.
1. The SRDemo seem to have a very minimal implementation of a business layer. From what I can see, it is essentially some straightforward wiring between database attributes and their viewable representation. Is there a demo/tutorial containing a bit more meat in the business layer that you are aware of?
2. Given our non SQL based persistent data store, how would you go about implementing EJB3 for such scenario. Is it recommended at all? How would you go about integrating the rest of the application (business layer and representation layer) to data arriving from such source?
3. SRDemo is not intended to be exposed as a portlet. Is there a tutorial that we can use incorporating JSR168, ADF Faces and EJB3 in the same application? I also understand that there is a JSF-JSR168 bridge available. Can you provide some pointers here? Where can we find it? Would we be able to use it in jDeveloper 10.1.3.5?
Regards

Matt,
The only way to associate an "x-axis" with a signal in the Write Data VI would be to feed it waveforms, which are constrained to use time as the x-axis unit. There is really no way around this, so in my opinion, the best solution for you would be to use the "rows are channels" conversion and write the frequency and amplitude values to the file independently. Then when you read the file in DIAdem, take the two channels and build a graph out of them there.
Regards,
E. Sulzer
Applications Engineer
National Instruments
E. Sulzer
Applications Engineer
National Instruments

Similar Messages

  • How to combine Session Facade and Transfer object?

    Hello All!
    I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
    I have problems with business logic architecture.
    Here is the brief description of backend application architecture design:
    1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
    2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
    3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
    4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
    Questions:
    1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
    * Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
    * Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
    * So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
    3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
    * So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
    2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
    Thank you!
    Astghik

    Astghik wrote:
    Hello All!
    I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
    I have problems with business logic architecture.
    Here is the brief description of backend application architecture design:
    1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
    I would simply recommend establishing a service tier. Your services should be stateless. You can go the extra mile and have a session facade, but in the majority of cases, coding to an interface for your service accomplishes the same goals.
    2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
    The idea of the transfer object is very similar to the Command pattern. I think if you investigate that pattern, it will be more obvious. The transfer object reduces network latency by consolidating all the parameters into an object, ideally, this also consolidates multiple method calls. If you combine a transfer object (or command object) with a service tier, you get the best of both worlds. The service can delegate calls to helper objects (or other services or components) using the data in the transfer / command object.
    3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
    The is your domain. It will vary from application to application. The principles above are more general (e.g., patterns and architectural tiers) and should apply to most domains. However, your actual use case may require something different.
    4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
    Consider using something like iBatis or Spring's JDBC templating to make your life easier with JDBC.
    Questions:
    1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
    * Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
    * Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
    * So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
    3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
    * So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
    Versioning is a separate issue. Generally, the more coarsely grained your transfer / command object is, the more changes are likely to impact dependent objects.
    Your command or transfer object does not have to be a vanilla JavaBean, where you are basically creating a bean that has data from other objects. You can simply use your command / transfer object to encapsulate already existing domain objects. I see no need to map to a JavaBean with what you have described.
    Generally, a method signature should be understandable. This means that many times it is better to pass the method, say, two coarsely grained objects than a signature with a dozen primitives. There are no hard and fast rules here. If you find a method signature getting large, consider a transfer / command object. If you want one service to delegate calls to a number of other services, you can also create a transfer / command object to furnish the controlling service with the data it needs to invoke the dependent services.
    2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
    This is a large, open-ended question. If you are going to display it to a user on a screen, I do not see how you avoid a network transfer with the data. The general answer is to not pass the data itself but rather a token (such as a primary key, or a primary key and a start and stop range such as you see on a Google search result). You do want to limit the data over the network, but this comes at a cost. Usually, the database will receive additional load. Once that becomes unacceptable, you might start putting things into session. Then you worry about memory concerns, etc. There is no silver bullet to the problem. It depends on what issues you are trying to address and what trade-offs are acceptable in your environment.
    Thank you!
    AstghikBest of luck.
    - Saish

  • Difference between session facade and business delegate patterns

    Hi,
    How the session facade and business delegate patterns differ from each other, as both of them have similar and almost same forces to be addressed.
    Please address.
    Satya.

    BTW, in J2EE Core patterns :
    When the Business Delegate is udes with a Session Facade, typically there is a one-to-one relationship between the two. This one-to-one relationship exists because logic that might have been encapsulated in a Business Delegate relating to its interaction with multiple business services (creating a one-to-many relationship) will often be factored back into a Session Facade.[I/]

  • Difference between Session Facade and Business Delegate??

    Hello,
    I am currently working on design patterns and I am confused what the difference is between the Session Facade and Business Delegate pattern. They look identical.
    What's the difference?
    Balteo.

    We implement Business Delegators (BD) as follows:
    1. The client always talks to the BD.
    2. The BD then talks to either our Session Facade, Session EJB, or Java Class, etc, etc directly.
    This allows the client end code to never change whilst allowing our BD to swap between different providers of the service we require.
    It's the good 'ole "layer of indirection" thingy.

  • Difference between Session Facade and Business Delegate design patterns

    Can someone tell me the differences between Session Facade and Business Delegate design patterns

    1. Session Facade decouples client code from Entity beans introducing session bean as a middle layer while Business Delegate decouples client code from EJB layer ( Session beans).
    2. SF reduces network overhead while BD reduces maintenance overhead.
    3. In SF any change in Session bean would make client code change.
    While in DB client is totally separate from Session bean because BD layer insulate client from Session beans(EJB layer).
    3. In only SF scenario, Client coder has to know about EJB programming but BD pattern no EJB specialization needed.
    4.SF emphasizes on separation of Verb, Noun scenario while BD emphasizes on separation of client(presentable) and EJB layer.
    Anybody pls suggest more differences ?

  • Session Facade and Business Delegate Pattern

    Hi!
    The only way to use the Session Facade Pattern, is if I use EJB for Persistence.
    Is valid to do this?:
    I use Ejb for simple update, insert querys. From my business delegate I call the Session Facade Layer, and from this I invoque Entyties for persistence.
    But if I have complex querys, is correct to make PL SQL Procedures and do the following:
    From my business delegate I call to the Dao layer, and from this via JDBC I call the Procedure.
    Please explain me the best form to do this, having complex querys for reporting and simple querys for inserts/update.
    Is valid to combine the use of CMP (for simple persistence cases), BMP (for complex persistence cases), and JDBC for complex select querys with multiple result rows.
    Thanks!!

    The session facade is borrowed from the facade pattern, so you could have a facade to almost anything.
    A session facade is usually against other beans...for example if you
    (Not deployed as CMR)
    1. Address bean
    2. Phone Bean
    3. Customer bean
    as entity beans then you can build a session facade such as
    CustomerFacadeBean which will CreateReadUpdateDelete(CRUD) address and phone as well when a customer is CRUD ed.
    In your case you said you have very complex sql's so one way would be
    Business Delegate -> Session Facade -> (Bean Managed) Entity Bean -> DataAccessObject.
    If you think this is a overkill then, write a custom pattern such as DataDelegate
    DataDelegate -> (Bean Managed) Entity Bean -> DataAccessObject.
    In the above scenario you should be quite sure that the system will not evolve into a case mentioned above such as when customer is deleted a phone and address object are also thrown away.
    You said this scenario
    Business Delegate -> DAO..
    I don't think this is a good idea because, a business delegate is a proxy against business objects....and usualy in J2EE business objects are session beans. Entity and DAO objects are data objects not business ones.
    Besides if you do the above scenario you will end up wiring all the transactions, etc etc in your DAO which is not a good idea.
    Although you could use BusinesDelegates against entity beans it will lead to a misnomer.

  • Business Delegate and Session Facade usage.

    Hi guys.
    I am new to JavaEE and I recently learnt the Business Delegate and Session Facade design patterns. The tutorials from Oracle did gave me a basic idea of what they are and why they are used, but the example didn't really answer all my questions. So I decided to use a real life scenario here and put my question in to it. Any help is appreciated.
    Assume I want to create a search employee page for my company, the employees are categorized by his or her department and the province he or she is in. I have in the database a look up table for department and province. (as shown in the image below)
    http://oi46.tinypic.com/idvpsl.jpg
    So I create three JPA entities, one for each table. Now I am stuck with what is the proper way to design the session facade design pattern. I know that I will need the to access all three entities in my page. (to get the drop down list for Provinces and Departments, and to retrieve list of Employees based on the selection) So should I create a Stateless Session Bean as session facade to access all three JPA Entities or should I create three separate Stateless Session Bean to manage one Entity each?
    I came up three component diagram in the below picture.
    The first one has one Stateless Session Bean as session facade and manages all three Entities.
    The second one has a session facade to manage the relationship between business objects such as ProvinceManagerEJB and DepartmentManagerEJB which will manage the corresponding Entities.
    The last one has three Stateless Session Beans that will manage one Entity each, all three Stateless Session Beans can be looked up via the Business Delegate pattern.
    http://oi46.tinypic.com/10pqets.jpg
    Please let me know if any one of them is the proper way to use business delegate and session facade. or none of them is correct. (which I assume might happen)
    Again, thank you so much for your help.
    Cheers
    Edited by: 992005 on 05-Mar-2013 18:15
    Edited by: 992005 on 05-Mar-2013 18:17

    Well I can't access any of your diagrams from here so can't comment on them. For dividing the functionality into separate classes, think about
    1.) Quantity - Are there many enough service calls to require splitting up or will one application service class be enough? The size of the system is important here.
    2.) Are you duplicating logic in the services? e.g save person, delete person in one service and save department, delete department in another e.t.c is better factored into one service with save entity, delete entity calls because the JPA entity manager doesn't know about the type anyway and it's easier to apply common logic (e.g logging auditing) around the calls.
    3.) Will each service makes sense on it's own or do you always need the other functionality to completely describe the service? Here it is important not think about entities but about the business use cases. Process1Service is better than Entity1Service, Entity2Service ... EntitynService.Think granule of reuse = granule of release. Only split out individually reusable services. A good way to understand granules of reuse in your system is to think about (or start by writing) test cases for the functionality. Testable code is reusable code.
    4.) Will the services change together? At class level you would look at common closure principle (classes that change together should be packaged together). You can apply the closure to the methods as well. Make it easy for future developers to recognize dependent functionality by packaging it together.
    These are just general because in enterprise development requirements are king. You can chose to follow or discard any of these rules depending on your requirements as long you understand the impact of each decision.

  • Value-list handler, value-list iterator and session-facade strategy

    Hello all,
    Further to an earlier post, I rewrote my post trying to me more accurate in my question.
    Here is my problem:
    I am trying to implement the value-list handler design pattern using the session facade strategy. In the pattern as it is described here
    (http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html) the client accesses the value-list handler AND the iterator directly.
    As I chose the session-facade strategy having my value-list handler as a stateful session ejb, I don't know how the client is going to access the iterator. I see only one option: Having the client access the iterator through the ejb value-list handler. This requires adding new methods to the ejb.
    Is this the correct way of doing it? Is there another way of doing this?
    Thanks in advance,
    Julien Martin.

    u can use project list handler as ur session facade.
    regarding ur second question ..session facade and value list handler session bean which is also a session facade( but there is difference between first and second) so u can use session facade and value listhandler

  • Bussines Delegate -- Session Facade

    Hi,
    My design is:
    client --> bussines delegate --> session facade ---> application service --> dao
    ........................................................................................................|
    ........................................................................................................|
    ......................................................................................................pojo
    I have 2 session facade: PurchaseManagement and InventoryManagement.
    I have a use case that need access to services provided by both session facade.
    Which is the best solution?
    1- Define a bussines delegate for each session facade and the client use both bussines delegate
    2- Define a unique bussiness delegate that access to both session facade
    3- ????
    Thanks.

    I have 2 session facade: PurchaseManagement and
    and InventoryManagement.
    I have a use case that need access to services
    ces provided by both session facade.
    Which is the best solution?
    1- Define a bussines delegate for each session
    ion facade and the client use both bussines delegate
    2- Define a unique bussiness delegate that access
    ess to both session facade
    3- ????If you are using a client-side Business Delegate, you do not need a one-to-one mapping to each Session Facade. The single Business Delegate should be composed of business methods from both Session facades. This will help keep the application modular. If you ever decide to change the design of the business tier, nothing will have to be changed in the presentation tier.
    Best,
    Sam
    http://www.softwareleadership.org/docs/overview_UW_RPM.html

  • What is session facade

    what is session facade and what is its use in session beans

    SessionFacade shows how to partition business logic in the system to help minimize dependencies between client and server, while forcing use cases to execute in one network call and in one transaction. It avoids inefficient remote client access of Entity Beans by wrapping them with a Session Bean.
    The Session Fa�ade design pattern is useful in situations where client objects need to interact with a set of EJBs to perform tasks in a workflow. Take the case of an on-line trading system where customers submit orders to buy and sell stocks, the orders are verified and executed, and results are returned. Here the client need to make numerous remote calls to get the work done.
    A session fa�ade solves such problems by presenting client objects with a unified interface to the underlying EJBs. Client objects interact only with the fa�ade, which resides on the server and invokes the appropriate EJB methods. As a result, dependencies and communication between clients and EJBs is reduced.

  • Business Delegate / Session Facade interaction questions

    I understand the concept and the benefits of a business delegate "front-ending" a session facade. I am hoping that someone can answer the following questions:
    Is it acceptable if a business delegate were to front-end more than one session facade in order to create a more unified service. For example is it ok to create one business delegate that provides Account Inquiry and Maintenance functionality and behind the scenes it talks to an AccounInquiry Session Facade and AccountMaintenance Session Facade?
    We are looking at a designing a Account Inquiry business delegate. It will return an AccountProfile business object. A behaviour of the AccountProfile object will be update capability (i.e. update account status, modify balance, etc.). Considering that the business object is a "business tier" component, is it ok fif it were to talk directly to an Account Update Session Facade or instead should it use a business delegate which in turn will call the session facade?

    I understand the concept and the benefits of a
    business delegate "front-ending" a session facade. I
    am hoping that someone can answer the following
    questions:
    Is it acceptable if a business delegate were to
    front-end more than one session facade in order to
    create a more unified service. For example is it ok to
    create one business delegate that provides Account
    Inquiry and Maintenance functionality and behind the
    scenes it talks to an AccounInquiry Session Facade and
    AccountMaintenance Session Facade? This is a feasible solution. As long as you have 1:2 ratio or a ratio which is very less, it is fine. But one of the intents for having this pattern is also to make the client's life easier. If the client who's using your delegate is someone else, sitting else where, he/she would be wondering about the reason for a single class like AccountInquiryMaintenanceDelegate providing two different functionalities. So, this has to be kept in mind before coming up with a single class.
    We are looking at a designing a Account Inquiry
    business delegate. It will return an AccountProfile
    business object. A behaviour of the AccountProfile
    object will be update capability (i.e. update account
    status, modify balance, etc.). Considering that the
    business object is a "business tier" component, is it
    ok fif "it"what does "it" mean here?? Did you mean the 'AccountProfile' bussiness object?? or the AccountInquiry business delegate??
    were to talk directly to an Account Update
    Session Facade or instead should it use a business
    delegate which in turn will call the session facade?
    HTH,
    Kalyan

  • Business Delegate, Session Facade or both?

    Hi,
    I'm having some problems with figuring out the point of using both Business Delegate (BD) and Session Facade (SF). As far as I can see, you often have a 1-1 mapping between the BD and SF, so why not use the SF directly?
    Here's my scenario. I have a web application that uses WebWork for presentation and pageflow, a session facade implemented using an ejb, which aggregates calls to the businness objects into "business rule"-methods and business objects implemented using plain java objects. Is there really any need to have a business delegate here? I might as well use the session facade directly from the webwork actions? Or..?
    Any suggestions? Am I far off? ;-)

    As far as I can see, you often have a 1-1 mapping between the BD and SF, so why not use the SFYou can have one Business Delegate encapsulate all of the business methods that are exposed by one or more Session Facades. The benefit here is that you protect the web component from any details of the business tier. e.g. your business tier has five session facades and the web tier has a single Business Delegate. The BD can be extended to call web services as well.
    Here's my scenario. I have a web application that uses
    WebWork for presentation and pageflow, a session
    facade implemented using an ejb, which aggregates
    calls to the businness objects into "business
    rule"-methods and business objects implemented using
    plain java objects. Say you eliminate the EJB implementation. What effect will this have on the web tier objects? The Business Delegate will enable you to easily replace the business implementation with little impact on the web components.

  • Filtering results based on dynamic date in coldfusion and access database

    Hello Guys, i am using a cfquery and am trying to return results based on date. the idea is to return entries that are less than or equal to date but am not getting any results but when i change to greater than or equal to i get the all results in databse which is wrong.
    Below is my code. is there something am doing wrong? Please help.
    <cffunction name="getBal" access="remote">
    <cfargument name="ID_biodata" type="string" required="true">
            <cfargument name="quater" type="string" required="true"/>
            <cfargument name="datePaid" type="date" required="true"/>
            <cfquery name="qBal" datasource="bond100">
    SELECT ID_biodata, quater, datePaid, amountPaid, manFees
    FROM collections
    WHERE datePaid <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#parseDateTime(arguments.datePaid)#">
                AND ID_biodata = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.ID_biodata#">
                AND quater = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.quater#">
                ORDER BY datePaid
    </cfquery>
            <cfquery dbtype="query" name="results">
            SELECT SUM(CAST(amountPaid as INTEGER) + CAST(manFees as INTEGER)) AS totalPaid
                FROM qBal           
            </cfquery> 
            <cfreturn results />
        </cffunction>

    Turn on debugging so that you can see what ColdFusion is sending to your database server.
    The debug info will show the SQL statement with query parameter values below it.
    Cheers
    Eddie

  • Client based settings and non-client based settings

    Can I knwo what is the client based settings and what are the non-client based settings.

    Hi,
    Slight error in you question:
    There are 2 settings:
    1. Client specific: These are customising settings which impact only in the client you are making the changes in.  Let us say that in an instance you have 2 clients, 800 and 900.  When you change a client specific setting in 900, it is not reflected in client 800.  This is beacuse the table where this setting is stored contains the client as one of the fields.
    2.  Cross Client settings:  Here, a change in one client is also replected in all the clients in that installation.  Needless to say, the tables for these settings will not have client as one of the fields.
    Cheers

  • Session Facade design and TopLink objects

    Hi, we are just about to start using Toplink as our ORM tool. Ideally we want to wrap all business logic behind stateless session bean facades. So instead of BMP entity beans we are thinking of encapsulating the relevant Toplink objects in each facade and querying, updating that object when the session facade bean is instantiated.
    We are using Weblogic 70. Example code:
    e.g. MySessionBean implements sessionbean...
         MyTopLinkObject myObject = null;
         public void populateObject(String myID) throws java.rmi.RemoteException {
              try {
                   MyTopLinkObject myObject = new MyTopLinkObject(myID);
              catch (Exception e) {
         public void setMyTopLinkObjectsName(String name) {
         //persist this change via the toplink object...
         myObject.setName(name);
    Then in MyTopLinkObject:
    public class MyTopLinkObject {
         private String myID;
         private String myName;
    public MyTopLinkObject(String myID) {
              build(myID);
    public void build(String myID) {
              //read TOPLINK cache and populate this MyTopLinkObject name etc
    public void setName(String myName) {
         //persist this change...
         this.myName = myName;
    // more gets sets
    I will then want to update MyTopLinkObject data in for example in calling. MySessionBean.setMyTopLinkObjectsName("my name") from the remote interface on the client.
    So what I want to know is how do I can I do this efficiently. I'm too too versant with TopLink caches etc. For example to read the cache do I have to pass thru a TopLink client/server Session to each Session Facade bean so the cache is available for that read, update etc?
    Any other tips is using this design would be appreciated!
    Thanks in advance,
    J

    Don, thanks for ur advice yet again.
    I think now I am getting a better grasp of how TopLink should be used. However there is very little doco out there in terms of using TOPLInk in as EJB session facade scenario.
    After your advice my thoughts are to provide something like the TOPLInkFactory object as you say which will encapsulate the ServerSession TOPLink API and provide more fine grain access to the TOPLInk API. e.g. instead of having to create a ClientSession in each client call b4 getting a UnitOfWOrk, this factory class would provide a method to do this directly:
    public final class TOPLinkFactory {
         private static ServerSession serverSession = null;
         private static final String TOPLINK_CONFIG_FILE = "C:\\test.xml";
         private static final String TOPLINK_SESSION = "toplink";
         public TOPLinkFactory() throws Exception {
              super();
         private static ServerSession createServerSession(ClassLoader cl) throws Exception {
              try {
              Project builderProject = XMLProjectReader.read(TOPLINK_CONFIG_FILE, cl);
         serverSession = (ServerSession)builderProject.createServerSession();
              serverSession.login();
                   return serverSession;
              catch (Exception e) {
              return null;
         public static UnitOfWork getUnitOfWork(ClassLoader cl) {
              try {
                   return createClientSession(cl).acquireUnitOfWork();
         public static ClientSession createClientSession(ClassLoader cl) throws Exception {
              try {
                   if (serverSession == null) {
    serverSession = createServerSession(cl);
    ServerSession s = (ServerSession)SessionManager.getManager().getSession(TOPLINK_SESSION, cl);
                   return serverSession.acquireClientSession();
              catch (Exception e) {
              return null;
    Then in my Session EJBs I could write a method like this where Thing is a TOPLInk object mapped to the thing table:
         public boolean setThingStatus(String thingID) {
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression expression = builder.get("THING_ID").equal( Integer.parseInt(thingID));
    ClientSession s = TOPLinkFactory.createClientSession(this.getClass().getClassLoader());
    Thing thing = (Thing) s.readObject(Thing.class, expression);
    UnitOfWork uow = TOPLinkFactory.getUnitOfWork(this.getClass().getClassLoader());
    Thing thingClone = (Thing)uow.registerObject(thing);
    thingClone.setStatus("WITH JASON");
    TOPLinkFactory.commitAndReleaseUnitOfWork(uow);
    return true;
    Now if the above looks OK and there are no Thread/Session issues that you could make me aware of (or perhaps you would encourage using a full Singleton pattern instead).
    I have another question in relation to ClassLoaders. In this architecture I have been passing around the ClassLoader (as above) to the TOPLInkFactory methods to create the unit of works etc... Is this necessary? Or could I avoid it?
    Also I think some people in my team are thinking its a good idea for all TOPLink business objects to extend an abstract base class that contains this behaviour and provides these TOPLinkFactory methods. I no expert on TOPLInk but I would have thought this code should not be coupled with the TOPLink business objects for reasons such as:
    1) Why should a TOPLink Person object (attributes name, age etc) e.g. extend a class with TOPLink API methods and attributes - I just don't see the logic there as I thought TOPLink was to be non-intrusive. For example a Person object should not encapsulate a ServerSession object and nor does it need to. To this end they are then coupled and if for example we wanted to move these Person objects to work with another persistence framework then they would have to be rewritten to remove all TOPLInk attribute/method references
    2) I would have thought accessing the TOPLInk API is only necessary when the client code needs to invoke calls to the database for reads and updates. i.e. that's where you start getting your sessions, unit of works etc. Like in the setThingStatus Session EJB method (i.e. the client code) above and NOT in your business methods of for example the TOPLink Person object?
    Please tell me if I am mistaken!
    If you could clear some of this up it would be great.
    Regards,
    Jason

Maybe you are looking for