Blogadda

Blogadda
Visit BlogAdda.com to discover Indian blogs

Saturday, December 26, 2009

AN EQUAL MUSIC- VIKRAM SETH

Perhaps this could have stayed unstated.
Had our words turned to other things
In the grey park, the rain abated,
Life would have quickened other strings.
I list your gifts in this creation:
Pen, paper, ink and inspiration,
Peace to the heart with touch or word,
Ease to the soul with note and chord.
How did that walk, those winter hours,
Occasion this? No lightning came;
Nor did I sense, when touched by flame,
Our story lit with borrowed powers -
Rather, by what our spirits burned,
Embered in words, to us returned.
BY VIKRAM SETH

Friday, December 25, 2009

UNCLAIMED

To make love with a stranger is the best.
There is no riddle and there is no test. --

To lie and love, not aching to make sense
Of this night in the mesh of reference.

To touch, unclaimed by fear of imminent day,
And understand, as only strangers may.

To feel the beat of foreign heart to heart
Preferring neither to prolong nor part.

To rest within the unknown arms and know
That this is all there is; that this is so.

Vikram Seth

Monday, December 14, 2009

5 Features of Flex Builer 4

Feature 1: Generation of accessor functions

Software development can be tedious. Many applications follow the same coding practices and patterns, and developers frequently spend lots of time on repetitive coding tasks—time that could otherwise be spent implementing more interesting logic. For Flash Builder 4 beta, we targeted a number of these common coding tasks and delivered ways to get them done quickly.

The task that developers most often asked us to automate was the creation of accessor functions. Developers wanted a way to generate getter and setter methods, which comprise a public interface to access private class members. With Flash Builder 4 beta, you can create these functions by simply placing your cursor on a class variable name and choosing Source > Generate Getter/Setter from either the main menu or the context menu. You can use the Generate Getter/Setter dialog box that opens to configure details about the accessor functions, and there’s even an option to preview the changes that Flash Builder 4 beta will make to your code (see Figure 1).

preview of the code generated by the new getter/setter feature

Figure 1. A preview of the code generated by the new getter/setter feature

Feature 2: Event code generation

Another common developer request is for generating event code. This feature is helpful both for experienced Flex developers looking to spend less time on tedious coding and for beginners unfamiliar with event-based development. For example, developers with a background in procedural web scripting technologies—like PHP or ColdFusion—may have never needed to implement an event listener to handle an event, such as a button being clicked. Flash Builder 4 beta can automatically generate the event handler functions for a UI object from the Flex Properties view, the context menu for an item in Design view, or with content assist for an item in Code view.

Each UI item, including buttons, lists, scrollbars, and so on, has a default event. A Button, for example, has the click event. If you select a button in Design view and right—click, you will see a context menu option Generate Click Handler. Likewise, the Property Inspector will show a field labeled “on click” and a button to generate the event. Of course, you can generate event handlers for all events of a UI item by selecting Show All Events in the context menu or by expanding the Events node for the item in the Property Inspector. Once you generate an event handler, Flash Builder 4 beta generates a unique name for the event handler based on the object’s class name, properties, or a custom name you specify. The event handler is placed in the first script block of the file and you will be taken to that position in Code view. If you’re starting in Code view, you can also generate events for components. Place your cursor in a closed component tag and open content assist for the properties of the component by typing a space after the class name. The list of properties displayed includes events (for example, Click). Select an event and then select Generate Event Handler.

If you’re new to ActionScript and event—driven programming, the event code generation feature can help you learn the basics of connecting component events to methods. If you’re an experienced Flex developer, the feature can save you time by quickly generating stubs for all of your event functions.

Feature 3:Command—line builds

Many customers told us that as their Flex projects have grown in complexity, the need for Flex to fit into their enterprise development processes and systems has become more acute. One of the most common requests we heard from these customers was for a way to add Flex applications to nightly automated build processes. Unfortunately, previous versions made it difficult to synchronize a developer’s individual build settings with the nightly build. Flash Builder 4 beta solves this with the new task and the task, which you can use in custom scripts for nightly builds.

Command line builds can be used even if Flash Builder 4 beta is not installed on the nightly build machine. If Flash Builder 4 beta is present, the task ensures that the nightly build’s settings exactly match the settings used by developers during their daily work. It also allows you to automate some of the common tasks included in a Flash Builder 4 beta build, for example automatically compiling associated library projects and copying assets such as JPEGs into the output directory. If Flash Builder 4 beta is not installed on the build machine, you can write a custom script, such as an Ant script, that uses the task, but the build machine must have the Flex SDK available. You will also need to keep two sets of build settings to synchronize. One set is kept in Flash Builder 4 beta and used by developers during their daily work. The other set is maintained on your nightly build machine. Consult the Adobe Flex 4 Features and Migration Guide for more details about how to use both approaches.

Feature 4: Debugger enhancements

Having a full featured debugger is one of the great benefits of an integrated development environment. Flex Builder 3 has excellent debugging capabilities, but there were still many additional features and enhancements for which you’ve been asking. So for Flash Builder 4 beta, we’ve invested heavily in taking the debugger to the next level.

Sometimes, you may need to stop the debugger from executing when specific conditions are met. With Flash Builder 4 beta, you can use expressions to define these conditional breakpoints to halt execution when the expression evaluates to true, when the value of the expression changes, or when a specified hit count has been reached. Evaluation of watch expressions has also been enhanced in this release. You can use the Expressions view to watch variables you selected in the Variables view, as well as to add and evaluate watch expressions while debugging your applications.

When debugging an application, you may want to know when specific instances of variables change value. Flash Builder 4 beta allows this with a new feature called watchpoints. You set a watchpoint on a specific instance of a variable from the Variables view during a debugging session, and execution will be halted when the watched variable changes value.

Finally, if you have ever set a debugger breakpoint within a loop that repeats many times, you’ll appreciate the new run—to—line command, which can be used to break out of a loop during a debugging session.

Feature 5: Network Monitor

Nearly all Flex applications exchange data with a server or service of some sort. The requests and responses move back and forth between the client and server in different formats depending on the technique that you use as a developer. In Flex 3 you have little insight into what’s happening as the exchange occurs, no matter what technique you use. You can debug your Flex application and see what remote call is made, but then you have to wait and see what (if anything) comes back from the server. Likewise, you can debug your server—side logic, but it’s difficult to know what happens to the data once you send it back to Flex. Monitoring the actual network traffic—the requests and response data—has not been possible with Flex Builder.

Flash Builder 4 beta introduces the Network Monitor, a tool that you can use to examine the SOAP, AMF, Remote Object, XML, and HTTP traffic that flows between your Flex application and its data service or services. Now you have a simple view, active when you’re in the Debugging perspective, that provides extensive monitoring and debugging information to make building data—centric applications much easier.

To begin, click the Enable Network Monitor icon on the Network Monitor toolbar and then run the debug version of the application as you would normally. As you interact with your application, the Network Monitor captures and stores all calls to remote services in chronological order. At any time, you can switch back to the Network Monitor view to see the results of each call. The results from calls to each remote service are presented in a table listing the time of the request, the requesting service, the operation and URL (if applicable), the time of the response, and the elapsed time. You can also examine the response, including the actual data sent back. You can analyze this information as the application is running, or you can click the Save icon to write all captured information to an XML file for later analysis.

Wednesday, December 2, 2009

मत करो कोई वादा जिसे तुम निभा न सको,

मत करो कोई वादा जिसे तुम निभा न सको,

मत चाहो उसे जिसे तुम पा न सको,

प्यार कहाँ किसी का पूरा होता है,

इसका तो पहला शब्द ही अधूरा होता है.. !!

...............iska Jawab...............


माना की प्यार का पहला अक्षर अधूरा है,

लेकिन 'प' को निकल दो तो यार रह जाता है

और आप जैसा यार हो

तो ज़िंदगी से भी प्यार हो जाता है



...............remember Always………..


यूं तो प्यार करने वाले तुम्हें कम न मिलेंगे,

मिल जाएंगे हम जैसे बहुत ,,, पर हम न मिलेंगे.




...............now Enjoy...............



उन्हें भूलने की कोशिश की मैंने,

दिल ने कहा याद करते रहना...

वो हमारे दर्द की फरियाद सुने न सुने,

अपना तो फ़र्ज़ है उन्हें प्यार करते रहना...............

Friday, November 27, 2009

Silverlight

Silverlight is a cross-browser, cross-platform and cross-device browser plug-in that helps companies design, develop and deliver applications and experiences on the Web. Silverlight enables a new class of rich, secure and scalable cross-platform experiences.

Silverlight 3 introduces major media enhancements, out of browser support allowing Web applications to work on the desktop; significant graphics improvements including perspective 3D graphics support, GPU acceleration and H.264 video support; and many features to improve RIA development productivity. To fully integrate all the .NET developer tools, Visual Studio 2008, Visual Studio 2010 and Visual Web Developer Express support a fully editable and interactive designer for Silverlight.

Silverlight include:
Support for Higher Quality Video & Audio
Empowering Richer Experiences
Improving Rich Internet Application Productivity
Enhanced Data Support
Improved performance
Out of Browser Capabilities

Tuesday, November 24, 2009

Kafi arsa beet gaya
Janay ab wo kaisa hoga
Waqt ki sari kadwi baten
Chup chap hi sahta hoga
Ab hiB bheegi barish me
bin chhatri ke chalta hoga
Mujh se bichde arsa beeta
Ab wo kis se ladta hoga
Achha tha jo sath hi rahte
Baad me us ne socha hoga
Apne dil ki sari baten
Khud hi khud se kahta hoga

Monday, October 12, 2009

Sirf Itna Hi Kaha Hai, Pyaar Hai Tum se
Jazbaton Ki Koi Numayish Nahin Ki

Pyaar Ke Badle Sirf Pyaar Manga Hai
Rishte Ki To Koi Guzarish Nahin Ki

Chaho To Bhula Dena Humein Dil Se
Sada Yaad Rakhney Ki Sifarish Nahin Ki

Khamoshi Se Toofan Seh Letey Hai Jo
Un Baadlon Ne Izhar Ki Baarish Nahin Ki

Tumein Hi Mana Hai Rehnuma Apna
Aur to kisi Cheez Ki Khwahish Nahin ki

Wednesday, October 7, 2009

वो भूखा था फिर भी लड़ता था...

वो भूखा था फिर भी लड़ता था...
वो घायल था फिर भी बढ़ता था
लिए ज़ख्म जिस्म पे अपने
वो आगे ही आगे बढ़ता था
पथरीली चट्टानों पर
लिए बन्दूक कंधो पर
दुर्गम से दुर्गम पथ पर
वो न थकता था न रुकता था
बस आगे ही आगे वो बढ़ता था
तूफानी नदियों में
बर्फीली तुफानो में
बस वो मुस्कुराता रहता था
कभी बनता सहारा पल भर का ..
कभी किसी की जान बचाता
वो मसीहा सा लगता था
वो एक फौजी था जो बस
आगे ही आगे बढ़ता जाता था
खून से सने वर्दी में
वो जो कदरदान था तिरंगे का
न थकता था चिलचिलाती धुप में
लगा सर पे टोपी
बस ख्वाब अमन का देखता था
वो भूखा था फिर भी लड़ता था
भूल गया था उस मासूम को
अपने एकलोते नए प्यार को
माँ बाप भी याद नहीं है उसको
याद करता है बस भारत माँ को
सामने दुश्मन के वो तूफान
कभी मासूम कभी हैवान
दुम हिलाता था दुश्मन भी
जब शेर बन वो दहाड़ता था
बस वो लड़ता ही जाता था
वो बस बढ़ता ही जाता था ......
"जय जवान "
है लिए हाथ में हथियार दुश्मन तक में बैठा उधर
और हम तैयार है सीना लिए अपना इधर
खून से खेलेंगे होली गर वतन मुस्किल में है
सरफरोशी की तमन्ना अब हमारे दिल में है
हाथ जिनमे हो जूनून कटते नहीं तलवार से
सर जो उठ जाते है वो झुकते नहीं ललकार से
और भड़केगा जो शोला सा हमारे दिल में है
सरफरोशी की तमन्ना अब हमारे दिल में है
हम तो घर से निकले ही थे बांध कर सिर पर कफ़न
ज़िन्दगी तो अपनी मेहमान मौत की मह

Monday, September 14, 2009

Scala-- The Future of java is here!!

Scala is a statically typed, object-oriented programming language that blends imperative and functional programming styles. Scala is designed to integrate easily with applications that run on modern virtual machines, primarily the Java virtual machine (JVM). The main Scala compiler, scalac, generates Java class files that can be run on the JVM. However, another Scala compiler exists that generates binaries that can be run on the .NET CLR, as Scala is designed to integrate with both the Java and .NET worlds. In the Java world, the Scala language can be used alongside the Java language—either as an alternative to Java—to build applications that run on the JVM.

Scala was developed starting in 2003 by Martin Odersky's group at EPFL, Lausanne, Switzerland. Previously, Martin had been active in the Java field. He co-designed the first version of Java generics and was the original author of the current javac compiler. The work on Scala was motivated by the desire to overcome limitations imposed by backwards compatibility with Java. So Scala is not a superset of Java, but it retains seamless interoperability.

One reason you might want to use Scala is that it allows you to increase your productivity compared to Java while leveraging JVM execution speed, your existing investments in Java code, knowledge, and the vast array of APIs available for the JVM. It has the conciseness of a dynamic language like Ruby or Python, but it is statically typed, like Java. Another reason is that Scala comes with an Erlang-like Actors library that greatly simplifies concurrent programming, but runs on the JVM.



By: http://www.artima.com/scalazine/articles/steps.html

Wednesday, September 9, 2009

Mashups

Mashups
In the context of learning and assessments mashups can be categorized as follows:

  1. Portlet – configured by an end user
  2. Page (Web, Wiki or Blog) – configured by a web author
  3. Data – configured by a programmer

Portlet Based Mashup
Portlet based mashups provide different “windows” that interact with different and separate applications and users can move these portlets around their screen to meet their own personal requirements.

Page Based Mashup
Page based mashups are configured by the author of the web page, wiki and or blog to determine where application data and interactions might occur.

Documentation, learning content and assessments are often available throughout an organization’s infrastructure but challenging to find and they are especially difficult to find in context. Wikis, blogs and web pages can be used to expose existing resources, wrap context, to provide a meaningful learning and/or assessment experience. Learning mashups can improve learner experiences and learning outcomes.

Data Mashups

A data mash up is where data is drawn from different data sources and displayed within a single page. In this style a programmer constructs a program to retrieve the data, from different data sources, and then display it within a web page.

Courtesy- http://www.linkedin.com/news?viewArticle=&articleID=66406667&gid=55108&articleURL=http%3A%2F%2Fblog.eric.info%2F2009%2F09%2F01%2Flearning-mashups%2F&urlhash=tz-h&trk=news_discuss

Monday, September 7, 2009

Load balancing FMS servers using LVS (DR mode)

Load balancing FMS servers using LVS (DR mode)

How do we configure LVS (or any load balancer for that matter) to detect when there has been a failure of a particular real server?

Answer by Jean--

It is possible to load balance using LVS, we could do an HTTP health monitor against FMS since it supports tunneling over HTTP. We can also probably hit the admin service port of the FMS server, which has a REST like interface and use some metrics like the number of streams or number of application instances. keep alived or something similar should work for the actual interface for putting servers in an out of rotation for local server load balancing. People generally know who use LVS write their own custom health check layer.

Friday, September 4, 2009

Lawn Tennis - Scoring

Lawn

Tennis - Scoring

The Server wins the point
  • if the ball served, not being a let, touches the receiver or anything which he wears or carries, before it hits the ground

  • if the receiver loses the point

The Receiver wins the point

  • if the server serves two consecutive faults

  • if the server loses the point

If the ball in play touches a permanent fixture (other than the net, posts, singles sticks, cord or metal cable, strap or band) after it has hit the ground, the player who struck it, wins the point;

If the ball in play touches a permanent fixture (other than the net, posts, singles sticks, cord or metal cable, strap or band) before it hits the ground his opponent wins the point.

In a doubles game, if the ball served touches the partner of the receiver or anything which he wears or carries, before it hits the ground, the server wins the point. The ball shall be struck alternately by one or other player of the opposing pair and if a player touches the ball in play with his racket in contravention of this rule, his opponents wins the point.

A player loses the point if

  • he fails to return the ball in play directly over the net, before it hits the ground twice consecutively

  • he returns the ball in play so that it hits the ground, a permanent fixture or other object, outside any of the lines which bound his opponents court

  • he volleys the ball and fails to make a good return even when standing outside the court

  • he touches or strikes the ball in play with his racket more than once in making a stroke

  • he or his racket or anything which he wears or carries, touches the net, posts, cord or metal cable, strap or band or the ground within his opponents court at any time while the ball is in play

  • he volleys the ball before it has passed the net

  • the ball in play touches him or anything that he wears or carries, except his rackets or hands

  • he throws his racket and the racket hits the ball

  • a player deliberately and materially change the shape of the racket during the game

Result

If the player wins his first point, the score is called 15 for that player. On winning his second point, the score is called 30 for that player. On winning his third point the score is called 40 for that player and the fourth point won by the player who's score is 40 will win the game.

If both the players have won three points, the score is called Deuce and the next point won by a player is scored Advantage for that player. If the same player wins the next point, he wins the game. If the other player wins the next point the score is again called Deuce and so on, until the player wins the two points immediately following the score at deuce, when the game is scored for that player.

A player (or players) who first wins six games wins a Set, except that he must win by a margin of two games over his opponent and where necessary a Set shall be extended until this margin be achieved.

Tuesday, September 1, 2009

मैं ढूँढता तुझे था

मैं ढूँढता तुझे था, जब कुंज और वन में।
तू खोजता मुझे था, तब दीन के सदन में॥

तू 'आह' बन किसी की, मुझको पुकारता था।
मैं था तुझे बुलाता, संगीत में भजन में॥

मेरे लिए खड़ा था, दुखियों के द्वार पर तू।
मैं बाट जोहता था, तेरी किसी चमन में॥

बनकर किसी के आँसू, मेरे लिए बहा तू।
आँखे लगी थी मेरी, तब मान और धन में॥

बाजे बजाबजा कर, मैं था तुझे रिझाता।
तब तू लगा हुआ था, पतितों के संगठन में॥

मैं था विरक्त तुझसे, जग की अनित्यता पर।
उत्थान भर रहा था, तब तू किसी पतन में॥

बेबस गिरे हुओं के, तू बीच में खड़ा था।
मैं स्वर्ग देखता था, झुकता कहाँ चरन में॥

तूने दिया अनेकों अवसर न मिल सका मैं।
तू कर्म में मगन था, मैं व्यस्त था कथन में॥

तेरा पता सिकंदर को, मैं समझ रहा था।
पर तू बसा हुआ था, फरहाद कोहकन में॥

क्रीसस की 'हाय' में था, करता विनोद तू ही।
तू अंत में हंसा था, महमुद के रुदन में॥

प्रहलाद जानता था, तेरा सही ठिकाना।
तू ही मचल रहा था, मंसूर की रटन में॥

आखिर चमक पड़ा तू गाँधी की हड्डियों में।
मैं था तुझे समझता, सुहराब पीले तन में।

कैसे तुझे मिलूँगा, जब भेद इस कदर है।
हैरान होके भगवन, आया हूँ मैं सरन में॥

तू रूप कै किरन में सौंदर्य है सुमन में।
तू प्राण है पवन में, विस्तार है गगन में॥

तू ज्ञान हिन्दुओं में, ईमान मुस्लिमों में।
तू प्रेम क्रिश्चियन में, तू सत्य है सुजन में॥

हे दीनबंधु ऐसी, प्रतिभा प्रदान कर तू।
देखूँ तुझे दृगों में, मन में तथा वचन में॥

कठिनाइयों दुखों का, इतिहास ही सुयश है।
मुझको समर्थ कर तू, बस कष्ट के सहन में॥

दुख में न हार मानूँ, सुख में तुझे न भूलूँ।
ऐसा प्रभाव भर दे, मेरे अधीर मन में॥

Monday, August 31, 2009

Flex Ajax Bridge

Flex Ajax Bridge

The Flex Ajax Bridge (FABridge) is a small code library that you can insert into an Flex application, a Flex component, or an empty SWF file to expose it to scripting in the browser.

Rather than having to define new, simplified APIs to expose a graph of ActionScript objects to JavaScript, with FABridge you can make your ActionScript classes available to JavaScript without any additional coding. After you insert the library, essentially anything you can do with ActionScript, you can do with JavaScript.

Adobe Flash Player has the native ability, through the External API (the ExternalInterface class), to call JavaScript from ActionScript, and vice versa. But ExternalInterface has some limitations:

  • The ExternalInterface class requires you, the developer, to write a library of extra code in both ActionScript and JavaScript, to expose the functionality of your Flex application to JavaScript, and vice versa.
  • The ExternalInterface class also limits what you can pass across the gap - primitive types, arrays, and simple objects are legal, but user-defined classes, with associated properties and methods, are off-limits.
  • The ExternalInterface class lets you define an interface so your JavaScript can call your ActionScript. FABridge lets you write JavaScript instead of ActionScript.

When to use the Flex Ajax Bridge

The FABridge library is useful in the following situations:

  • You want to use a rich Flex component in an Ajax application but do not want to write a lot of Flex code. If you wrap the component in a FABridge-enabled stub application, you can script it entirely from JavaScript, including using JavaScript generated remotely by the server.
  • You have only one or two people on your team who know Flex. The FABridge library lets everyone on your team use the work produced by one or two Flex specialists.
  • You are building an integrated rich Internet application (RIA) with Flex and Ajax portions.Although you could build the integration yourself using ExternalInterface, you might find it faster to start with the FABridge.

Requirements for using the Ajax Bridge

To use the FABridge library and samples, you must have the following:

  • Flex Ajax Bridge, which is included in the following directory of the Flex 3 SDK installation:

    installation_dir\frameworks\javascript\fabridge

  • Adobe Flex SDK
  • Adobe® Flash® Player 9 or Adobe® AIR™
  • Microsoft Internet Explorer, Mozilla Firefox, or Opera with JavaScript enabled
  • Any HTTP server to run the samples

To run the samples:

  1. Browse to the files found within the installation_dir\frameworks\javascript\fabridge
  2. Place the src and samples folders side by side on any HTTP server.
  3. Open a web browser to http://yourwebserver/samples/FABridgeSample.html and samples/SimpleSample.html and follow the instructions there. Make sure you access the samples through http:// URLs and not file:// URLs. The Flash Player security sandbox prevents them from working correctly when they are accessed as local files.
Courtesy.. Flex LiveDocs

Sunday, August 16, 2009

SCROM, AS3 MIX QUESTIONS

  1. How to access the CDATA tag data from xml in AS2 and AS3.
  2. What is the difference between data fetching process from xml in AS and AS3.
  3. What are the commonly used LMSs.
  4. What is the latest version of SCORM. Which LMS is using the latest version of SCORM.
  5. What are the differences between the AICC standards and SCORM standards.
  6. What are differences between scorm 1.2 and 2004.
  7. How we suggest the client to go for which version of SCORM.
  8. What is the most widely used SCORM version.
  9. What is the use of adobe presentor.
  10. How we include the WMV format video in our courses.
  11. What are the basic things which needs to be take care of when developing the CORM compliant Courses.
  12. If we want to design an SCROM compliant course in flash how we move ahead.
  13. Can we design the complete course in flash or we need some other technology or language for designing.
  14. Can we make a complete course in adobe captivate.
  15. What r basic architectures we follow in designing the e-learning courses.
  16. What is the difference between the function of scorm 1.2 and 2004.
  17. what is the use of remote client and media servers in the e-learning.

Monday, August 10, 2009

Will you dance with me tonight..

It’s been so long
Since I’ve known right from wrong
Got no job, sometimes I just sit down and sob
Wondering if anything will go right
Or will you dance with me tonight

When the sun departs
I feel a hole down in my heart
Put on some shoes
Come down here and listen to the blues
Wondering if anything will go right
Or will you dance with me tonight

I’m looking at you
You’re looking at me
We’re the only two off the dance floor
Do you see what I see
Two broken lives working in harmony
Might make for a decent time
So get up and dance with me

I know that it seems that the grass will grow
Better on the other side of the barb wire fence
But that other side is not in sight
So I’m fine with what I have now
If you’ll dance with me tonight

What’s the point of life
If risk is just a board game
You roll the dice
But you’re just hoping that the rules change
What’s the point if you can’t bring yourself to say
Things you wanna say like
Dance with me tonight
Courtesy-- Music And Lyrics.. Hugh Grant...

Sunday, August 9, 2009

Local Shared Object

LSO, a bigger better cookie

Local Shared Object (LSO) or Flash cookie, like the HTTP cookie, is a way of storing information about us and tracking our movement around the Internet. Some other things I learned:

  • Flash cookies can hold a lot more data, up to 100 Kilobytes. A standard HTTP cookie is only 4 Kilobytes.
  • Flash cookies have no expiration date by default.
  • Flash cookies are stored in different locations, making them difficult to find.

    The only way you can access information about resident Flash cookies is by going to Flash Player’s Web site.

    Courtesy- http://blogs.techrepublic.com.com/security/?p=2299&tag=nl.e036

Wednesday, August 5, 2009

DTO (Data Transfer Objects)

A Data Transfer Object, or DTO is a design pattern for a very specific type of object that is used to transfer data between different parts of your application.

A DTO is just for temporarily storing information whilst it is in transit. Therefor a DTO has limited behaviour, only that of storing, retrieving, validating, and internal consistency checking of its own data. They should have no responsibility in terms of security, transaction, and business logic. This de-coupling of storage and business logic will enable us to use the same DTO in different contexts.

DTOs come in two different types: generic collections, or custom objects.

Generic Collections

Generic collections, eg. Dictionaries or Arrays, are advantageous in that you only require a single DTO for all your data transfer needs. The main disadvantage is that the client has to access fields either by position index (in the case of Arrays), or by key (in the case of Dictionaries). A further problem is that as the type of objects in a collection is unknown. In a future revision of Actionscript Arrays will be typed, which will only allow collections to store data of one type. This can lead to items being stored as a generic Object type, which can lead to subtle but fatal coding errors that cannot be detected at compile time.

The creation of a dynamic generic objects can be costly as Flash doesn’t know how much memory to allocate. By typing all your variables, Flash can then allocate the necessary memory for those variables and no more. This avoids the creation of a Hash Table and will therefor decrease memory consumption and increase performance.

Custom Objects

Creating a custom class for your DTOs provides strictly typed objects which allow for compile-time checking and support code editing features like FDTs “code assist” feature (ctrl + space). The only drawback is the creation of a large amount of DTOs that might be required for a large application.

Fields contained within a custom DTO should be of primitive/simple types eg. strings, booleans, etc. or arrays of those, and it may even contain other DTOs. As DTOs are meant to be temporary objects for transferring data, their fields should be immutable (read-only). Although this can be particularly difficult to achieve under certain circumstances.


  1. package ch.forea.exampleDTO {
  2. public class CardDTO{
  3. private var _name:String;
  4. private var _address:String;
  5. private var _phone:String;
  6. public function CardDTO(name:String, address:String, phone:String){
  7. _name = name;
  8. _address = address;
  9. _phone = phone;
  10. }
  11. public function get name():String{
  12. return _name;
  13. }
  14. public function get address():String{
  15. return _address;
  16. }
  17. public function get phone():String{
  18. return _phone;
  19. }
  20. }
  21. }


The purpose of all this is to package all required information in to one package, therefor transferring everything in one call rather than multiple calls. This method can be advantageous if the call is to a remote system, as any further calls to the DTO are made locally to the client.



http://forea.ch/blog/2008/11/14/back-to-basics-the-data-transfer-object-dto/


Tuesday, August 4, 2009

ApplicationDomain class

Using the ApplicationDomain class

Using the ApplicationDomain class

The purpose of the ApplicationDomain class is to store a table of ActionScript 3.0 definitions. All code in a SWF file is defined to exist in an application domain. You use application domains to partition classes that are in the same security domain. This allows multiple definitions of the same class to exist and also lets children reuse parent definitions.

You can use application domains when loading an external SWF file written in ActionScript 3.0 using the Loader class API. (Note that you cannot use application domains when loading an image or SWF file written in ActionScript 1.0 or ActionScript 2.0.) All ActionScript 3.0 definitions contained in the loaded class are stored in the application domain. When loading the SWF file, you can specify that the file be included in the same application domain as that of the Loader object, by setting the applicationDomain parameter of the LoaderContext object to ApplicationDomain.currentDomain. By putting the loaded SWF file in the same application domain, you can access its classes directly. This can be useful if you are loading a SWF file that contains embedded media, which you can access via their associated class names, or if you want to access the loaded SWF file's methods, as shown in the following example:

package {    

import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
public class ApplicationDomainExample extends Sprite {
private var ldr:Loader;
public function ApplicationDomainExample() {
ldr = new Loader();
var req:URLRequest = new URLRequest("Greeter.swf");
var ldrContext:LoaderContext = new LoaderContext(false,
ApplicationDomain.currentDomain);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
ldr.load(req, ldrContext); }
private function completeHandler(event:Event):void {
ApplicationDomain.currentDomain.getDefinition("Greeter");
var myGreeter:Greeter = Greeter(event.target.content);
var message:String = myGreeter.welcome("Tommy");
trace(message); // Hello, Tommy } } }




Using the ApplicationDomain class

Other things to keep in mind when you work with application domains include

the following:

  • All code in a SWF file is defined to exist in an application domain.
    The current domain is where your main application runs.
    The system domain contains all application domains, including the current
    domain, which means that it contains all Flash Player classes.
  • All application domains, except the system domain, have an associated parent
    domain. The parent domain for your main application's application domain is
    the system domain. Loaded classes are defined only when their parent doesn't
    already define them. You cannot override a loaded class definition with
    a newer definition.

YOUR EPITAPH

YOUR EPITAPH

I've got whole worlds staring at screens
And yet no one ever senses me in between.
I could be any of the ones or the zeros
One of its zillion unsung heroes
I'm told I'm a geek god in a glass temple
Worshipped. Overpaid. Replaceable.
A human architect in this digital crucible,
Neo, Invincible, One, Invisible.
I exist, God-like in a desk job mode
And on the 7th day I rest
I can be benched, right sized or dropped on the road
Never lived for, though I too will live forever with the index
So my friend, if you, like myself, are seeking me now
I pray this song finds you somehow.
Coz my world is so much smaller these days
So small, precious little is face to face
And if I've earned one epitaph no one grudges me,
It's for being human, behind the screen
For putting the ones and zeros in place
And most of myself in this digital embrace
You see the world is so much smaller these days
How could something so small take away my face?
- SALTMARCH MEDIAS DEVELOPER ANTHEM

Monday, August 3, 2009

REST parameter

ActionScript 3.0 introduces a new parameter declaration called the ... (rest) parameter. This parameter allows you to specify an array parameter that accepts any number of comma- delimited arguments.

function getItems(...rest):void
{
// ... logic goes here
}

Notice that the only parameter the getItems method is ...rest, this is a rest parameter. When creating a rest parameter you should keep the following things in mind:

  • Rest parameters are untyped. It is up to you to validate any special type requirements as you loop through the rest parameter array.
  • Rest parameters must be at the end of a method's parameters.
  • The rest parameters must have ... in front of it, but the variable name can be anything.

When you want to retrieve values out of a rest parameter you simply iterate (loop) through them like you would any other array. Here is an example:

 
function getItems(...items):void
{
var total:int = items.length;
for( var i:int = 0; i < total; i++)
{
trace("Look up item", items[i]);
}
}

getItems("testA","testB","testC", 10);

When we call the method we can pass in any number of items as
long as they are separated by a comma. Back in the getItems method we get the
total from the rest parameter just like we would an array.


http://www.linkedin.com/news?viewArticle=&articleID=55481685&gid=
113435&articleURL=http%3A%2F%2Fwww.insideria.com%2F2009%2F08%2Fas-3-
rest-parameter.html&urlhash=9xja&trk=news_discuss

Key ways to reduce vulnerability and improve security in SCORM

Key ways to reduce vulnerability and improve security.

  • Audit trails and accountability. Have a second source of data to cross-check. Ideally this data should be automatically collected. Data sent to a SCORM or AICC LMS is also sent to a Questionmark Perception server via a different data conduit.
  • Secured Communication. Transfer responsibility for the result data to a server. Questionmark’s secure server-to-server implementation of AICC does this.
  • Increased Client/Browser Security. Reduce the attack surface of the runtime. Use a Secured Browser that disables or limits functionality not directly needed for the primary activity. Questionmark Secure is a browser that does this for AICC or SCORM.
  • Direct Proprietary Communication. This approach works by centralizing the chain-of-custody for the data to one trusted provider. Questionmark Perception can manage the process completely from authoring to scheduling to delivery to reporting.

Audit trails. Keeping parallel records such as with a double-entry accounting system is one way to achieve an audit trail. Having such an audit trail is key to identifying and recovering from errors or misdeeds. Questionmark provides capabilities for such an audit trail through both its SCORM and its AICC implementations. Perception achieves increased security and this audit trail by sending data to the LMS using the SCORM or AICC standard and, in parallel, sending data directly to the secure Perception server database. In the case of an error or misdeed, the LMS system results and the results in the secured Perception database can be compared to recover from either a security breach or an error.

Secured Server-to-Server Communication. In the cheatlet exploit, the openness of the published SCORM API and the browser JavaScript layer are used to inject false data from the client side. One way to increase the security is to remove this client side vulnerability and use AICC instead of SCORM. The innovative Perception server-to-server implementation of the AICC HACP specification demonstrates this, by having the browser relay minimal data to the Perception server. The client is not capable of directly injecting falsified overall score data. The Perception server is ultimately responsible for judging response and data communication with the LMS, not the browser client.

Increased Browser Security. As currently implemented, this exploit relies on user access to the UI to open a bookmark. Changes to the launch environment (browser) can reduce this vulnerability. The Questionmark Perception Secure Browser is a commercialized browser solution built for the rigorous requirements of high-stakes testing environments. When a participant takes an online assessment using Questionmark Secure, the secure browser displays the HTML content of the assessment, but disables key functions such as task-switching, right click options, screen captures, menus and printing. There simply isn’t a means to access a menu or bookmark to trigger.

Direct Proprietary Communication In this scenario, one trusted party is responsible for the full span of access, delivery, and results. It does run somewhat contrary to cybersecurity practice of published protocols and specifications that can bear wide scrutiny. It can also undermine interoperability, something near and dear to my heart. In the long run, I believe you’ll find Questionmark moving in directions that addresses these type of concerns.

However, there are many valid circumstances where the values of single party chain of custody and trusted relationship trumps other concerns. High stakes test are often the prime case for this, and it is critical to expand cyber-defense-in-depth with adjunct security measures (such as tight control of source materials, exam monitors, proctors/invigilators).

Work-around versus defend-against. Finally, as an exercise for the reader, you may consider reading the the two ADL workarounds published April 2, 2009. You’ll find that the excerpt on Securing Your Assessments provides a means of masking the location of answer-judging source code sent to the client by some systems. While useful, it doesn’t provide the same security and depth of defense as other approaches. Consider for instance using Questionmark Secure (prevents ‘view source’) with the Perception SCORM implementation (adds audit trail) and Perception server-side evaluation logic (secures the evaluation logic on the server-side). That is defense in depth. One might even replace SCORM with AICC in this case for additional security in addition to or in lieu of Questionmark Secure.


Courtesy-- TechRepublic


Sunday, August 2, 2009

Domain Specific Languages (DSLs)

Domain Specific Languages (DSLs) are specialized languages that are targeted for a specific problem area or domain. These rely on the jargons of domain experts and provide fluency for them to communicate with your application. There are two types of DSLsexternal and internal. While internal DSLs rely on a host language they currently lack tools for validation. External DSLs on the other hand require parsing, but can benefit from good validation before processing. In this presentation you'll learn about DSLs, their characteristics, and how to edit, parse, and validate external DSLs using Java based tools.

Thursday, July 30, 2009

Adobe Stratus

What is Adobe Stratus?

With Flash Player 10, Adobe brought in enhancements that make writing P2P applications a reality. Flash Player 10 provides support now for a new protocol called Real Time Message Flow Protocol (RTMFP). This protocol is well suited to creating applications that need to communicate to each other directly. This communication is facilitated via the Adobe Stratus Service which supports the RTMFP protocol and is a rendezvous Hosted Service that facilitates connection between two Flash Player 10 instances.

Once the Flash Player 10 instances are connected to each other, the two applications can continue to talk to each other without going through an intermediate server side.

Adobe has had Flash Media Server (FMS) over the years and recently they have also introduced Adobe Flash Collaboration Services (AFCS), formerly known as Cocomo. FMS currently does not support the RTMFP protocol but future versions of it could. On the other hand, Adobe Stratus in conjunction with the Flash Player 10 APIs does not provide support for full P2P capabilities like relay, shared data models, etc. but depending on the kind of application that you may require, it might just about the fit the requirements of your P2P Application without requiring additional server side architecture.

Plz refer

http://www.linkedin.com/news?viewArticle=&articleID=54537631&gid=113435&articleURL=http%3A%2F%2Fwww.insideria.com%2F2009%2F07%2Fgetting-started-with-adobe-str.html&urlhash=LoE9&trk=news_discuss

Wednesday, July 29, 2009

Skinnign FLV Component

Skinning FLV Playback Custom UI components individually

The FLV Playback Custom UI components allow you to customize the appearance of the FLVPlayback controls within your FLA file and allow you to see the results when you preview your web page. These components are not designed to be scaled, however. You should edit a movie clip and its contents to be a specific size. For this reason, it is generally best to have the FLVPlayback component on the Stage at the desired size, with the scaleMode set to exactFit.

To begin, simply drag the FLV Playback Custom UI components that you want from the Components panel, place them where you want them on the Stage and give them instance names.

These components can work without any ActionScript. If you put them on the same timeline and frame as the FLVPlayback component and there is no skin set in the component, the FLVPlayback component will connect automatically to them. If you have multiple FLVPlayback components on Stage, or if the custom control and the FLVPlayback instance are not on the same Timeline, then Action is needed.

After your components are on the Stage, you edit them as you would any other symbol. After you open the components, you can see that each one is set up a little differently from the others.

Tuesday, July 28, 2009

Send and Load Example


  1. package {
  2. import flash.events.*
  3. import flash.net.*;
  4. public class SendAndLoadExample {
  5. public function SendAndLoadExample() {}
  6. public function sendData(url:String, _vars:URLVariables):void {
  7. var request:URLRequest = new URLRequest(url);
  8. var loader:URLLoader = new URLLoader();
  9. loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  10. request.data = _vars;
  11. request.method = URLRequestMethod.POST;
  12. loader.addEventListener(Event.COMPLETE, handleComplete);
  13. loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  14. loader.load(request);
  15. }
  16. private function handleComplete(event:Event):void {
  17. var loader:URLLoader = URLLoader(event.target);
  18. trace("Par: " + loader.data.par);
  19. trace("Message: " + loader.data.msg);
  20. }
  21. private function onIOError(event:IOErrorEvent):void {
  22. trace("Error loading URL.");
  23. }
  24. }
  25. }

Sunday, July 19, 2009

Dost!!

Dost to rukhsat ho jaate hain,
par kuch yaadon ke dayre ban jaate hain…
Bhool jaana to insaan ki fitrat hai,

par kuch acche dost yaadon mein bas jaate hain..

Friday, July 17, 2009

More AS questions

1. How do you call a static method without using the "Class Name." method name.
2. How would the for in and for each loop give the output tracing values in object.
3. How can you add video cue-point so that u can execute any action upon or middle of video.
4. Skinning of Flv component.
5. How you load one XML and read all the attributes of a node in E4X.
6. How u deal in a situation if your team member is not good @ work.
7. How would u response to a client mail when he has just bashed your project and there is no senior member present in the office.
8. Suppose in 10 hrs of learning...2 days before delivery u come to know that. The product designed is not as per client requirement. The prototype version has many changes suggested by client. How will u deal with this situation.
10. Give example of method overloading and overriding in code.
11. How u access your linked classes to other class in shared library architecture. Syntax
12. How you handle depth in AS3.0
13. 3 ways to execute Java-script from Flash.
14. Why we should prefer FSCOMMAND than GetURL in AS2.0.
15. MVC architecture and implementation.
16. Will u do a copy paste work if required for a project
17. Differences between AS2.0 - 3.0

Sunday, July 12, 2009

The Song of the Free

The wounded snake its hood unfurls,
The flame stirred up doth blaze,
The desert air resounds the calls
Of heart-struck lion's rage.

The cloud puts forth it deluge strength
When lightning cleaves its breast,
When the soul is stirred to its in most depth
Great ones unfold their best.

Let eyes grow dim and heart grow faint,
And friendship fail and love betray,
Let Fate its hundred horrors send,
And clotted darkness block the way.

All nature wear one angry frown,
To crush you out - still know, my soul,
You are Divine. March on and on,
Nor right nor left but to the goal.

Nor angel I, nor man, nor brute,
Nor body, mind, nor he nor she,
The books do stop in wonder mute
To tell my nature; I am He.

Before the sun, the moon, the earth,
Before the stars or comets free,
Before e'en time has had its birth,
I was, I am, and I will be.

The beauteous earth, the glorious sun,
The calm sweet moon, the spangled sky,
Causation's law do make them run;
They live in bonds, in bonds they die.

And mind its mantle dreamy net
Cast o'er them all and holds them fast.
In warp and woof of thought are set,
Earth, hells, and heavens, or worst or best.

Know these are but the outer crust -
All space and time, all effect, cause.
I am beyond all sense, all thoughts,
The witness of the universe.

Not two nor many, 'tis but one,
And thus in me all me's I have;
I cannot hate, I cannot shun
Myself from me, I can but love.

From dreams awake, from bonds be free,
Be not afraid. This mystery,
My shadow, cannot frighten me,
Know once for all that I am He.

By Swami Vivekanand-(1895)

Saturday, July 11, 2009

Top 20 Universities in USA by Happy Schools Blog

Top 20 Universities in USA by Happy Schools Blog

  1. Massachusetts Institute of Technology
  2. Stanford University
  3. University of California–Berkeley
  4. Carnegie Mellon University
  5. Cornell University
  6. Princeton University
  7. University of Illinois–Urbana-Champaign
  8. University of Washington
  9. Georgia Institute of Technology
  10. University of Texas–Austin
  11. University of Michigan–Ann Arbor
  12. University of Wisconsin–Madison
  13. California Institute of Technology
  14. University of Maryland–College Park
  15. University of California–Los Angeles
  16. Columbia University
  17. Harvard University
  18. University of California–San Diego
  19. Purdue University–West Lafayette
  20. Duke University

Friday, July 10, 2009

Tribute to Dinkar!!!

तुझको या तेरे नदीश, गिरि, वन को नमन करूँ, मैं ?
मेरे प्यारे देश ! देह या मन को नमन करूँ मैं ?
किसको नमन करूँ मैं भारत ! किसको नमन करूँ मैं ?

भू के मानचित्र पर अंकित त्रिभुज, यही क्या तू है ?
नर के नभश्चरण की दृढ़ कल्पना नहीं क्या तू है ?
भेदों का ज्ञाता, निगूढ़ताओं का चिर ज्ञानी है,
मेरे प्यारे देश ! नहीं तू पत्थर है, पानी है।
जड़ताओं में छिपे किसी चेतन को नमन करूँ मैं ?

भारत नहीं स्थान का वाचक, गुण विशेष नर का है,
एक देश का नहीं, शील यह भूमंडल भर का है ।
जहाँ कहीं एकता अखंडित, जहाँ प्रेम का स्वर है,
देश-देश में वहाँ खड़ा भारत जीवित भास्कर है ।
निखिल विश्व को जन्मभूमि-वंदन को नमन करूँ मैं ?

खंडित है यह मही शैल से, सरिता से सागर से,
पर, जब भी दो हाथ निकल मिलते आ द्वीपांतर से,
तब खाई को पाट शून्य में महामोद मचता है,
दो द्वीपों के बीच सेतु यह भारत ही रचता है।
मंगलमय यह महासेतु-बंधन को नमन करूँ मैं ?

दो हृदय के तार जहाँ भी जो जन जोड़ रहे हैं,
मित्र-भाव की ओर विश्व की गति को मोड़ रहे हैं,
घोल रहे हैं जो जीवन-सरिता में प्रेम-रसायन,
खोर रहे हैं देश-देश के बीच मुँदे वातायन।
आत्मबंधु कहकर ऐसे जन-जन को नमन करूँ मैं ?

उठे जहाँ भी घोष शांति का, भारत, स्वर तेरा है,
धर्म-दीप हो जिसके भी कर में वह नर तेरा है,
तेरा है वह वीर, सत्य पर जो अड़ने आता है,
किसी न्याय के लिए प्राण अर्पित करने जाता है।
मानवता के इस ललाट-वंदन को नमन करूँ मैं

Saturday, July 4, 2009

JUNIT

Go for the JUNIT for testing ur Java Classes..!

http://junit.sourceforge.net/doc/faq/faq.htm#tests_16

Thursday, July 2, 2009

Choosing Between Timer and Event.ENTER_FRAME

Choosing Between Timer and Event.ENTER_FRAME

As we’ve just seen, the Timer class and the Event.ENTER_FRAME event can both be used
to produce animation. So which one is right for your family? Here are the major factors
to consider:

1. Frame rate is subject to change

When a .swf file is loaded by another application, the frame rate of that application
might be vastly different than the .swf file’s designated frame rate, potentially
causing the .swf ’s animations to play too quickly or too slowly. The loaded
.swf file can, of course, set the frame rate, but that change in frame rate might
cause undesirable playback behavior in the parent application. The Timer class
offers some frame-rate independence (subject to the limitations discussed in the
earlier section “Frame Rate’s Effect on Timer”).

2. Using many Timer objects requires more memory

In decentralized animation management architectures, using a separate Timer to
control the animation of each object requires more memory than would be
required by the analogous Event.ENTER_FRAME implementation.

3. Using many Timer objects can cause excessive screen update requests

In decentralized animation management architectures, using a separate Timer in
conjunction with updateAfterEvent( ) to control the animation of each object
leads to multiple independent requests for screen updates, possibly leading to
performance problems.

Sunday, June 28, 2009

Silex-- A new Approach

Silex is an open source RIA that enables you to build Flash websites for Flash Player 7, 8, 9, and 10. Silex is a new kind of CMS, a mix between an editing software like the Adobe Creative Suite, and Wiki based software. All multimedia file formats -- images of all kinds, texts, videos with chapters and subtitles, audio and playlists, 3D animations, .pdf files, etc. can be assembled in Silex WYSIWYG editor to publish online, on a local computer, or on a CD-R. Silex can be used to display all types of data -- either static or dynamic -- from text files, databases, a CMS, blog, Web TVs, etc. HTML and Flash are both supported by Silex. Search engine support is provided by generating an HTML equivalent on the fly of the contents of Silex web sites as if they were HTML web sites. You can get more details on the official Silex site.

Thursday, June 25, 2009

Another Hectic Day

Again it gonna be a hectic day at office..

when i opened the mailbox a bunch of mails were waiting for me.. adn the full 10-12 hours of schedule was there :(

Lets hope for a not too busy weekend.. thinking go hometown adn catch up with few old friends !!

Saturday, June 20, 2009

The whole week ends in the Work

Also i have gone thru few interesting topics. For some of my friends it may be a crap kinda stuff :)

Sprituality-- Osho's History, Swami Vivekanand's Teachings adn Speeches, A tak between Ishwar Chand Vidyasagar and Master Ramakirshan Paramhans.

Technical Front--(not much)..
but tried to make music player kinda thing :) in flash.. completed 70% now stuffed in between the as classes.. , gone thru ATOM and RSS fields patterns and yes the GutterShark Framework as well..

Celebrating Father's Day

My special DAD

I always search for you,
because you feel I can do.
You are always there
to help me grow
encouraging me
in all my show.
I know I will never fail,
Because you are always there.
Holding my finger tight,
to teach me walk always right.
You care like a mother,
play with me like a brother.
Your affection is like a sister,
What else can be better.
Your dedication to the family,
is as great as sky blue
Every work you do ,
Your dedication is always true.
I thank GOD to give me,
a wonderful gift like You.
I wish if next birth is true,
You are always my DAD
and I am always your LAD. :)

Friday, June 19, 2009

USB 3.0

USB 3.0 specifications were announced in November by Intel and Intel developer Sarah Sharp has been busy coding the linux drivers ever since. The drivers have been ready and have been scheduled to be merged with the Linux mainstream kernel in the version 2.6.31. Traditionally it has always been that Windows is the first OS to get the hardware drivers and the linux geeks tend to reverse engineer or design it based on the specification but this time around tables have been turned over.

The support of Intel to mainstream linux and to the development of open hardware drivers does seem to be a road of change on the part of the hardware manufacturers who have traditionally been windows centric.

The USB 3.0 hardwares have not made to the market yet although NEC is producing 1 million xHCI PCI-Express add-in cards for september release.

Sarah is also working to ensure that these drivers make it to mainstream distributions like Redhat and Ubuntu, according to the post on her blog.

For those who do not know USB 3.0 specification gives a 10x increase over the existing USB standard delivering a transfer rate of 5.0Gbps. You can read further details here: http://en.wikipedia.org/wiki/USB#USB_3.0

For those who live on the edge and want to test out the drivers(in case you are the lucky few with the hardware), head on to The Geekess blog at http://sarah.thesharps.us/2009-06-09-13-30.cherry and follow her instructions. For those who would like to wait, wait for the next kernel release.

Wednesday, June 17, 2009

FEW MORE AS QUESTIONS

Disadvantages of event dispatcher.

Linkage between components.

What are v2 components.

What are mxp and mxi file and how they r relate to swc file.

Do we have method overloading and operator overloading in flash,

Any workaround on method or class overloading.

Can we exclude our as file not to be included during the runtime or can we specify to the debugger which as file to use or not.

How garbage collector works in flash.

Can we use interfaces in flash.

How do we implement MVC pattern.

How do we use observer pattern.

How we create the custom components.

Any experience on as editor or any other IDE.

Any experience on third party compilers.

What OOPS things were not there in as2 which are added to as3.

What is delegate class.?

How we use getter and setters methods in component designing.?

How we integrate our as files with the fla file.

What is linkage.

What type of polymorphism is being supported by flash.?

Load movie and load movienum

Diff. between stage and root.

Diff. between sealed classes and dynamic classes.

Exception handling methodology in flash.

What is external interface class.

How we add the page in the printjob class.

What is the way the print job class works .

Tuesday, June 16, 2009

AS3 INTERVIEW QUESTIONS

--External Interface Class

--Diff. between Overloading and Overriding

--Can we have overloading in flash?

--Do we need to override the function in same class or the different class.?

--How we start and stop video playback?

--How we load a audio , play, pause and stop, resume etc.

--Explain the sound object and How do we use it.?

-- Explain Design Patterns.?

--Diff. between Design patterns and Frameworks.?

--Whats OOP..?-- the famous borng question ever :)

--How we implement OOP approach.?

--Is as2 OOP based.?

--Do we have packages in as2.?

--How do we can achieve flash and client side communication.?

--How to communicate between flash and javascript.?

--Do we have fscommand in as3.?

A lot of others coming soon..

Monday, June 15, 2009

Adobe Flash Collaboration Service aka Cocomo

AFCS (Adobe Flash Collaboration Service) previously known as 'Cocomo' is a Platform as a Service (PaaS) that that allows Flex developers to address a class of applications known as collaborative applications.

Collaborative Applications have progressed from a nice cool thing into serious applications. Almost all of us would have participated in an online chat or a web meeting, which allows a group of users to chat, share files, do screen sharing, take polls, ask questions and receive answers, etc. AFCS aims to lower the barrier to entry for developers to bring such collaborative features into their applications.

A developer would have general questions like:
  • Why do we need a set of components to enable collaborative features in my application?
  • It should not be that complex to build a collaborative application, right? Isn't chat and sharing some files the maximum that I would want?
  • …and many more.
Well, building collaborative applications is not as simple as it sound. If you wish to build a collaborative application - you will need to consider the following in your application:
  • Handle Audio, Video and all other forms of transcoding data
  • Ensure that your application can scale to a large number of users.
  • Enable shared state in your application and ensure that multiple users are co-coordinated with each other so maintain data integrity
  • Reuse commonly used components like chat, notes, whiteboard, etc so that you can build the applications quickly and not reinvent the wheel.
  • Handle User Management and Permissions

Courtesy-- TechRepublic!!!!!!!!!!!!!!!

Friday, June 12, 2009

Apache Pivot

What is Apache Pivot?

Apache Pivot is an open-source platform for building rich internet applications in Java. It combines the enhanced productivity and usability features of a modern RIA toolkit with the robustness of the Java platform. Pivot applications are written using a combination of Java and XML and can be run either as an applet or as a standalone, optionally offline, desktop application.

Like other modern development platforms, Pivot provides a comprehensive set of foundation classes that together comprise a "framework". These classes form the building blocks upon which more complex and sophisticated applications can be built.

Who is Pivot's target audience?

Pivot was designed to be familiar to web developers who have experience building AJAX applications using HTML, CSS, and JavaScript. However, it provides a much richer set of standard widgets than HTML, and allows developers to create sophisticated user experiences much more quickly and easily. Pivot will also seem familiar to Swing developers, as both Swing and Pivot are based on Java2D and employ a model-view-controller (MVC) architecture to separate component data from presentation. However, Pivot includes additional features that make building modern GUI applications much easier, including declarative UI, data binding, effects and transitions, and web services integration.

Why RIA?

The web has become the defacto standard method for application delivery. However, functional requirements for web applications have begun to scale beyond the capabilities of the browser. Even with the addition of scripting support, dynamic element manipulation, and asynchronous server communication, it is difficult to create a user experience in HTML that is truly on par with that of a desktop application.

Rich internet application (RIA) development platforms are a means of bridging the gap between the web and desktop experiences. Using browser plugins, these platforms allow developers to build applications that look and feel more like native desktop applications but are deployable via the web, like traditional, HTML-based web applications. RIAs also often incorporate visual effects intended to enhance the overall user experience, such as animations and other dynamic behavior.

Adobe Flex and Microsoft Silverlight are arguably the most high-profile of these platforms; others include OpenLaszlo and Curl. Pivot itself falls into this category.

Why Pivot?

Pivot was created for two primary reasons:

  • To provide a viable option for developers who want to build rich client applications in Java. Flex applications are written in ActionScript, an ECMAScript variant; Silverlight applications can be written in either C# or JavaScript; OpenLaszlo applications are written in JavaScript. Pivot allows developers to write rich internet applications in Java (or any other language that can run in a JVM).
  • To provide a freely-available, open source alternative for RIA developers. Flex, Silverlight, and Curl are all proprietary platforms. We believe that a large part of HTML's success was its due to its openness. While we certainly hope that developers will use Pivot to build revenue-generating products and applications, we believe that the platform itself should be free and driven by its technological merits, not by corporate objectives.

Where did Pivot come from?

Pivot began as an R&D effort at VMware in 2007. It was announced as an open-source project in June of 2008 under the Apache 2.0 license. Version 1.0 was released in October, 2008, and version 1.1 in April, 2009. Work is currently underway on version 1.2, scheduled for release in mid 2009.

What platforms does Pivot support?

Pivot applications run on any operating system with a Java Virtual Machine (JVM) version 5 or greater. They can be run locally as Java desktop applications or via the web using the Java plugin.

Who is developing Pivot?

Pivot has been developed primarily Greg Brown and Todd Volkert of VMware. However, it is a community-driven effort that has recieved contributions from a number of developers around the world. An RIA platform is a large undertaking that needs the support of a larger developer base if it is to succeed and thrive. Interested developers are encouraged to participate; information on how to do so is available on the Pivot home page.

How does Pivot compare to Swing?

While it is technically feasible to build an RIA in Java using the Swing toolkit, Pivot offers a number of advantages that make it a more compelling, modern alternative:

  • Pivot provides an XML markup language called WTKX for simplifying user interface construction. Flex, Silverlight, and OpenLaszlo all offer a similar feature; web developers are comfortable with the markup metaphor, and it can considerably reduce overall development time.
  • Components are not limited to an "atomic" preferred size; they are allowed to report a preferred size as constrained by either width or height - this facilitates such features as label wrapping, which Swing does not support.
  • Pivot employs a consistent data model that is used throughout the entire framework; for example, JSON data returned from a REST service is serialized into the same data structures used by a table view component to present data. No additional translation is necessary, which can significantly improve performance. A common data model also reduces the learning curve for new developers.
  • Pivot includes built-in support for REST-based data services, which Pivot calls "web queries". This provides parity with Flex, which comes with out-of-the-box support for RPC via the AMF protocol, and Silverlight, which supports both SOAP and REST-style services. Swing does not include any built-in facilities for server communication, making it less convenient to work with.
    Note, however, that Pivot is not limited to REST for server communication. Because it runs in a JRE, a Pivot application can take advantage of any client/server protocol that has a Java API; for example SOAP-based services via Axis or Flex RPC using the BlazeDS AMF client.
  • Pivot includes built-in data binding support, which allows data returned from web queries (as well as other types of data services) to easily be mapped to form contents.
  • Pivot includes (and takes advantage of) platform-level support for visual effects and transitions (i.e. animations).
  • Pivot applications are inherently resolution independent. Bitmapped and vector images are interchangeable, and the entire user interface can be scaled to take advantage of high-resolution displays or for accessibility purposes.
  • Pivot defines a single Application inteface that is used for launching both desktop and web-based applications - multiple codebases for applets and applications are not required.
  • Because it requires Java 5, Pivot is able to take advantage of newer Java language features such as generics, enums, for..each loops, and annotations.

How does Pivot compare to JavaFX?

Fundamentally, Pivot and JavaFX appear to be serving two different use cases. Pivot is designed primarily to address the "Application" in "RIA", whereas JavaFX appears to be geared more towards the "Rich" part of the acronym. This isn't to say that the two are mutually exclusive - Pivot supports a variety of features for adding visual richness to an application. However, Pivot is first and foremost a tool for creating applications - animations and other effects are primarily intended to enhance the user experience of those applications, not serve as simple eye-candy.

Pivot additionally differentiates itself from JavaFX by allowing developers to build applications in Java, rather than the JavaFX scripting language. Finally, JavaFX's widget support is based on Swing, which suffers from the limitations outlined above.

In a sense, Pivot represents what we think Sun should have done instead of JavaFX.

How does Pivot compare to the Google Widget Toolkit (GWT)?

While GWT allows developers to use the Java language to write web-based applications, the runtime enviroment for a GWT application is the browser itself, not a JVM. This has a number of drawbacks:

  • The compiled code executes as interpreted JavaScript, not bytecode.
  • The only libraries available are those that have been ported to GWT by Google.
  • All presentation must be done via CSS and DOM manipulation rather than via a true 2D drawing API.
  • Additionally, GWT does not support an XML markup language - all UI elements must be created programmatically.

Pivot allows developers to efficiently construct RIAs that can truly take advantage of the Java platform.


Thursday, June 11, 2009

Multiple Inheritance in Java and Delegate Factory pattern

When Sun was designing Java, it omitted multiple inheritance - or more precisely multiple implementation inheritance - on purpose. Yet multiple inheritance can be useful, particularly when the potential ancestors of a class have orthogonal concerns. This article presents a utility class that not only allows multiple inheritance to be simulated, but also has other far-reaching applications.

Have you ever found yourself wanting to write something similar to:

public class Employee extends Person, Employment {
// detail omitted
}

Here, Person is a concrete class that represents a person, while Employment is another concrete class that represents the details of a person who is employed. If you could only put them together, you would have everything necessary to define and implement an Employee class. Except in Java - you can't. Inheriting implementation from more than one superclass - multiple implementation inheritance - is not a feature of the language. Java allows a class to have a single superclass and no more.

On the other hand, a class can implement multiple interfaces. In other words, Java supports multiple interface inheritance. Suppose the PersonLike interface is:

public interface PersonLike {
String getName();
int getAge();
}

and the EmployeeLike interface is:

public interface EmployeeLike {
float getSalary();
java.util.Date getHireDate();
}

If Person implements the Person-Like interface, and Employment implements an EmployeeLike interface, it's perfectly acceptable to write:

public class Employee implements PersonLike, EmployeeLike {
// detail omitted
}

Here there is no explicit superclass. Since we are allowed to specify at most one superclass, we could also write:

public class Employee extends Person implements PersonLike, EmployeeLike {
// detail omitted
}

We would need to write the implementation of EmployeeLike, but the implementation of PersonLike is taken care of through the Person superclass. Alternatively we might write:

public class Employee extends Employment implements PersonLike, EmployeeLike{
// detail omitted
}

This is the opposite situation: the EmployeeLike interface is taken care of through the Employment superclass, but we do need to write an implementation for PersonLike.

Java does not support multiple implementation inheritance, but does support multiple interface inheritance. When you read or overhear someone remark that Java does not support multiple inheritance, what is actually meant is that it does not support multiple implementation inheritance.

Stay Adaptable
Suppose then that you have the concrete implementations Person, which implements the PersonLike interface, and Employment, which implements the EmployeeLike interface. Although only one can be selected to be the superclass, it would be useful to somehow exploit the other implementation.

The easiest way to do this in Java is by applying the (Object) Adapter pattern. If we make Person the superclass, we can use Employment using an object adapter held within the employee:

public class Employee extends Person implements PersonLike, EmployeeLike {
private EmployeeLike employment = new
Employment();
public float getSalary() { return
employment.getSalary(); }
public java.util.Date getHireDate() { return employment.getHireDate(); }
}

For each method of EmployeeLike, the employee delegates to the object adapter. This helps motivate the decision as to whether Person or Employment should be the superclass; choose the one with the most methods as the superclass so there will be less manual delegation code to write when dealing with the other interface.

The Adapter pattern is a fine way to support multiple interface inheritance while exploiting two concrete implementations. Indeed, it's more often the case that an anonymous inner class is used as the object adapter, allowing customization of behavior with respect to the context (of being embedded within a subclass).

However, writing that delegation code is tedious, especially if both interfaces to be implemented have many methods in them. In many cases, we can get Java to do the delegation to the would-be superclass(es) automatically.

Enter Dynamic Proxies
Dynamic proxies were introduced into Java in J2SE v1.3. Part of the java.lang.reflect package, they allow Java to synthesize a class at runtime. The methods supported by this synthesized class are specified by the interface (or interfaces) that it implements. The implementation is taken care of through an invocation handler (java.lang.reflect.InvocationHandler) that is handed an object representing the method being invoked (java.lang. reflect.Method). As you can see, dynamic proxies use heavy doses of the Java Reflection API.

This then is the key to simulating multiple implementation inheritance within Java. We can write a custom InvocationHandler that is constructed with a set of classes; these represent the superclasses of the subclass to be synthesized. The interface(s) of our subclass will be the union of the interfaces implemented by these superclasses. Our InvocationHandler will instantiate instances of these superclasses so that it can delegate to them. We then arrange it so that the invocation handler, on being given a method to be invoked, will reflectively invoke the method on the appropriate superclass object instance. (There must be one; remember the subclass's interface is derived from the superclass's, so at least one superclass must be able to handle the method invocation.)

To make things simple, we can make our InvocationHandler implementation also return the proxy. In other words, the invocation handler can act as a factory, able to return instance(s) of the synthesized subclass that will delegate to the superclass instances. We call our invocation handler implementation DelegatorFactory for this reason:

// imports omitted
public final class DelegatorFactory
implements InvocationHandler {
public Object getObject() {
return Proxy.newProxyInstance(
this.getClass().getClassLoader(),
getSupportedInterfaces(),
this);
}
}
// code omitted
}

The supported interfaces of the resultant object are derived from the superclasses provided in the DelegatorFactory's constructor:

// imports omitted
public final class DelegatorFactory implements InvocationHandler {
public DelegatorFactory(final Class[]
ancestors) {
// implementation omitted
}
// code omitted
}

There is more to DelegatorFactory as we shall soon see, but we now have enough to simulate multiple implementation inheritance. Going back to the question first posed, instead of:

public class Employee extends Person, Employment {
// detail omitted
}

followed (presumably) by:

Employee employee = new Employee();

We can instead write:

Object employee =
new DelgatorFactory(
new Class[] {
Person.class,
Employee.class
}
).getObject();

Although the syntax is somewhat different, the same essential information is being provided. That is, the concrete implementations are provided in Person and in Employment. This object will use the implementation of Person if invoked as a PersonLike, and the implementation of Employment if invoked as an EmployeeLike:

((PersonLike)employee).getAge();
((EmployableLike)employee).getHireDate();

How Convenient
In the above example, the casts are necessary because the getObject() method of DelegatorFactory can only return a reference of type java.lang.Object. But the clunkiness arises because our original aim of defining the Employee class with two concrete superclasses actually does something else as well:

public class Employee extends Person, Employment {
// detail omitted
}

Not only does this indicate that the implementation of Employee should be based on that of its superclasses, it also defines Employee as a type. In other words, it's then possible to write:

Employee employee;

What is missing in our dynamic proxy solution is this definition of type. Let's first do that in the usual way. As shown in Figure 2, we don't need to use a class though; an interface is sufficient.

As code, this is simply:

public interface Employee extends PersonLike, EmployeeLike { }

There is no detail omitted here; this is our complete definition. Note that Employee is now an interface and not a class. The following will not work, however:

Employee employee =
(Employee)
new DelegatorFactory(
new Class[] {
Person.class,
Employment.class
}
).getObject();

This is because the only interfaces implemented by the dynamic proxy returned by getObject() are PersonLike and EmployableLike. No matter that logically the Employee interface does not require any additional implementation from our dynamically created object; Employee is not an interface that we can cast to. However, DelegatorFactory does provide an alternative constructor:

Employee employee =
(Employee)
new DelegatorFactory(
new Class[] {
Person.class,
Employment.class
},
Employee.class
).getObject();

Note the new second argument (Employee.class) to the constructor. Casting the object returned from getObject() to Employee will now work. Behind the scenes, the Delegator- Factory simply adds this interface to the set of those to be implemented by the dynamic proxy. Note that Delegator Factory takes this interface object on trust: there is no validation that the interface doesn't introduce any new methods that are not already present in the interfaces of the superclasses.

Initializing the Superclasses
In "regular" Java, if a superclass does not provide a no-arg constructor, it's necessary for the subclass to correctly initialize the superclass using constructor chaining. Normally this is done by including the superclass's constructor's argument(s) in the subclass's constructor's argument(s), and then passing them up the class hierarchy using super().

The facilities shown in Delegator-Factory thus far do not support this. The DelegatorFactory is given a list of superclasses, and then instantiates an instance of each (to delegate to) using java.lang.Class.newInstance(). This requires a public no-arg constructor to exist.

If the would-be superclass does not offer a public no-arg constructor, the DelegatorFactory should be instantiated using a different constructor that takes preinstantiated superclass instances:

Person person = new Person("joe", 28);
Employment employment =
new Employment(someCalendar.getTime(),
30000);
Employee employee =
(Employee)
new DelegatorFactory(
new Object[] {
person, employment
},
Employee.class
).getObject();

If the would-be superclass does not have a public constructor, or is abstract, a custom subclass (probably an anonymous inner class) should be instantiated and used instead.

Dealing with Diamonds
Typically, multiple implementation inheritance is used when the superclasses have orthogonal concerns. Certainly this is the case with PersonLike and EmployeeLike, and each method is unambiguous as to which ancestor it relates to.

However, sometimes there may be a common super-interface in the interfaces implemented by the "superclasses." For example, suppose we have the concrete class, Car, which implements Driveable, the Boat class, which implements Sailable, and both Driveable and Sailable extend from Steerable. Since we want to use both Car and Boat to define a new subclass, we will also introduce a convenience interface, AmphibiousCar (see Figure 3).

The steer() method of Steerable is used to alter the bearing (0 to 359 degrees) of the steerable object. The getBearing() method, of course, should return this bearing.

For simplicity, the drive() method of Driveable and the sail() method of Sailable return a suitable string indicating the current bearing. Invoking drive() might return a string such as:

driving at bearing 30 degrees.

From what we currently know, we would create an amphibious car object using:

AmphibiousCar ac =
(AmphibiousCar)
new DelegatorFactory(
Class[] {
Car.class, Boat.class
}).getObject();

What happens if we invoke the steer() method on our new amphibious car ac? Should the invocation handler delegate to the Car superclass object or the Boat? The default behavior is to delegate to the first matching object. Hence, we will get:

ac.steer(30);
System.out.println(ac.drive());
// prints "driving at bearing 30 degrees"
System.out.println(ac.sail());
// prints "sailing at bearing 0 degrees"

The Boat superclass component of our class never knew that the bearing had changed.

It's this kind of problem that persuaded the Java language designers to exclude multiple implementation inheritance. This is too large an area to cover in this article, but what we have here is an example of part of the so-called "diamond" problem, where there is a common ancestor. You can see the diamond in the interfaces: Steerable, Driveable, Sailable, and Amphibious-Car.

The DelegatorFactory utility deals with the diamond problem by allowing you to specify the invocation behavior to the delegate superclasses as a pluggable strategy (an example of the Strategy pattern). The strategy is defined by the InvocationStrategy interface. The default strategy (InvokeFirstOnlyStrategy) is to invoke the first ancestor superclass that can handle the method. However, in the case of the diamond, what is required is that both ancestors need to handle the method. The InvokeAllStrategy handles this. If the method being invoked has a nonvoid return type, the return value from the first ancestor is returned. The two strategies are shown in Figure 4.

The invocation strategy can either be set after the DelegatorFactory has been instantiated, or can be set through (yet another) overloaded constructor. Hence our amphibious car should be created using:

AmphibiousCar ac =
(AmphibiousCar)
new DelegatorFactory(
Class[] {
Car.class, Boat.class
},
new InvokeAllStrategy()
).getObject();

This time, we get:

ac.steer(30);
System.out.println(ac.drive());
// prints "driving at bearing 30 degrees"
System.out.println(ac.sail());
// prints "sailing at bearing 30 degrees"

The InvokeFirstOnlyStrategy and InvokeAllStrategy are not the only strategies available (indeed we shall see one more shortly); however, they should work for most situations.

If a custom invocation strategy is required, it can be written by implementing the InvocationStrategy interface:

public interface InvocationStrategy {
Object invoke(final List ancestors,
final Method method,
final Object[] args)
throws Throwable
}

The ancestors parameter is an immutable list of the object instances representing the superclass. The method parameter represents the Method being invoked, and the args parameter contains the arguments to that Method. A typical invocation strategy would likely call method.invoke(S) somewhere within its implementation, with the first argument (the object upon which to invoke the method) being one of the ancestors.

We shall look at some applications of custom invocation strategies shortly. For now, though, an adaptation of InvokeAllStrategy might be to return the average return value of all ancestors, not just the return value of the first one.

Implicit Diamonds
In the previous diamond example, the Steerable interface is explicitly a super-interface of both Driveable and Sailable. What if the super-interface has not been explicitly factored out, though?

For example, in the original PersonLike and EmployeeLike example, what if each provided a foo() method, returning a string. Not imaginative, but never mind. Let's construct our employee and use an InvokeAllStrategy:

Employee employee = (Employee)
new DelegatorFactory(new Class[]{Person.class, Employment.class},
Employee.class,
new InvokeAllStrategy())
.getObject();

Now let us invoke foo():

employee.foo(); // what will happen?

Should the Person's implementation be called, that of Employment, or both? Although you might wish that both would be called (by virtue of our installed strategy), the sad truth is that only Person's implementation would be called. This is because the dynamic proxy has no way of knowing which interface to match foo() to, so it simply matches it to the first interface listed. (It's a java.lang.reflect.Method that is passed to the DelegatorFactory, not the string literal "foo()". Methods are associated with a specific declaring class/interface.) In terms of the DelegatorFactory's implementation, this means the first superclass listed in its constructor.

Note also that the compile time type does not matter. Neither of the following will change the outcome:

((PersonLike)employee).foo(); ((EmployeeLike)employee).foo();

In fact, it would be possible to modify DelegatorFactory to make Invoke-AllStrategy effective in this case, but that would involve parsing on the Method.getName() rather than the method. However, this has deliberately not been done. We'd rather you factored out the super-interface and made the diamond explicit. In the above example, add a FooLike (or Fooable) interface and make both PersonLike and EmployLike extend from it.

Other Applications
The issue raised by diamonds (implicit or otherwise) is that of how to deal with more than one implementation of a given method within an interface. However, it's interesting to turn this on its head.

In aircraft and other safety-critical environments, it's common to implement subsystems in triplicate. For example, there may be three different navigational systems, possibly with each implemented by different subcontractors. Each of these would be able to respond to the request, "Where is the location of the aircraft?"

Other systems within the aircraft interact with the navigational subsystem through a broker. This accepts the request on behalf of the navigational subsystem, and then forwards the request onto each implementation. Assuming there are no bugs in any of those implementations, they should all respond with the same data (within some delta of acceptable variance).

If there is a bug in one of the implementations, it may produce a response that differs wildly from the other two implementations. In this case, the broker disregards that response completely and uses the responses of the other implementations that agree with each other.

The design of DelegatorFactory and its pluggable invocation strategies make it easy to implement such a broker. Imagine a Calculator interface that defines a single method add(int, int):int. We can then have three implementations of this interface, as shown in Figure 5.

The FastCalculator uses regular integer arithmetic. The OneByOne- Calculator rather long-windedly performs its arithmetic by incrementing the first operand one-by-one in a loop. Both of these implementations are correct, just different. The final BrokenCalculator is just that; it actually performs a subtraction, not an addition.

The InvokeSafelyStrategy invocation strategy requires at least three ancestors that implement each method invoked. It will invoke the method on all ancestors, and then look to see that there is precisely one response that is most popular. Here is how to create a safe calculator that will ignore the incorrect implementation within the BrokenCalculator:

DelegatorFactory dfInvokeSafely =
new DelegatorFactory(
new Class[] {
BrokenCalculator.class,
OneByOneCalculator.class,
FastCalculator.class
},
Calculator.class,
new InvokeSafelyStrategy()
);
Calculator safeCalculator =
(Calculator)dfInvokeSafely.getObject();
assertEquals(7, safeCalculator.add(3,4));

Note that the InvokeSafelyStrategy is not all that intelligent. It stores the return values from each ancestor within a HashSet, so it relies on an accurate implementation of equals() and hashCode(). If the actual return type were a float (wrapped within a Float object), a more sophisticated invocation strategy would most likely be required. In general, this strategy will work only with well-defined value objects that can intrinsically deal with any rounding and other such errors.

You could easily adapt or refine the InvokeSafelyStrategy into further strategies. For example:

  • A parameterized version of InvokeSafelyStrategy could be used to deal with floats and other return types that would have rounding issues.
  • A background strategy might perform each invocation within a separate thread. Any invocation that had not responded within a certain timeout would be discarded.
  • A high-performance system, on the other hand, might use a strategy that again uses a backgrounding strategy but returns the result of the first one to finish, killing off the rest.
  • A logging strategy might perform some logging and then forward the invocation (typically to a single delegate).
  • A caching strategy would check its cache with respect to the input parameter, and only if the result is unknown would it invoke the delegate (caching the subsequent result).
  • A listener/broadcast strategy could represent a collection of listener objects; notifying all listeners of an event would require notifying only the broadcaster, which would then iterate over all listener objects as required.

    Moreover, there is nothing to prevent multiple invocations from being chained together, (that is, the Decorator pattern). Alternatively, we could imagine a composite strategy (the Composite pattern) that combines a set of strategies together. Either the invocation chain (decorator) or the set of leaf strategies (composite) could be changed at runtime, meaning that we can change the behavior and responsibilities of the object dynamically. This is a fundamentally different paradigm from conventional Java with its static typing. Normally, it's the type/class of the object that determines its behavior, something that cannot be changed once the object is instantiated. Here, though, we have ended up configuring the behavior of objects on an instance-by-instance basis: so-called instance-based programming. In effect, the whole notion of type becomes much less important.

    There are echoes here too of aspect-oriented programming. Most aspect-oriented programming uses compile-time techniques (the term used is "weaving") to add in behavior to classes. The classic example of aspect-oriented programming is to add logging within all method calls. You can easily see, though, that these same features can be incorporated dynamically using invocation strategies; the decorator/composite invocation strategies would allow an arbitrary set of aspects to be added to a class. The difference though is that now the aspects are applied at runtime (and hence can be changed without recompile and redeployment).

    Conclusion
    The DelegatorFactory is simple to use, supporting classic mix-in (orthogonal) multiple-implementation inheritance "out-of-the-box" and - with its pluggable invocation strategy design - allows diamond hierarchies to be easily supported. Moreover, the design also lends itself to other quite unrelated problem spaces; for example, creating safe systems was explored. Taken to its logical conclusion, the approach supports both instance-based programming and aspect-oriented programming.

    Of course, what makes DelegatorFactory work is Java's support for dynamic proxies, and that in turn requires that the ancestor superclasses implement interfaces. This approach won't work for class-based designs (JDOM is an example that comes to mind). But arguably class-based designs should be used only for value objects that should be final anyway. Those situations where multiple inheritance is desired are more likely to occur when working with reference objects.

    One particular case deliberately not supported by DelegatorFactory is when there is a so-called implicit diamond. The solution though is to pull out the methods that appear in both interfaces, and move them into a new super-interface. Then, make sure you use InvokeAllStrategy rather than the default InvokeFirstOnlyStrategy.

    Of course, using a dynamic proxy object will be slower than a hand-crafted solution, principally because reflection is used. However, the difference may not be noticeable in practice. In recent releases of Java, Sun has put much effort in speeding up reflective invocation; as of JDK 1.4.1, it may well be that regular invocation is only twice as fast as reflective invocation (previously this figure was something like 40 times faster).

    Using DelegatorFactory
    The DelegatorFactory utility class and supporting classes described here can be downloaded from www.sys-con.com/java/sourcec.cfm, and are compilable using Ant (v1.5.1 was used to create the build file). A JUnit-based test harness is also provided; JUnit v3.8.1 is required. The motivating examples in this article are based on the JUnit tests, so they should be easy enough to follow.

    To run the tests with JUnit's text-based test runner, use:

    ant test

    Alternatively, you can use JUnit's test runner by running directly:

    ant rebuild
    java -classpath
    dist/halware-util-dynamic-bin.jar;dist/halware-util-dynamic-bin-test.jar
    com.halware.util.dynamic.test.AllTests gui

    (The GUI test runner is not the default since JUnit's classloaders do not understand the Class-Path manifest attribute.)

    I hope you find DelegatorFactory useful. It has been distributed under the GNU Lesser Public License, so you are free to embed it within your own software as required.