Dynamic inheritance: wouldn't it be useful sometimes?

Hey, you ever have this problem?
You are holding a reference to an object of some class that was given to you by an external source. However you'd like to override one of the methods to do something else, and then perhaps call the original method. Wouldn't it be nice if you could somehow dynamically inherit from an already existing object.
An example might be, you get a ldap DirContext object from somewhere, It's possible under some circumstance you don't want to close it. What you'd like to do is override close, and possibly call the original objects close depending on some setting.
I realize the answer is 'use aggregation', not inheritance, but that can be a royal pain if the base object has alot of methods.
Hmm, maybe that's what java.lang.reflect.proxy is all about....
anyone?

Ok, first i agree with what you are saying (all), i'm just not happy about it. Here's an example.
I've got a class that provides an LDap DirContext, through a "get" type method. Sometimes I'd like this class to maintain a persistent connection to the ldap server (through this DirContext) other times I wan't the connection to be recreated each time. Either way, the user uses the same interface to get this objects so:
interface LDAPProvider
DirContext getDirectoryContext();
When it's in persistent mode, it just returns a member variable, when not it creates a new one.
Well, I certainly don't want the user calling close on this returned object, as it may be that i'm maintaining a persistent connection. I also do want them to call close in the case that it is not a persistent connection.
So, i do
interface MyLDAPProvider
DirContext getDirectoryContext();
void releaseDirectoryContext( DirContext ctx );
and hope the user calls my method and not close... Which is just plain ugly and dangerous.
Alternately i create a DirContext implementing object (luckily i can cause this is an interface, what to do if this is a class that's final) and use aggregation, and implement all the DirContext methods, yuck, just to get the one close behavior. Also oogley
I really just want to do, (get out the mallots)
ctx.extendInterface( new DirContext()
private MyLDAPProvider lp = getTheAboveProviderSomeHow();
public void close()
if (!lp.isPersistent())
super.close();
}

Similar Messages

  • I could do this before installing Maverick but cannot do it now.It is nice and convenient how Mac OS X Mail displays messages semi-automatically when you just select them. But wouldn't a bigger view of the mailbox be useful sometimes? Yes, and it's easier

    It is nice and convenient how Mac OS X Mail displays messages semi-automatically when you just select them. But wouldn't a bigger view of the mailbox be useful sometimes?
    Yes, and it's easier to get than you maybe think.
    Hide the Preview Pane and Delete Mail Without Opening It in Mac OS X Mail
    To hide the message preview pane in Mac OS X Mail:
    Double-click the bar that separates the message pane from the mailbox pane.
    Now, to delete any email:
    Highlight the message or messages you want to delete.Hold down the Command key while selecting with the mouse to highlight multiple emails and Shift to highlight a range.
    Press Del.
    To get the preview pane back, double-click the same bar again.
    Cannot do this now since installing Maverick

    It is nice and convenient how Mac OS X Mail displays messages semi-automatically when you just select them. But wouldn't a bigger view of the mailbox be useful sometimes?
    Yes, and it's easier to get than you maybe think.
    Hide the Preview Pane and Delete Mail Without Opening It in Mac OS X Mail
    To hide the message preview pane in Mac OS X Mail:
    Double-click the bar that separates the message pane from the mailbox pane.
    Now, to delete any email:
    Highlight the message or messages you want to delete.Hold down the Command key while selecting with the mouse to highlight multiple emails and Shift to highlight a range.
    Press Del.
    To get the preview pane back, double-click the same bar again.
    Cannot do this now since installing Maverick

  • I have an old (first generation) iMac that I still use sometimes for the applications that are on it. I was using it yesterday and unfortunately had a power cut. I went to turn it on today, and nothing at all happens. It's as though no power is getting to

    I have an old (first generation) iMac that I still use sometimes for the applications that are on it. I was using it yesterday and unfortunately had a power cut. I went to turn it on today, and nothing at all happens. It's as though no power is getting to it. I've checked the obvious things, changed the fuse, tried different cables, poked paperclips in reset holes, but nothing doing. I wonder if there is anyone who knows what might be wrong. I was hoping to get some of its content transferred soon, but I'm guessing that can't be done if it can't be started up. Many thanks, if you can help

    Hello,
    >It's as though no power is getting to it.
    Would it be correct to assume that no sounds at all can be heard? Also, no lights, not even green or amber at the power button?
    >unfortunately had a power cut.
    Was it possibly a power cut in connection with a thunderstorm? Any other evidence of higher than normal voltages (light bulbs, et cetera)? Has the line voltage been checked (measured with an appropriate voltmeter/multimeter)?
    If necessary, it would be possible to remove the hard drive, and then connect it to an external IDE/ATA to USB adapter (example below). That way you could gain access to files on the hard disk from another computer.
    http://www.newertech.com/products/usb3_universaldriveadap.php
    Jan

  • When I use dynamic link how do I continue using it after closing and reopening a project?

    Hi
    Im very new to AF
    I cant seem to find the answer to this in any tutorials.
    When I using dynamic link, how do I continue using it after closing and reopening a perm pro project?
    Thanks
    Philip

    Hi Kevin
    Thank you very much for such a quick reply.
    I actually figured it out. As usual it was fairly obvious solution.
    I opened both project at the same time.
    Thanks again and sorry for waisting your time.
    R
    Philip

  • Store Wouldn't Let Me Use Coupon?!?

    I'd appreciate any help that could be offered on this.  I went into the BB in Newington, NH yesterday to purchase the MacBook Air 13" for the advertised price of $899.99.  I recently moved and had a 10% off coupon that was with my change of address form from the post office.  I attempted to use the coupon and the sales associate wouldn't let me use the 10% off coupon, claiming that the sale price and the coupon couldn't be "stacked".  There is nothing on the coupon stating it couldn't be used on a sale price item, and nothing in the terms that would prohibit one from using it on the MacBook Air.  What gives?
    Coupon image attached.

    Hi figment 79,
    I apologize for the lateness of my reply. We’ve been working through a backlog of posts ever since Thanksgiving, so we appreciate your patience while waiting for assistance.
    When I was in college, having my own laptop was a great help to managing my time wisely when it came to writing papers and working on group projects. I completely understand wanting to buy a new computer before your current one decides to quit on you, so it’s regrettable to hear our Newington location didn’t allow your mover’s coupon to be used on your new MacBook Air purchase.
    As there isn’t anything in the terms and conditions of the coupon prohibiting its use on an Apple product or a sale item, I’m not sure why we would have denied your request.  However, I realize you’ve already purchased the computer, so please know I’ve sent you a private message to gather more information from you. You may view it by logging into the forum and clicking on the envelope icon in the upper right-hand corner of the page.
    Thank you for posting,
    Alex|Social Media Specialist | Best Buy® Corporate
     Private Message

  • How to dynamically create a treeview in sharepoint using javascript or jquery

    How to dynamically create a treeview in sharepoint using javascript that displays spsites ,spweb,splist

    Hi,
    In SharePoint 2010, we can customize web service and use Server Object Model to get all the SharePoint sites, webs and lists, then call the web service using jQuery and using the jQuery Treeview plugin to display the data.
    The following articles for your reference:
    Walkthrough: Creating a Custom ASP.NET Web Service
    https://msdn.microsoft.com/en-us/library/office/ms464040%28v=office.14%29.aspx?f=255&MSPPError=-2147217396
    Using Jquery to call an ASMX service in sharepoint 2010
    http://stackoverflow.com/questions/9035539/using-jquery-to-call-an-asmx-service-in-sharepoint-2010
    jQuery-ui Treeview
    https://plugins.jquery.com/btechcotree/
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Why does creative cloud is still asking serial number after i purchase and it wouldn't let me use it anymore because my trial is over need help NOW PLZ

    why does creative cloud is still asking serial number after i purchase and it wouldn't let me use it anymore because my trial is over need help NOW PLZ

    Hi There,
    Kindly try the following steps:
    Sign out and sign in to Creative Cloud app: Sign out, Sign in | Creative Cloud Desktop app
    Sign in, activation, or connection errors | CS5.5 and later
    Thanks.
    Atul Saini

  • HT201412 while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    Hi there bencong111,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    -Griff W. 

  • What inheritance mapping strategy would you use here, if any?

    [Scenario]
    I have a somewhat unusual problem. I have a set of entities, like Movie, Book etc. that all inherit Item class and that are perfectly identical in their structure (as none of them has any specific fields on it's own). They all have Id, Name, Description and Image fields, nothing else. The only difference between them is that some, obviously, represent movies, some of them books etc. If I didn't need to know their type, I wouldn't need inheritance at all.
    [SINGLE_TABLE]
    Obviously, all these entities could be easily persisted into the same table with a discriminator column (and entities themselves would have a @DiscriminatorValue) i.e using SINGLE_TABLE strategy. But, I would avoid this approach as there will be a lot of persisted entities, like, tens of thousands of each type (which means tables that map M-M relations could have millions or tens of millions of rows), so I'm guessing this approach would kill the performance.
    [JOINED]
    JOINED strategy has the same problems as SINGLE_TABLE.
    [TABLE_PER_CLASS]
    My opinion here, is that TABLE_PER_CLASS strategy would be the best approach, as I will rarely, if ever, query across multiple types. Item (the supertype) has only unidirectional 1:M relations, so , if I get this right, this is OK as well, as it avoids UNION when queried (please confirm or correct me on this), e.g. the query to fetch books and their votes (1:M) would resolve to SELECT * FROM Book b JOIN Vote v ON b.id = v.item_id, so no UNION... right?
    But maybe I don't need inheritance mapping at all then...
    What is your opinion here? Any shared thoughts are appreciated.

    The disadvantage of using table_per_class would be that you have to duplicate the field structure many times (e.g. code duplication). If you ever want to change certain fields you (or the db-administrator) would have to do that a few times. Since in eventually you always have to use direct sql one time or another, making the database design as clear as the java code (where you wouldn't want code duplication either). Direct SQL you'd often need for optimilazition or because certain operations can be done in one SQL query, while requiring a lot of code if done in java.
    You could use a single table, without losing performance. If you add an index to the discriminator type, a modern database will optimize queries and won't to full table scan. That way you have a clean database design, without losing performance.
    If you ever need extra fields for say movie that you don't need for book (like duration in minutes, director), you can then create an extra table movie that contains only the fields that are extra. Retrieving movie then requires a join of item and movie, but since movie would be a smaller table and the join will be on indexed field, that wouldn't hurt performance.The database design keeps being clear and readable, as well as your java code.
    If you really don't care about your relational database design, don't use a relation database but rather an object database. Object database are optimized for retrieving object graphs (retrieving a graph of objects won't require joins and table scans). The only disadvantage, aggragation of data is usually slower.

  • File name cant be fetched from Dynamic configuration...mutli-mapping used

    In a scenario, i have a BPM which has a transformation step which contains a mutimapping ...means 2 messages mapped to 1 messgaes, here in the mapping i m using an UDF and written code to extract the file name from dynamic configuration.....
    the problem is ...the same BPM contains another transformation step which contains a message mapping (which is not multi mapping), and here the code (UDF) works to fetch the file name...
    the code is all correct....and it looks like
    DynamicConfiguration conf = (DynamicConfiguration)
    container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String sourceFileName = conf.get(key);
    if (sourceFileName == null ){
    sourceFileName = "ErrorFile.xml";}
    return sourceFileName;

    Hi,
    Yes u r correct it will show error in operation mapping.. bcoz u cannot check the DynamicConfiguration in Operation mapping...
    It will throw Exception..
    The parameter to UDF depends on ur requirement.... Let us know ur requirements exactly...
    If u r doing for file to file means no UDF required,, just check ASMA on both sides....
    Babu

  • Is there a way to dynamically figure out the FIRSTROW & LASTROW using Bulk Insert?

    I noticed most of my files follow a certain convention, so I can use Bulk Insert with this:
    FIRSTROW = 2, LASTROW = 224
    However a few files have many more records.  I'd like SQL Server to dynamically figure out the first and last rows with data, but I don't know if that's possible.  Can someone confirm?
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Nope, you would need read the files from some program. Could be a CLR stored procedure if you want to do it from SQL Server. But from BULK INSERT alone, no.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Need Dynamic attributes for XI adapter to use in Dynamic Configuration ..!!

    Hi Friends,
    We are planning send message to different receivers through XI adapter by using Dynamic Configuration.
    Can anyone please tell me what are the dynamic attributes used for XI adapter.
    In my scenario, I want to pass the Service Number and Path prefix of XI adpater dynamically by using sender ID from Idoc payload.
    I know how to use the dynamic configuration UDF in message mapping. But I don't know the dynamic attributes which we can pass to Service Number and Path prefix of XI adpater.
    Kindly suggest ..
    Thanks
    Deepthi.

    Hi Sourabh,
    >> You need to set these attributes explicitly in the adapter configuration..
    Can you please elaborate on this like how to implement this? Do we need to use any module configuration in the adapter?
    We will use XI adapter only while sending the data directly from IE without using any feautures of AE (like adapters, modules etc). It is like directly sending data from ABAP stack without using J2EE stack. That is the reason we can't use any Modules in XI adpater and it is in disabled by default.
    When I checked in SXMB_MONI.. as you said details are found in
    - <SAP:Attribute>
      <SAP:Name>host</SAP:Name>
      <SAP:Value>10.190.25.16</SAP:Value>
      </SAP:Attribute>
    - <SAP:Attribute>
      <SAP:Name>httpDestination</SAP:Name>
      <SAP:Value />
      </SAP:Attribute>
    - <SAP:Attribute>
      <SAP:Name>path</SAP:Name>
      <SAP:Value>/rcvA/receiver</SAP:Value>
      </SAP:Attribute>
    - <SAP:Attribute>
      <SAP:Name>port</SAP:Name>
      <SAP:Value>8210</SAP:Value>
      </SAP:Attribute>
    XI adapter uses mainly three parameters Host, Port and Path.
    I want to pass any two of these values dynamically to achieve my solution. Can you please suggest your solution how we can implement it.
    -Deepthi.

  • How to build dynamic query strings in the query using DB adapter 'Pure SQL'

    Dear Forum,
    I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works fine, but my inputs parameters will vary. So I need to make my query dynamic to append the query strings at runtime depending on the inputs.
    For example I have 3 input variables - input1,input2 and input3 (in my request xsd) which are used in the pure sql query. Now if I get a 4th input parameter input4 in the request, I need to append this to query string as 'AND input4=[some value]' at runtime. Otherwise my query should have only 3 parameters. Please suggest how this can be achieved.
    Regards,
    Satya.

    This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
    Thanks,
    N

  • Dynamic text in PI Alerts without using BPM

    Hello everyone,
    Is it possible to have dynamic text in alert mail subject or mail details without using BPM in PI?
    If I want to configure generic single alert category for all interfaces in my project , and in the subject line of Alert mail, I need to have the Interface ID (unique identifier for that interface) or integration directory scenario name for which this alert has been raised, then is it possible to use some custom alert container for this purpose?  Or is there any other way to have these dynamic texts ?
    We are using PI7.1 in project landscape.
    Thanks in advance,
    Minal

    Hi,
    >>I need to have the Interface ID (unique identifier for that interface) or integration directory scenario name for which this alert has been raised
    those two are not available in the container:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/d0/d4b54020c6792ae10000000a155106/content.htm
    Regards,
    Michal Krawczyk

  • How to dynamically configure JPA setting at runtime using java code?

    Hi,
    I am new to EJB 3.0 and JPA. I am trying to help my company to deploy the use of JPA in EJB3.0. Currently, i am trying out with OpenJPA in IBM Webshpere Application Server 7.0. We have four different WAS servers running for testing, system integration testing, user testing and production respectively, and in each region, the configurations for data source, JDBC username and password, schema, etc are different. So i think i would need to configure the JPA setting during runtime using Java code that determines which is the environment. And apparently i am stuck with the limited knowledge i have.
    1) I understand that i could override the JDBC in the persistence xml by creating entity manager using entity manager factory. But is it possible that i do similar thing by using inejction of persistence context on entity manager to obtain a container managed entity manager?
    2) Alternatively, it is possible to create multiple persistence unit in the XML and inject different PU to the entity manager, am i right? But how to inject dynamically since @PersistenceContext(unitName="xxx") only accepts constant declaration.
    3) Is it possible that the JDBC username and password are read from properties file?
    Thanks for your help in advance!

    Hi
    Thanks for the reply.
    Are you saying that i have to configure the data source authentication to the backend DB2 using the JAAS-J2C? Correct me if i am mistaken. I guess i am unable to do so as the application server setup only contains one data source, and the server hosted a number of applications. Every applications has their own JDBC username and password supply to the data source (the ID supplied at the DB2 side will decide which resource can access) and thus, i have to supply the username and password at runtime. Talked to the server guy and seems that it is not feasible to have seperate datasource for each applications as considered to the volume of applications hosted inside the server.
    Any suggestion?

Maybe you are looking for

  • New iPod Touch 4th gen. cannot connect to home wi-fi network

    When I launch wi-fi on my new iPod Touch 4th gen. my home network's name is displayed, but after entering my password the iPod is unable to connect - the wheel to the left of the network name just keeps spinning.   The network still functions properl

  • Itunes + Switching Library from PC to MAC

    I've been reading the FAQ's on iTunes, and I've notived it only has guides that shows how to transfer your music from PC to another PC or Mac to Another Mac. I'm buying a MacBook Pro this week, and I want to keep all my music, is this going to be pos

  • File format for external harddrives between apple and windows

    i have a windows desktop and an apple mac book pro. the mac will read files from ntfs system but as read only. the windows will only read exfat or ntfs. what should i do? will exfat work as read and write between the two?

  • Functionality of Bell Curve in PD module

    Hi, Can anybody flash some light on the functionality of bell curve in apprisals...hows its used in SAP.Any standard config available in the system? Please help Thanks in advance, Ashwini

  • Perte du programme gpao

    bonjour,je suis une etudiante en 2eme année master au cours de préparer mon stage dans une entreprise algerienne 'naftal' ils ont un probleme et à nous de le regler! ils ont  perdu le programme gpao'gestion de production assisté par ordinateur' il et