tag:blogger.com,1999:blog-170122132024-03-05T04:39:26.127-05:00Wade Chandler's Programming BlogThis is my blog for software development. I am a professional software engineer. I work on various projects. I also contribute to open-source projects such as <a href="http://www.netbeans.org">www.netbeans.org</a>Wade Chandlerhttp://www.blogger.com/profile/14769496774355020270noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-17012213.post-90885630208512508312016-09-13T22:25:00.001-05:002016-09-13T22:25:32.838-05:00"Run Focused Test Method" and "Debug Focused Test Method" for NetBeans Groovy Support Now in main-golden and Nightly BuildsIf you use NetBeans nightly builds you will now have this functionality. Try it out, and let me know if you experience any 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-79059206180049228052016-09-11T18:28:00.000-05:002016-09-11T18:28:21.200-05:00"Run Focused Test Method" and "Debug Focused Test Method" for NetBeans Groovy Support in main and main-silver Hg RepositoriesThe ability to run or debug a single Groovy test from the IDE has now been merged into the main and main-silver Hg repositories for the NetBeans IDE. I assume this will work into main-golden and thus the nightly dev builds soon. I will post another update once that happens.<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-27754185376353930222016-09-06T22:41:00.000-05:002016-09-11T18:28:47.557-05:00Adding "Run Focused Test Method" and "Debug Focused Test Method" to NetBeans Groovy SupportIf you are a NetBeans and Groovy fan, then you have probably noticed over the years you can not execute nor debug an individual test method if using Groovy for testing. I have contributed to other parts of the IDE at various times, but hadn't looked into the Groovy support until recently. I finally had enough executing all tests in a file.<br />
<br />
The code isn't necessarily difficult. For what I am adding it is slightly complicated due to NetBeans Groovy support module dependencies, and some things needing to be broken out a little differently. For now I am using reflection to access what I need, and that will work fine enough in the near term. Long term I plan to work with other community contributors to clean things up.<br />
<br />
Another thing which makes coding this interesting is a mismatch between NetBeans notion of an offset into a source file and the Groovy ASTs notion of it. NetBeans uses a cursor or single integer value offset, and Groovy uses the notion of a line and column. So, some translation and AST traversal is needed to pinpoint the selected method. Standard editor things, but of note for this fix.<br />
<br />
Too, the previous code halfway attempted to do this, but it seems some copy and paste happened between the Java and Groovy support as that code was using Java specific features which will not exactly work as Java is a subset of Groovy. The Groovy AST classes along with a little translation fixed it right up.<br />
<br />
The changes should make their way into the code base soon. I have things working locally. I am now cleaning things up. I figure I will tackle other items which bother me about NetBeans Groovy support now that I am getting into it.<br />
<br />
I will update once merged in, so check back.<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-2619808601526898782016-03-04T15:16:00.001-05:002021-05-31T16:29:24.581-05:00Writing AgainIt has certainly been a while since I have written. It will be an experience to start up again. The formula I have used in the past is to write about things I'm working on or feeling passionate about, and to lay out some element of that to share, either in pure informational or tutorial form, while occasionally whining or barking about something which perhaps I should or should not exert such effort.<br />
<br />
In my new attempts, I will strive to further limit non-software development topics for this blog. I am thinking of a couple others specifically for electronic and energy experiments as I do like to tinker, and no other topics beyond those at the moment, even if politics does tend to affect my sensibilities.<br />
<br />
I have nothing against other topics outright, but they seem more suited to other compartmentalized blogs or resources, and too, planning and writing, even about topics which I'm knowledgeable, takes time regardless of its enjoyment, and I would like this round to be more lasting, and hopefully reaching into my elder years; which would be a good run, and perhaps wishful dreaming :-)<br />
<br />
My hope is this post will be a public, self inspiring or fulfilling way to kick start the process of writing again (and a reminder). Who knows, maybe it will lead to a YouTube channel as well, but I love the written format.<br />
<br />
With more responsibility, maturity, and a family, I hope can keep at it, and it becomes something I can share with my children and family, and though they may or may not write about software, electronics, or energy, perhaps they will be inspired to produce content of their own, and discover the act of creation is just as much about learning and enjoyment as anything.<br />
<br />
A sample of topics I am pondering for the software blog include<br />
<br />
<ul>
<li>Programming Languages; including Java, Groovy, JavaScript, Python, C, C++, C#, Ceylon, Kotlin, Ruby, PHP, Go, and Web Assembly</li>
<li>the Amazon Cloud</li>
<li>Containers</li>
<li>Microservices; including Sprint Boot and Dropwizard</li>
<li>Data Stores</li>
<li>HTML5 Games and Phaser.io</li>
<li>Drone and Quadcopter Software</li>
<li>NetBeans and the NetBeans Platform</li>
</ul>
<div>
We will see.</div>
<div>
<br /></div>
<div>
For some relevant background, I am a husband, father, amateur experimenter, and software engineer with over 18 years experience architecting and implementing solutions for multiple computing profiles using various technologies and operating systems.</div>
<div>
<br /></div>
<div>
Currently, in my professional time, I work daily with the AWS Cloud, Groovy, Java, JavaScript, AngularJS, and Node.js plus other Web backend and front end technologies, and am a senior lead software engineer for a media company where internally we are focusing on distributed services, single page applications, and evolvable systems to support our business users and media partners as best as possible. It is a wonderful experience and set of teams.</div>
<div>
<br /></div>
<div>
<span style="color: #333333; line-height: 21px;"><span style="font-family: "times" , "times new roman" , serif;">With my current personal time, I am attempting game design and development as well as learning Drone technology. I also dabble in simple energy experiments such as salt water batteries and biodiesel, try to learn as much about physics and mathematics as I can find time, and have a few other interests.</span></span></div>
<div>
<span style="color: #333333; line-height: 21px;"><span style="font-family: "times" , "times new roman" , serif;"><br /></span></span></div>
<div>
<span style="color: #333333; line-height: 21px;"><span style="font-family: "times" , "times new roman" , serif;">Life is way too short, and goes by way too fast. See you next time.</span></span></div>
<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-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 {
if(project.hasProperty("test.forkEvery")){
println "Setting the tests to fork every ${project.getProperty("test.forkEvery")} for project ${project.name}"
forkEvery = project.getProperty("test.forkEvery")
}
}
</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 {
if(project.hasProperty("test.forkEvery")){
println "Setting the tests to fork every ${project.getProperty("test.forkEvery")} for project ${project.name}"
forkEvery = Long.parseLong(project.getProperty("test.forkEvery"))
}
}
</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.com4tag: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<Void, Void> = new SwingWorker<Void, Void>{<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.com3tag: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-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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXWQRxbLjCZ6lHddzA6_K7WhZ26JCf662fE0ZR8aRyqoK55bnavEKMZC4JUmCqyBL2UcDIdL8G8eHv1z_ZqhJRalOynsTcEUfg9mTyODFHnCPMvjJOdjmqbfSZ06W-idu6CD-V/s1600/se_manager.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 372px; height: 400px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXWQRxbLjCZ6lHddzA6_K7WhZ26JCf662fE0ZR8aRyqoK55bnavEKMZC4JUmCqyBL2UcDIdL8G8eHv1z_ZqhJRalOynsTcEUfg9mTyODFHnCPMvjJOdjmqbfSZ06W-idu6CD-V/s400/se_manager.png" alt="" id="BLOGGER_PHOTO_ID_5595100173199868114" border="0" /></a><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizD4vgpsIkAol-QDXajLIDxnGCG5ncsPYyqqE2iyXCaaMokU715C7kL73bZqi2T1ML-HKBkqDp26SxEwwVZmBOBE-MRksyswE_xdk6oCMDxF__eF5FAerlogbwFKnUvMsMQA05/s1600/se_configure.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 177px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizD4vgpsIkAol-QDXajLIDxnGCG5ncsPYyqqE2iyXCaaMokU715C7kL73bZqi2T1ML-HKBkqDp26SxEwwVZmBOBE-MRksyswE_xdk6oCMDxF__eF5FAerlogbwFKnUvMsMQA05/s400/se_configure.png" alt="" id="BLOGGER_PHOTO_ID_5595100005706161138" border="0" /></a><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniqDQ-THD78ryx48VNZEw_N3MxeuBh5A12CAO3CjOJswi249SYYSByFSMcNy0xkbYKKF88KeW6Hkbq1Gl6qJfvBHIJyA2007uZMhOzl7WVxit-T3xroL2hHX208UVrJ8xXu2n/s1600/connection_editor.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 280px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniqDQ-THD78ryx48VNZEw_N3MxeuBh5A12CAO3CjOJswi249SYYSByFSMcNy0xkbYKKF88KeW6Hkbq1Gl6qJfvBHIJyA2007uZMhOzl7WVxit-T3xroL2hHX208UVrJ8xXu2n/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc9boTRz9NIO_FdbK6RNFxW4-lQZuL97oAYDOPA7G2hf7AxG6hPxpECDe4MIDaADix-i2cru3v2Dx5O_9_AWvHSYOeb5KUwgfvY3GeNzl0SL7LfiBYcm_osbSjKUFI3IddKmHJ/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc9boTRz9NIO_FdbK6RNFxW4-lQZuL97oAYDOPA7G2hf7AxG6hPxpECDe4MIDaADix-i2cru3v2Dx5O_9_AWvHSYOeb5KUwgfvY3GeNzl0SL7LfiBYcm_osbSjKUFI3IddKmHJ/s400/se_start_server.png" alt="" id="BLOGGER_PHOTO_ID_5595100185784519106" border="0" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEA2x6lOr1S59JFaSo55rlb-i3TGxzQ3j80GQxYViTNf94p87YZGkYUUdN9ldgZo41P2uRN5dbG5Rln56fkdmrw68UpOlwEPpS2EDPZ3ZcUSO3x8N78AztR4NnfZtuShDj8PCs/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfSe6XdbXfl8i8xrZWqLNS6cnd0Ln-2cog6vasrxNFGbguWjx_b7t8VagMbt9IJv2T1QZZUka7B9qwdOpfLrkFT_pFbBFy6e6KhEZ_1Niz0glB23crhwCgrPjs2i_Ohu07MtfU/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfSe6XdbXfl8i8xrZWqLNS6cnd0Ln-2cog6vasrxNFGbguWjx_b7t8VagMbt9IJv2T1QZZUka7B9qwdOpfLrkFT_pFbBFy6e6KhEZ_1Niz0glB23crhwCgrPjs2i_Ohu07MtfU/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3R511ZRqnCGETm300c37oRlhC41UAD6tvQDf1Ybyaz0ocl1zkW-qpz43qoBsiDysxHpYIGg-FLmg1Mck-YQJjTa8LRRrQoHPATIdHYHOg6bo_2w40GvQGWC5nzbBmde4jpHaA/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3R511ZRqnCGETm300c37oRlhC41UAD6tvQDf1Ybyaz0ocl1zkW-qpz43qoBsiDysxHpYIGg-FLmg1Mck-YQJjTa8LRRrQoHPATIdHYHOg6bo_2w40GvQGWC5nzbBmde4jpHaA/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5pOBByPdCXAwP4Z4wRb3Zk9NNgBNkAjFxt-VM3KC6Vzaq4kzwBfkDVWVEfwU38C0GJxwgVVa05fWzcBGaC4PnSeuDzCdzMYb0Y0ven_O1HZey2fedMTcAPzQkUjzOMik-09HY/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5pOBByPdCXAwP4Z4wRb3Zk9NNgBNkAjFxt-VM3KC6Vzaq4kzwBfkDVWVEfwU38C0GJxwgVVa05fWzcBGaC4PnSeuDzCdzMYb0Y0ven_O1HZey2fedMTcAPzQkUjzOMik-09HY/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_jCTbNHQhv5fDxuhdGLfbFlSqza3RCR53etkfNWNTtJpb86huRqk6YVLlZSLB6IrhuH4csGL9f1ZvukC9Qz9-abDjKY0TMFupmW9M3cIP8-9QY-U5PNiOUed5eMiWrFNso8vb/s1600/grab_html.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 391px; height: 400px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_jCTbNHQhv5fDxuhdGLfbFlSqza3RCR53etkfNWNTtJpb86huRqk6YVLlZSLB6IrhuH4csGL9f1ZvukC9Qz9-abDjKY0TMFupmW9M3cIP8-9QY-U5PNiOUed5eMiWrFNso8vb/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU3oihzPy3wz-0YAEO3J-9YWKrCfdR-rGRboUfYLhvGloyq0nR8476FxUkCt6KdST4Z11xvB0khn7IQr1zxUz9OihDIyWQMUHmA4dSdG3Myh4y69YpPDssjfbFSaQQMyVM-jlG/s1600/examples_js.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 306px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU3oihzPy3wz-0YAEO3J-9YWKrCfdR-rGRboUfYLhvGloyq0nR8476FxUkCt6KdST4Z11xvB0khn7IQr1zxUz9OihDIyWQMUHmA4dSdG3Myh4y69YpPDssjfbFSaQQMyVM-jlG/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkA9QPUprSglzDxqM39J2jew-vkd6HVB5xgTdui824mmH1YwAaIcVdcAvKoWXQKo_6GSbbgYtu-vlf1uL2FThSyD5kPplJP9ZhGFXiHT-kjsK8gz9OgYsXNLIbR38UiIsW_Nwo/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkA9QPUprSglzDxqM39J2jew-vkd6HVB5xgTdui824mmH1YwAaIcVdcAvKoWXQKo_6GSbbgYtu-vlf1uL2FThSyD5kPplJP9ZhGFXiHT-kjsK8gz9OgYsXNLIbR38UiIsW_Nwo/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUhHmxaEOod2_mSLyMU7RjynTJnYL1o494bGG_eTALIdJz9_CzekCZQW5Xw3IqDPeeH2-Pu74g19cSKIKTYZ-2l_MsOJ_yvxPGePWxiGgx3lbgp8eJLYSj1LMTZrO-HLYdZD1v/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUhHmxaEOod2_mSLyMU7RjynTJnYL1o494bGG_eTALIdJz9_CzekCZQW5Xw3IqDPeeH2-Pu74g19cSKIKTYZ-2l_MsOJ_yvxPGePWxiGgx3lbgp8eJLYSj1LMTZrO-HLYdZD1v/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPMDKSh4RmBXaWwePMH1mrgkBUy7RZ8XiFwbT1yjDhlcH3M7q5ODmKOPHbsV8BJD07ZQUo7UjjELGM6_dIvvcVazyBHpko69UNopMfCPoay2YVZ8KDlGMVhRMPbDN-duSSKKdo/s1600/java_support.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 361px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPMDKSh4RmBXaWwePMH1mrgkBUy7RZ8XiFwbT1yjDhlcH3M7q5ODmKOPHbsV8BJD07ZQUo7UjjELGM6_dIvvcVazyBHpko69UNopMfCPoay2YVZ8KDlGMVhRMPbDN-duSSKKdo/s400/java_support.png" alt="" id="BLOGGER_PHOTO_ID_5595099787657905634" border="0" /></a><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEA2x6lOr1S59JFaSo55rlb-i3TGxzQ3j80GQxYViTNf94p87YZGkYUUdN9ldgZo41P2uRN5dbG5Rln56fkdmrw68UpOlwEPpS2EDPZ3ZcUSO3x8N78AztR4NnfZtuShDj8PCs/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEA2x6lOr1S59JFaSo55rlb-i3TGxzQ3j80GQxYViTNf94p87YZGkYUUdN9ldgZo41P2uRN5dbG5Rln56fkdmrw68UpOlwEPpS2EDPZ3ZcUSO3x8N78AztR4NnfZtuShDj8PCs/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaz96zWIFt8NosXpaThDN30btjfXlMJpi1T66bSePv9drx7tbMqDUgmDJg0RYdWotbauv4OcFdahhcRijbvPw2mwoGM0d7DP_t8kEAy2vWQa_WsfeEk-tvZeWzmEnJif5dniw1/s1600/inject_scripts.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 316px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaz96zWIFt8NosXpaThDN30btjfXlMJpi1T66bSePv9drx7tbMqDUgmDJg0RYdWotbauv4OcFdahhcRijbvPw2mwoGM0d7DP_t8kEAy2vWQa_WsfeEk-tvZeWzmEnJif5dniw1/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia-9GynkDQVltiVRdd5BQuI1NQeCvPnKsq6Xw05l_qg3P6qT1BszVo6s4kEFSrt3JI6RtT8R1iM4GTsqPmc8HFwYMelJepLHMGe3qYLXaXCW47D4acaKcAmioFvfkLTZ5HoYVM/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia-9GynkDQVltiVRdd5BQuI1NQeCvPnKsq6Xw05l_qg3P6qT1BszVo6s4kEFSrt3JI6RtT8R1iM4GTsqPmc8HFwYMelJepLHMGe3qYLXaXCW47D4acaKcAmioFvfkLTZ5HoYVM/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>Unknownnoreply@blogger.com1tag: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("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEingKpoMRNs1fP9dFw25XLRSTbunkSgp5G5SAxFyCdF9dVP5MFw6z-ZhawFupR3DYLHbNqHA-wZZG3Pi9JML8YL88Dsc_k-OX7hUAN1c3Sjepd64jVwJAnmmt9MKpMep7itBsQTIA/s320/codebg.gif") 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("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEingKpoMRNs1fP9dFw25XLRSTbunkSgp5G5SAxFyCdF9dVP5MFw6z-ZhawFupR3DYLHbNqHA-wZZG3Pi9JML8YL88Dsc_k-OX7hUAN1c3Sjepd64jVwJAnmmt9MKpMep7itBsQTIA/s320/codebg.gif") 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("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEingKpoMRNs1fP9dFw25XLRSTbunkSgp5G5SAxFyCdF9dVP5MFw6z-ZhawFupR3DYLHbNqHA-wZZG3Pi9JML8YL88Dsc_k-OX7hUAN1c3Sjepd64jVwJAnmmt9MKpMep7itBsQTIA/s320/codebg.gif") 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 < 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>Unknownnoreply@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><<span style="font-weight: bold;">a\\b[^>]*href=\"[^>]*>(.*?)</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>Unknownnoreply@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>Unknownnoreply@blogger.com2tag: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>Unknownnoreply@blogger.com1tag: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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFYhHDPgfTOR16uUNoIeJyTW26OpLDnPxoK7w1H-y18CW6J6TatxOw4-KJpgtgl83ZfuXyG8W58HFBnnYfGcZMgAIYoo-IuG_apHhieYWzQVLTDeuywj6SkfY2s4HnctkM4xkU/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD0mP-WMZlMedEE75aRRD_yxNOyK-a_Sngc8XYgw7Hit8PpHCC0UZFPaanaOBKP-pGdi3aV0cO2B6cu4nXHQ2lc3gBhyEUPAnB_7dgCI8tVMTHE5wkL0ZUjSSNJbefHaf0sNOo/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD0mP-WMZlMedEE75aRRD_yxNOyK-a_Sngc8XYgw7Hit8PpHCC0UZFPaanaOBKP-pGdi3aV0cO2B6cu4nXHQ2lc3gBhyEUPAnB_7dgCI8tVMTHE5wkL0ZUjSSNJbefHaf0sNOo/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>Unknownnoreply@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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAXC6TWjODybqOjmDTO2yT6nQr_P4M28KKfo541rnkDZBCiKqZxBj6HlEeN57p1i3QBwukQWP0ZRWb-h2yAUwEryrF4I1ooX4CX3OZXoOdk_lEz-T6a2gxQBftDFaNrhjLibwX/s1600-h/NB_template1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAXC6TWjODybqOjmDTO2yT6nQr_P4M28KKfo541rnkDZBCiKqZxBj6HlEeN57p1i3QBwukQWP0ZRWb-h2yAUwEryrF4I1ooX4CX3OZXoOdk_lEz-T6a2gxQBftDFaNrhjLibwX/s400/NB_template1.png" alt="" id="BLOGGER_PHOTO_ID_5223641664821575554" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbhbIITvGP7xpvQp5vX9hx3FInzUjKDWtOl7RvZvVnL_EAkJGbDXFF1WWUydOy3HLUyCRpUaLUnXjGi-BzIPId3Rvq3wNcNVDSeHfNVJK5CTIIqrbvXf8jrnNS9aHJKxa1byKI/s1600-h/NB_template2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbhbIITvGP7xpvQp5vX9hx3FInzUjKDWtOl7RvZvVnL_EAkJGbDXFF1WWUydOy3HLUyCRpUaLUnXjGi-BzIPId3Rvq3wNcNVDSeHfNVJK5CTIIqrbvXf8jrnNS9aHJKxa1byKI/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjefuIp7t6hlNRV0uH_HCjrL4wTvRVqnvHXa-oWRUAZlwlWYoTHswpGeokl8RaqAUBtoxvyahGh7sNDtyvjLa0A55tTL1fnhv5e2r9M3eodiJUrJNRPmuxVHOO4PKx0EizQnfix/s1600-h/NB_template3.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjefuIp7t6hlNRV0uH_HCjrL4wTvRVqnvHXa-oWRUAZlwlWYoTHswpGeokl8RaqAUBtoxvyahGh7sNDtyvjLa0A55tTL1fnhv5e2r9M3eodiJUrJNRPmuxVHOO4PKx0EizQnfix/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>Unknownnoreply@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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjflcVZfZdUAmXVyhbkrU5rOrSAD5TlxnTUT9XbPjeAmH38o8jmyJRUErf9yK7JM1k8puTxlJ-qXhTDPcNZNBIy-zwK4DEruiQqSfBuvsL4IbWhFMm8ySxEsoG-otk4EG3BudLU/s1600-h/glasspane1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjflcVZfZdUAmXVyhbkrU5rOrSAD5TlxnTUT9XbPjeAmH38o8jmyJRUErf9yK7JM1k8puTxlJ-qXhTDPcNZNBIy-zwK4DEruiQqSfBuvsL4IbWhFMm8ySxEsoG-otk4EG3BudLU/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9KGhryyFdn3qsyC_Jtv00S8GonDSKlrt7a6_YsebgjlNyY0h-eubhFOUKbkNentO1Qkp8LACJNNX_0zoufjgrsvjjS7hdgZKQ9CVvScoB0xg1foJrtSDNkHPN_5rzVbPL9Mg9/s1600-h/glasspane2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9KGhryyFdn3qsyC_Jtv00S8GonDSKlrt7a6_YsebgjlNyY0h-eubhFOUKbkNentO1Qkp8LACJNNX_0zoufjgrsvjjS7hdgZKQ9CVvScoB0xg1foJrtSDNkHPN_5rzVbPL9Mg9/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn9kNxsg5TrL7vQgl4k74tayeLYu0gP2TU38Kw60Mcp42fDSGQvyydf0htpU75gmmDBS3rwxHG60-JrDEI5Gu_wkQYbJw7OFlyz5nlObrQZLbUgq7Ch91PQ15JkWmquSCTY20Z/s1600-h/menu1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn9kNxsg5TrL7vQgl4k74tayeLYu0gP2TU38Kw60Mcp42fDSGQvyydf0htpU75gmmDBS3rwxHG60-JrDEI5Gu_wkQYbJw7OFlyz5nlObrQZLbUgq7Ch91PQ15JkWmquSCTY20Z/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh53RgngNPMflENODc9e8z4VG8CRwqvFI7T3ITHQ8TLvPXumxvuxSGNCpvdo-qidX7qqNx4kOpByBNYsNSLTkuqedMQki-rM84bviofkb1N_PkxAdqBO5YOUKkCL7SYKu05yfjw/s1600-h/menu2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh53RgngNPMflENODc9e8z4VG8CRwqvFI7T3ITHQ8TLvPXumxvuxSGNCpvdo-qidX7qqNx4kOpByBNYsNSLTkuqedMQki-rM84bviofkb1N_PkxAdqBO5YOUKkCL7SYKu05yfjw/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>Unknownnoreply@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>Unknownnoreply@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>Unknownnoreply@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>Unknownnoreply@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>Unknownnoreply@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>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-17012213.post-81944580604791086642007-05-20T19:01:00.000-05:002008-12-10T20:34:27.767-05:00OpenSuSE 10.2, Fedora Core 5, Kubuntu Fiesty Fawn, Vista, XP, VMWare, Windows Development, Open-Source, Java, Computer Forensics, and Everything ElseIn the screen shot below, the black space on the bottom of the left comes from the image having to be rectangular. My screen ends where the black begins on the left. The black on the right is where I have Windows resolution set smaller so I don't have scroll bars on the outside of my screen. I have a newer resolution I'll post more images of once I get them. I'll have to think of something cool to show you like developing Windows, Linux, and Java applications at the same time.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmRaUwqXt7iXoYIiHN6fKjxfs6_zwAuUWPgsvmTVE7v3nTg36A-M1-nc90gWOe_9eEZCp-Pr-VDnCBYZMSslTd6ofTfx1xh7uiLXJM_TQAa0qysFgq1QPLES48V43edJXJGzg2/s1600-h/wade_opensuse_10.2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmRaUwqXt7iXoYIiHN6fKjxfs6_zwAuUWPgsvmTVE7v3nTg36A-M1-nc90gWOe_9eEZCp-Pr-VDnCBYZMSslTd6ofTfx1xh7uiLXJM_TQAa0qysFgq1QPLES48V43edJXJGzg2/s320/wade_opensuse_10.2.png" alt="" id="BLOGGER_PHOTO_ID_5066834436043941122" border="0" /></a><br />My employer targets Microsoft platforms. I also have to create ISAPI Web Applications and Windows Desktop Software (using Windows APIs). However, I end up writing Java source more than anything as part of some of our contracts.<br /><br />Personally, I have always loved Linux and all the utilities and flexibility which comes with it; the entire operating system is built for computer work and application development/software engineering. The reality is no matter where I work, even for myself, I will run into Windows development, so, no matter what, I can never (in the foreseeable future) do away with Windows development and Windows.<br /><br />I do a lot of different computer related things in the software field. I have recently been working on becoming a certified computer examiner and getting into computer forensics. I have been using Linux a lot for forensics. Unix class systems such as Linux offer a lot for forensics as there are many ways in which to access data without mounting a drive and altering time stamps or data; one can even see exactly what much of the source code is doing if something comes into question. Windows makes this much harder.<br /><br />My development laptop's screen started acting weird, so I decided I needed to get another backup computer so I could fix it. My current computer was my last backup. This time I went to Best Buy and bought a Toshiba Satellite P105-S6177.<br /><br />It has some decent (not awesome) hardware built in. However, it is not without issues. Even while running Vista, the operating system which came pre-installed, it could not hibernate without blue screening. I know it was blue screening because the error message in the log said it was, but the screen would just go black any time I tried to hibernate; the patch Vista found on the Microsoft web site did not remedy the issue. One certainly wonders why they pay 299.99 for an Ultimate Upgrade with noticeable issues such as this. I have used hibernate ever sense it became possible. It seems to save me a lot of time as I use it daily unless forced to reboot.<br /><br />After the computer seemed to be having a few issues with Vista, I decided to try a new method for development. I have used virtualization for different things such as testing on different versions of operating systems, and the company uses virtualization for web servers. I have not tried to use it, until now, to run a mutli-OS desktop development environment.<br /><br />I have used dual and triple booting, but I wanted to be able to work on different projects in different contexts at the same time and on the same machine for multiple operating systems, and I have been wanting to see what it would be like to get to use Linux all day every day, setup a multi-monitor X system, and contribute more to a Linux distro.<br /><br />OpenSuSE 10.2 seemed promising and I have used 10.1 on another system for some time, so I ended up going with it. I downloaded CentOS 5 (which is Red Hat Enterprise for free), but it could not detect the graphics card and monitor. I even gave Kubuntu Fiesty Fawn a test drive, but I didn't like it as much as I like SuSE. I have used CentOS for different things and like it a lot, but I needed to get going as fast as possible and had hardware issues from the beginning, and I find the SuSE administration tools extremely useful. The YaST tools are not 100% perfect but what is.<br /><br />I have used Linux off and on since 1996. I had all kinds of cool features when consumers thought Windows 95 was cool. Through the years I have given different distributions a shot including different Debian based ones. Mostly I have been back and forth with Red Hat and SuSE, and I have always had a place in my heart for Slackware even though I don't use it any more (nothing personal...I'm not using Red Hat or Fedora at the moment either). I think mostly I love the word slack :-). I also use Helix and Knoppix for specialized tasks.<br /><br />I think it is important to make sure everyone knows this is not my first time with Linux as it wasn't like I just installed this from a CD or DVD and all was good without some manual labor. It took a week or so to get this computer just right.<br /><br />The issues:<br /><ol><li>Dual Monitor Support:<br /><br />Sax2 setup the main screen fine. It could not setup dual monitor support correctly. Even cloned display was incorrect. I had to edit the xorg.conf file by hand. Once configured I noticed the support works better than the dual monitor support under Windows XP. I didn't even have to have extra software to have a taskbar on each screen.<br /><br />I had to read and figure out exactly how the X configuration files work. Once I spent the time to learn the files, I quickly learned I could use Sax2 to get the initial file created. Then, by reconfiguring for my specifics I could get it working correctly. I can use Xinerama which lets me drag from screen to screen or is one giant desktop, I can use the normal view which is an X server on each display, thus each has its own sepearte taskbar and I can not drag between the two, or I can use a cloned display which isn't very useful for anything except maybe a cash register, kiosk, dual developers on the same machine during a code review, or something similar to these.<br /><br />The big gotcha on my system is that the two screens are not the same size and resolution. They are even different aspects. One is a wide screen laptop display capable of 1280x800 and some higher resolutions and the other a LCD monitor capable of 1280x1024.<br /><br />I noticed to really test the X configuration I had to completely reboot, otherwise it didn't look as it should and I would keep changing the file with no good result. I'm not sure if this is some type of a bug in X or something to do with a buggy ACPI system in the Toshiba or some other firmware issue. The LCD monitor is a zero configuration monitor which I push a button and it auto configures the screen layout based on its input.<br /><br />The display related sections below show some of the things. Notice I have the one mode for the external monitor. This might not be so good for other external monitors, but it is the only resolution,I have found, which works well with this monitor (a Samsung SyncMaster 960BF).<br /></li><li>Sound Support:<br /><br />I had issues with sound. I also had some other issues with USB device removal and certain devices not working once they were plugged in again. I had a suspicion these were ACPI errors. I could disable ACPI:<br />apm=off acpi=off noapic<br />and things worked correctly except for anything ACPI specific and no dual core support on my dual core CPU.<br /><br />I had decompiled my DSDT and had looked it over. I noticed it had a determination for the OS, so I set the boot parameter acpi_os_name="Windows 2006" per the decompiled Intel DSL code. This had no affect. So, I thought maybe this was an issue with something else. I had seen talk about ICH7 and the Conexant codec. I saw another post where the individual had completely hard coded the DSDT setting of OSYS, and was replacing ALSA with a newer version. So, I started to work through his steps. Turns out the first step, hard coding the DSDT setting of OSYS the Windows 2006 value (0x07D6). was all I needed.<br /><br />In total:<br /><br />I downloaded and built the Intel ACPI tools and compiler iasl and added them to the PATH.<br /><br />I then extracted my DSDT to my project folder using (you have to have started with ACPI enabled even if with bugs):<br />cat /proc/acpi/dsdt > dsdt<br /><br />Next, I decompiled the code:<br />iasl -d dsdt<br /><br />I then found the following code and changed it by commenting out the OS checks and hard coding the Windows 2006 value:<br /> If (CondRefOf (_OSI, Local0))<br /> {<br /> /*If (_OSI ("Linux"))<br /> {<br /> Store (0x03E8, OSYS)<br /> }<br /> Else<br /> {<br /> Store (0x07D1, OSYS)<br /> If (_OSI ("Windows 2001 SP2"))<br /> {<br /> Store (0x07D2, OSYS)<br /> }<br /><br /> If (_OSI ("Windows 2001.1"))<br /> {<br /> Store (0x07D3, OSYS)<br /> }<br /><br /> If (_OSI ("Windows 2001.1 SP1"))<br /> {<br /> Store (0x07D4, OSYS)<br /> }<br /><br /> If (_OSI ("Windows 2006"))<br /> {<br /> Store (0x07D6, OSYS)<br /> }<br /><br /> If (LAnd (MPEN, LEqual (OSYS, 0x07D1)))<br /> {<br /> TRAP (0x3D)<br /> }<br /> }<br /> */<br /> Store (0x07D6, OSYS)<br /> }<br /><br />Then, I compiled the code using:<br />iasl -tc -f dsdt.dsl<br /><br />There will be errors and warnings, but the -f forces the dsdt.aml file to be created even though there are compiler errors. If you try to fix the errors you get from this code it will not work. I have already been down that path. Apparently the _T_0,_T_1,etc variable/storage names are required even though the Intel compiler says they are reserved words which I could find no documentation. I assumed they were just variable names, but this must not be the case for these particular storage identifiers with these names.<br /><br />Next, you need to be root:<br />su -<br />enter your password, and you'll be back at a prompt. Now cd back to your project directory.<br /><br />Next I copied this to the etc directory.<br />cp dsdt.aml /etc/DSDT.aml<br /><br />I then started YaST. I then went to System|/etc/sysconfig Editor|System|Kernel|ACPI_DSDT. I set it to /etc/DSDT.aml. I clicked Finish.<br /><br />Next, we have to tell the Kernel where to find it (after setting the ACPI_DSDT in YaST SuSE now knows where the DSDT we want to use is):<br />mkinitrd<br /><br />Then reboot your system. Either use the user interface (Restart) or type:<br />reboot<br /><br />You should now be able to configure your sound card and it work. If the card is already configured, even if no sound was coming out previously, you should notice sound upon reboot. This was my experience.</li><li>IRQ Balancing:<br /><br />Looking in /proc/interrupts, I noticed that CPU 0 was the only CPU getting interrupts. The irqbalance start up script was not starting irqbalance even while telling it to manually on the command line. Looking in /etc/init.d/irq_balancer (the script which runs it), I noticed this code:<br />start)<br />echo -n "Starting irqbalance "<br />if [ $PHYS -gt 1 ] || [ $PROC -gt 1 -a $PHYS -eq 0 ] ; then<br />startproc $IRQBALANCE_BIN<br /># Remember status and be verbose<br />rc_status -v<br />else<br />rc_status -u<br />fi<br />;;<br /><br />where PHYS and PROC are set by:<br />PHYS=$(grep '^physical id' /proc/cpuinfo | sort -u | wc -l)<br />PROC=$(grep -c '^processor' /proc/cpuinfo)<br /><br />So, any system must have at least 1 CPU, so the test:<br />$PHYS -eq 0<br />will always fail, so I changed it to:<br />$PHYS -eq 1<br /><br />and now irqbalance is actually started, and works correctly on a multi-core system versus only working on a true multi-processor system. The only bottle kneck now should be the CPU cache locking and serialization.</li><li>Installing and Configuring VMWare:<br /><br />The free version of VMWare I'm using doesn't work directly on SuSE. I had to make sure I had all the source packages for SuSE and dependencies for VMWare installed. Once I had the dependencies installed I had to run vmware-config.pl and allow it to build the modules for my kernel. Once I did this VMWare seemed to run fine.</li><li>VMWare Sound Issues:<br /><br />VMWare sound doesn't work exactly the best. Actually, without doing a couple things it would make VMWare lockup while it had input control, so while it was locked up I could not operate my system until it unlocked. I found a VMWare forum message which mentioned adding a serial port to the virtual machine and in the same message mentioned setting sound.smallBlockSize and sound.maxLength to some value other than the 512 default.<br /><br />I found on my system this required setting the values to 64 and also adding a serial port which output to a file. Anything else and I still had the issue, though if I had a real serial port on my system I'm sure hooking it up to the virtual machine would have had the same effect as the fake one. Sound still has some issues, but the performance is not hindered and doesn't lock up the virtual machine and it doesn't break up all the time. I tried to use 128, 32, 48, 256, etc, but 64 was the only one to work correctly.<br /><br />Some of my issues may come from using Napster. I have a paid Napster account, and it says it only runs on XP, and Napster crashes quite frequently on Vista. So, I can't be sure if the issues are all VMWare.</li></ol>Now that I'm past the issues, everything seems to be fine. It is a really awesome environment, and I think everyone should have one. I can program just about anything I want. I figure if I ever upgrade to VMWare Desktop I can even install MacOS, but I have not confirmed this as being supported, but it would be cool to be able to developer for all these different OS using Linux and virtual machines. When and if Xen (Linux Virtualization) gets to the point it can support Windows and MacOS and others such as Solaris, I'll give it a shot, and hopefully, I'll have a reason to get an even bigger drive!<br /><br />If any of you go to setup a system like this let me know your experiences. It isn't the easiest thing the first time you run into new issues such as ACPI or try new things such as Xinerama with different monitors and resolution, but in the end, at least for me, it is worth it. Have fun!<br /><br /><span style="color: rgb(255, 0, 0);"><span style="font-weight: bold;">Update 2007-05-24<span style="font-weight: bold;"><span style="color: rgb(0, 0, 0);"><br /></span></span></span><span style="color: rgb(0, 0, 0);">I found out I had an issue with USB and VMWare as SuSE 10.2 and many other Linux distros no longer support usbfs. I downloaded the 30 day trial for VMWare Desktop 6, and it is amazing. It works so much better. I still have some sound issues, but everything else works so much better; even the display is faster. VMWare Tools is also a life saver. I definitely recommend this setup to others. I can even run Vista or XP as a large desktop which covers both my X terminals running in Xinerama. Good stuff! I'm going to purchase a commercial license for VMWare.<br /><br /><span style="color: rgb(255, 0, 0);"><span style="font-weight: bold;">Update 2007-06-01<br /><span style="color: rgb(0, 0, 0);">Multiple monitors and independent taskbars</span><br /></span><span style="color: rgb(0, 0, 0);">I decided to post a new screen shot. I have setup my desktop with some new panels. KDE is amazingly configurable. You have to play around with it a bit. Once you figure it out, it is just awesome. I have, on both monitors, a similar taskbar, and each taskbar is independent yet shows the same windows. Check out the window floating between both monitors.<br /><br />Notice the same titles are showing on the bottom. I can easily drag between the monitors, yet I have both showing all processes. I also have different applets and panels in each taskbar panel. On the right I have a color picker, the weather, and even a world clock. On each I have a trash can which makes it easy to move files to the trash bin.<br /><br /></span></span></span></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS2ZeXQTq__zR3FFRXhqLCI1KVHwCcQ5ajPtAKSLf7iOYCJ6uMgYa-IPVdjL2sPSK40QKJNmkF4mAX_2pOhZPX_VXS5WMt3q6vlE-HiBDCJtHKun-701BP4quF9ng06KSVKHt1/s1600-h/wade_opensuse_10.2_1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS2ZeXQTq__zR3FFRXhqLCI1KVHwCcQ5ajPtAKSLf7iOYCJ6uMgYa-IPVdjL2sPSK40QKJNmkF4mAX_2pOhZPX_VXS5WMt3q6vlE-HiBDCJtHKun-701BP4quF9ng06KSVKHt1/s320/wade_opensuse_10.2_1.png" alt="" id="BLOGGER_PHOTO_ID_5071169235963410466" border="0" /></a><span style="color: rgb(255, 0, 0);"><span style="color: rgb(0, 0, 0);"><span style="color: rgb(255, 0, 0);"><span style="font-weight: bold;"><br /><span style="color: rgb(0, 0, 0);">Here is one I like: Linux and Vista side by side thanks to VMWare<br /></span></span><span><span style="color: rgb(0, 0, 0);">The new VMWare Desktop does much more than the free version I was trying to use. For instance, I can full screen VMWare on a single monitor. I can then move my cursor freely between the two without pressing a key. I can also copy and paste from the virtual machine to my host operating system. In this case OpenSuSE 10.2. I can't drag a file or text across the boundary, but I can copy the file then paste it. I can do the same with similar data flavors as long as the target accepts the value.<br /><br /></span></span></span></span></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdVzds4keOuZHmGS-RjOLPVru9Lr0_YHzN-GPUXyaPiRNp8Ktk_WlXELdb9mjDIbtw_l01St9tqQxxxUf5XCeSY5uCJzAd4yaXcJ7VHpkTNsIQ5aKy8wlAPaWfdH413amvqyQY/s1600-h/wade_opensuse_10.2_2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdVzds4keOuZHmGS-RjOLPVru9Lr0_YHzN-GPUXyaPiRNp8Ktk_WlXELdb9mjDIbtw_l01St9tqQxxxUf5XCeSY5uCJzAd4yaXcJ7VHpkTNsIQ5aKy8wlAPaWfdH413amvqyQY/s320/wade_opensuse_10.2_2.png" alt="" id="BLOGGER_PHOTO_ID_5071175875982850098" border="0" /></a>finally, I can have VMWare allow the guest OS (Vista in this case) to use both monitors. This is so cool, and so flexible.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFYhHDPgfTOR16uUNoIeJyTW26OpLDnPxoK7w1H-y18CW6J6TatxOw4-KJpgtgl83ZfuXyG8W58HFBnnYfGcZMgAIYoo-IuG_apHhieYWzQVLTDeuywj6SkfY2s4HnctkM4xkU/s1600-h/wade_opensuse_10.2_3.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFYhHDPgfTOR16uUNoIeJyTW26OpLDnPxoK7w1H-y18CW6J6TatxOw4-KJpgtgl83ZfuXyG8W58HFBnnYfGcZMgAIYoo-IuG_apHhieYWzQVLTDeuywj6SkfY2s4HnctkM4xkU/s320/wade_opensuse_10.2_3.png" alt="" id="BLOGGER_PHOTO_ID_5071177692754016322" border="0" /></a>Anyways, I finally figured out my sound issue was only with Napster. Windows Media Player itself works fine. I can jam out to WMA and MP3 files easily using Windows. I get the flexible programming world of Linux. It is really powerful.<br /><br />The only issue I now seem to have is that many Windows programmers seem to have crazy ideas about how to use file names. Seems they believe if they use <span style="font-style: italic;">filename</span> in one location they should use <span style="font-style: italic;">FileName</span> in another and <span style="font-style: italic;">FILENAME</span> in another. Well, let's just say, sharing file systems is hard with software developers inconsistencies. I need to figure out a good case-insensitive file system to use or I need to be able to tell Samba to do this for me, so expect at least one more update to this blog post.<br /><br /><span style="color: rgb(255, 0, 0);"><span style="color: rgb(0, 0, 0);"><span style="color: rgb(255, 0, 0);"><span style="font-weight: bold;">Update 2007-10-14<br /></span></span></span></span>I finally have suspend/hibernate working correctly. Apparently it all had to do with the SuSE version of s2ram (suspend to ram) not knowing my machine (the actual hardware identifiers). I had to go into:<br />/etc/pm/config<br /><br />and set:<br />S2RAM_OPTS="-f"<br /><br />or "force" and this not only made suspend to ram from the applications menu work correctly, but apparently suspend to disk also requires suspend to ram to function properly. If suspend to ram fails then apparently suspend to disk doesn't just quit and leave the computer system running, it does something and then writes it to disk. You restart your computer, it will run for a few minutes, then it will just turn off completely without any warning forcing you to lose anything you were working on :-(.<br /><br />I am very pleased now. I can truly hibernate this hardware, and it seems to work correctly. Even the wireless NIC starts itself correctly without me having to turn it off and back on and even reconnects itself. Previously , when hibernate was working incorrectly, I would notice that s2disk apparently didn't store the hardware state correctly as the wireless NIC would always have to be turned off, with the physical switch, then turned back on after 10 seconds (and you did have to wait the 10 seconds...any less and it just wouldn't work at all) just to be able to connect to the internet or network. Previously that was all futile as the computer would shutdown after it had been running for a few minutes. Now all seems well, and it has made life so much nicer with this system.<div class="blogger-post-footer">Link to by RSS feed using http://wadechandler.blogspot.com/atom.xml</div>Unknownnoreply@blogger.com