Generics with multiple interfaces

I'm trying to figure out why the following is not valid:
public class MediaService<L extends Deque<MediaFile> & List<MediaFile>> {
        L x = new LinkedList<MediaFile>();
}Gives:
Type mismatch: cannot convert from LinkedList<MediaFile> to LSeeing as LinkedList implements both these interfaces, I would expect this to be legal. What else is the use of the & operator in Generics?

lhunath wrote:
Basically:
public static <T extends Deque<MediaFile> & List<MediaFile>> T newMediaList() {
return new LinkedList<MediaFile>();
It is possible to do this using covariant return types and a generic abstract factory, like this:
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
public class GT20 {
   public static void main(String[] args) {
      DequeListFactory<String, ?> factory = new LinkedListFactory<String>();
      Deque<String> d = factory.create();
      List<String> l = factory.create();
   private interface DequeListFactory<T, L extends Deque<T> & List<T>> {
      L create();
   private static class LinkedListFactory<T> implements DequeListFactory<T, LinkedList<T>> {
      @Override
      public LinkedList<T> create() {
         return new LinkedList<T>();
}However, I would seriously question the use of such a factory. If you really have a need for a union of interfaces (I would suggest a design that requires/allows users to use your objects as Lists and Deques, something is seriously wrong), I would create such a union and use that in your contract. Java doesn't allow anonymous unions as you're trying to do, and using generics is just a hack. Here's what I might consider:
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
public class GT21 {
   private interface ListDeque<T> extends List<T>, Deque<T> {}
   private interface MyInterface<T> {
      ListDeque<T> getListDeque();
   private static class MyClass<T> implements MyInterface<T>{
      @Override
      public ListDeque<T> getListDeque() {
         return new MyLinkedList<T>();
   private static class MyLinkedList<T> extends LinkedList<T>
      implements ListDeque<T> {
}

Similar Messages

  • Loading datastore with multiple interfaces

    We want to have multiple interfaces load the same datastore. Each of these processes can run in parallel. The problem we have is when the LKM fires it creates a C$ table with the same name in each interface. Is there a way to prevent this from creating a duplicate name?
    Troy

    Hi-
    Whenever ODI creates a loading table it will add the prefix with the name of C$ with the name of your table name. That is the reason you are getting the table name with more than 30 characters.
    Loading table prefix is a mandatory field that should be there in your physical schema definition. So whenever you are creating a table it should not exceed the characters defined in the technology or database.
    Thanks,
    Saravanan Rajavel

  • Generics bug with multiple interface inheritance?

    Hi,
    I've noticed what I believe to be a compiler bug (I am getting an error where I believe none should exist). Can someone please comment on the following use-case?
    interface Interface1<SelfType extends Interface1<SelfType>>
    interface Interface2
    class Superclass implements A<Superclass>
    class Dependant<Type extends Interface1<Type>>
       public static <Type extends Interface1<Type>> Dependant<Type> getInstance(Class<Type> c)
         return new Dependant<Type>();
    class Subclass extends Superclass implements Interface2
      Subclass()
        Dependant<Subclass> dependant = Dependant.getInstance(Subclass.class);
    }The problem is that in the above code the compiler will complain that Dependant<Subclass> is illegal because "Subclass is not within its bounds" . The compiler requires that Subclass implement Interface1 and Interface2 directly and implementing Interface1 by extending Superclass doesn't seem to count. If you replace Subclass's definition by "class Subclass implements Interface1<Subclass>, Interface2" the problem goes away.
    Is this a compiler bug?
    Thank you,
    Gili

    Actually now I understand what you mean.... Ok, now I am going to modify the problem slightly and add Interface2 into the picture. The new code is:
    interface Interface1<SelfType extends Interface1<SelfType>>
    interface Interface2
    class Superclass implements Interface1<Superclass>
    class Dependant<Type extends Interface1<Type>>
       public static <Type extends Interface1<Type> & Interface2> Dependant<Type> getInstance(Class<Type> c)
         return new Dependant<Type>();
    class Subclass extends Superclass implements Interface2
      public Subclass()
        Dependant<Subclass> dependant = Dependant.getInstance(Subclass.class);
    }Now, previously I could replace:
    Dependant<Subclass> dependant = Dependant.getInstance(Subclass.class);
    with
    Dependant<Superclass> dependant = Dependant.getInstance(Superclass.class);
    and it solved the problem, but now that Type must implement Interface2 I cannot.
    The reason I added this requirement is that this is actually what is going on in my applicationI had made mistakely omited this detail from the original use-case.
    Can you think up of a possible solution to this new use-case?
    Thanks,
    Gili

  • Timesten replication with multiple interfaces sharing the same hostname

    Hi,
    we have in our environment two Sun T2000 nodes, running SunOS 5.10 and hosting a TT server currently in Release 7.0.5.9.0, replicated between each other.
    I would like to have some more information on the behavior of the replication w.r.t. network reliability when using two interfaces associated to the same hostname, the one used to define the replication element.
    To make an example we have our nodes sharing this common /etc/hosts elements:
    151.98.227.5 TBMAS10df2 TBMAS10df2-10 TBMAS10df2-ttrep
    151.98.226.5 TBMAS10df2 TBMAS10df2-01 TBMAS10df2-ttrep
    151.98.227.4 TBMAS9df1 TBMAS9df1-10 TBMAS9df1-ttrep
    151.98.226.4 TBMAS9df1 TBMAS9df1-01 TBMAS9df1-ttrep
    with the following element defined for replication:
    ALTER REPLICATION REPLSCHEME
    ADD ELEMENT HDF_GNP_CDPN_1 TABLE HDF_GNP_CDPN
    CHECK CONFLICTS BY ROW TIMESTAMP
    COLUMN ConflictResTimeStamp
    REPORT TO '/sn/sps/HDF620/datamodel/tt41dataConflict.rpt'
    MASTER tt41data ON "TBMAS9df1-ttrep"
    SUBSCRIBER tt41data ON "TBMAS10df2-ttrep"
    RETURN RECEIPT BY REQUEST
    ADD ELEMENT HDF_GNP_CDPN_2 TABLE HDF_GNP_CDPN
    CHECK CONFLICTS BY ROW TIMESTAMP
    COLUMN ConflictResTimeStamp
    REPORT TO '/sn/sps/HDF620/datamodel/tt41dataConflict.rpt'
    MASTER tt41data ON "TBMAS10df2-ttrep"
    SUBSCRIBER tt41data ON "TBMAS9df1-ttrep"
    RETURN RECEIPT BY REQUEST;
    On this subject moving from 6.0.x to 7.0.x there has been some changes I would like to better understand.
    6.0.x reported in the documentation for Unix systems:
    If a host contains multiple network interfaces (with different IP addresses),
    TimesTen replication tries to connect to the IP addresses in the same order as
    returned by the gethostbyname call. It will try to connect using the first address;
    if a connection cannot be established, it tries the remaining addresses in order
    until a connection is established.
    Now On Solaris I don't know how to let gethostbyname return more than one interface (the documention notes at this point:
    If you have multiple network interface cards (NICs), be sure that “multi
    on” is specified in the /etc/host.conf file. Otherwise, gethostbyname will not
    return multiple addresses).
    But I understand this could be valid for Linux based systems not for Solaris.
    Now if I properly understand the above, how was the 6.0.x able to realize the first interface in the list (using the same -ttrep hostname) was down and use the other, if gethostbyname was reporting only a single entry ?
    Once upgraded to 7.0.x we realized the ADD ROUTE option was added to teach TT how to use different interfaces associated to the same hostname. In our environment we did not include this clause, but still the replication was working fine regardless of which interface we were bringing down.
    My both questions in the end lead to the same doubt on which is the algorithm used by TT to reach the replicated node w.r.t. entries in the /etc/hosts.
    Looking at the nodes I can see that by default both routes are being used:
    TBMAS10df2:/-# netstat -an|grep "151.98.227."
    151.98.225.104.45312 151.98.227.4.14000 1049792 0 1049800 0 ESTABLISHED
    151.98.227.5.14005 151.98.227.4.47307 1049792 0 1049800 0 ESTABLISHED
    151.98.227.5.14005 151.98.227.4.48230 1049792 0 1049800 0 ESTABLISHED
    151.98.227.5.46050 151.98.227.4.14005 1049792 0 1049800 0 ESTABLISHED
    TBMAS10df2:/-# netstat -an|grep "151.98.226."
    151.98.226.5.14000 151.98.226.4.47699 1049792 0 1049800 0 ESTABLISHED
    151.98.226.5.14005 151.98.226.4.47308 1049792 0 1049800 0 ESTABLISHED
    151.98.226.5.44949 151.98.226.4.14005 1049792 0 1049800 0 ESTABLISHED
    Tried to trace with ttTraceMon but once I brought down one of the interfaces did not see any reaction on either node, if you have some info it would be really appreciated !
    Cheers,
    Mike

    Hi Chris,
    Thanks for the reply, I have few more queries on this.
    1.Using the ROUTE CLAUSE we can use multiple IPs using priority level set, so that if highest priority level set in thr ROUTE clause for the IP is not active it will fall back to the next level priority 2 set IP. But cant we use ROUTE clause to use the multiple route IPs for replication simultaneously?
    2. can we execute multiple schema for the same DSN and replication scheme but with different replication route IPs?
    for example:
    At present on my system, I have a replication scheme running for a specific DSN with stand alone Master-Subscriber mechanism, with a specific route IP through VLAN-xxx for replication.
    Now I want to create and start another replication scheme for the same DSN and replication mechanism with a different VLAN-yyy route IP to be used for replication in parallel to the existing replication scheme. without making any changes to the pre-existing replication scheme.
    for the above scenarios, will there be any specific changes respective to the different replication schema mechanism ie., Active Standby and Standalone Master Subscriber mechanism etc.,
    If so what are the steps. like how we need to change the existing schema?
    Thanks In advance.
    Naveen

  • Setting The Default Route in a Jumpstart Install with Multiple Interfaces

    Greetings,
    I'm performing a Jumpstart install on a SPARC v240 server, which has multiple network interfaces. I'm trying to configure all of the interfaces as part of the Jumpstart setup. However, Jumpstart doesn't like the default route that I'm supplying. If I add the default_route parameter anywhere but under the first interface, Jumpstart complains that the default route is missing (by making me add it after it dumps out to the suninstall screens. If I add the default route under the first interface, Jumpstart dumps me to the suninstall screen which says that the route could not be added.
    What am I doing wrong ? Am I trying to get Jumpstart to do something that it won't do ?
    Here is my sysidcfg file. The file shown below will cause Jumpstart to dump to the suninstall screen, which will indicate that the route cannot be added:
    Please wait while the system information is loaded... /
    Please wait while the system is configured with your settings...
    The route provided could not be added at this time. If you wish to accept the
    route provided, press 'Accept' and the address will be added for reboot,
    otherwise press 'Cancel' and provide another address.
    1. Accept
    2. Cancel
    Enter the number corresponding to your choice [1]
    Here is the sysidcfg file:
    name_service=NONE
    network_interface=bge0
    {hostname=conwe125
    ip_address=10.15.8.122
    netmask=255.255.0.0
    default_route=158.73.175.254
    protocol_ipv6=no}
    network_interface=bge1
    {ip_address=10.15.9.122
    netmask=255.255.0.0
    protocol_ipv6=no}
    network_interface=bge3
    {ip_address=158.73.175.117
    netmask=255.255.0.0
    protocol_ipv6=no}
    network_interface=ce0
    {ip_address=10.16.0.208
    netmask=255.255.0.0
    protocol_ipv6=no}
    network_interface=ce3
    {ip_address=158.73.175.118
    netmask=255.255.255.0
    protocol_ipv6=no}
    root_password=5Z5XTytD2Eddo
    security_policy=NONE
    terminal=vt100
    system_locale=en_US.ISO8859-1
    timezone=US/Eastern
    timeserver=localhost
    Thanks In Advance,
    Chris Hanrahan

    That sysidcfg seems a bit odd anyway, have you by any chance put the different interfaces of your jumpstart server into it? Normally you won't need to specify a default router since the jumpstart will figure it out anyway.. Does your jumpstart server have an interface on each network you want to jumpstart?
    7/M.

  • Dual uplinks with single 5400 and single 6509 (with multiple interface cards)

    I have a single 5400 with two gige ports and a single 6509 with dual gige line cards.
    What would be the best method for running them with dual connections in case an interface or line card goes bad?
    Thanks in advance.

    Thank you for the reply Joseph. I swear I've ran SLA on 6500's before. This box is running IOS 12.2 so maybe that's the culprit.
    I found a simple way to configure both devices redundantly using administrative distanced routes pointing through a specified interface. On the 6509, the routes point to a loopback address on the 5400, on the 5400 it's configured as default routes. Like this document explains:
    http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/27082-ip-static-routes.html
    Seems to work like a champ.

  • [solved] Arch linux access point with multiple interfaces for the NAT

    Hi, I have a router running Arch linux. It is connected via LAN (let's call it eth0) to the internet. It has a second LAN interface, eth1, and a wireless interface in master mode, wlan0.
    Now, Everything works perfectly except providing network connectivity on eth1 and wlan0 simultaneously. I followed the guide in the "Internet share" wiki article and use dnsmasq/hostapd for the AP. It appears as if all traffic from the router is sent to the wlan0 interface, even if it came in through eth1 (for example, dhcp requests). I cannot really find information how to solve this. The words "bonding" and "iptables" are floating around, but there is not really an easy to understand tutorial for this.
    What do I need to do to use both the eth1 and wlan0 interface (for different clients!) on my router?
    Best regards, and thank you in advance
    Jan Oliver
    /e: This seems to be my problem: http://www.novell.com/support/kb/doc.php?id=7000318 How do I solve this using the usual iptables? (The way described in the article doesn't work: "RTNETLINK answers: No such process" errors.)
    Last edited by janoliver (2013-09-25 22:24:53)

    Or you could bridge eth1 and wlan0, and make dnsmasq bind/listen on that bridge...

  • One SOAP-SOAP scenario with multiple interfaces

    Hi,
    I am developing a scenario SOAP-SOAP using PI 7.10 Sp6.
    The wsdl has around 8 service interfaces and i am planning to create 8 Outbound and 8 Inbound interfaces for the same mesg type and create a scenario without MM or Operation mapping.
    If I plan to use only one Sender CC and only one configuration scenario for this developement, how do I provide my end point in the following format?
    http://<host>:<port>/XISOAPAdapter/MessageServlet?senderParty=&senderService=<SEND_BS>&interface=Interface_Out&receiverParty=&receiverService=<RECV_BS>&interfaceNamespace=http://test.com/xi/SAP/
    Venkat.

    Raj/Pavan,
    I added other service interfaces to one service interface in operations.
    But the request messages have not appeared because of which it is throwing an exception when I activate the message interface.
    I do not have problems on the receiving side, One receiver CC should take care of the problem as we dont specify in the recvr SOAP action attribute.
    I am worried about sender side only !
    Thanks,
    Venkat.
    Just now I created a dummy DT, MT and SI and added this to existing even that request message did not show up in the SI.
    Edited by: Venkat A on Jun 16, 2010 11:03 AM

  • TCPDump with multiple interfaces

    Hi,
    I'm wondering if its possible to use TCPDump to capture traffic (to a file) from all interfaces on a server simulteanously under Solaris 10? From the TCPDump man pages, this seems to be possible under Linux by specifying "-i any" but this doesn't seem to work in Solaris. Would any know if there is an equivilent option, or even a more round-about way of achieving this?
    One think I thought was I could start seperate TCPDump processes for each interface, writing the output of each interface to seperate files. Then after capture was complete, we would cat all the files together and use a program such as Ethereal or Wireshark to sort and interpret the output. Has anyone ever done this and or know if it would work?
    Thanks,
    - Adrian

    Have you tried snoop? It can only capture from one interface at a time, but it may be worth a look since it is the native Sun utility used to capture network packets on a Solaris machine.
    john

  • Referencing component usage with different interfaces

    Hi experts,
    First of, some details;
    - I'm on NW04.
    - I have a generic WDP interface named: IModelComponent
    - I have a specific WDP interface named: IEmployee
    - I have a WDP component implementing both interfaces named: Employee
    Now I want to create some sort of component factory component. In this component I have:
    - defined 'Used Web Dynpro Component' IModelComponent
    - Created a method getComponentUsage (static names just for clearer example):
    wdThis.wdGetIModelComponentComponentUsage().createComponent("x.x.x.org.mdc.empl.EmployeeModelComponent", "x.x/x~org~mdc~employee");
    return wdThis.wdGetIModelComponentComponentUsage();
    Next I have a client view component which refers to the component factory and the employee interface
    - defined 'Used Web Dynpro Component' IEmployee
    - defined 'Used Web Dynpro Component' ComponentFactory
    - On request I call the factory method getComponentUsage
    Now, when I use this component usage the following way:
    wdThis.wdGetIEmployeeComponentUsage.enterReferencingModeUnsafe(receivedComponentUsage);
    Then things work perfectly! This is basically what I want to achieve.
    But the method enterReferencingModeUnsafe is deprecated, so I wonder if there are other, better ways to achieve usage referencing of components with multiple interfaces (create as one interface, use as the other interface).
    Looking forward to any comment.
    Grtz,
    Chris
    Edited by: Chris van de Wouw on Feb 6, 2010 5:20 PM

    Basically solved it myself. I'm now using the actual required component usage (IEmployee) as entry point for the factory, which will create the correct implementation component (based on configuration). For IModelComponent specific methods I can use the getInterfaceController() of the employee component usage class and cast it to the model component interface.

  • DHCP and multiple interfaces

    Is it better to list each machine and interface as a separate entry in 10.5.7 DHCP or make a single entry with multiple interfaces?
    I am looking at grouping my Wireless AP, instead of having to list each one separately.
    For example:
    MAIN-MDF00-01
    XX:XX:XX:XX:XX:XX 10.0.2.1
    Or
    MDF-AP
    XX:XX:XX:XX:XX:XX 10.0.2.1
    XX:XX:XX:YY:YY:YY 10.0.2.2

    Joe,
         Currently you cannot base the anchoring on the AP group.  It is only based on the SSID.
    Now, do you really need to split up the guest into different subnets?  Or are you concerned about the AP groups?
    If you truly need to break up the guest to different subnets, then you would need to create different SSID on the internal and anchor controller.  Then on the anchor, link to the appropriate interface.
         If you are concerned about the AP group, don't be.  Just because you are using the AP group, doesn't meant that all the guest ssid can't link to the same interface, they can.  You can even create a dummy interface on the internal WLC, so that if the anchoring doesn't work, they do not get an address.
    Cheers,
    Steve
    If  this helps you and/or answers your question please mark the question as "answered" and/or rate it, so other users can easily find it.

  • Mapping in Services Interface with multiple operation... ?

    Hi ALL,
    I have a SOAP to SOAP scenario here Just PI 7.1 with EHP1 acting a bus no mapping nothing .
    1) I have the WSDL file from the receiver system with multiple synchronous operations  in it ..i imported the wsdl as External Definition .. i used the same the WSDL file to create the sender Service interface also...
    when i created the service interface with the operation in it , i just gave the same operation name from the WSDL.this i followed for the sender and receiver service interface.
    1)now the issue is do i need any operation mapping if the service interface has more than one operation ...?
    2) I compelted the scenario without any operation mapping ..but i am getting this error ..Problem occurred in receiver agreement for sender -ICRM_D to receiver -EXACTTGETWEBSERVICE_D,http://ICRMtoExactTaetWebservice.com.si_os_ICRM_EXACTTETWEBSERVICE: No standard agreement found for , ICRM_D, , EXACTTARGEBSERVICE_D, http://ICRMtoExactarebservice.com, si_os_ICRM_EXACGETWEBSERVICE..?
    pls help me in this issue..
    Thanks
    Souz

    you might want to read this /people/shabarish.vijayakumar/blog/2010/09/08/service-interface-and-multiple-operations--is-it-just-an-hype
    you will need to create additional configurations for multiple operations to be supported

  • Any possiblity to use single Inbound Service Interface with multiple Receiver Agreements

    Hi All,
    Scenario: PROXY to FILE.
    Requirement is to receive to two locations.
    Is it possible to use single Inbound interface with multiple Receiver Agreements. I tried using two operation in the Inbound Service Interface, and Operation Specific in Determination. But couldnt proceed further. Do I need to use seperate Service Interface for two receiver locations?
    Please suggest some solution.

    Hi Naveen,
    There is a possibility but in the case in the same server location with dynamic configuration: Placing file in two different directories using single receiver communication Channel
    With different location you would need to develop a new adapter module as Amit Srivastava explains and develops here Send File to Two Different Locations using Adapter Module
    Regards.

  • Interface with multiple msg.PM

    Hi, Experts,
    I’m considering the parallel migration to FS-PM from legacy system using migration solution.
    As far as I know, FS-PM has the business validation step (check data, recalculation the premium) after finishing the technical validation.
    To deal with the parallel approach for the business validation in the FS-PM, I would like to know that FS-PM can interface with the multiple msg.PM system.
    It means that 2 or 3 msg.PM can connect with a FS-PM system to reduce the migration time (or load balancing).
    My assumption may be wrong in the parallel migration. But I really want that multiple interface with msg.PM can be possible or not in terms of the technical aspects.
    Please let me know if you have some idea or relevant experiences.
    Thank you in advance.
    Best regards,
    Kyoungkeun

    Hi Kyoungkeun,
    If no reaction you should blog to Planet Insurance.
    If there is no reaction you should raise an internal message.
    Best regards
    Boris
    Boris Greven
    Insurance GTM Lead &
    Cloud Business Development
    IBU Insurance
    Visit Planet Insurance

  • Generic Extractor using Function module with Complex Interface

    Hi,
    Has anyone created Generic extractor using Function module with Complex Interface?
    What is the difference between Complex and Simple interface in Function module?
    Pls explain.
    Thanks,
    Gopal

    Hi,
    Go through this link.....
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d3219af2-0c01-0010-71ac-dbb4356cf4bf
    GTR

Maybe you are looking for

  • Unable to deploy ADF application to weblogic server

    Hi, We are developing ADF application using jDeveloper 11.1.1.1 and deploying to Weblogic Server 10.3.1. The application is working without any problems on 10.3.1 wblogic platform. We procured new 64 bit hardware and installed weblogic 10.3.2 and jde

  • Extension Manager in 10.1.3

    I see that the Extension Manager has been modified in 10.1.3. Till 9.0.5.2 I could disable or enable individual extensions to my will depending on what I use frequently (as sepaarte profiles). But I now see the core features come as two groups only J

  • Edge Animate and Raphael

    I'm using Raphael to draw some dynamic curves and it works basically. http://raphaeljs.com/ But one problem I found is that the mouseover/click events of all elements will not trigger if they are inside the Raphael paper area. Who deal with this prob

  • Running windows xp applications on a macbook air

    I need to run some legacy windows xp applications in my new macbook air.  What version of windows 7 I need to use?

  • CS5 crashing randomly once I upgraded the PC

    Hello, My system has Intel i5-2400, gigabyte Z68A-D3-B3 MB, 8GB kingston hyperx ram, Nvidia GT520. The system is running at 3.2ghz, which is 0.1 more than normal for that CPU. The system is stable and super fast for everything. PS works great, especi