How do I call methods with the same name from different classes

I have a user class which needs to make calls to methods with the same name but to ojects of a different type.
My User class will create an object of type MyDAO or of type RemoteDAO.
The RemoteDAO class is simply a wrapper class around a MyDAO object type to allow a MyDAO object to be accessed remotely. Note the interface MyInterface which MyDAO must implement cannot throw RemoteExceptions.
Problem is I have ended up with 2 identical User classes which only differ in the type of object they make calls to, method names and functionality are identical.
Is there any way I can get around this problem?
Thanks ... J
My classes are defined as followes
interface MyInterface{
     //Does not and CANNOT declare to throw any exceptions
    public String sayHello();
class MyDAO implements MyInterface{
   public String sayHello(){
          return ("Hello from DAO");
interface RemoteDAO extends java.rmi.Remote{
     public String sayHello() throws java.rmi.RemoteException;
class RemoteDAOImpl extends UnicastRemoteObject implements RemoteDAO{
     MyDAO dao = new MyDAO();
    public String sayHello() throws java.rmi.RemoteException{
          return dao.sayHello();
class User{
   //MyDAO dao = new MyDAO();
   //OR
   RemoteDAO dao = new RemoteDAO();
   public void callDAO(){
          try{
          System.out.println( dao.sayHello() );
          catch( Exception e ){
}

>
That's only a good idea if the semantics of sayHello
as defined in MyInterface suggest that a
RemoteException could occur. If not, then you're
designing the interface to suit the way the
implementing classes will be written, which smells.
:-)But in practice you can't make a call which can be handled either remotely or locally without, at some point, dealing with the RemoteException.
Therefore either RemoteException must be part of the interface or (an this is probably more satisfactory) you don't use the remote interface directly, but MyInterface is implemented by a wrapper class which deals with the exception.

Similar Messages

  • Applet with 2 methods with the same name in ie

    Hi,
    I have a problem with the Java 1.5 plugin for Internet Explorer .
    When my Applet contains 2 methods with the same name but not the same return type, ie does not take the good return type.
    Here is an exemple :
    * Class TestApplet
    package test.applet;
    import java.applet.Applet;
    public class TestApplet extends Applet {
         public void init() {
              System.out.println("init()");
         public void start() {
              System.out.println("start()");
         public String test(String s) {
              System.out.println("test(String) :" + s);
              return s;
         public boolean test(int i) {
              System.out.println("test(int) :" + i);
              return true;
    }I have 2 methods test(), one returns a String and the other a boolean.
    I use the following html code :
    <html>
    <head>
    <script>
    function test() {
         alert(document.DataAccess.test("hello"));
    </script>
    </head>
    <body>
    <applet WIDTH="500" HEIGHT="200" ID="DataAccess" NAME="DataAccess" CODE="test.applet.TestApplet">
    </applet>
    <div onclick="test()">test</div>
    </body>
    </html>
    When I click on "test", the alert show "true" instead of "hello".
    The problem only occurs with a JVM 1.5. It work fine with JVM 1.4.
    Any idea ? Is it a bug ?
    Thanks.

    In your javascript method:
    function test() {
    alert(new String(document.DataAccess.test("hello")));
    MSJVM and SUN jre use different conversion from javaScript objects to Java.
    if you call from javaScript:
    document.getElementById("myApplet").myMethod(22);
    The method in MSJVM should look like this:
    public whatever myMethod(Double d);
    and SUN jre:
    public whatever myMethod(Integer i);
    The best thing to do is this:
    public whatever myMethod(Object o);
                   int col = 0;
                   if (o.getClass().getName().toLowerCase().indexOf("integer") != -1) {
                        col = ((Integer) o).intValue();
                   } else {
                        col = ((Double) o).intValue();
                   }

  • How can I merge folder with the same name so that the content does not replace the other

    How can I merge folder with the same name so that the content does not replace the other?

    >
    That's only a good idea if the semantics of sayHello
    as defined in MyInterface suggest that a
    RemoteException could occur. If not, then you're
    designing the interface to suit the way the
    implementing classes will be written, which smells.
    :-)But in practice you can't make a call which can be handled either remotely or locally without, at some point, dealing with the RemoteException.
    Therefore either RemoteException must be part of the interface or (an this is probably more satisfactory) you don't use the remote interface directly, but MyInterface is implemented by a wrapper class which deals with the exception.

  • Query parameters with the same name and different values

    According to HTTP, multiple query or post parameters with the
    same name and different values are permitted. They are transfered
    over the wire in the following format -
    name1=val1&name1=val2&name1=val3
    The problem is that I can't see anyway of assigning multiple
    parameters with the same name and different values to the request
    object of mx.rpc.http.HTTPService. I have tried using the
    flash.utils.Dictionary object as it does strict key comparison but
    that doesn't work too. I have tried setting an array of values to a
    property of the request object but that sends the request to the
    server in the following format -
    name1=val1,val2,val3
    The java servlet engines throw exceptions when they see this.
    Any help would be greatly appreciated.

    If you're not on 8.1.4 move there. 8.1.3 had limitations in the wsrp
    release.
    wrote:
    I have an html select box that contains several values, and multiple
    selection is enabled. When my code runs as a remote portlet, the
    following is showing up in the soap monitor when I select multiple
    values and submit the form:
    <urn:interactionParams>
    <urn:portletStateChange>cloneBeforeWrite</urn:portletStateChange>
    <urn:interactionState>_action=addEmployeesToGroup</urn:interactionState>
    <urn:formParameters
    name="P62005wlw-select_key:{actionForm.selectedEmployees}OldValue">
    <urn:value>true</urn:value>
    </urn:formParameters>
    <urn:formParameters
    name="P62005wlw-select_key:{actionForm.selectedEmployees}">
    <urn:value>beatest1</urn:value>
    </urn:formParameters>
    In this case, I selected beatest1 and beatest2, but only beatest1 comes
    through to the remote portlet. Is this a known bug, and, if so, is
    there a patch or workaround available?
    Thanks in advance,
    Andy

  • How to create reports servers with the same name in two nodes in Reports

    Greetings
    We are migrating Oracle Application Server 10g (9.0.4) to a better hardware infrastructure with high availability. We want to provide 2 new Oracle Application Server 10g (9.0.4) in High availability and we want to avoid modify the existing forms and reports code, but the code is looking for a specific reports server name when calling reports, but I couldn't create the same reports server name in the both oas machines, I could create the reports server in only one node. I want to create a reports server with the same name in both nodes but it is not possible. I know that there is a procedure to do that in 10.1,2 (Note 437228.1, How to Create Two Reports Servers With the Same Name in the Same Subnet) but I couldn't find the equivalent procedure in 9.0.4.
    Anybody kwows how to create a reports server with the same name in two nodes using 10g (9.0.4)
    Thanks
    Ramiro Ortiz.

    Hello.
    I applied the patch 4092150 on my oas 9.0.4.2 and I modified my rwnetwork.conf file changing the port to 14022 by following the note "How to Create Two Reports Servers With the Same Name in the Same Subnet? [ID 437228.1]" but I am facing the same error rep-56040 "server already exists in the network".
    When I run osfind command I get the following information (My reports server is senarep and I want to create it on SNMMBOGOAS10):
    osfind: Found 2 agents at port 14000
    HOST: SNMVBOGOAS10.sena.red
    HOST: SNMVBOGOAS09.sena.red
    osfind: There are no OADs running on in your domain.
    osfind: There are no Object Implementations registered with OADs.
    osfind: Following are the list of Implementations started manually.
    HOST: SNMVBOGOAS10.sena.red
    REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
    OBJECT NAME: senarep2
    REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
    OBJECT NAME: senarep2
    HOST: SNMVBOGOAS09.sena.red
    REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
    OBJECT NAME: senarep
    REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
    OBJECT NAME: senarep
    Any Ideas?

  • When saving files under options the file name is duplicated how to remove extra folder with the same name

    Under Firefox Options I clicked Saving Files under Downloads but the file name appears twice and an extra folder with the same name is created within the folder i.e.:
    G:\Akbar's Songs\HAMARA FORUMS DOWNLOADS\HAMARA FORUMS DOWNLOADS
    As you can see the folder is repeated, how can I correct this?
    Also the music files I download from a site downloads as WinRar file and I need to open it. Is there an option where the files open automatically in the folder I have selected?
    Many thanks for your help.

    The "beta" version is for testing and may be more prone to problems, so I suggest trying the regular version (9.20) even though it hasn't been updated since 2010.

  • How do you force instances with the same name on the same layer to update?

    Maybe someone can tell me why flash doesn’t redraw
    components’ x,y positions if they have the same instance name
    and are on adjacent frames? (movieclips work fine, just not
    components) If I have a button on frame 1 and a button on frame 2
    both with the same instance name but different locations on the
    stage, frame 2’s button doesn’t show up in the position
    I placed it, it stays at the position of frame 1 but still has the
    properties of frame 2’s button. The label changes and
    everything. If I stick a button on a frame in between and give it a
    different instance name there is no problem. I thought it might be
    the style manager bug
    http://www.gskinner.com/blog/archives/2007/12/cs3_component_b.html
    but it didn’t seem to affect. This happens for textareas too
    and probably all components although I haven’t tried them.
    I’ve tried using drawNow() and validateNow() with no luck
    either
    http://www.adobe.com/devnet/flash/articles/creating_as3_components_pt3_05.html
    Thank you!
    // put this on frame 1 along with a button on the stage with
    instance name: b
    function doit(event) {
    if (currentFrame == 1)
    gotoAndStop(2);
    else
    gotoAndStop(1);
    b.addEventListener(MouseEvent.CLICK, doit);
    stop();
    // put another button on frame 2 along with this code and
    also make it’s instance name: b but move it so it’s not
    in the same x,y coordinates as the button on frame 1
    stop();
    Something possibly related. I have a movieclip on a layer,
    one instance with name “a” on frame 1 and one instance
    with name “a” on frame 2 and it has event listeners
    inside it that update something on the movieclip. Unless I put the
    movieclips on separate layers the event listeners won’t reset
    each frame. (example: a button with a tooltip onmouseover that you
    want to change the text of from frame 1 to frame 2) You’d
    think if they were on separate keyframes at least but no, they need
    to be on separate layers too.
    I want the movieclip to update each frame. Any ideas?

    instances (whether components or not) with the same name may
    or may not be the same instance. it depends upon how they were
    created.
    for example, if you create an instance on frame 1 of your
    main timeline, give it an instance name and then create a keyframe
    on frame 2, the two instances will be the same.
    but if you create an instance on frame 1 of your main
    timeline, give it an instance name and then create a blank keyframe
    on frame2 and create another, what you think is a duplicate,
    instance and give it the same name, it will be a different
    instance.

  • How to put two files with the same name into the same folder?

    How can I put two files with the same name and the same extention into the same directory?
    Is this even possible?
    Thanks in advance. 

    Are you sure? I would be very surprised if that was the case.
    How does the computer/filing system differentiate the files, if not by their names?
    How do you tell the computer which one you want? (On the command line.)

  • How to open a file with the same name?

    Hi, now I practicing making web pages where I put sample codes in one directory and I copy them to edit.
    The probrem is, I couldn't open one file while I'm opening another file with the same name.
    Is it possible to open  a file with the same name in Dreamweaver?

    That could be a very error prone practice.
    May I suggest you take advantage of DW "Snippets" feature instead.
    Simply save any blocks of code you will reuse regularly as snippets,
    and give each one a descriptive name you like.
    Then you can simply place your cursor in code view where you wish the code,
    and click insert on the selected item from the snippet panel.

  • Two AM's with the same name but different forms causes Deployment problems

    Two Masters forms, DOC & PM are cloned except for the "where clause" in the View's query and the titles in their JSP's.
    DOC workspace has a BC project and a BC4JSP Project. The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='DOCTOR'.
    In Java Webserver :-
    The JSP's are located in C:\source\Doctor\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\Doctor\pol_ValueSet\..
    If I execute Doctor in JWS the records are getting filtered properly.
    PM workspace has a BC project and a BC4JSP Project. Again The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='PAY_MODE'.
    In Java Webserver :-
    The JSP's are located in C:\source\PMode\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\PMode\pol_ValueSet\..
    If I execute PM in JWS, the PM's JSP comes (the title is correct) but the records pertaining to DOC appears. I checked the View's xml file in C:\source\PMode\pol_ValueSet\ the "where clause" is correct. The xml & classes have the same name but their contents are different.
    I want to know whether this problem is because both have the same name for the AM and the BC4JSP's property file.
    Please clarify.

    Deploying two app modules with the same name will definitely cause problems.
    The JSPs use the information in the properties file to connect to the application module and get the data they need from the appropriate View Objects in those app modules. If you have two app modules with the same name, when a JSP tries to connect, it has no way of knowing which one of the app modules to connect to if they both have the same name.
    You could:
    1. Just use one application module that contains all the View Objects you need to access.
    or
    2. Rename one of the application modules or the package it is located in so the names are distinct. If you choose this method, you will also need to update the JSPs (specifically the 'registerApplicationFrompPopertyFile' method call), and your JSP project's appmodule property file.

  • Is it possible to call a function with the same name from 2 different dll's at the same time.

    I'm trying to call a function ( F ) form 2 different libraries ( A.dll and B.dll ) at the same time. The first lib loaded determines the function F. A->F and B->F have same interface and name but different implementation.

    Hi,
    I tried it with two dll's, both with the same interface, and at the same
    time, in the same VI. The popups even appear at the same time.
    But now I understand the problem... Both dll's are created by LabVIEW! If
    they are not (or one is not, and the other is), this is no problem.
    And VI's in memory cannot have the same name. LabVIEW doesn't care if VI's
    are in a dll or not.
    This might not help, but if you want to make some sort of "plug in" system,
    you might consider using llb's. By loading VI's dynamically, you can select
    the path from which they are loaded. You must unload (close all references)
    one before the loading the other, or the same problem will occur. If you go
    this way, I consider a different approach. Make on
    e library (or even a dll)
    that has the interface you like, this is the "loader". Now make several
    "plug in"'s, with the same interfaces. The name of each function in a plug
    in is a concatenation of the library name and the function name. The loader
    has one extra function, that loads (and unloads, when done) references to
    all desired libraries to use (the names of the functions can be figured out
    easily). All that the loader functions do is dynamically call the library
    functions. You can use a call by reference node for this (you can use the
    connector pane or the loader vi, since the interface must be the same!).
    If you go this way, I guess the loader library can be converted to a dll...
    Hope this helps.
    Wiebe.
    "rsam" wrote in message
    news:[email protected]..
    > Thx Wiebe,
    >
    > did you load both dll at the same time? For example in 1 vi. Somehow
    > the first loaded function keeps to overrule the second. Notice that
    > the interface is
    exactly the same.
    >
    > I loaded 2 dll created in Labview with results described above.
    >
    > Regards Ruud

  • How to load the same classes of the same name, from different jars

    Hi,
    I have several different versions of my project in respective jars. I am trying to develop a configuration app, which will have the most current version of my app packaged within it. Then the user will make a selection, and if that selection is an older version, a specific class from one of the jars...which will continue to load other classes within that same jar. If it is the current version, the class will be found within the codebase.
    My question is if this is even possible? Can I load a class from a jar file which has the same file name and package as what is in my current code?

    nasch_,
    So I have been searchin around, and found some good tutorials on classloaders, But i still see a problem.
    Whether I use the same classloader for different sources or not, the problem lies within the reference to the class i am loading. Since this class (a different version of it), is also in the classpath, how does the code know which class is being returned?
    I am having trouble putting this into words, but basically. i don't see how my application will know that i am returning an instance of a class which is not in my classpath.

  • How do you two Ipods with the same name on one computer?

    I had the 2nd generation ipod touch and then I got the new one.When i put the new ipod on my itunes i used the same ipod name. I then lost the new one and wanted to use the old one. I had bought some new stuff that i wanted to download. But when i plugged it in a synced it a message came up saying: The ipod

    You omitted what the message said.  If yu post it them maybe we can help.

  • Why can't iTunes down load two songs with the same name but different artists to my iPhone?

    I noticed this a couple of years ago but had forgotten about it. Today I purchased two songs, both called Bop Gun (One Nation) but by different artists. When I looked at the purchased list on one appears. If I go back to iTunes and download the other one, the former disappears. Are they honestly saying that these phones are intelligent enough to distinguish a song by artist rather than track listing?
    Epic Fail!!!

    Usually a song is uniquely identified by song name, artist, album and track number. That said internally I suspect the iTunes Store may allow one song to appear on more than one album while they only need to store one copy of the audio data. (They must also be able to cope with the situation, for example, where the UK & US version of an album have a different track order). It is also possible there is an error in the database that means you're not getting the song you're expecting. If you can't successfully download the two (presumably) different versions of the song then use the report a problem links in your account history and explain the issue. Hopefully the iTunes Store support staff can get it resolved.
    tt2

  • Is it possible to have 2 instances with the same name but different edition in the same server?

    Hi everybody!
    I have in a little trouble ....
    *** Scenario.
    Oracle Enterprise Edition 11gr2 over Oracle Solaris 11
    3 instances: PROD, QA, DEV
    1 ASM instance
    Listener ports: 1520, 1530 & 1540
               Those are production system
    *** The problem:
    Customer can't pay Oracle EE, they want to change to Oracle Std One
    Limitations:
    I cant have a similar system to test.
    *** My idea:
    Install Oracle Std One, in the same path:
    /u01/app/oracle/product/11.2.0/db          <-- EE
    /u01/app/oracle/product/11.2.0/db_one   <-- Std Ed One
    ASM:
    /u01/app/11.2.0/grid          <-- EE                    +ASM
    /u01/app/11.2.0/grid_one   <-- Std Ed One        +ASM1
    Create databases:
    Asign similar disks to +ASM1
    Create DGs on +ASM1
    Create databases: PROD, QA, DEV for Std Ed one
    - is it posible that they have same instance name?
    - if not, i suppose create as: PROD1, QA1, DEV1
    Configure Listener port : 1521, 1531 & 1541
    Migration technique:
    Create Tablespaces, schemas
    Lock users in EE
    down listener: 1520, 1530 & 1540
    Import data of final users in a window maintanance
    configure and up listener: 1521, 1531 & 1541
    Customer should test access and apps in new
    Please tell me if my Idea is reallistic, all comments are going to be very apreciated.

    sol.beach
    I suppose end customer use a port per database in order to separate in a logical way the access to the databases,
    i mean PROD, QA & DEV has the same users.
    Hemant K Chitale
    1. I've seen physical servers with 3 ASM instances: +ASM1, +ASM2, +ASM3
       on Solaris & Oracle 10g, I suppose is posible on 11g
    2. The sever has occupied 2  sockets (2 physical CPU), so I can use Oracle Standard Ed One.
    JohnWatson2
    Thanks for your comments.
    WadhahDaouehi
    1. - You cannot run two ASM instance simultaneously on one Server, but you can run many Oracle database simultaneously
          on the same server which they use the ASM as storage type.
      As a mentioned to  Hemant K Chitale, I've seen a system with several instances running
      About
         "you can run many Oracle database simultaneously on the same server which they use the ASM as storage type."
      I'm not sure if i can use the same ASM which is part of a current Enterprise Ed over the new installation with Oracle Std Ed One.
    2. - Why you want the same instance name?
    If it is about the service name, which has by default the same instance name, just you can create a different instance name
    and create the service name with the name that you wish.
    SQL> alter system set service_names='instance_name';
    Is a similar name, not the same
    PROD, QA & DEV
    PROD1, QA1 & DEV1
    I consider add "1" at the end to refer "Oracle Standar Ed One"
    But I agree with you, i can customize throught service_name.
    Regards,
    Abraham Mtz.

Maybe you are looking for