tag:blogger.com,1999:blog-170122132014-11-22T04:28:31.004-05:00Wade Chandler's Programming BlogThis is my blog for software programming and development. I am a professional software engineer. I work on various projects; including those for Food Network and the Army Research Laboratory. I contribute to a few open-source projects such as <a href="http://www.netbeans.org">www.netbeans.org</a>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-17012213.post-10510826100428244322014-07-30T12:54:00.002-05:002014-07-30T12:54:49.494-05:00Gradle and Dynamically Setting Test.forkEveryI ran into an interesting problem today when customizing my teams Gradle build. I wanted to be able to dynamically set the forkEvery value for our test tasks. So, using common property techniques, wrote:<br /><br /><pre>test {<br /><br /> if(project.hasProperty("test.forkEvery")){<br /> println "Setting the tests to fork every ${project.getProperty("test.forkEvery")} for project ${project.name}"<br /> forkEvery = project.getProperty("test.forkEvery")<br /> }<br />}<br /></pre><br />Through simple observation I knew the tests were completing too fast. No errors, but something was off. I hard coded the value to 1 (not quoted), and that worked fine. Hmmmm. Considering Groovy would print 1000 for this: <br /><pre>def l = 1L; l = "1000"; println l;</pre>I had to assume something must be happening with type conversion, and Gradle is not giving me an error for it. The fix was Long.parseLong: <br /><pre>test {<br /><br /> if(project.hasProperty("test.forkEvery")){<br /> println "Setting the tests to fork every ${project.getProperty("test.forkEvery")} for project ${project.name}"<br /> forkEvery = Long.parseLong(project.getProperty("test.forkEvery"))<br /> }<br />}<br /></pre><div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-80166061700450531242013-03-13T17:02:00.000-05:002013-03-13T17:02:56.411-05:00Thunderbird Keeps Giving An Alarm For A Past Event; How To Get Rid Of ThemI ran into a strange issue where Thunderbird just simply would not quit reminding me about the calendar events from one day in one of my remote calendars. I suppose in all fairness this is really the Lighting extension which did this. I dug around in the extensions sources on my system, and I found where it was happening, but didn't have time to really formulate a real "fix". But, what I noticed is it was using a cache to hold this information. So, I started looking at the folders under my profile.<br /><br />What I noticed was the folder calendar-data directly under my profile. On Linux this can be found at ~/.thunderbird/yourprofile/calendar-data. The next thing I noticed was the cache.sqlite file along with some others you most likely want to keep. I opened the database in sqliteman, and I could sure enough find the entries there. I had already deleted the events from my remote calendar through my phone, and my other events, future and recurring, still exist in my remote calendar.<br /><br />I thought, I can either find all the rows for these, as there are multiple tables in the database, or I can just blow away the cache, and not really worry about it. My preferences for how many days to cache would determine how much would be downloaded again; on my office or home connection, it would not be a problem.<br /><br />For some, blowing away the cache may be a big deal, so know what that means for you if that is the option you choose, but for me, it was a great option. I made sure I synchronized to push any of my changes, shutdown Thunderbird, deleted cache.sqlite, and restarted Thunderbird. As predicted it downloaded everything again, and the constant alarm stopped.<br /><br />Problem Solved!<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-84330859336206323092012-02-22T08:36:00.007-05:002012-03-01T06:50:08.488-05:00Java Module Systems The EDT and ClassLoader IssuesAs mentioned in <a href="http://wadechandler.blogspot.com/2012/02/java-module-systems-swingworker.html">Java Module Systems SwingWorker, Runnable, Thread and ClassLoader Issues</a>, where invokeLater and invokeAndWait are discussed, the EDT is a separate thread with its own context classloader, and this is most likely the system classloader. It is important to understand this.<br /><br />If you create a user interface in a modular system, such as the NetBeans RCP, upon a user action logic will run on the EDT, and if in that logic you access classes by name, create new instances of them, or perform casts <span style="font-weight: bold;">and</span> those classes could possibly be in more than one module, you will run into classloader collision issues. I will restate here that this also affects EventQueue.invokeLater and invokeAndWait.<br /><br />Along with collision issues, you need to also understand that certain class access may be blocked depending on the classloader being used once you set the thread context classloader. Imagine you have some classes your current UI components classloader can see; they are part of its dependencies. Those dependencies classloaders may not have access to each other. If you use a classloader which does not have access to some classes to set the thread context classloader, then access will be blocked to those classes, and your logic will not work.<br /><br />Suppose there is a button and it has an action listener attached to it. It could be written as:<br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>public class MyActionListener implements ActionListener {<br />public void actionPerformed(ActionEvent evt){<br /> ClassLoader oldCl = Thread.currentThread().getContextClassLoader();<br /> try {<br /> //here we are actually taking the current instances classloader<br /> //which could be slightly better than<br /> //MyActionListener.class.getClassLoader()<br /> Thread.currentThread()<br /> .setContextClassLoader(getClass().getClassLoader());<br /> //create instances, cast, load classes by name<br /> }finally{<br /> Thread.currentThread().setContextClassLoader(oldCl);<br /> }<br />}<br />}<br /></code></pre><br /><br />The above could make an assumption it is the only possible some.specificpackage.MyActionListener to be within any module in the system at one time were it to use MyActionListener.class.getClassLoader(), and if that were not to be the case, you would need to get creative in the manner in which you get a classloader into this object.<br /><br />The code does slightly guard against that since it uses getClass().getClassLoader() versus the static MyActionListener.class.getClassLoader() which would unequivocally infer it is expected to be the only one in the system per the way the class and classloader are being accessed. This means the instances classloader will be used, and if the instance was created using a specific classloader, and it is correct, then the code will simply work. If the classloader is not correct, then the logic which created the instance will need to be fixed.<br /><br />This is another subtle way in which classloader issues can creep into the domain of concurrency and Java modular systems. You can use this information to ensure you have protected your modules logic from being broken by other modules at runtime which you probably will not have tested against.<br /><br />Remember, if you use 3rd party libraries in a module, or you are writing one, it is highly probable and definitely possible others will too, and you may use the same ones. Whether the library is the same version or not, unless it is accessed in the context of a shared module classloader, i.e. the library is itself in a module versus a simple JAR dependency and all other modules use it this way, it can cause collision and access issues.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-78873656436813832332012-02-21T20:56:00.005-05:002012-02-22T07:01:21.484-05:00Agile MVC User Interface Design - Not Soley For The Web<span style="font-size:180%;">Introduction</span><br /><br />When I wrote this I mainly had Java Swing developers in mind, particularly members of my current development team working on a <a href="http://platform.netbeans.org/">NetBeans RCP</a> based application, and I was initially going to title it Java Swing User Interface Design, but it certainly applies to any user interface work I have done in C, C++, C#, and JavaScript.<br /><br />There are a few things to keep in mind when starting to design and develop a user interface. First, and most importantly, has anyone from the user community contributed to the interface you are working on; ideas, use cases/user stories, business rules? Next, has the user community reviewed any ideas and UI mock ups before starting any heavy coding? Have you taken time to design the user interface before adding complex business rules or worrying about concurrency and threading? These things affect time and resources which impacts how quickly they can be done correctly.<br /><br /><span style="font-size:180%;">User Community Initial Input - User Stories or Use Cases</span><br /><br />The essential question to basically everything we do may be: Why am I doing this? The user community, which a developer could possibly be a member, knows their domain or business. In many cases, they don't know how to get that result out of a user interface or possible ways the experience can be better until they are shown, but they know what data goes in and what data should come out; roughly at a minimum.<br /><br />This is where requirements gathering comes into play. These have to start some where. The initial user stories (interchange with use cases) will be broad statements of what the users want to do. Users need to be coached into breaking those broad statements down into some very discreet ones which collectively would allow them to achive the one which is more broad. In project management terms, this starts to form what is known as a work breakdown structure.<br /><br />The above is the top tier of the work breakdown structure or the work to be performed which allows the application and project to fulfill its purpose. A developer should be able to take this information and create those portions of the application. If the user stories are refined enough, developers should be able to understand them, and in turn, create tasks which will guide the development of their source code.<br /><br />The tasks the developers create will become the lower tiers of the WBS. If the developers have a hard time deriving tasks from the refined user stories, they need to push back on the users until the stories are refined enough to allow this to happen. To the point. This represents why you are doing the thing you are doing. In this case, and more specifically, why the user interface will work the way it does.<br /><br /><span style="font-size:180%;">User Contributions to The User Interface - User Interface Mock Ups</span><br /><br />The advantage to iterative development, or in construction speak - design build, is direction can change more easily as development progresses. As the system gradually grows, replacing the whole becomes a more and more expensive proposition. If additions are built incrementally or in baby steps, they can be corrected within an iteration or two. Getting feedback from users ahead of time through UI mock ups helps with this as it relates to user interface design.<br /><br />A UI mock up should be as simple as possible while expressing and displaying enough of the UI layout along with functionality to the assumed user community, or at least a narrowed test group of the user community. Various tools can be used to perform this work.<br /><br />In some cases, a simple graphics application with annotated screen shots can be extremely useful. This is good when minor improvements or tweaks are added to existing functionality. This can be useful less the screen shots as well; imagine a simple form is thought to be all that is needed. Image applications can be useful for creating general layout examples along with rudimentary form objects. There are tools designed specifically for creating these type UI mock ups too, but many of the image manipulation programs one uses often work well.<br /><br />In other cases, more developer oriented tools are better suited. With developer oriented tools, such as the <a href="http://www.netbeans.org/">NetBeans IDE</a> and its UI designer, a partially functional representation can be created complete with real UI form components and windows and dialogs. Executable JAR files can be given to users which when run allow the user to play with an actual UI and get a feel for the ideas being presented.<br /><br />Along with the above, branch development provides yet another option. In a branch of the source code, parts of the UI changes can be worked into an existing and running application. Though the parts will not be complete, remember this is a mock up, they give the user a glimpse of exactly how those pieces will fit into the current system. The whole thing need not be working or a large amount of work done to achieve the desired result. If the UI is acceptable, then the rest of the UI work can take place inside the branch taking advantage of the work which went into the mock up; some refactoring will certainly be required, but at least much of the UI components will be in place even if simply copied and pasted.<br /><br />In some other cases, it may be best to create some kind of a functional prototype as mentioned above along with taking screen shots and then annotating them. It is often going to be much easier to create certain graphical effects in an image manipulation program than to write logic or source code from scratch to work those effects into an application; even if it is a prototype. The user can then take the functionality you can give them quickly, examine it, take the screen shots into consideration, and then make a determination as to whether such a feature adds value.<br /><br />All features should be evaluated as to which of the above will work best. Remember: mock ups should show the user the intent and give them a glimpse of possibilities as quickly as possible to allow the team to change course if needed. If too much code and time goes into the mock up, then it may not provide as many advantages. But, there are times where a more in depth prototype will be required. It simply depends on whether users really understand what they are being shown or not, so always remember that communication is the best tool.<br /><br /><span style="font-size:180%;">Incrementally Add Complexity</span><br /><br />Possibly the best designed user interface will have as little business logic in the UI components as possible. The UI components should merely be a vessel for retrieving information from the user and displaying it to them. Initially this will be to get and set information intentionally not adding progress updates and background threading possibly long processes.<br /><br />Progress updates and background operations will be determined by the data being set and retrieved per user operations and the processes required to get it. If taken into consideration in the user interface from the start, the user interface components are more likely to require changes often and in multiple places as use cases and operations evolve per user feedback. Minimise this until absolutely necessary. If the interface, along with data models - which probably differ from the data, capture the business rules correctly, then adding progress updates and threading at the end should require less work than reworking them.<br /><br /><span style="font-size:180%;">MVC</span><br /><br />In general an MVC pattern should be used. Data models, general utilities, controller logic, and the UI classes should be built into separate classes and files allowing them to be tested independently. This will also reduce the size of the individual files of the project. It will probably help produce a better design, and definitely with better separation.<br /><br />UI components should know how to take a data model and display it or convert it from a model into something the user sees through the lens of the component. Data models should be able to take a set of data and expose it through a particular programming interface which various logic can access. Often models will have selected values, data, and fire events upon certain changes or at least allow a domain to tell it when to fire such an event through something like a fireXEvent() method call.<br /><br />UI components should expose setters and getters or mechanisms to set and retrieve data the users actions have modified. These can expose data or models. These components should also allow various listeners to be added, removed, and retrieved. User actions, even if pressing a single button in some complex UI component, should generally be exposed through listeners and cause nothing to necessarily change in the UI unless it is purely related to the UI state.<br /><br />The controller should attach listeners and act upon such actions, and the logic which enables, disables, or changes various features of the user interface, such as setting a new model or updating an existing one which was a result of the action, should be built into the controller. The controller should contain the business logic. Other extraneous logic which seems fairly generic in the process should go into some possibly shareable utility class and not pollute the controller.<br /><br />A simple example of an MVC would be a file search utility. Suppose the UI of this utility has a single text field called searchTerm. Next, there is a button to the right of searchTerm called searchButton with a magnifying glass on it. The UI contains a tree table below called searchResults. The searchResults displays a model called searchModel of the type SearchModel (which is just an interface). The component has a property inSearch which when true searchButton has a magnifying glass which moves slowing in a circle, and searchTerm is disabled. When false, searchButton has its default still graphic, and searchTerm is enabled.<br /><br />Let's simply state that searchModel has a method called getFile which accepts an integer as the row in the model as well as one called getSize. It doesn't provide any filtering or anything. This is done by the controller by way of the searchTerm. The UI component knows how to take a model and show its files represented in a tree structure by way of getFile(ndx).getParent(), and that is all this component knows of this model.<br /><br />The UI component allows add/remove/getSearchButtonActionListener(s), get/setSearchTerm which sets and gets searchTerms text, set/getSearchModel, and set/isInSearch. The controller uses these exposed attributes of the UI component to do all the work and tell the UI how to look. It hooks in a searchButton listener, when searchButton is clicked, it sets inSearch to true, performs its background work, retrieves data, creates a model, which may be empty, sets the model, and finally sets inSearch to false. All the UI component did was fire an event, handle the button animation, and get and display information from and to the user.<br /><br />As it relates to incrementally adding complexity, there are a couple things which would have been done last in the above example. They are probably obvious, but they are 1) animating the searchButton, and 2) background work of the search. The actual functionality is the most important part. Once that works correctly, then backgrounding some logic and animating a button can be done. Those are not very high risk items on an agenda. It is safe to say that once one has done such a thing a couple times they will be able to do it in various situations over and over; static from a pure human memory perspective. The domain/business logic is the higher priority and most difficult and dynamic piece.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com5tag:blogger.com,1999:blog-17012213.post-47322563975758269232012-02-10T07:46:00.009-05:002012-02-15T12:29:36.655-05:00Java Module Systems, SwingWorker, Runnable, Thread and Class Loader IssuesPeople often have a hard time getting used to a Java module systems constraints on class loaders and dealing with compile time versus runtime dependencies. There are a lot of issues just around getting the dependencies organized.<br /><br />Often overlooked is how threading impacts class loaders. NetBeans modules, when "they" create a thread for you, will generally set the context class loader to the current class loader. However, in your own code you need to handle this.<br /><br />Note Runnable is mentioned above. This does not necessarily consider the cases of EventQueue.invokeLater and invokeAndWait as those things are generally cases where the object instances have been realized, and class loading is no longer in the picture, or at least they should be, as those things should be short and to the point as they happen on the EDT, but it focuses on Runnable when given to the Thread constructor.<br /><br />However, this could become a source of issues, and if creating new object instances in the Runnable, and it is ever a possibility those classes could be included in more than one module in the targeted system, then you should probably go ahead and deal with a class loader change out as your code will be running on the EDT.<br /><br />Either way, the reason this becomes important is class access and class collision.<br /><br />Access deals with the visibility or permissions a given class loader gives the calling code. Calling code may not have access to a certain class, and thus the current class loader should not be the one to load classes, but should instead delegate that to another module which has access to not only the public API but the private API of the module itself. That would be the one loading the classes the caller can access or the public API of the called module.<br /><br />Collision is a more subtle thing to deal with. Imagine one module has class mine.Foo and another module does as well. Even though these modules may not call or touch each other and thus not collide with each other under normal calling conditions, they may very well do that in a thread without setting the context class loader as those classes will have to be loaded some how, and here the system class loader will be used which will access all the class loaders, and that means either an arbitrary class must be chosen or the first one found, and in nearly all conditions this is not what you want.<br /><br />In the NetBeans module system this will cause an error as the NetBeans developers do not want this to be a surprise and thus hide crashes. Others may load them; I'm not sure, so if anyone knows how various module systems handle this please comment. Either way, unless you give Java and the module system more guidance, you will run into strange and unusual problems.<br /><br />Given a class, the following should really be used:<br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code><br />public class MyClass {<br /><br />Runnable r = new Runnable(){<br /> public void run(){<br /> ClassLoader oldCl = Thread.currentThread().getContextClassLoader();<br /> try {<br /> Thread.currentThread().setContextClassLoader(MyClass.class.getClassLoader());<br /> }finally{<br /> Thread.currentThread().setContextClassLoader(oldCl);<br /> }<br /> }<br />};<br /><br />Thread t = new Thread(){<br /> public void run(){<br /> ClassLoader oldCl = Thread.currentThread().getContextClassLoader();<br /> try {<br /> Thread.currentThread().setContextClassLoader(MyClass.class.getClassLoader());<br /> }finally{<br /> Thread.currentThread().setContextClassLoader(oldCl);<br /> }<br /> }<br />};<br /><br />SwingWorker&lt;Void, Void&gt; = new SwingWorker&lt;Void, Void&gt;{<br /> public Void doInBackGround(){<br /> ClassLoader oldCl = Thread.currentThread().getContextClassLoader();<br /> try {<br /> Thread.currentThread().setContextClassLoader(MyClass.class.getClassLoader());<br /> }finally{<br /> Thread.currentThread().setContextClassLoader(oldCl);<br /> }<br /> return null;<br /> }<br />};<br /><br />}<br /></code></pre><br /><br />This does a couple things at various runtimes. When the code runs in a regular Java application with no module system, the system class loader will always be used. Next, when run in a modular application, the current caller, or current module will use its class loader in the threaded logic. Finally, in both cases, the loader is reset to whatever it was before; for throw away threads, that is probably not a big deal, but what if your code is using a thread pool?<br /><br />This is a basic convention to follow for safety and refactorability. Safety as noted in access and collision. If your code is used in a modular system, and does not follow the above, it will crash as soon as you add the same classes to other modules. Refactorability per the fact that if more than one module later adds a different version of a class, or the same version different class loader, then the application will start to crash until fixed, and if the person tracking down the issue has to spend time finding and/or fixing it, they can't focus on refactoring code to work with the same classes in different ways.<br /><br />Another thing to keep in mind is there are times when you may need to pass a specific class other than your own for some block of code to pin-point an exact class loader. Imagine some code you are calling will need classes which your class loader does not have access as the module being called does not expose them as part of its public API.<br /><br />So, there are times when you have to think beyond the current class loader, but the good thing is no matter which class works in the modular system, the code will continue to work if used outside of one in a standard Java application.<br /><br />The one major time this differs are libraries written to load and use classes dynamically. MyBatis is a good example. In such cases, the current thread context class loader should be passed along. The idea being the caller is telling you which class loaders to use. This only applies to threads however as the module wrapping the called code will have configured the context class loader as needed for the current thread.<br /><br />The MyBatis folks were working to address this issue the last time I was on the lists. Someone using it in such a context now should comment if able.<br /><br />I hope this will help projects (open source and not) write Java code which is compatible in both modular and non-modular applications.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com2tag:blogger.com,1999:blog-17012213.post-14506163352010128952012-02-09T06:55:00.006-05:002012-02-15T12:14:33.652-05:00Java Community Process (JCP) 2.8 Seems Encouraging But What's MissingI'm looking at the <a href="http://jcp.org/en/resources/2.8">JCP 2.8</a> and I am encouraged by what I'm reading. For instance, in "Changes for Specification and Maintenance Leads" it states "You are responsible to provide a public communication channel for posting and archiving all Expert Group nominations and your deliberations on them (1.2.1), all Expert Group communications (1.1.1), and all Expert Group documents (1.1.1)." and too "You are responsible to provide and maintain an Issue Tracker visible to the public and a mechanism for the public to log issues in that tracker (1.1.2). ". My favorite is "The Specification license you provide at JSR Proposal may not change (1.1.3). ".<br /><br />That stated, I am let down that I see <span style="font-weight: bold;">no reference to compatibility kits and any requirements upon their openness</span>. Does anyone have more information on this? To me, this is one big thing which caused rifts in the Java community. Too, I feel there <span style="font-weight: bold;">should be something in the JCP about JSRs openness</span> as well. How open and freely usable the specifications are determines how they will be used for innovation to move the Java ecosystem forward.<br /><br />In my opinion, there <span style="font-weight: bold;">should at a minimum be a statement that the Java Community Process favors more open and free JSRs</span>. That doesn't mean implementations, except for the reference implementation, need to be free. The reference implementation should always be free, and if not in the JCP, that needs to be added. The reason for such a requirement should be obvious, but how does one create a specification known to work without an actual proof of concept? Experience tells me if one does it will be mostly flawed, and to have the right to create a specification and market it through the JCP process, one should have to prove it.<br /><br />It may be the concerns I raise have already been addressed, and I just do not see them. If so, that's awesome, and thank you to anyone who points them out. If not, then I believe there is still more to do before the JCP can live up to its potential. Here's to hoping it does!<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-84233954700625719832012-01-18T07:22:00.004-05:002012-01-18T07:26:48.467-05:00Tell Congress NO on SOPA and PIPA!Tell both parties in Congress NO! This has to stop. We are constantly under assault. Sooner or later the only companies able to have a web site will be multi-billion dollar conglomerates and those related to the media, movies, music, or Government. This is insanity. With these type regulations, eBay and Amazon wouldn't exist, and other companies, such as mine, will be limited in our options online. It is a fact the Internet in its current form contributes hundreds of billions of dollars to the economy. Tell Congress THEY need to be worrying about things which create jobs instead of stifling voices, commerce, and freedom!<br /><br />Go to <a href="https://www.google.com/landing/takeaction/">https://www.google.com/landing/takeaction/</a> and sign the petition!<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-51378122293073232732011-12-21T08:47:00.005-05:002011-12-21T08:56:32.023-05:00lwp-request or GET and POST and self signed SSL certificates (HTTPS)I was using the command line last night when I needed to hit one of my pages real quick. I didn't need the output all browser fancy, and I just needed a blurb of text, so I typed GET and the page address plus my credentials. I received an error from down in the bowels of Perl and the LWP::UserAgent library about my certificate not being verified.<br /><br />I looked around the Internet, and I saw different posts, but nothing told me exactly what to do. Different peoples solutions were vastly different. So, I looked for the documentation for the LWP libraries, and I found them. There I found the exact solution. The library can be affected by environment variables. The specific one is PERL_LWP_SSL_VERIFY_HOSTNAME. It is a boolean value or 0/1 in Perl. So on the command line I <a href="http://search.cpan.org/perldoc?PERL_LWP_SSL_VERIFY_HOSTNAME" class="podlinkpod"></a>simply ran:<br /><br />export PERL_LWP_SSL_VERIFY_HOSTNAME=0<br /><br />I then reran GET, and everything was good. So, if you run into this problem, then here is your fix. Simple and sweet.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-41987694277124054342011-04-13T10:41:00.018-05:002011-04-13T14:04:43.902-05:00Automated Web Testing with Selenium and The NetBeans Rich Client PlatformI developed tooling for work I do for Scripps which helps me create Selenium based automated user tests more easily. These are not open source at this time, though that may be possible some day. I might use the ones I have created as an example to make some better for OSS since I have learned lessons along the way.<br /><br />This tooling has been built on the NetBeans Rich Client Platform, but too, will run right in the IDE. I show IDE examples in this post. It helps create Java projects for using Selenium for automated user testing. This ties in nicely with the IDE.<br /><br />There are different technologies supported in the tooling. There is a JavaScript runner or window which allows one to run JavaScript inside Selenium using runScript and getEval. Too, there is project support for Java and Groovy. I don't show the Groovy support here, but it is exactly the same as the Java examples less you will be using a Groovy file instead of a Java file, so you can derive how it works from that.<br /><br /><span style="font-weight: bold;">This is not the same as the tooling available in the current NetBeans auto update centers</span>. I noticed it when I started this, and I don't see that it addresses things in the same manner which I do. I don't focus on the tests in this case as much as I focus on being able to test chunks of code as you are trying to develop the logic which will exercise your application.<br /><br />The reason I do this is because I do not just write tests. I create automation APIs which can be used to affect the system. This then allows tests to be created using those APIs. That limits the impact of application changes to the high level test scripts which use the APIs I create. Thus, if a change occurs in the application which can break the tests, then I change one file versus many.<br /><br />The above may be a topic of another post one day. I will now get on with showing the tooling.<br /><br />First, and not really shown here, I needed a way to proxy calls to a Selenium session. I created a library which implements certain aspects of Selenium to allow this to happen. This simply gets and sets the Selenium session ID so calls for a Selenium session may come from multiple places. In this case, the user serializes those things. You will see it references in code which follows.<br /><br />Next, I needed a way to manage Selenium server connections, and too I needed a simple way to kick off a Selenium server in the development environment. The "Selenium Manager" top component handles this for me. Certain aspects are configurable.<br /><br /><a href="http://4.bp.blogspot.com/-EbeZjUnuJyU/TaXJ9qJOANI/AAAAAAAAAHQ/FP7R5l9Igbk/s1600/se_manager.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 372px; height: 400px;" src="http://4.bp.blogspot.com/-EbeZjUnuJyU/TaXJ9qJOANI/AAAAAAAAAHQ/FP7R5l9Igbk/s400/se_manager.png" alt="" id="BLOGGER_PHOTO_ID_5595100173199868114" border="0" /></a><br /><a href="http://1.bp.blogspot.com/-WrNzYiNaokk/TaXJz6Lm2_I/AAAAAAAAAG4/NLrm_MwIK1g/s1600/se_configure.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 177px;" src="http://1.bp.blogspot.com/-WrNzYiNaokk/TaXJz6Lm2_I/AAAAAAAAAG4/NLrm_MwIK1g/s400/se_configure.png" alt="" id="BLOGGER_PHOTO_ID_5595100005706161138" border="0" /></a><br /><br /><a href="http://2.bp.blogspot.com/-9EzMlp3nzis/TaXJmkN8suI/AAAAAAAAAF4/3CgaxHWvqUk/s1600/connection_editor.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 280px;" src="http://2.bp.blogspot.com/-9EzMlp3nzis/TaXJmkN8suI/AAAAAAAAAF4/3CgaxHWvqUk/s400/connection_editor.png" alt="" id="BLOGGER_PHOTO_ID_5595099776472101602" border="0" /></a><br />You can also start and stop the in IDE Selenium server here. The output uses the NetBeans output window for this.<br /><br /><a href="http://1.bp.blogspot.com/-yyJvPxXLvNM/TaXJ-ZBoicI/AAAAAAAAAHo/6B4ky-L2kMs/s1600/se_start_server.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 294px;" src="http://1.bp.blogspot.com/-yyJvPxXLvNM/TaXJ-ZBoicI/AAAAAAAAAHo/6B4ky-L2kMs/s400/se_start_server.png" alt="" id="BLOGGER_PHOTO_ID_5595100185784519106" border="0" /></a><a href="http://3.bp.blogspot.com/-Xrh-SYO1KAw/TaXJndKmsqI/AAAAAAAAAGY/j2CunHSHBC8/s1600/java_support_output.png"><br /></a><br />Once you have configured connections, you can start and use them one at a time<br /><br /><a href="http://4.bp.blogspot.com/-uDJ9m1p2ulk/TaXJ9xhZvvI/AAAAAAAAAHg/5Kv2AsA4MwA/s1600/se_session_started.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 284px;" src="http://4.bp.blogspot.com/-uDJ9m1p2ulk/TaXJ9xhZvvI/AAAAAAAAAHg/5Kv2AsA4MwA/s400/se_session_started.png" alt="" id="BLOGGER_PHOTO_ID_5595100175180349170" border="0" /></a><br />Once a live session is available, the manager allows you to stop it or to copy the session ID using context menus<br /><br /><a href="http://4.bp.blogspot.com/-0KhliM3L_jE/TaXJ9zux1iI/AAAAAAAAAHY/xcLBRbu4spo/s1600/se_manager_session_started.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 331px; height: 400px;" src="http://4.bp.blogspot.com/-0KhliM3L_jE/TaXJ9zux1iI/AAAAAAAAAHY/xcLBRbu4spo/s400/se_manager_session_started.png" alt="" id="BLOGGER_PHOTO_ID_5595100175773324834" border="0" /></a><br />Next, and most importantly, there is the ability to do productive things.<br /><br />There is a Selenium JavaScript runner. This is a special window where one can type in JavaScript, execute it, and see the response. Too, one can ask for the current HTML from the page based on the DOM and not the plain HTML sources before any JavaScript logic has applied changes.<br /><br /><a href="http://4.bp.blogspot.com/-hDUI248uR68/TaXJzS0_QmI/AAAAAAAAAGg/7KhKl-fEvF4/s1600/js_runner_google.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 385px; height: 400px;" src="http://4.bp.blogspot.com/-hDUI248uR68/TaXJzS0_QmI/AAAAAAAAAGg/7KhKl-fEvF4/s400/js_runner_google.png" alt="" id="BLOGGER_PHOTO_ID_5595099995142308450" border="0" /></a><br />Notice the syntax highlighting options in the output below. I suppose I could add the ability to view that as JSON too. This is an example of using the "Grab HTML" button<br /><br /><a href="http://3.bp.blogspot.com/-qxzST1grnTI/TaXzVM3HpyI/AAAAAAAAAHw/lNNxmlQ_sgw/s1600/grab_html.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 391px; height: 400px;" src="http://3.bp.blogspot.com/-qxzST1grnTI/TaXzVM3HpyI/AAAAAAAAAHw/lNNxmlQ_sgw/s400/grab_html.png" alt="" id="BLOGGER_PHOTO_ID_5595145657632925474" border="0" /></a><br /><br />Notice the part above dealing with ret=ret in the JavaScript image. This is due to the way this logic will be run directly in Selenium and the way it returns the last evaluation instead of having the caller use the return statement; this is a Selenium thing (see Selenium.getEval). That could have been worked around in the JavaScript runner if I had put the logic in a function and called it, but for the purposes of using this window that is a little overhead I don't need.<br /><br />Above, you may have noticed the use of jQuery. How did it get there? Right, there is a difference in the JavaScript used in your application, and that used in Selenium. You can see my other blog post for more information, but I injected jQuery into the current Selenium session using Selenium.addScript from some Java code.<br /><br />I will show you how that gets there in a bit.<br /><br />It should be obvious we are using the started session here, but just to be clear, before I can run this JavaScript, I had to start a Selenium session and drive the state of the browser manually to get to what I wanted to operate against. In this case not really as the session opened on the Google home page.<br /><br />Above, I mentioned injecting jQuery. Well, if you can inject jQuery, then you can inject your own JavaScript as well. You can take the logic you figure out in the JavaScript runner and move that into your own JavaScript files which you will inject.<br /><br /><a href="http://1.bp.blogspot.com/-ny9RhWqCefw/TaXJm-9Cf5I/AAAAAAAAAGA/5wfS_D6P3Mc/s1600/examples_js.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 306px;" src="http://1.bp.blogspot.com/-ny9RhWqCefw/TaXJm-9Cf5I/AAAAAAAAAGA/5wfS_D6P3Mc/s400/examples_js.png" alt="" id="BLOGGER_PHOTO_ID_5595099783648935826" border="0" /></a><br /><br />Next, you can create a regular Java project in the NetBeans IDE. Then, you can create a standard Java class. You can then click on a line in the Java file and bring up a context menu and ask the tooling to inject the required Selenium proxy logic to allow you to write code using the current session.<br /><br /><a href="http://4.bp.blogspot.com/-9HKXGB81tAU/TaXJz9ExnVI/AAAAAAAAAHA/PfK8LZNtXxU/s1600/se_insert_selenium_session_proxy.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 299px;" src="http://4.bp.blogspot.com/-9HKXGB81tAU/TaXJz9ExnVI/AAAAAAAAAHA/PfK8LZNtXxU/s400/se_insert_selenium_session_proxy.png" alt="" id="BLOGGER_PHOTO_ID_5595100006482812242" border="0" /></a><br />This can be in a main method as above in which case it will be a local variable, or it can be at the class level. Repeated uses of the above action will just overwrite the previously injected code unless it is deleted; in that case it will be added back. This is needed if you stop the Selenium session and restart it. In this case you get a new session ID. Once you use the action, your class will look like this<br /><br /><a href="http://1.bp.blogspot.com/-9gbCtaFaxpE/TaXJzqtXdjI/AAAAAAAAAGo/xgCjCjfu2zU/s1600/se__after_insert_selenium_session_proxy_java_editor.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 261px;" src="http://1.bp.blogspot.com/-9gbCtaFaxpE/TaXJzqtXdjI/AAAAAAAAAGo/xgCjCjfu2zU/s400/se__after_insert_selenium_session_proxy_java_editor.png" alt="" id="BLOGGER_PHOTO_ID_5595100001552791090" border="0" /></a><br />Then you fill in some scratch pad type code to exercise some logic you will later add to an actual API. <span style="font-weight: bold;">This may seem counter intuitive, but the point is to be able to drive the state of the application with the browser while you write some finite pieces of the whole which you know work</span>. This greatly reduces the time to get the state in place and start the test etc. The develop test cycle becomes easier to manage.<br /><br /><a href="http://2.bp.blogspot.com/-7lFTgq7KNHM/TaXJnN42heI/AAAAAAAAAGQ/uLK3aXH964A/s1600/java_support.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 361px;" src="http://2.bp.blogspot.com/-7lFTgq7KNHM/TaXJnN42heI/AAAAAAAAAGQ/uLK3aXH964A/s400/java_support.png" alt="" id="BLOGGER_PHOTO_ID_5595099787657905634" border="0" /></a><br /><a href="http://3.bp.blogspot.com/-Xrh-SYO1KAw/TaXJndKmsqI/AAAAAAAAAGY/j2CunHSHBC8/s1600/java_support_output.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 182px;" src="http://3.bp.blogspot.com/-Xrh-SYO1KAw/TaXJndKmsqI/AAAAAAAAAGY/j2CunHSHBC8/s400/java_support_output.png" alt="" id="BLOGGER_PHOTO_ID_5595099791758897826" border="0" /></a><br />So, how did our JavaScript and jQuery come to reside in the Selenium session? It was put there with another scratch pad Java class.<br /><br /><a href="http://1.bp.blogspot.com/-ZxNza8BiMMA/TaXJmxHCrLI/AAAAAAAAAGI/JiuYcd03QyM/s1600/inject_scripts.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 316px;" src="http://1.bp.blogspot.com/-ZxNza8BiMMA/TaXJmxHCrLI/AAAAAAAAAGI/JiuYcd03QyM/s400/inject_scripts.png" alt="" id="BLOGGER_PHOTO_ID_5595099779932794034" border="0" /></a><br />The related libraries were added to my Java project automatically for me by the tooling too. This includes the proxy library which I first wrote about.<br /><br /><a href="http://4.bp.blogspot.com/-ASsc5wsUvk8/TaXJz7W1x8I/AAAAAAAAAGw/Ojjx1DD5Jrw/s1600/se__after_insert_selenium_session_proxy_project_properties.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 285px;" src="http://4.bp.blogspot.com/-ASsc5wsUvk8/TaXJz7W1x8I/AAAAAAAAAGw/Ojjx1DD5Jrw/s400/se__after_insert_selenium_session_proxy_project_properties.png" alt="" id="BLOGGER_PHOTO_ID_5595100006021711810" border="0" /></a><br />I'm obviously trying to use a very simple example here. To get real work from these tools I have a full blown AUT API I have designed and developed for the project I'm testing. Too, I have developed the infrastructure needed to use the API including a set of tests and Ant build scripts.<br /><br />The individual tests I can run directly from the IDE as they are JUnit tests, and their core logic can be developed, along with the APIs, running against a live Selenium session. The Selenium JavaScript injection is done automatically by my base JUnit test along with other preliminary things.<br /><br />Hopefully at some point in the near future I will create an OSS version of this tooling. I don't have an ETA at this moment. But, I hope as I feel it could be useful for many.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com2tag:blogger.com,1999:blog-17012213.post-15219261168217266292011-04-11T14:45:00.004-05:002011-04-12T08:02:07.290-05:00Using Selenium and jQuery for Automated User TestingI am assuming you are familiar with both jQuery and Selenium. Too, I'll assume you want to use jQuery inside locators or in some way through Selenium to make locators easier using more utilities. So, I'll show you how to do that as well as use your own custom JS files and logic through Selenium just the same by using Selenium.getEval.<br /><br />First, the below is made possible using the Selenium command or API call addScript. Next, we need a way to take our file or URL based resource and convert it easily into a string which is what addScript is expecting. I use this utility I have:<br /><br /><pre style="font-family: arial; font-size: 12px; border: 1px dashed rgb(204, 204, 204); width: 99%; height: auto; overflow: auto; background: url(&quot;http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif&quot;) repeat scroll 0% 0% rgb(240, 240, 240); padding: 0px; color: rgb(0, 0, 0); text-align: left; line-height: 20px;"><code style="color: rgb(0, 0, 0); word-wrap: normal;"> public static String inputStream2UTF8(InputStream in) throws IOException {<br /> String ret = null;<br /> BufferedInputStream bin = new BufferedInputStream(in);<br /> InputStreamReader isr = new InputStreamReader(bin, "UTF-8");<br /> StringBuilder sb = new StringBuilder();<br /> int iread = -1;<br /> while ((iread = isr.read()) != -1) {<br /> sb.append((char) iread);<br /> }<br /> ret = sb.toString();<br /> return ret;<br />}<br /></code></pre><br /><br />Next, I like having a more utilitarian method of injecting these resources into the current Selenium session. I use the following two methods together:<br /><br /><pre style="font-family: arial; font-size: 12px; border: 1px dashed rgb(204, 204, 204); width: 99%; height: auto; overflow: auto; background: url(&quot;http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif&quot;) repeat scroll 0% 0% rgb(240, 240, 240); padding: 0px; color: rgb(0, 0, 0); text-align: left; line-height: 20px;"><code style="color: rgb(0, 0, 0); word-wrap: normal;"><br /> /**<br /> * Merges all these different resources into a single input stream, puts them<br /> * into a single JS memory file, and injects this into Selenium using the given<br /> * js element tag ID (jsTagID).<br /> * @param resourceLocator class used to locate resources using cpResourcePaths<br /> * @param cpResourcePaths resource paths relative to resourceLocator or fully qualified<br /> * @param filePaths file system paths, these can be relative if used from a<br /> * running directory, but generally should be full<br /> * @param jsTagID the ID of the script element to inject into Selenium<br /> * @param se the Selenium instance to inject into<br /> */<br /> public static void injectJavaScriptResourcesTogether(Class resourceLocator,<br /> String[] cpResourcePaths,<br /> String[] filePaths,<br /> String jsTagID,<br /> Selenium se) {<br /> ArrayList<inputstream> ins = new ArrayList<inputstream>();<br /> try {<br /><br /> for(String cpResourcePath : cpResourcePaths){<br /> InputStream in = resourceLocator.getResourceAsStream(cpResourcePath);<br /> if (in != null) {<br /> ins.add(in);<br /> }<br /> }<br /><br /> for(String filePath : filePaths){<br /> File f = new File(filePath).getAbsoluteFile().getCanonicalFile();<br /> InputStream in = new FileInputStream(f);<br /> ins.add(in);<br /> }<br /><br /> SequenceInputStream sin = new SequenceInputStream(Collections.enumeration(ins));<br /><br /> String js = inputStream2UTF8(sin);<br /><br /> //don't swallow here...let the caller do that if<br /> //they need to. API should not eat exceptions generally<br /> se.addScript(js, jsTagID);<br /><br /> } catch (Throwable e) {<br /> if (RuntimeException.class.isInstance(e)) {<br /> throw RuntimeException.class.cast(e);<br /> } else {<br /> throw new RuntimeException(e);<br /> }<br /> } finally {<br /> for (Closeable closer : ins) {<br /> try {<br /> closer.close();<br /> } catch (Throwable e) {<br /> }<br /> }<br /> }<br /> }<br /><br /> public static void injectJavaScriptResource(Class resourceLocator,<br /> String cpResourcePath,<br /> String jsTagID,<br /> Selenium se) {<br /> ArrayList<closeable> closeables = new ArrayList<closeable>();<br /> try {<br /> InputStream in = resourceLocator.getResourceAsStream(cpResourcePath);<br /> if (in != null) {<br /> closeables.add(in);<br /> }<br /> String js = inputStream2UTF8(in);<br /><br /> //don't swallow here...let the caller do that if<br /> //they need to. API should not eat exceptions generally<br /> se.addScript(js, jsTagID);<br /><br /> } catch (Throwable e) {<br /> if (RuntimeException.class.isInstance(e)) {<br /> throw RuntimeException.class.cast(e);<br /> } else {<br /> throw new RuntimeException(e);<br /> }<br /> } finally {<br /> for (Closeable closer : closeables) {<br /> try {<br /> closer.close();<br /> } catch (Throwable e) {<br /> }<br /> }<br /> }<br /> }<br /></closeable></closeable></inputstream></inputstream></code></pre><br /><br />You can see in the logic above that I attempt to locate the resources given to the methods in different ways. That is pretty straight forward, so I will let the code document itself.<br /><br />Next, I add JS files into my Java project in NetBeans in a Java package. I will access those things as classpath resources per the code above. I use the following code below from some of my other source code:<br /><pre style="font-family: arial; font-size: 12px; border: 1px dashed rgb(204, 204, 204); width: 99%; height: auto; overflow: auto; background: url(&quot;http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif&quot;) repeat scroll 0% 0% rgb(240, 240, 240); padding: 0px; color: rgb(0, 0, 0); text-align: left; line-height: 20px;"><code style="color: rgb(0, 0, 0); word-wrap: normal;"><br /> public void injectSupportingJavaScript() {<br /> ArrayList<closeable> closeables = new ArrayList<closeable>();<br /> try {<br /> String[] resources = new String[]{<br /> "resources/jquery-1.4.4.min.js",<br /> "resources/utils.js",<br /> "resources/nav-utils.js",<br /> "resources/image-dialog-utils.js",<br /> "resources/asset-dialog-utils.js",<br /> "resources/module-utils.js"<br /> };<br /> <br /> try {<br /> SEUtilities.injectJavaScriptResourcesTogether(getClass(),<br /> resources,<br /> new String[0],<br /> "ff-aut-javascript",<br /> se);<br /> } catch (Throwable e) {<br /> log.log(Level.WARNING, "Unable to inject required Java Script as a single stream. Will attempt to inject the required .js files individually and continue to run.", e);<br /> try {<br /> for (int i = 0; i &lt; resources.length; i++) {<br /> SEUtilities.injectJavaScriptResource(getClass(), resources[i], "ff-aut-javascript-" + i, se);<br /> }<br /> } catch (Throwable e2) {<br /> StringBuilder emsg = new StringBuilder();<br /> emsg.append("Unable to inject required Java Script as individual streams. ");<br /> emsg.append("Will not be able to continue as the locators can not be used in testing. ");<br /> emsg.append("Selenium may need to be hacked a bit, or ");<br /> emsg.append("the Firefly AUT API .js files need to be further broken up. ");<br /> emsg.append("This is because Selenium HUB has issues with too large of requests. ");<br /> emsg.append("The API already tries to compensate for this, and this measure has failed ");<br /> emsg.append("which usually indicates a .js file injected into Selenium at test time has ");<br /> emsg.append("grown too large in size.");<br /> log.log(Level.SEVERE, emsg.toString(), e);<br /> }<br /> }<br /><br /> } catch (Throwable e) {<br /> if (RuntimeException.class.isInstance(e)) {<br /> throw RuntimeException.class.cast(e);<br /> } else {<br /> throw new RuntimeException(e);<br /> }<br /> } finally {<br /> for (Closeable closer : closeables) {<br /> try {<br /> closer.close();<br /> } catch (Throwable e) {<br /> }<br /> }<br /> }<br /> }<br /></closeable></closeable></code></pre><br />Notice the part about a single resource versus individual in the logic. I do this because there is an issue with Selenium Grid where it seems to use HTTP GET instead of POST in some cases where it should be using POST; at least this is my assumption per the error messages I received. This provides a decent fall back.<br /><br />In the above, your custom logic will obviously need to inject your own .js files and those will need to be relative to your own class. Once you do that, you can then create a Selenium locater using either pure jQuery inline or you can use your own JS functions to limit the JS logic you have to place in Java files.<br /><br />Too, using Selenium.getEval(String) you can execute JavaScript directly in the Selenium session. Sometimes you need to do this if your logic depends on some jQuery event listeners and the standard Selenium calls will not activate that logic correctly.<br /><br />The one caveat to using these things, due to JavaScript targeting, is <span style="font-weight: bold;">always </span>pass in window.document to jQuery or your own custom JavaScript functions. The reason is that Selenium will be running in a separate browser window from your application. window.document will point to the window where your applications DOM resides. If you have any question about that specifically let me know.<br /><br />Some locater example might be:<br />"dom=your_js_function_doSomething(window.document);"<br /><br />For getEval it would simply be:<br />"your_js_function_doSomething(window.document);"<br /><br />Remeber, the last evaluation or the return statement will be what Selenium returns to the calling logic. Too, you can use the throw statement in your JS to propagate better messages to the calling Java logic.<br /><br />Enjoy.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-50380771509128003312011-03-31T16:22:00.003-05:002011-03-31T16:37:45.334-05:00Multi-line HTML Tag Parsing with Regular Expressions and JavaI was looking at some regular expression related posts earlier today, and I noticed many of them showing something along the lines of:<span style="font-family: monospace;"><br /><br /></span>&lt;<span style="font-weight: bold;">a\\b[^&gt;]*href=\"[^&gt;]*&gt;(.*?)</span><br /><span style="font-family: monospace;"><br /></span>The issue is in the<br /><span style="font-weight: bold;">.*?<br /><br /></span>That<span style="font-weight: bold;"> </span>may exclude line terminators. If you use<br /><span style="font-weight: bold;">[\\W\\w\\s]*</span><span style="font-family: monospace;"><span style="font-weight: bold;"></span></span><span style="font-weight: normal;"><br /><br />in place of that. It will work around the line terminator issues. That is unless you are specifically looking for some specific tag without a line terminator.<br /><br /></span><div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-38718119275515749912011-02-04T14:05:00.003-05:002011-02-04T14:32:45.900-05:00MochaHost: Was hoping they were going to be reliable Java hosting company; they are not even closeRecently I had the displeasure of trying out <a href="http://www.mochahost.com">http://www.mochahost.com</a>. I noticed their price points, and too they offer VPS for what seemed to be a great price. However, with hosting services, the ability to provision a new server in a timely manner, good customer service, infrastructure which just works, all matter. My experience was lacking in every way.<br /><br />First, provisioning the VPS took over a week. I used their online live chat, and too I emailed their support. After days I finally had some information. They said their billing system had a bug in it, and they didn't receive my order until later. OK, I can give someone that initially; wasn't warm and fuzzy, but I could deal.<br /><br />Next, I didn't know anything about their services, so I used a prepaid card to register, and only registered for a month. Thirty dollars US seems a great deal for a 1GB RAM bursting to 1.2-1.6GB VPS. But, I like to try things out in the safest way possible as you never know who is fronting a criminal or poorly managed or insecure business. No lock in and a safer card.<br /><br />I recommend small businesses adopting the prepaid card trick by the way, and too, never EVER sign up for something over a month on contract until you have tried it out. VERIFY!<br /><br />Well, they double billed me as soon as they got the server set up. The card declined. They turned off my service. This after they had a history of me writing their support and asking where the system I had already paid for was. Back to support I go.<br /><br />I write support, and I explain the situation, and I go ahead and copy and forward previous emails. They wrote back apologizing, and said they changed my invoice date etc. OK, server on, lets try it out.<br /><br />Well, they use WHM and cpanel. During the stint with the card, their automated processes have disabled those. Now, I can't manage things through those interfaces, and too, I'm paying a little extra for those programs; they force you to pay that extra amount on account creation; must have some panel with their VPS.<br /><br />I'm sitting wondering after all which has occurred why they didn't verify the system. Not looking good. So, I write them again. At this point most would have walked away I'm sure. But, I was wanting a beating.<br /><br />They tell me they have it fixed. I get into WHM, and there isn't much I can manage there. Too, cpanel isn't setup; I can't log into the system through it. I get some weird error.<br /><br />I mean, I am using a hosting service right? Kind of the point: I don't have to manage "everything".<br /><br />I write them and explain that I don't want WHM nor cpanel which they forced me to pay extra for and use at sign up. I tell them it seems it is just not working with their VPS configurations, and it doesn't; even email account configuration seems to not exist. I tell them I don't want to have it on the system at all, and that way I can try out their rest of their services and support without it, and that I use Linux all the time and would just rather the command line. I even tell them I could write about this experience one way or another, and the ball is in their court, but that I'm still willing to see what they have.<br /><br />I say a) I want the system freshly installed b) no WHM or cpanel or to at least know if that is a possibility c) explanation of whether the "unlimited" email accounts are to be on the VPS or through other hosted services they may have, and roughly that is about all I want less their promised 99.9% up time outside of my own coding or GlassFish 3 crashes if they occur.<br /><br />I get an email back asking me to detail what I expect. So, I go into the details again. Too, I ask them to review the history of my account, and why I am dissatisfied with their service. I even tell them they should be reviewing this case to help make their business better, because there is obviously something wrong. The whole time, outside of explaining this is something I've paid for, I'm deliberately polite.<br /><br />I get another email back telling me they can't do anything with my account until I take care of an outstanding balance! This being the double bill. I sent them a copy of my receipt, the transaction ID from the CC company, and asked for my money back.<br /><br />We'll see if that happens or not, but just be warned. MochaHost is not what you're looking for if you want anything remotely close to good service. At this point, service under par would be good. END RANT<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-47171877835173558502011-01-28T10:34:00.004-05:002011-01-28T10:51:14.555-05:00Java, @Override, and refactoringWe have been making some changes to the user interface of a project of which I'm a member. This requires me to change some automated user testing APIs and interfaces to match the new reality.<br /><br />I don’t remember exactly who I was talking one day when they mentioned my use of the @Override annotation even when implementing interfaces. I told them the IDE added that, and I just left it at that. I couldn’t think of a great use case for that being there at the time, but since the IDE did it for me I figured there must be some point even in the case of interface implementation, so I left it in the code as it didn’t cause any issue and was correct logic.<br /><br />Now that I have begun to refactor and remove some methods which no longer make sense, I am finding the @Override annotations very useful because the IDE points out what is implemented as an @Override when it isn’t actually overriding anything from a super class or interface. This is a compile time error, and were I not using a fancier IDE, I would still be alerted to the problem when the project was compiled. Thus, the annotation has been a nice aid in this type of refactoring.<br /><br />This would also be the case of an actual method override in the case where the super method was not called from the override. In such a case, and without @Override, the logic would simply no longer be used, but would compile just fine. The call would be removed from calling code of the super class or interface for the obvious compiler reasons one would encounter, but if someone left that logic in the existing class by mistake, and someone thought it should be called because some other state depended on it without that class being rethought at the time of some major refactoring, then a serious issue has been introduced which could be hard to figure out.<br /><br />I wanted to share this with everyone as I believe it can help everyone if @Override is always used. If you have a different opinion or thoughts on the topic please share.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-29807465126472162372009-03-27T10:19:00.003-05:002009-03-27T10:42:20.734-05:00The problem with standards; the chicken before the eggI saw a headline. "Microsoft Calls for Open Cloud Standards". I love standards. The problem is putting standards before there are enough really good examples to honestly have a good standard; chicken before the egg or the cart before the horse.<br /><br />I have actually changed my stance on this over the years. I used to be all about a standards body, and everyone getting together and hashing out the details. The problem in doing this before there are really good real world examples, more than a couple, is there are a lot of details we don't actually know about such needs, requirements, use cases, etc which simply are not feasible to just throw together or to try to formulate; our industry always assumes we know more about all of the above than we do.<br /><br />The needed information only comes with real application experience, and that will not come from developers in an office purely working on infrastructure who never have to use what they design in real implementations; I have seen it way to many times.<br /><br />There are two big things at work here. Yes, you must have the infrastructure and developers for that. Part of what comes from this is knowing what will work (think more about programming and low level details...not end user use cases), how the pieces fit together to provide different features of the system, and something which can be used; this is really iterative.<br /><br />Next, you have to have those building solutions with that system. It must be put through its paces. On top of that, those end developers will add their own features, provide feedback, and tell you what does and does not work. We are really just talking about agile processes, but seemingly this gets lost in drives for standards.<br /><br />Sure, we have many examples of grid computing and other very similar technologies. Too, there are clouds that have been available for a while now. Virtualization has been around for a good long while too.<br /><br />OK, I concede all of that ahead of time. But, too many standards bind a project to implement some very under used features, require resources to implement, and then change so much over time as to essentially cause some of the fuss and confusion they are trying to avoid before everyone involved, including the users, know the real details about that which is being standardized.<br /><br />Were innovators to do what they do and innovate. Then, only after a market has formed around multiple implementations of similar technologies, try to form a consensus on a standard. The standard would be more complete up front, and groups wouldn't have a hard time getting behind it or accepting it as input would be available from those with their noses to the grind stones to really give the standard the respect something we should call a <span style="font-weight: bold;">standard</span> deserves.<br /><br />That's it.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com1tag:blogger.com,1999:blog-17012213.post-90567633235802855052009-03-24T09:26:00.003-05:002009-03-24T09:46:03.813-05:00What happened to Chris Cornell??? Scream? I did.OK, not so much about programming, but if you are like me you find yourself jamming along to something while you work. Today, I was clicking through my Napster account and saw a new album from Chris Cornell. It is called <span style="font-style: italic;">Scream</span>. I had been wondering when we would see something else from him.<br /><br />I am a big Cornell fan, so it was a complete and utter shock to me this album was produced by Timberland; funny, I didn't actually know that until reading about it later, but thought it sounded similar. I completely hated it. I missed the guitar, chords, drums, and in it all I missed Chris Cornell.<br /><br />I get the desire to put a different spin on things you do, but not only did I not like it, it had nothing to do with the genre. I must admit pop isn't near the top for me; I would put most pop below most classical, and below the bluegrass that I don't like. There is a lot of classical I like, but a lot I do not, and the bluegrass I don't like, is pretty bad; I go for more rock I believe just not too hard, but definitely a lot music from different genres that I love except for rap.<br /><br />So, when I say this, you have some context, I would put this entire album at the bottom of the pop genre, and right above rap, and I don't listen to rap, but if I had to pick listening to <span style="font-style: italic;">Scream</span> again I would maybe listen to some rap. I couldn't think nor program to this music, and quite possibly could not walk, chew gum, and listen to it at the same time; it is that annoying.<br /><br />I sure hope Chris finds his way back. The reviews of this thing hopefully are the kind he can. I can't imagine many of his real fans liking it, but I can't imagine them not giving him another chance. Surely we can all agree to chalk this one up to humorous trial and error no matter how painful it was.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-8520027990472361932008-11-03T15:10:00.002-05:002008-12-10T20:34:25.494-05:00openSuSE 11, Sun VirtualBox, Windows XP, and OpenSolarisI upgraded my laptop from openSuSE 10.3 to 11.0, and I must say that I really like it. It has many small improvements, but most importantly I have not had to decompile and compile my own ACPI DSDT, it actually hibernates correctly, and just works with the Toshiba hardware. See my <a href="http://wadechandler.blogspot.com/2007/05/opensuse-102-fedora-core-5-kubuntu.html">10.3 post</a> for my issues with this laptop.<br /><br />The one draw back was I went with KDE 4, and while it seems a really awesome desktop function wise, it's stability left a horrible taste in my mouth. So, I decided to give Gnome a try after all these years of being a big KDE fan. I really like Gnome 2.2, but I'm not sure if I'll keep using it or go back to KDE 3.x and wait on KDE 4 to catch up.<br /><br />In <a href="http://wadechandler.blogspot.com/2007/05/opensuse-102-fedora-core-5-kubuntu.html">my previous setup</a> I was using VMWare Workstation 6.0 (which I paid over a couple hundred dollars). I really liked it function wise, mostly. The main draw back is it wasn't really kept up to date to run on newer kernels shipped with Linux distros such as openSuSE and probably even Fedora. At least I couldn't find the updates, and I was having to resort to hacking the source code to get it to build against my kernel. So, I gave Sun's VirtualBox a try, and I must say that I've been very impressed with the overall performance and Linux distro updates, but there are a few things it needs to do better.<br /><br />VMWare Workstation will let me use multiple monitors just like X. In other words (see my screen shot) I literally have two separate screens which I may drag windows across. A single desktop with two monitors. Pretty common indeed. Well, VirtualBox doesn't support this. The best it can do is have a single window non-full screen stretched across my multiple monitors. Not so great (horrible actually). See my <a href="http://wadechandler.blogspot.com/2007/05/opensuse-102-fedora-core-5-kubuntu.html">screen shots from the 10.3 and VMWare post</a> to see what I mean; <a href="http://1.bp.blogspot.com/_nhYhoq2dQSE/RmBxPkl8-EI/AAAAAAAAAAk/gSfyfMm5Au8/s1600-h/wade_opensuse_10.2_3.png">check out Vista</a>.<br /><br />ALSA sound support is very choppy. I don't know what the deal is, but VMWare had this issue too though my other applications such as Firefox, Banshee, etc are fine. Right now, what VMWare couldn't do, I'm using OSS for sound, and this is a little better, but it gets choppy when I try to use something like Napster and play my music from Windows.<br /><br />Seems networking is easier in VMWare. This is probably due to custom network drivers which VirtualBox doesn't have, so VirtualBox can't easily, and independent of the network interfaces, setup standalone network interfaces. Now, it wasn't such a big deal to setup VirtualBox from a networking perspective, but I venture to say those newer to Linux or Unix will have a harder time getting VirtualBox working than VMWare if they need to go beyond NAT.<br /><br />In my setup my virtual machines have their own IP addresses. This way they act as true independent computers when I need them for testing etc, and this makes network shares and other necessities much easier to use. Anyways, I had to setup a bridge, disable NetworkManager, and do some things by hand versus using the GUI. Having to disable NetworkManager means using wireless networks will now be harder as I have to use the keyboard versus a UI, but as I've used Linux for years it is not that much harder for me.<br /><br />USB interfacing seems to be harder. I haven't gotten this setup yet, but I haven't really needed it yet, so I haven't done much digging. Regardless, it isn't working out of the box where as VMWare did. In VMWare I could just connect a USB device, connect it to the virutal machine with the UI, and I was using it without the need for any extra dependencies in the OS. Seems VirtualBox has some dependency I'm missing from my openSuSE installation.<br /><br />OK, screen shot time. In this screen shot, I'm running two monitors, one with 1440x900 resolution, and the other with 1680x1050. I can full screen a virtual machine on either monitor, and after I install the virtual box extensions into the guest operating systems they can resize their resolutions to fit the resolution of which ever monitor I happen to be running or the size of the Window in which they're running. At least this is true for Windows. In this screen shot, I'm updating Windows XP to service pack 3, installing OpenSolaris 2008.05, building a NetBeans 6.5 daily build, and browsing the openSuSE online store. Enjoy.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_nhYhoq2dQSE/SQ9knofEc2I/AAAAAAAAACk/kajkW-3oU6k/s1600-h/opensuse11_building_NB_installing_OS.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 134px;" src="http://4.bp.blogspot.com/_nhYhoq2dQSE/SQ9knofEc2I/AAAAAAAAACk/kajkW-3oU6k/s400/opensuse11_building_NB_installing_OS.png" alt="" id="BLOGGER_PHOTO_ID_5264537121464808290" border="0" /></a><div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-60571433289630263362008-07-16T10:44:00.002-05:002008-12-10T20:34:26.149-05:00Make adding properties to classes in NetBeans a simpler taskNetBeans has a great feature called Code Templates. This is used to create shortcuts which may be typed in the editor then expanded into a template which the editor will ask the user to fill in the blanks. There are many useful ones which come configured upon installation within the NetBeans IDE, but one I have used for a long time, yet never written about except on the NetBeans mailing lists, is one to create properties more easily.<br /><br />These properties are plain properties un-bounded and not incorporating property change events, but none the less very useful, and it isn't much work to transform into your choice of other useful property creating templates. Without further delay, my code template is:<br /><blockquote>private ${TYPE} ${VAR} = ${VAL};<br /><br />public ${TYPE} get${NAME}(){<br />return ${VAR};<br />}<br /><br />public void set${NAME}(${TYPE} ${VAR}){<br />this.${VAR} = ${VAR};<br />}<br /><br />${cursor}</blockquote>Mine is named prop, so when I am in a Java file I type<br /><blockquote>prop</blockquote>then press the TAB button/key. The template is expanded and asks me to fill in the details. Below are some screen samples of this in action.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nhYhoq2dQSE/SH4aawmev4I/AAAAAAAAABM/diuM1AKsnBE/s1600-h/NB_template1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_nhYhoq2dQSE/SH4aawmev4I/AAAAAAAAABM/diuM1AKsnBE/s400/NB_template1.png" alt="" id="BLOGGER_PHOTO_ID_5223641664821575554" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nhYhoq2dQSE/SH4abEHlZRI/AAAAAAAAABU/CH3x4oSHr1w/s1600-h/NB_template2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_nhYhoq2dQSE/SH4abEHlZRI/AAAAAAAAABU/CH3x4oSHr1w/s400/NB_template2.png" alt="" id="BLOGGER_PHOTO_ID_5223641670060696850" border="0" /></a>I simply press the TAB button to jump between the fields <span style="font-style: italic;">TYPE</span>,<span style="font-style: italic;">VAR</span>, and <span style="font-style: italic;">VAL</span>, enter the values, and when I have them all filled in press the ENTER button and my cursor is placed at the ${cursor} position or offset in the editor.<br /><br />The final result is a read-write property with the source code all laid out nicely<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nhYhoq2dQSE/SH4bmxnHzwI/AAAAAAAAABc/g0BzsNcnoeI/s1600-h/NB_template3.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_nhYhoq2dQSE/SH4bmxnHzwI/AAAAAAAAABc/g0BzsNcnoeI/s400/NB_template3.png" alt="" id="BLOGGER_PHOTO_ID_5223642970762759938" border="0" /></a><br />To expand the function of the template is easy enough. I have one which adds the logic for property change events. I have it named eprop in my IDE.<br /><blockquote>private ${TYPE} ${VAR} = ${VAL};<br /><br />public ${TYPE} get${NAME}(){<br /> return ${VAR};<br />}<br /><br />public void set${NAME}(${TYPE} ${VAR}){<br /> ${TYPE} lold${VAR} = this.${VAR};<br /> this.${VAR} = ${VAR};<br /> pcs.firePropertyChange("${VAR}",lold${VAR},${VAR});<br />}<br /><br />${cursor}</blockquote>It assumes you have an instance of <span style="font-style: italic;">java.beans.PropertyChangeSupport</span> called pcs.<br /><br />I have another one named ewprop which stands for Wrap or Wrapper, and in this case another field is needed to handle wrapping primitive types to pass the call to firePropertyChange, and it also assumes a variable named pcs:<br /><blockquote>private ${TYPE} ${VAR} = ${VAL};<br /><br />public ${TYPE} get${NAME}(){<br /> return ${VAR};<br />}<br /><br />public void set${NAME}(${TYPE} ${VAR}){<br /> ${TYPE} lold${VAR} = this.${VAR};<br /> this.${VAR} = ${VAR};<br /> pcs.firePropertyChange("${VAR}",new ${WTYPE}(lold${VAR}),new ${WTYPE}(${VAR}));<br />}<br /><br />${cursor}</blockquote>That covers much of what one wants to do with beans.<br /><br />One thing still missing from the pre 6.0 or 5.5 days is the ability to easily manage JavaBean patterns. This involves things such as being able to rename a property and have the field and method names change at once. The ability to add JavaBean properties has been added back to the IDE at least, but these code templates I'm writing about are easier to use, or at least quicker, than the UI to add properties through the Java editor once you are used to using them, but maybe that can be remedied by adding a quick pop up menu for doing things with JavaBean patterns to the Java editor; if I have time this year that can be one of my community contributions :-D<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com2tag:blogger.com,1999:blog-17012213.post-80370683850448497352008-04-02T18:50:00.004-05:002008-12-10T20:34:26.979-05:00Who says a RootPane always has to be at the top?Some friends and I have started a project to extend functionality inside the NetBeans RCP (Rich Client Platform). We call it PlatformX, and it is located on the web at http://platformx.netbeans.org. We hope to have the repository public soon for others to use and contribute.<br /><br />One of the APIs I'm working on is called RootPaneTopComponent. For the uninitiated in NetBeans RCP, a TopComponent is a Swing component managed by the NetBeans platform. They may work as regular components or can also be used as dockable/undockable components which may be moved around in the application.<br /><br />A RootPaneTopComponent is a TopComponent which implements the RootPaneContainer interface. It allows one to use a glass pane, a menu and menu items, or a layered pane in more component based classes such as JFrame, JInternalFrame, and JApplet do for the more encompassing classes, so this new class in PlatformX allows the same thing yet at a lower level.<br /><br />I'll have more information as soon as possible about this class and its sister class CloneableRootPaneTopComponent when I get it finished and we are closer to having a more public release of our first Platformx APIs and repository access. Until now here are some simple screen shots.<br /><br />Imagine you have a dockable component you need disabled or the ability to cover with some user blocking message until another application state has been reached, and you do not want to block the entire window or a dialog. This is where component level glass panes come in handy:<br /><br />Now you see me:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nhYhoq2dQSE/R_QgesjKLWI/AAAAAAAAAAs/-J0MR3s35Tw/s1600-h/glasspane1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_nhYhoq2dQSE/R_QgesjKLWI/AAAAAAAAAAs/-J0MR3s35Tw/s400/glasspane1.png" alt="" id="BLOGGER_PHOTO_ID_5184804782737075554" border="0" /></a><br />now you don't:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_nhYhoq2dQSE/R_QgusjKLXI/AAAAAAAAAA0/wIKc3L8cZC0/s1600-h/glasspane2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_nhYhoq2dQSE/R_QgusjKLXI/AAAAAAAAAA0/wIKc3L8cZC0/s400/glasspane2.png" alt="" id="BLOGGER_PHOTO_ID_5184805057614982514" border="0" /></a>and I'll leave it up to you to figure out ways you could use this in your applications today. I'm using it to block certain components which need the user to login to be able to use them.<br /><br />I mentioned the menu bar. I have also coded this particular class to allow north, south, east, and west components to be placed around it. This could be used for multiple things. I have chosen in this example to imagine some type of an editor which might have search functionality and maybe a notes editor which could show different notes for paragraphs or diagrams or any thing else one might think of:<br /><br />No notes showing:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_nhYhoq2dQSE/R_Qi0cjKLYI/AAAAAAAAAA8/Tx0Iic9hGL0/s1600-h/menu1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_nhYhoq2dQSE/R_Qi0cjKLYI/AAAAAAAAAA8/Tx0Iic9hGL0/s400/menu1.png" alt="" id="BLOGGER_PHOTO_ID_5184807355422485890" border="0" /></a><br />and now they are:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_nhYhoq2dQSE/R_QjDMjKLZI/AAAAAAAAABE/p1HBaOKu4IY/s1600-h/menu2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_nhYhoq2dQSE/R_QjDMjKLZI/AAAAAAAAABE/p1HBaOKu4IY/s400/menu2.png" alt="" id="BLOGGER_PHOTO_ID_5184807608825556370" border="0" /></a>Anyways, this is just a simple example to show some of the capabilities of what I'm working on at the moment. This entry is to make it easier to show the others working on the project how it works right now more than anything, but it can be a preview as well :-D. Hopefully it, along with some other things, will be released soon. It's NetBeans, so of course it is open-source.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-51671772910922780702007-12-18T23:10:00.001-05:002008-04-03T08:19:26.862-05:00Central Lookup: Creating a central repository and lookup for an application context in a NetBeans RCP application<span style="font-size:100%;"><span style="font-family:verdana;">I have been working on a NetBeans RCP project where I needed a central place to register different interfaces and allow different views to operate on these regular POJOs one would use in a regular Swing application and to be able to listen to changes to them from the standpoint of some kind of an Application Context where different instances will come and go. A good example is a desktop application requiring a login. You will have user information and want to be able to track a global login or validation token.</span><br /><br /><span style="font-family:verdana;">I create a simple class and API in a NetBeans module and called it CentralLookup. This is all the code for such a simple thing (please ignore the formatting of the code...maybe I can update it later, but it seems blogger isn't wanting to format it correctly when posted): </span></span><br /><br /><span style="font-size:85%;"><span style="font-family:courier new;">package org.netbeans.modules.centrallookup.api;<br /></span><span style="font-family:courier new;"><br />import java.util.Collection;<br /><br /></span><span style="font-family:courier new;">import org.openide.util.Lookup.Result;<br /><br /></span><span style="font-family:courier new;">import org.openide.util.lookup.AbstractLookup;<br /><br /></span><span style="font-family:courier new;">import org.openide.util.lookup.InstanceContent;<br /></span><span style="font-family:courier new;"></span><br /><span style="font-family:courier new;">/**<br /></span><span style="font-family:courier new;"> * Class used to house anything one might want to store<br /><br /></span><span style="font-family:courier new;"> * in a central lookup which can affect anything within<br /><br /></span><span style="font-family:courier new;"> * the application. It can be thought of as a central context<br /><br /></span><span style="font-family:courier new;"> * where any application data may be stored and watched.<br /><br /></span><span style="font-family:courier new;"> *<br /><br /></span><span style="font-family:courier new;"> * A singleton instance is created using @see getDefault().<br /><br /></span><span style="font-family:courier new;"> * This class is as thread safe as Lookup. Lookup appears to be safe.<br /><br /></span><span style="font-family:courier new;"> * @author Wade Chandler<br /><br /></span><span style="font-family:courier new;"> * @version 1.0<br /><br /></span><span style="font-family:courier new;"> */<br /><br /></span><span style="font-family:courier new;">public class CentralLookup extends AbstractLookup {<br /></span><br /><span style="font-family:courier new;"> private InstanceContent content = null;<br /><br /></span><span style="font-family:courier new;"> private static CentralLookup def = new CentralLookup();<br /></span><br /><span style="font-family:courier new;"> public CentralLookup(InstanceContent content) {<br /></span><span style="font-family:courier new;"> super(content);<br /></span><span style="font-family:courier new;"> this.content = content;<br /></span><span style="font-family:courier new;"> }</span><span style="font-family:courier new;"><br /><br />public CentralLookup() {</span><br /><span style="font-family:courier new;"> this(new InstanceContent());</span><br /><span style="font-family:courier new;"> }</span><span style="font-family:courier new;"></span><span style="font-family:courier new;"><br /><br />public void add(Object instance) {</span><br /><span style="font-family:courier new;"> content.add(instance);</span><br /><span style="font-family:courier new;"> }</span><span style="font-family:courier new;"><br /><br />public void remove(Object instance) {</span><br /><span style="font-family:courier new;"> content.remove(instance);</span><br /><span style="font-family:courier new;"> }</span><br /><br /><span style="font-family:courier new;"> public static CentralLookup getDefault(){</span><br /><span style="font-family:courier new;"> return def;</span><br /><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;">}</span></span><br /><span style="font-size:100%;"><br /><span style="font-family:verdana;">The nice thing about this code is that it is real simple. The strange thing for me is that there hasn't been something already implemented in the base RCP. It seems pretty common a thing. For instance, the normal global lookups deal with Actions, Services, and Nodes (which are part of the NetBeans data model), and that is fine until one needs to work with generic interfaces and classes from a global perspective. </span></span><br /><br /><span style="font-family:verdana;"><span style="font-size:100%;"><span style="font-family:verdana;">Regardless, I can now write code to listen to changes in this global context or Lookup in this case. The code doesn't have to know about any implementation except for the code which does the injection, and the code in other places can just setup a result and a listener. The following illustrates this a bit, and of course it is just a sub-set of the code:<br /></span></span></span><br /><span style="font-size:85%;">final class CentralLookupTest1TopComponent extends TopComponent {<br /><br />private static CentralLookupTest1TopComponent instance;<span style="font-weight: bold;"><br />private Lookup.Result<userinformation> userInfoResult = null;<br /></userinformation></span> private CentralLookupTest1TopComponent() {<br /><span style="font-weight: bold;"> <br /> Lookup.Template<userinformation> template = new Lookup.Template(UserInformation.class);<br /><br /></userinformation></span><span style="font-weight: bold;"> CentralLookup cl = CentralLookup.getDefault();<br /></span><span style="font-weight: bold;"> userInfoResult = cl.lookup(template);<br /></span><span style="font-weight: bold;"> userInfoResult.addLookupListener(new UserInformationListener());<br /></span> }<br /><br />private javax.swing.JTextField name;<br />private javax.swing.JTextField pwd;<br />private javax.swing.JTextField token;<br />private javax.swing.JTextField uid;<br /><br />private class SetterRunnable implements Runnable {<br /> UserInformation ui = null;<br /><br /> public SetterRunnable(UserInformation ui) {<br /> this.ui = ui;<br /> }<br /><br /> public void run() {<br /> name.setText(ui.getName());<br /> pwd.setText(ui.getPassword());<br /> uid.setText(ui.getUserID());<br /> token.setText(ui.getToken());<br /> <span style="font-family:courier new;">}<br /></span><span style="font-family:courier new;"> }<br /><br /></span><span style="font-family:courier new;"> private class </span><span style="font-weight: bold;font-family:courier new;" >UserInformationListener implements LookupListener</span><span style="font-family:courier new;"> {<br /><br /></span><span style="font-family:courier new;"> </span><span style="font-weight: bold;font-family:courier new;" >public void resultChanged(LookupEvent evt)</span><span style="font-family:courier new;"> {</span><span style="font-family:courier new;"><br /> Object o = evt.getSource();<br /></span><span style="font-family:courier new;"> if (o != null) {<br /></span><span style="font-weight: bold;font-family:courier new;" > Lookup.Result<userinformation> r = (Lookup.Result<userinformation>) o;<br /> Collection infos = r.allInstances();<br /></userinformation></userinformation></span><span style="font-family:courier new;"> if (infos.isEmpty()) {<br /></span><span style="font-family:courier new;"> EventQueue.invokeLater(new SetterRunnable(new DefaultUserInformation()));<br /></span><span style="font-family:courier new;"> } else {<br /></span><span style="font-weight: bold;font-family:courier new;" > Iterator it = infos.iterator();<br /></span><span style="font-family:courier new;"> while (it.hasNext()) {<br /></span><span style="font-weight: bold;font-family:courier new;" > UserInformation info = it.next();</span><span style="font-weight: bold;font-family:courier new;" ><br /> EventQueue.invokeLater(new SetterRunnable(info));<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;">}</span></span><br /><br /><span style="font-size:100%;"><span style="font-family:verdana;">Notice we have a result. The result has attached to it a listener. The listener knows about DefaultUserInformation and the UserInformation interface, and that is it. It then knows it needs to listen for instances of UserInformation and act accordingly. It doesn't know how it got there, but knows what it must do with it. We then have some other code in another class which will inject the instances into the CentralLookup based on some user input removing any previous: </span></span><br /><br /><span style="font-size:85%;"><span style="font-family:courier new;">private void buttonActionPerformed(java.awt.event.ActionEvent evt) {<br /></span><span style="font-family:courier new;"> //ok we need to remove any user information from the central lookup<br /></span><span style="font-family:courier new;"> //and then we need to add this new one<br /><br /></span><span style="font-weight: bold;font-family:courier new;" > CentralLookup cl = CentralLookup.getDefault();<br /></span><span style="font-weight: bold;font-family:courier new;" > Collection infos = cl.lookupAll(UserInformation.class);<br /><br /></span><span style="font-family:courier new;"> if(!infos.isEmpty()){<br /></span><span style="font-family:courier new;"> Iterator it = infos.iterator();<br /></span><span style="font-family:courier new;"> while(it.hasNext()){<br /></span><span style="font-family:courier new;"> UserInformation info = it.next();<br /></span><span style="font-weight: bold;font-family:courier new;" > cl.remove(info);<br /></span><span style="font-family:courier new;"> }<br /></span><span style="font-family:courier new;"> }<br /><br /></span><span style="font-family:courier new;"> DefaultUserInformation info = new DefaultUserInformation();<br /></span><span style="font-family:courier new;"> info.setName(name.getText());<br /></span><span style="font-family:courier new;"> info.setPassword(pwd.getText());<br /></span><span style="font-family:courier new;"> info.setUserID(uid.getText());<br /></span><span style="font-family:courier new;"> info.setToken(token.getText());<br /></span><span style="font-weight: bold;font-family:courier new;" > cl.add(info);<br /><br /></span><span style="font-family:courier new;">}</span></span><br /><span style="font-size:100%;"><br /><span style="font-family:verdana;">You can get a good idea from here the possibilities. This is a rather simple example, but it certainly shows it working. This can be used for any other services which need to use regular POJOs and not much else. Why add more overhead of class wrappers etc when they are not needed for everything? Sometimes one just needs a dynamic application context which can breakup the application into a more modular framework of simple classes and interfaces without major restrictions.<br /><br /></span><span style="font-family:verdana;">I have an AVI video formatted video of this in action. It is a very simple example, but it shows it working. The one piece of code doesn't know anything other than the fact that user information will appear magically in the CentralLookup in the form of the UserInformation interface.<br /><br /><br /></span></span><object height="350" width="425"><param name="movie" value="http://www.youtube.com/v/2JKHasLlzMM"><embed src="http://www.youtube.com/v/2JKHasLlzMM" type="application/x-shockwave-flash" height="350" width="425"></embed></object><div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com5tag:blogger.com,1999:blog-17012213.post-84889783765334509742007-08-09T11:06:00.000-05:002007-08-10T07:10:17.896-05:00Have to say it: What Sun is doing with the JCK (Java Development Kit and runtime TCK/compatibility kit) license seems pretty dirtyThe part which seems dirty is the way the license is obviously being extended to OpenJDK based projects to allow OpenJDK project contributors to be able to use the TCK without any encumbrances on their builds fields of use while keeping other, from scratch, open-source efforts from being able to do the same. The obvious part: if developers were not able to use the TCK, it would hurt the OpenJDK effort as contributors would not be able to distribute any builds and call them Java as they would not have passed the TCK. Passing the TCK is part of the rules for being able to implement the Java specifications, claim adherence, and distribute the end result.<br /><br />If the goal is to support open source Java and to be fair, then any open-source Java implementation regardless of the license would be able to use the TCK in the same manner. So, as a pretty open Sun supporter, I do not like what they are doing with the TCK at all, and it damages my view of them as a corporation as it specifically relates to honesty. I think if they are going to go about it this way they should at least have the honor and guts to say exactly what they mean and the reason for doing it instead of dancing around the issue by talking about license terms, not open-sourcing the TCK because they want to protected what it means to be "compatible" (which I totally understand), and not being able to please everyone. These reasons are pretty weak as a reason for the terms of the license only being given to OpenJDK based projects.<br /><br />The fact is they could just as easily let anyone use the TCK for free to certify any open-source implementation. The TCK does not have to be open sourced for this to happen. I think if the reason, which to me it can only be, is to protect corporation investments and only support those efforts which directly support their interests then they should just say it. Personally I don't think this is outside the bounds of what corporations try to do; I mean lets face it, they have to make money, but the JCP (<a href="http://www.jcp.org/">http://www.jcp.org</a>) member agreement and processes clearly state what can and can not exist in limiting anyones right to fully implement JCP specifications, and the scholarship TCK license itself does encumber ones ability to create clean and independent implementations of the Java specifications, and this is the only free license organizations or individuals creating open-source Java implementations can obtain unless they are based on Suns OpenJDK and also use the GPL license. This is against the agreement of the JCP as I have read it as it imposes restrictions beyond the ones stated in the agreement, and the agreement specifically states that no more restrictions beyond those listed within the agreement can exist which hinder anyones ability to create independent implementations of any JCP specification.<br /><br />So, Sun employees, don't take this personal. I happen to work with a few of you on different open-source projects, and you know who you are :-D, and I know you don't have anything to do with these decisions. The law department and which ever managers approved this however, this seems pretty darn dirty, at least what I have seen so far. Maybe someone has a good explanation, but for now I'm calling it what it looks like.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-4287039667175090762007-07-27T08:56:00.001-05:002008-04-03T08:20:08.944-05:00I have updated my "Java Text Copy Paste Module/Plugin"The Java Text Copy Paste Module/Plugin now works in NetBeans 6.0. I tested it and am using it in 6.0. The module <span id="form1:center_container:page_border:fixed_contentarea:fixed_contextbox:bottomPanel:categoryDetailPanel:descPanel:txtDescription">helps copy and paste text from and to Java source code. This module works well with SQL or HTML or XML which needs to be embedded in Java source code or needs to be extracted from Java source code. Look for the "Java Text Copy and Paste" context menu inside Java source files. There are no default hot keys for the functionality. I suggest playing around with the different actions to get a feel for how they work. + signs are pre-pended at the beginning of lines of source to make hand editing of generated code easier.<br /><br />This module allows source code to be selected then formatted back into the text format it was before converted into Java source. It also allows one to select XML, HTML, or SQL in their favorite tool (as text) and then paste into the NetBeans Java editor where it is automatically formatted as Java source code. I find I use it all the time and comes in very handy.<br /><br /><b>Version 1.1</b> added a new way to copy the text from the editor which keeps newlines in the selected text yet removes any newlines fromJ the actual Java sources.<br /><br /><b>Version 1.2</b> adds tested support for NetBeans 6.0 and corrects a bug which deals with concurrent access of the edited document. The bug has not shown any issues yet, but possibly could as concurrent access could have unknown results.<br /><br /><b>Version 1.3</b> fixes an issue dealing with the context menu sorting and NetBeans 6.0.</span><br /><br />Enjoy!<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-55095578796242025852007-07-24T23:19:00.001-05:002008-04-03T08:20:42.971-05:00Sharing classes with modules and non-module based JARs in a NetBeans RCP ApplicationSometimes, such as when using JPA or Hibernate from more than one module, it is necessary to share classes between any number of modules and non-module based libraries/JARs in a NetBeans RCP/Platform based application. The reason this solution is needed is because some libraries, and even at times modules, need to be able to see classes from other libraries and modules at runtime to use certain patterns and these classes and modules have a cyclic dependency because of the type of classes being used. JPA or Hibernate are perfect examples where the entity manager will reside in one library and needs to be able to create instances of classes from another library or module, which also references other JPA or Hibernate classes themselves, using annotations or XML descriptors. This usually happens dynamically at runtime in these type situations.<br /><br />In NetBeans the module system provides good separation. The problem is this can at times be too strict. To work around this issue you need to create a custom platform and then find the platform#/core directory under the platform directory and put the libraries and JARs in it. I will update this later to explain how to setup a custom platform.<br /><br />Once you have the libraries in the core directory they can be used by any module or other library at runtime. These JARs can be copied to the core folder at build time and before distribution using ANT, so it is a good idea to make this custom platform reside relative to your project. Another good reason to have them reside relative to the project is that these common JAR files will have to be referenced by your module projects. To reference these JARs from your module projects you will have to edit project.properties and add a property:<br />cp.extra<br /><br />which is a colon delimited list of JAR files needed for the classes the particular module needs to reference. Once cp.extra is setup, any errors you may see in the Java editor, related to these classes, should disappear and you can actually compile your project.<br /><br />It is best to avoid doing this if possible as it removes the ability to use different versions of the same libraries by different modules while also removing the ability to auto-update these libraries, but when it is not possible to avoid such things then they are certainly needed. You wouldn't shoot yourself in the foot for spite, nor do I suspect you would not complete your project just because it best to not step outside the bounds of the regular module class loaders.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-65622947651760205042007-07-09T13:32:00.001-05:002007-07-09T13:46:20.366-05:00Eclipse 3.3 Europa SPAM, regular emails, and magazine articles related to simultaneous project releasesNot wanting to start a flame war, but I want to talk about this. I have been getting "alot" of SPAM from places like bzmedia and ZD (Ziff-Davis) about Eclipse 3.3 Europa. I have also been getting emails from my magazine subscriptions such as eWeek and SD Times. I have also seen articles in my different magazines about it.<br /><br />The main talking point in the articles and emails I'm referring focuses on the simultaneous release of 21 projects in the Eclipse IDE. These are the core Eclipse projects, so I'm not talking about 3rd party projects. This means the plug-ins/projects will all run with Eclipse 3.3, so you don't have plug-in Z supported in 3.3 yet X and Y are only supported up to 3.2.<br /><br />It is no secret I'm a member of the NetBeans community. I certainly don't try to hide the fact. Anyways, NetBeans has been doing this for years. JSP, Web, EE, Swing UI, Mobile developer, NetBeans RCP, etc have always been released together and work in the current version of the IDE. I think it is good that Eclipse is doing this now, but I also think the apparent amount of resources going into highlighting this fact, promoting it, and that it took this long for it to happen is funny.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-14631841155728035182007-06-23T18:01:00.000-05:002007-06-23T18:05:53.188-05:00American Internet ConnectionsI'm driving back from the beach early so I can get back home and get some work done. It is a long drive, so I stopped for a Subway grilled chicken sandwich at a truck stop in the middle of the interstate with no large city near.<br /><br />I thought I would check email to try to wake up a bit before getting back on the road. Of course, for this, I will need an internet connection. I am happy to say I have one and I am writing this from an exit with nothing around but this one Shell fuel and truck station. The connection is great.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-42710173289136839242007-05-22T00:24:00.000-05:002007-05-22T01:27:38.618-05:00Tie that binds Sun, NetBeans and Java criticizedA friend told me about this article. I read it. I was immediately peeved:<br /><a href="http://searchwebservices.techtarget.com/originalContent/0,289142,sid26_gci1255657,00.html">http://searchwebservices.techtarget.com/originalContent/0,289142,sid26_gci1255657,00.html</a><br /><br />One paragraph from this article reads:<br /><span style="font-style: italic;">Roth argued that Sun Microsystems Inc. has tied the NetBeans IDE to Java in a way that takes unfair advantage of Sun's custodial relationship to the Java language and ignores the developers working with the Eclipse IDE. "I think what they're doing is morally reprehensible," he said.<br /><span style="font-style: italic;"><br /></span></span>Personally, I first want to see what it is Mr. Roth is exactly talking about. I am not a Sun employee, and I haven't seen anything in NetBeans I do not have access or which isn't being converted for me to access, and I certainly have not seen anything in Java which is specific to NetBeans other than IDE features.<br /><br />NetBeans is a Java IDE. Of course the IDE project is going to ignore Eclipse IDE users. They are not NetBeans users. It would be like us Americans going up and voting in Canadian elections and not paying Canadian taxes and getting Canadian benefits. What flipping sense would that make.<br /><br />If he is talking about features, then I'm not sure how there can exist multiple IDEs and them have the same exact feature sets. Otherwise, why even have more than one. I for one do not like Eclipse nor SWT; that does not mean others don't, but I believe I have the right to choose. I'm glad I have an alternative.<br /><br />There are many things like the mentioned paragraph in this article. I find many of them to be extreme contradictions of their own words. How can one have an autonomous project if it is exactly like another one (Eclipse)? NetBeans is not Java. NetBeans is not Eclipse. It is a Java IDE, so of course it supports Java features. Instead of telling Sun to contribute to Eclipse, these people could just as easily contribute to NetBeans as it is an open-source project.<br /><br />For instance:<br /><span style="font-style: italic;">Jason Bloomberg, senior analyst with ZapThink LLC., strongly supports the criticism, saying, "Bill Roth from BEA is right on the money."</span><br /><br />OK, so what exactly are you talking about? It still eludes me. I have yet to see anyone quoted as saying what it is specifically Sun is doing to give NetBeans an unfair advantage...repeated...enough said on that front...waiting for answers.<br /><br />I'm a member of the NetBeans Dream Team. I have been around the NetBeans project for years, and I contribute as much as I can. I love the IDE, and around 4.0 I started playing with the Rich Client Platform; I help other users among other things and is why I'm part of the team. I have at times voiced my concerns in our community about community involvement and Sun.<br /><br />That doesn't mean I think Sun runs NetBeans as some kind of totalitarian project. I strongly believe differently. I have never been a Sun employee, and I have a good community relationship with many Sun folks, and it stays good even when in disagreement.<br /><br />Like any project I have seen, there are some who are easier to work with than others. It doesn't mean they are bad folks; they are simply people. Different people see things differently. Just like people, different projects are run differently and in turn behave differently. That should be no surprise to anyone involved in an open-source project.<br /><br />It seems to me the folks complaining are not complaining about Sun, Java, and NetBeans specifically though this is what they say. Their comments seem to allude they want Sun to contribute to Eclipse, have NetBeans go away, and that be it. To me it is about like asking SuSE developers to contribute to RedHat or Ubuntu or vice versa and the others go away.<br /><br />Those Linux projects all contribute to the Kernel just as all IDE and Java projects at times will contribute to patches and common APIs and tools for Java. That doesn't mean all projects for a technology should be merged into one. Different people love these products and projects. Eclipse users and developers: Imagine Eclipse going away and being stuck with NetBeans. NetBeans users and developers: Imagine NetBeans going away and being stuck with Eclipse.<br /><br />Obviously if Sun is working on a JSR they can add features to their IDE to gear up for supporting the API or specification. This is what BEA or any other company will be doing with their products if they are worth having investors or customers. I, as a user and community member, expect it. That doesn't mean an API was designed specifically for their projects, but it will always (for any company) play a part, and if any CEO or VP tries to tell you different, they are <span style="font-weight: bold;">lying</span>.<br /><br />It seems we have a few classes of folks when it comes to issues like these. I call the ones I read here whiners. Some seem to be commercial entities and employees looking for anything FUD or sound bite related to make their own case, and others are those who seemingly don't know and understand the daily ongoings of open-source projects and the intermingling of commercial and community contributions.<br /><br />NetBeans is just as open-source as anything else. If there is a feature these guys want in Eclipse they can take the code and use it. Many people in the NetBeans community do every day for their own projects. If they just want Sun to contribute to their IDE instead of NetBeans, they should just say it in those terms, and they should be asking instead of telling Sun how <span style="font-style: italic;">morally reprehensible<span style="font-style: italic;"> </span></span>they are for support their own open-source community. Regardless, will all those quoted in the article contribute to NetBeans as they are asking Sun to do for Eclipse?<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Wade Chandlernoreply@blogger.com3