How to refer to genericized interface

Hi,
I have the following interface:
package org.tbiq.gwt.tools.rpcrequest.server;
import org.tbiq.gwt.tools.rpcrequest.browser.RpcRequest;
import org.tbiq.gwt.tools.rpcrequest.browser.RpcRequestException;
import org.tbiq.gwt.tools.rpcrequest.browser.RpcRequestService;
import org.tbiq.gwt.tools.rpcrequest.browser.RpcResponse;
public interface RpcRequestHandler<ReqT extends RpcRequest<ResT>, ResT extends RpcResponse>
public boolean isCompatibleWith(Class<ReqT> rpcRequestClass);
public ResT execute(ReqT rpcRequest)
throws RpcRequestException;
}I also have a dummy implementation of this interface:
package org.tbiq.gwt.tools.rpcrequest.server;
import org.tbiq.gwt.tools.rpcrequest.browser.DummyRpcRequest;
import org.tbiq.gwt.tools.rpcrequest.browser.DummyRpcResponse;
import org.tbiq.gwt.tools.rpcrequest.browser.RpcRequestException;
public class NewDummyRequestHandler
implements RpcRequestHandler<DummyRpcRequest, DummyRpcResponse>
@Override
public DummyRpcResponse execute(DummyRpcRequest rpcRequest)
throws RpcRequestException
// TODO Auto-generated method stub
return null;
@Override
public boolean isCompatibleWith(Class<DummyRpcRequest> rpcRequestClass)
if (DummyRpcRequest.class == rpcRequestClass)
return true;
return false;
}This interface refers to 2 dummy objects DummyRpcRequest and DummyRpcResponse. There is nothing special about them. They are just regular beans that implement marker interfaces (RpcResponse and RpcRequest<T extends RpcResponse>).
DummyRpcResponse:
package org.tbiq.gwt.tools.rpcrequest.browser;
@SuppressWarnings("serial")
public class DummyRpcResponse
implements RpcResponse
}DummyRpcRequest:
package org.tbiq.gwt.tools.rpcrequest.browser;
@SuppressWarnings("serial")
public class DummyRpcRequest
implements RpcRequest<DummyRpcResponse>
}Somewhere else, I have a class that implements some other interface. Part of implementing that interface is this method:
@Override
public <T extends RpcResponse> T execute(RpcRequest<T> rpcRequest)
throws RpcRequestException
RpcRequestHandler<??????> handler = new NewDummyRequestHandler();
return handler.execute(rpcRequest);
}So, the '?????' is my question. How do I refer to the handler such that it compiles. Right now, now matter what I try in that line, the handler.execute(rpcRequest) doesn't compile.
Also, it's possible that I messed up my RpcRequestHandler interface and defined it in a wrong way (as far as generics are concerned). I am not sure.
Any help would be much appreciated!
Thanks,
Yaakov.
P.S. The code in the last method is obviously for testing only. I am planning to have a Map of those handlers and choose the handler dynamically based on the type of the RpcRequest that is passed into the execute method.
Edited by: ychaikin on Feb 23, 2010 1:10 PM

Had a play round some more with this to refresh my knowledge, and understand exactly where you're coming from
I don't know what your RpcRequest and RpcResponse interfaces look like - although since your concrete implementations DummyRpcRequest and DummyRpcResponse don't implement any methods, I guess that means that the two interfaces are blank.
The fact that the RpcRequest takes a parameter of a subclass of RpcResponse, though, implies that there's some sort of relationship there. Perhaps, in future, you intend to have a method sig in RpcRequest that say, returns a subclass of (the type of RpcResponse you created the concrete implementation of RpcRequest with). It's hard to offer more suggestions without knowing exactly what you intend with this code.
A handler takes a RpcRequest<RpcResponse>, runs its execute method, and somehow (depending on implementation) returns an RpcResponse.
So I tested some code which I guess summarises your situation, and which works okay - if you want, you can blat this all into a file Test.java and compile/run it in textpad.
interface Response {
     String message();
class SpecificResponse implements Response {
     public String message() { return "Why hello there!"; }
interface Request<E extends Response> {}
/* This Request subclass stores a canned, fixed Response object. */
class StoredResponseRequest<E extends Response> implements Request<E> {
     private E myResponse;
     public StoredResponseRequest(E useThis) {
          myResponse = useThis;
      public E getStoredResponse() {
          return myResponse;
/* A handler <B, A> is able to take in a B (extends Request<A>), and return an A. */
interface Handler<B extends Request<A>, A extends Response> {
     public A execute(B request);
/* A HandlerForStoredResponseRequests works by assuming that all the Request<A>s it gets passed are, in fact,
     StoredResponseRequest<A>s. It therefore extracts the necessary A from the object and returns it.  */
class HandlerForStoredResponseRequests <B extends Request<A>, A extends Response> implements Handler<B, A> {
     public A execute(B sreq) {
          return ((StoredResponseRequest<A>)sreq).getStoredResponse();
class Test {
     public static void main(String[] argz) {
          Request<Response> request = new StoredResponseRequest<Response>(new SpecificResponse());
          System.out.println( execute(request).message() );
     public static <T extends Request<E>, E extends Response> E execute(T request) {
          Handler<T, E> stuffHandler = new HandlerForStoredResponseRequests<T, E>();
          return stuffHandler.execute(request);
}

Similar Messages

  • How to change the Ethernet Interface name in Solaris 10

    I have to install Oracle 10G RAC on three nodes with different ethernet cards, but the ethernet interface name must be the same which is the precondition for Oracle RAC installation.
    So I want to know how can I change the ethernet name in Solaris.
    For example, the ethernet name in the OS is "ce0", how can i change the interface name "ce0" to "e1000g0".
    bash-3.00# dladm show-dev
    ce0 link: unknown speed: 1000 Mbps duplex: full
    ce1 link: unknown speed: 100 Mbps duplex: half
    ce2 link: unknown speed: 100 Mbps duplex: half
    ce3 link: unknown speed: 100 Mbps duplex: half
    ce4 link: unknown speed: 100 Mbps duplex: half
    ce5 link: unknown speed: 0 Mbps duplex: unknown
    Thanks in advance.

    s-wilson wrote:
    You can't. The ce or e1000g refers to the driver as well as the adapter itself. The only exception I am aware of is: the ipge and e1000g which both refer to the Intel Pro 1000.I'm pretty sure I've renamed a driver in the past (and all references to it in name_to_major, path_to_inst, driver_aliases, and minor_perm) and had it function just fine after 'plumb'ing it up. However I just tested this by trying to turn a 'pcn' driver into a 'foobar' driver on a vmware box. It looks like everything works except some internal bits of the driver continue to create one file with 'pcn' in the name instead of 'foobar'. And since this is Solaris 10, the /devices filesystem is dynamic and read-only. I can't seem to force the change.
    So while this may be possible with some drivers (and maybe only on older versions of the OS), it doesn't seem to be generally possible for all drivers on Solaris 10.
    Darren

  • Generic interface in abstract super class

    hello java folks!
    i have a weird problem with a generics implementation of an interface which is implemented in an abstract class.
    if i extend from this abstract class and try to override the method i get this compiler error:
    cannot directly invoke abstract method...
    but in my abstract super class this method is not implemented as abstract!
    do i have an error in my understanding how to work with generics or is this a bug in javac?
    (note: the message is trown by the eclipse ide, but i think it has someting to do with javac...)
    thanks for every hint!
    greetings daniel
    examples:
    public interface MyInterface <T extends Object> {
       public String testMe(T t);
    public abstract class AbstractSuperClass<T extends AbstractSuperClass> implements MyInterface<T> {
       public String testMe(T o) {
          // do something with o...
          // now we have a String str
          return str;
    public final class SubClass extends AbstractSuperClass<SubClass> {
       @Override
       public String testMe(SubClass o)
          return super.testMe(o);
    }

    Hi Wachtda,
    Firstly, T extends Object is redundant as all classes implicitly extend the Object class.
    Therefore :
    public interface MyInterface <T> {
       public String testMe(T t);
    }Secondly, abstract classes may have both abstract and non-abstract instance methods. Also, two methods, one abstract and one non-abstract, must have a different signature.
    The following example will give a compile error because the methods share the same signature :
    abstract class Test {
         public void sayHello() {
              System.out.println("Hello");
         abstract public void sayHello();
    }Therefore, to make an interface method as abstract would simply block the possibility of implementing it.
    BTW, you can do this :
    abstract class Test {
         public void sayHello() {
              System.out.println("Hello");
         abstract public void sayHello(String name);
    }Finally, there's no bug in javac.

  • How to Refer an component

    Hello All,
    How to refer an item from a component..
    For example,
    In a Report I have two columns,
    ID         NAME
    How to refer the id column.(I need to use it in a SQL query)Thanks in advance...

    Hi Davy,
    Just check this help-http://help.sap.com/saphelp_nw2004s/helpdata/en/79/69f9e32bbb9f41aa4043c4c4989a41/frameset.htm
    <i>How can I refer to Message Type or Data Type that is not defined locally in one namespace of my component?</i>
    This you can refer directly.. But you need to create message Interfaces.
    Thanks,
    Moorthy

  • RE : How to bind to two interfaces

    Gabriel,
    You can advertise an environment on two ip addresses
    by using multiple IP addresses instead of one in
    FORTE_NS_ADDRESS. Specify the IP addresses separated by semicolon
    setenv FORTE_NS_ADDRESS ip1:5000;ip2:5010;ip3:5012
    You will also have to define FORTE_LOCATIONS to point
    to these IP addresses so that Forte runtime knows where
    to find the environment and services. In this case you
    will always use the socket number 0 to allow Forte to
    pick any available socket.
    Ajith Kallambella M.
    Subject: How to bind to two interfaces
    Hi!
    On one of our Solaris servers we are facing the problem that we have
    two
    network interface cards in it.
    And we would like to access Forte on it through both cards. (avoid
    unnecessary network traffic)
    As far as I understand Forte needs a fix IP address to bind to (thus
    bound to one card).
    I tried to use 0.0.0.0 as a jolly-joker for all cards, but failed.
    Has anybody an idea? Or is it a restriction?
    If so, does Forte plan to improve the product in this way?
    GA'BRIEL, A'kos ([email protected]) Fax: (+36-1) 4312-977
    UNIX & Internet consultant Phone: (+36-1) 4312-979
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>
    Get Free Email and Do More On The Web. Visit http://www.msn.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hello
    I assume you want to create multiple instance of your class.
    Assuming that you class is NOT a singleton then simply repeat the CREATE OBJECT statement as many times as you need.
    TYPES: begin of ty_s_class.
    TYPES: instance   TYPE REF TO zcl_myclass.
    TYPES: end of ty_s_class.
    DATA:
      lt_itab      TYPE STANDARD TABLE OF ty_s_class
                     WITH DEFAULT KEY,
      ls_record  TYPE ty_s_class.
      DO 10 TIMES.
        CLEAR: ls_record-instance.
        CREATE OBJECT ls_record-instance.
        APPEND ls_record TO lt_itab.
      ENDDO.
    Regards
      Uwe

  • Generic Interface

    Hi
    I am working with a company which developed an application for procurement and selling to the client. My company has a
    client which is using Oracle E-business Suite R12 and want me to create an interface between the Procurement application
    ans Oracle E-business Suite R12. Now the requirement of my company is to develop a generic interface which can be used
    with any Oracle e-business Suite R12 instance regardless of the different setups. Can anyone give me an idea regarding the same.
    I am an Oracle E-Business Suite developer but the requirement seems new to me.
    Regards
    Ali

    I do not have many details about the generic interface you are planning to build, but you can refer to iREP/eTRM website for details about Oracle Procurement APIs.
    http://irep.oracle.com/index.html
    http://etrm.oracle.com/pls/etrm/etrm_search.search
    http://download.oracle.com/docs/cd/B53825_03/current/html/docset.html
    Thanks,
    Hussein

  • Generic interface methods

    The problem is that I want a generic interface that has a method that returns type T. And concrete implementations specify the type T and the method body.
    Given the interface and class below, why do I get an unchecked conversion warning, and how do I eliminate it? Or is there an alternative?
    Warning displayed by eclipse:
    Type safety: The return type String of the method convert(String) of type AsciiStringConverter needs unchecked conversion to conform to the return type T of inherited method.
    This code compiles...
    public interface StringConverter<T>
        public T convert(String string);
    public class CharacterValueConverter implements StringConverter<int[]>
        public int[] convert(String string) //unchecked conversion warning
            int[] values = new int[string.length()];
            for (int i = 0; i < string.length(); i++)
                values=(int)string.charAt(i);
    return values;
    Thanks,
    C.

    Here is the code that is used to test the CharacterValueConverter...
    public class Test
        public static void main(String[] args)
            int[] values = new CharacterValueConverter().convert("abc");
            for(int i : values)
                System.out.println(i);
    }

  • How to refer report items?

    Hi,
    How to refer the report items?
    I have standard sql report region contains 3 columns.
    doc_id,doc_name and No_units.all three items are apex item.
    below is my sql query for report.
    APEX_ITEM.SELECT_LIST_FROM_QUERY(17,doc_id,'select s_id from         
    sales')"doc id",
    apex_item.text(18, doc_name) "doc name",
    apex_item.text(19,  No_units) " No units",null
    from sale_docMy intention is to fire a dynamic action when event change in doc_id. So in when tab what i have to assign in item(s) fields for doc_id. i gave *#doc_id#* in items(s) field it doesnt work.
    how to resolve this?

    any help?

  • How to refer one view from another view?

    Hi,
    I have 2 views in my Adobe Flash Builder mobile app. I need to refer the first view in my second view.
    How to refer one view from another view? Or how to create a reference to a view wherever needed?

    I don't need any data from my first view. In a certain flow, I need to make my first view to be invisible.
    for eg., My First view is in portrait mode. I change the device to Landscape. In the landscape mode, I want to show a completely different view (second view).
    In this case, what happens is, I see my first view in Landscape mode for a second. Then the second view appears. When I change to Landscape mode, only the second view should be seen. I need to make my first view to be completely invisible in the OnOrientationChanging event of
    StageOrientationEvent
    As stage object and StageOrientationEvent works at application level, I need to know how to refer my first view object in the application level.
    private function onOrientationChanging(soe:StageOrientationEvent):void
          MyFirstView.Visible = False; ====> don't know how to refer MyFirstView here
    Is my question clear now?

  • How to refer a column value of a single row in conditional column display?

    Hello,
    does anybody have an idea, how i can refer a column value of a single row in conditional display of a column?
    So my idea is, that a report has a column, which value is only displayed, when another column value of this row has a specific value.
    I want to solve this problem with condition type: PL/SQL Function Body returning a boolean.
    But I do not know how to refer the column value of each single row!
    Thank you,
    Tim

    Here's a solution that, to me, seems easier to implement but, that's, of course, in the eye of the implementer.
    Rather than using APEX to generate a link column for you, actually create the link as part of your SQL.
    select '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>' CONTACT_LINK, ...
    etc.
    Test this out. You'll see that it works just like making a column a link using the column attributes.
    Next, we'll change the SQL to use a DECODE statement to either display the link or nothing depending on what your criteria is. For example, let's assume you only want a link for active contacts.
    select Decode( CONTACT_STATUS, 'A', '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>', NULL ) CONTACT_LINK, ...
    etc.
    This will not display the link in any rows in which the CONTACT_STATUS is not active, i.e. "A"
    -Joe

  • How to refer a .jar file in the code.

    How to refer a .jar file in the code.
    I want to use a library dnsjava.jar, which I download from the internet. I want to know how to refer it
         If I am compiling the code on Solaris
         If I compiling the code on windows using eclipse.
    I added the following line in my code to refer to this library. But it always complains of not found the class
    import org.xbill.DNS.*;
    I tried the following to add this library but did not work
    On eclipse/windows: Went to window-> preferences -> BuildPath _> class path Variable.
    On Solaris: Could not add this library /opt/java_reference/v1.6.0_04/jre/lib. Although I am logged in as root, but not able to add the library there. Complains of Permission denied.

    Set the classpath option when compiling.
    javac -classpath /path/to/lib/dnsjava.jar YourProgram.java
    I don't use Eclipse, but it probably has a library list on your project preferences. Add it there.
    Regards,
    Henrique Abreu

  • How to create a login interface in labview PDA module?

    How to create a login interface in labview PDA module? So that it checks with a list of usernames and passwords and allow to go to another VI?
    Anu

    Anu,
    I've attached a really short example that does something like what you're talking about.  It just compares the user's username and password a pre-determined username and password and then "logs the user in" based on that comparison.  Like Greycat said, you probably want to store this username and password info in some sort of file on the PDA that's in an encrypted format for both security and flexibility of your application.
    I hope this helps,
    Justin D.
    Applications Engineer
    National Instruments
    Attachments:
    LoginVI.vi ‏17 KB

  • How to refer field of DataSource in transfer rule for DSO object  in BI 7.0

    hello Gurus,
    I am new to BI 7.
    pls tellme how to refer field of DataSource in transfer rule for DSO object.
    I will assign points to proper answer.
    Praveen.

    hi praveen,
    when u create the transformation for the DSO, it asks for the source. in that you enter your datasource, then you get the datasource fields on one side and the rules in the middle and the DSO objects on the other side. whichever field of DataSource you want to refer in tranformation rule, just connect that field to the rule for the required object of the DSO.
    hope this will help you.
    regards
    vaibhav

  • How to refer to Excel tables (ListObjects) in PowerPivot

    I am trying to figure out how to import ListObjects in PP.
    As far as I can tell PP does not seem to "see" range names that refer to entire ListObjects i.e. =T_DTL[#All], while it "sees" ranges that refer to direct cells i.e. =Dtl!$O$3:$V$46.
    Is that correct and is there a way to work around it?
    The reason I am asking is that the tables I want to work with do not necessarily start on line 1 and PP references entire worksheets i.e. Dtl$, as per my example above.I tried different approaches with dynamic ranges but PP refuses to present them as choices
    while Selecting Tables and Views. The only way to achieve what I need is by creating named ranges with hardcoded start and end, which is a bit odd since Tables (ListObjects) are a powerful tool since Excel 2007 and I would expect a stronger integration with
    other powerful tools such as PowerPivot.Apart from the overhead of having to go through each workbook and define a range for every Table I wish to use.
    Am I missing something here?

    My PowerPivot attempt was abruptly broken about a month ago, hence my very late reply.
    Peter is quoting VBA statements on how to refer to a Table (ListObject), which is familiar to me as I am also writing VBA code. Unfortunately my problem is in interactive mode, not in code execution.
    When we open a file's PowerPivot window from within Excel we are prompted to select the tables we want to work with. That is where I cannot see my ListObjects / Tables. I am presented with all ranges that PowerPivot sees as declared in the file that I am
    opening (as in Formulas / Names Manager) EXCEPT for the ListObjects. Those are missing.
    Try it if you will and let me know if this behavior is relevant only to my installation or to yours as well.
    George Thalassinos

  • How to refer to a protected class outside the enclosing package

    Hi all,
    At the page 357 of the book Java Language Specification(Second Edition), when saying about checking accessibility of Type and Method, they concern Let C be the class containing the method invovation T.m, if T is in a different package than C, and T is protected then T is accessible if and only if C is a subclass of T. I just wonder how to refer a protected type outside the package it declared.
    For example,
    package test;
    public class test {
    static protected class protectedTest {
    public void foo() {..}
    in another package
    import test.*;
    class subtest extends test.protectedTest {  <- error
    Anyone can give me an example showing an invocation directly to foo() declared in class test.protectedTest ? The invocation should appear outside package test.
    Thanks,
    Ha Chau

    The protected inner class would be accesible only within a class which extends test, where you could either use or extend it as in:
    class subtest extends test {
        private static class sub2 extends protectedTest {
               }

Maybe you are looking for

  • Failure to launch Acrobat following Yosemite upgrade

    I've just installed Yosemite and now, when I try to open Acrobat I get a message that it 'cannot be launched. You must launch at least one other suite component (such as Adobe Photoshop) before launching Acrobat'. I have followed this instruction and

  • JSF component processing and rendering order

    Hi, I have a request level managed bean that has two list boxes on it. The first is always displayed, and the second should only ever be displayed when the first one has had a value selected in it. So, I use something like this: <h:selectOneListbox s

  • Applying field exclusion , if A then B.

    Hi, I am wondering if it's possible to 'switch' off fields based on the end-user's response. To simplify things, I have this example:  I have 3 fields.  If the answer for the (3rd) field is checked, then it negates all responses from 1-2 and thus, th

  • Multiple Units of Measurements for a single item

    Hi all, How do I maintain multiple units of measurements for a single Item/  I have a scenario where purchase orders are being made for sand in Metric Tons, Tons, Kgs and Cubit Feets.  Each measurement is being used at each construction site of the c

  • HT1338 preview does not work with mountain lion

    I updated my mid 2011 mac mini to mountian lion and i find Preview and all of MS Office 2011 for MAC fails to work I can cut and paset the logs, but lets astart with assessing whagt does not work with Mountain Lion.