Which pattern for this scenario ?

Hi all,
I have an EJB which connects to an external system (written in Perl) using plain HttpConnections and posting HTML content.
I would like to centralize this access using a design pattern.
Which pattern is would fit this scenario ?
I wonder if I should use the Adapter pattern or the Bridge Pattern.
What do you say to it ?
Thanks
Francesco

I'd kind-of guessed it was uni work :-)
in all honesty, I wouldn't even approach the problem from a patterns perspective. all I see is a subsystem I don't want to deal with directly, so I define an interface to hide it behind. could argue that it's an Adapter, since it's taking the Http interface and abstracting away from it, to a java one. on the other hand, since mucking around with Http in java isn't exactly straight-forward, you're defining a more simple interface, so it could be considered a facade. which do you think is closer?
most people, once au fait with design patterns, think less in terms of those patterns, and more in terms of what OO principles to apply. score some extra credit by writing a passage about how design patterns are not prescriptive, and that many coders lift ideas about encapsulation and separation from patterns, rather than use the pattern exactly as described.

Similar Messages

  • Re: Which pattern for RMI scenario

    Two different UIs talking to the same RMI service?
    How does the service tell the difference between the
    two?Basically the same way any other server distinguishes between its clients. It sends the response back to wherever the request came from.

    I'd kind-of guessed it was uni work :-)
    in all honesty, I wouldn't even approach the problem from a patterns perspective. all I see is a subsystem I don't want to deal with directly, so I define an interface to hide it behind. could argue that it's an Adapter, since it's taking the Http interface and abstracting away from it, to a java one. on the other hand, since mucking around with Http in java isn't exactly straight-forward, you're defining a more simple interface, so it could be considered a facade. which do you think is closer?
    most people, once au fait with design patterns, think less in terms of those patterns, and more in terms of what OO principles to apply. score some extra credit by writing a passage about how design patterns are not prescriptive, and that many coders lift ideas about encapsulation and separation from patterns, rather than use the pattern exactly as described.

  • Help required specifying Transation attributes for this scenario

    Hi ,
    I am trying to create/update rows in a database using BMP and CMP beans.
    A business method ( Method1 )in session bean calls a non-business method ( Method2) in the same session bean which inturn calls an EntityBean ( EB1-BMP) . EB1 can throw a certain business exception upon which , the Method1 in the session bean calls another EntityBean in a loop( EB2-CMP).
    The problem is that , when the EB1 throws the business exception, i am getting an exception ( part of the stack trace attached below ).
    Could any please explain what should be the transaction attributes to be specified for this scenario.
    Using RequiresNew for the EntityBeans would not work ( or would it ?? ) because the entity bean is being called in a loop and the commit or rollback should happen for all the methods.
    I feel the problem should be solved by specifying the transaction attribute for Method2 ( non business method in session bean ) as Required, but i guess this is not possible.
    How exactly will the transaction behave in this scenario, is the exception caused because EB1 has thrown an exception and i am trying to continue the transaction.
    Could someone please suggest a solution or workaround for this problem.
    Regards,
    Harsha
    ---- Begin backtrace for nested exception
    java.lang.IllegalStateException
    at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:1694)
    javax.ejb.EJBException: nested exception is: com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR6022E: Error using adapter to create or execute an Interaction. com.ibm.ws.rsadapter.cci.WSInteractionImpl@28d16547
    .

    tryout business method ( Method1 )in session bean with transaction as RequiresNew.
    catch exception in Method2 originated from EB1-BMP
    make the method in EB2-CMP as Required/Mandatory
    I have made a guess here so just tryout and let me know if works.
    Its recommend that not to use both BMP's and CMPs in your application. Have any one either.

  • What’s the best practice for this scenario?

    Hi,
    My users want the ability to change the WHERE and/or ORDER BY clause at runtime. They may define user preferences on each screen ( which is bind to a view object). They want to see the same records based on WHERE/ORDER BY defined on the last visit. That is why I keep the users preferences and load the screen based on that, using :
    View.setWhereClause(...);
    View.setOrderByClause(...);
    View.executeQuery();
    This works good when only one user working with the application but faced low performance when more than one user working with the application.
    What are the points to increase the performance and what is the best practice for this scenario?
    Thanks for your help in advance.

    Sung,
    I am talking only about 2 users in my testing. I am sure i missed something but could not recognize that.
    This page is my custom query page including a tag to instantiate app module in stateful mode at the top <jbo:ApplicationModule..> and a tag to instantiate data source <jbo:Datasource...> and release tag at the bottom <jbo:ReleasePageResources..> and some java code in the middle(body). The java code constructed the query statement and then fires the query to set the view object based on the query statement using the above methods.
    So, I am facing very slow performance(speed) when two clients load this page at the same time. Looks like the entire application locks for others when one client load this page and fire the query. i realized the battle neck is where executeQuery() is executing.
    what do you think.
    Thanks in advance for your comments.

  • Is there a design pattern for this?

    I'm looking for a solution to a design problem I have.
    For a restaurant booking system I need a number of different opening times describing when you can and cannot book. These opening times are essentially Jodatime Period objects. There's a set of opening times spanning a week and these are repeated for every week (a default set of opening times) however it's possible to override these opening times say for a specific day.
    The domain model would be something like a Restaurant class holding 2 Lists of OpeningTime objects one for defaultOpeningTimes and the other for overiddenOpeningTimes the overidden ones get used if they exist for the requested time period. However the database model would be a bit messy as I'd have 2 lists mapping to the same table (OpeningTime). Is that a good idea? Perhaps there's a design pattern for this, if someone could point me in the right direction I'd be very grateful, or perhaps this is the best solution? Thanks!

    jduprez wrote:
    But why do you put the logic in the database too (I'm no DB expert and I didn't know these concepts until I read your post, but that's what a dynamic view based on derived values looks like to me): performance (1 round-trip instead of two)?Hi jduprez. Long time no speakee.
    I guess part of it is that I spent many years as a DBA and modeller, and really appreciate what it's taught me about design. Also, databases are (or should be) designed from the ground up to provide data-directed requests optimally, and include all sorts of nice stuff like transaction handling that aid consistency, as well as speed.
    That said: I HATE SQL. Think Coliseum, with that emblazoned in 60-foot high letters around its walls, and it might come close to just how much I hate that so-called "language". I hate its form; I hate it's inconsistencies; I hate the fact that something like what OP is trying to do is NOT an easy task (and might involve the creation of a table that simply contains Dates, just in order to satisfy Boolean logic).
    However, once you work it out, a database view (at least from the database's standpoint; JDBC I'm not so sure about) is just like any other Table - and that I DO like.
    Programs are good at processing parameterized (ugh) temporal information; databases are good at persistence and high volume. Those two may meet at some point, but I reckon it's going to take another Codd (or Joda) before it does.
    - that's clearer to 90% of the dev team (my biased numbers, based on 50% of Java developers having decent knowledge of SQL and much less than that having the advanced SQL knowledge which I rank your suggestion at)Sounds to me like you'll get the solution that matches the skills you have then. Is that what you really want, if a better one is available?
    - that doesn't require investigating the if of your suggestion (JDBC support)Agreed, but only because my JDBC knowledge isn't what it could be. I'd also be surprised if it doesn't support access to a named view, since they were designed to be equivalent to Tables.
    - the Op is using DAOs, so it's possible, if profiling does show this is hampering performances, to change that with no impact on the client code that calls the DAO.There's no doubt that a database solution is much higher level than a programming one; but, as I said, it's what they were designed to do. And tinkering around with program optimization has the feel of a "hacker's solution" to me. Not that there's any particular problem with that - I do it quite often when I have no control over my source - but I also try to keep in mind what the "actual" problem is.
    Winston

  • Need inputs from u for this scenario?

    Hi all,
    I have one scenario I need all inputs from u all.
    My scenario is like this.
    I will get data from online transactions I need to collect all the day transaction into one folder and upload them into SAP system at one particular time.
    Which are the best adapters for this scenario.
    If I have standard IDOC I will go with IDOC adapter at receiver side if not proxy.
    But collecting all the data into one folder and schedule the process at particular time.
    How to do this and what are the adapter I can use.
    Thanks and Regards,
    Phani Kumar.

    Hi,
    I hope for online transactions and for tracking it and saving you can write a java script where you can prepare a XML file to get all transactions for particular order and always append it to the end of that xml file. At end of the day you will have a complete transaction list in the XML you are creating. You can use the file name as you desired but i will prefer datewise name.after the completion of that Transaction recording step, put it in some In folder from where your XI system willo take input.
    Now this is file to Idoc scenario or whatever you want to use to post data to SAP Systems. The sechdule this scenario to run in the night or your desired time. After processing the XML file put that file\ to some other complete folder , not to get it again.
    For collection of transactions you can also use databases. Then you scenario will be JDBC to IDOC or the thing you want to post data in SAP system.
    Hope this will help you.
    Regards
    Aashish Sinha
    PS : reward pints if helpful

  • Regex Pattern For this String ":=)"

    Hello All
    True, this isn't the place to ask this but here it is anyway, if you can help please do.
    Can anybody tell me the regex pattern for this String:
    ":=)"
    Thanks
    John

    Yep, cheers it's ":=\\)"
    public class Test {
         public static void main( String args[] ) {
              String s = "one:=)two:=)three:=)four";
              String ss[] = s.split( ":=\\)" );
              for( int i=0; i<ss.length; i++ )
                   System.out.println( "ss["+i+"] = {" + ss[i] + "}" );
    }resulting in:
    ss[0] = {one}
    ss[1] = {two}
    ss[2] = {three}
    ss[3] = {four}

  • Oracle features available for this scenario

    What is the best methos for replcating oracle database from a production database with every 15 min interval..
    what are the oracle features available for this scenario
    Thanks
    Shiju

    orashiju wrote:
    What is the best methos for replcating oracle database from a production database with every 15 min interval..
    what are the oracle features available for this scenario
    Thanks
    ShijuIs there any specific reason to open a new thread for the same discussion that you have started here,
    Please suggest a suitable method
    Aman....

  • Do I need a Singleton pattern for this case

    Hello,
    I'm writing a game in Java and I have a very simple score manager class which just tracks the points the player so far has. I need to access this class in different pars of my app (gui, game core ...) so I created a singleton class which looks like this
    public class ScoreManager {
            private static ScoreManager instance = new ScoreManager();
            private int score = 0;
         private int highScore = 0;
         public static ScoreManager getInstance() {
              return instance;
         public int getScore() {
              return score;
         public int getHighScore() {
              return highScore;
         public void addScore(int scoreToAdd){
              score += scoreToAdd;
              if(score > highScore) {
                   highScore = score;
    }so far so good ..
    I would like to read the "highScore" from a file when the game starts and write it back when the game ends. I added those two methods:
         public void init(File highScoreFile) {
              highScore = readFromFile(highScoreFile);
                    score = 0;               
         public void dispose(File highScoreFile) {
                   writeToFile(highScoreFile);
         }So basically I call the init() method when the game stars and the dispose() when the game ends.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place.
    What would be a better way to do this ?
    Thanks for your help,
    Jesse

    safarmer wrote:
    You could keep track of the state (initialised, destroyed etc) in the manager and only perform the action if it is an expected state.
    private enum State { NOT_INITIALISED, INITIALISED, DESTROYED};
    private State currentState = State.NOT_INITIALISED;
    // i will leave the rest up to your imagination :) this looks good, thanks
    anotherAikman wrote:
    >
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. And who would that be? You´re the only one using the code, aren´t you?
    If not, you could still include in the documentation where to call those methods.
    no I'm not the only one working on this. Documentation can be useful but does not prevent calling wrong methods.
    YoungWinston wrote:
    I don't see any constructor. Usually, a singleton class should have a private one, even if it has no parameters. If you don't have any, Java will create a public no-parameter one as default.ok I forgot the private constructor.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. Then my advice would be not to make them public. After all, your code is the only one calling these methods - yes?yes only the code of the app calls it.
    If you are convinced that your game requires one and only one score manager, then a singleton is probably the best way to go.
    I'm a little worried about the init() and dispose() methods though, because these suggest state changes, which is unusual for the singleton pattern. You may want to think about synchronizing them.
    An alternative might be to use properties to get and store your scores.ok for the synchronization. What would using the properties ? It would be just another type of storage backend and I'd still need to read/write it.
    Thanks for your help,
    J

  • What Permission Set Is Required For This Scenario?

    Hello,
    I currently have an environment where I have limited users to being able to create/delete databases that only they have created.  I did this by creating a Login with Public access and granting them the  CREATE ANY DATABASE permissions to their
    login. This works great as the users can create a database and delete their database but not anyone else's. The issue I have is the following scenario:
    Database A is backed up from Server 1 (a different server than the restore server) and the DB was created by User 1
    Database A is restored to Server 2 by User 2 who has CREATE ANY DATABASE permission (successfully).
    User 2 can see the restored database, but cannot access it: The database is not accessible error.
    When I view the database I see that the DB Owner is listed as User 1.
    I've been trying to figure out how to be able to allow the user to become the new owner so they can edit/delete the database, but still not affect other databases that they do not own.
    I've played with various permission sets but they end up being able to delete other user databases which I'm trying to avoid.  I also don't want to have to change the owner myself. 
    Is there a permission set that I can grant that will allow this scenario?

    That's a valid statement, let me explain my scenario and perhaps there is a better way to construct what I'm after.
    I have a QA server where different developers create databases.  All the databases backed up on the QA server are stored in a shared folder.  This shared folder is accessible on our DEV server.  We have a different set of developers
    who at times need to restore one of the QA backups on the DEV server for different testing reasons.  The permission set applied was simply to prevent someone from accidently deleting someone else's database.  Restoring someone else's database in
    our environment is not a concern.
    With this in mind, I was hoping there was an additional permission I could grant that would allow the user restoring the database to become the new owner. I don't want the burden of approving it as it will always be approved.
    I clicked on the connect link, but it returns as invalid -
    The system has encountered an
    unexpected error. We apologize for the inconvenience. The issue will be
    addressed as quickly as possible.

  • Tuning hints for this scenario?

    Every year, one customer has an opening for ticket sales on
    our machine. the machine is Dual Xeon 3 GHz with 2 GB RAM. It runs
    Win2k3, Apache 2.0.59, CF 7.02 Standard and Sybase ASA9 and a
    Mailserver, and of course our cf application which is the ordering
    and reservation system. Our internet provider gives us almost 10
    Mbps.
    As said, at some november's midnight, our customer opens his
    sale which draws a huge interest from the public. i.e. hundreds of
    even thousands of clients wait for that midnight to enter the
    reservation.
    and in any of those nights, our system seems to be very slow
    if not even behaving like a DOSed system. However, I can use remote
    control to see windows task maanger and I don't see an exhausting
    cpu load.
    Therefore my questions to the cracks: What could/should I
    change in the Request Tuning Section in CFAdmin?
    What about "Maximum number of simultaneous Template requests"
    ... currently I have 20. Default were 8. Does anyone have
    experiences regarding this value's range?
    Any other hints for our scenario are greatly welcome ...
    Thank you
    Martin

    Thanks for your reply. Iam sorry, if my earlier question was not clear.
    We are using parallel hints extensively. My question was
    Does Oracle has any in-built methodology or technique like any specific hits for this case scenario.
    Case1:
    select * from A,B
    where A.c1=B.c1
    Assuming A is driving table and B is lookup table, The size of B is very huge.
    Case2:
    select * from A,B
    where A.c1=B.c1
    Assuming A is driving table and B is lookup table, The size of B is very small.
    The ETL tools like IBM Datastage have specific stages to deal with the above scenarios.
    Anyways thank you.

  • What is the best design pattern for this problem?

    No code to go with the question. I am trying to settle on the best design pattern for the problem before I code. I want to use an Object Oriented approach.
    I have included a basic UML diagram of what I was thinking so far. 
    Stated simply, I have three devices; Module, Wired Modem, and Wireless Modem.
    In the Device Under Test parent class, I have put the attributes that are variable from device to device, but common to all of them.
    In the child classes, I have put the attributes that are not variable to each copy of that device. The attributes are common across device types. I was planning to use controls in the class definition that have the data set to a default value, since it doesn't change for each serial number of that device. For example, a Module will always have a Device Type ID of 1. These values are used to query the database.
    An example query would be [DHR].[GetDeviceActiveVersions] '39288', 1, '4/26/2012 12:18:52 PM'
    The '1' is the device type ID, the 39288 is the serial number, and the return would be "A000" or "S002", for example.
    So, I would be pulling the Serial Number and Device Type ID from the Device Under Test parent and child, and passing them to the Database using a SQL string stored in the control of the Active Versions child class of Database.
    The overall idea is that the same data is used to send multiple queries to the database and receiving back various data that I then evaluate for pass of fail, and for date order.
    What I can't settle on is the approach. Should it be a Strategy pattern, A Chain of Command pattern, a Decorator pattern or something else. 
    Ideas?

    elrathia wrote:
    Hi Ben,
    I haven't much idea of how override works and when you would use it and why. I'm the newest of the new here. 
    Good. At least you will not be smaking with a OPPer dOOPer hammer if I make some gramatical mistake.
    You may want to look at this thread in the BreakPoint where i trie to help Cory get a handle on Dynamic Dispatching with an example of two classes that inherit from a common parent and invoke Over-ride VIs to do the same thing but with wildly varying results.
    The example uses a Class of "Numeric"  and a sibling class "Text" and the both implement an Add method.
    It is dirt simple and Cory did a decent job of explaining it.
    It just be the motivation you are looking for.
    have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Programming logic for this scenario

    hi all,
    kindly help me with this scenario:
    i have a internal table with fields like this (among others)
    OBJEK                        ATINN         CHAR                                  CHARG            CHAR1
    000000000000000031 0000000188  Batchnumber: WEEK NO. 9  0000000052
    000000000000000031 0000000189  Visualinspection: OK            0000000052
    now wht i need to do is for SAME batch number i need to concatenate the values of CHAR into CHAR1.
    that is to say that CHAR1 shud have the value "Batchnumber: WEEK NO. 9 Visualinspection: OK"
    ive right now done it using 2 different internal tables and concatenating the values. want to know if theres an easier and simpler way.
    any pointers guys??
    pk

    solved it myself
    thanks to sujatha reddy's post in the following thread:
    Re: at end of  statement
    pk
    Edited by: prashanth kishan on Jul 11, 2008 9:19 AM

  • Do I use the Brdige pattern for this problem ?

    Hello
    I'm making a music mixer for mobile phones. For the canvas, i divided it up in tiles, to fill
    up with .png images if you want to place a sample in that specific tile. But if you have a phone with no colors and your screen is not big enough, the image is almost all black. So I want to create a different class, to only show a letter or a simple symbol if you can't handle the .png well.
    I read about the bridge pattern, where you encapsulate the implementation in an abstract class and seperate it from the base class with the abstractions. Should I use this pattern for my problem ? I have some doubt because I have multiple implementations (color vs non-color) but I don't have multiple abstractions (a tile to fill up with a symbol or picture).
    Are there other patterns that are more suited for my problem ?
    What about the implementation? Should I see the implementation as only producing the image or symbol, or should i see it as the whole canvas, with the tile system?
    For example, now the tiling looks good on most of the targeted phones. But what if the next generation of mobile phones has a screen with very different dimensions. Wouldn't it be better to incorporate this also in the implementation ?
    Thanks

    What are you trying to do when you say "When I put the password for my apple ID into icloud- it keeps reverting to another password"?
    Where are you doing when you try to enter your password?

  • Can i use SAP Predictive Analysis for this scenario?

    Hi guys. I'm new in this subject so I'm a little bit confused about in which cases SAP Predictive Analysis is helpful?
    Could it be helpful for this case? I have prices of rice for differente years, from 2007 to 2013.  Can  SAP Predictive Analysis help me forecast what will be the price of rice for 2014, 2015 and so on?
    Which algorithm should I use? Does it come integrated in the tool or is it an add-on?
    I´ll appreciate it very much if you could send me the right steps to achieve this.

    Hi Erika,
    SAP PA has only Triple exponential smoothing algorithm; In most cases, single exponential smoothing would not make any sense [this is available through HANA PAL or R integration with SAP PA];
    If you have R integration you should see something like this
    In Single exp smoothing only alpha is used;
    in double exp smoothing alpha and gamma is used; and all three in gamma.
    Why these alpha, beta and gamma... has a big derivation to understand; [let me know if you need any document, I have compiled as on some reference]
    What values alpha, beta and Gama should hold in Triple ... or what is the right value, .... actually there are no right value and wrong value for them.
    ... as for the steps to go in SAP PA, refer below:
    Please let me know if you need any assistance ...
    Regards,
    Arvind E

Maybe you are looking for