Advanced WebSphere 7.0 Administration Course Descriptions Posted

During the first part of this year we have seen a number of WebSphere clients moving to the 7.0 version with their WebSphere environments.  Since many clients have WebSphere administrators that are skilled enough where they don’t need the “basic” administration course we are often asked about more advanced training for this group.  In support of this we have just posted several new course descriptions, described below, for various advanced WebSphere 7.0 administration courses.  These courses are also good for those that are new to WebSphere but need more training in particular areas after attending our primary WebSphere 7.0 administration course.

Since the WebSphere administrators who would take an advanced class are also often not able to attend a 4-5 day training class we have kept the advanced courses short and focused.  You can have the flexibility to let your senior WebSphere administrators attend a class and develop their skills without being unavailable in training for a full week or perhaps even save travel dollars by running 2 classes the same week.  For more information about pricing and availability of these courses contact your Web Age Solutions sales representative.

You can also find these courses linked in our latest version of our WebSphere Application Server 7.0 Administration Course Map

WA1953 Administrative Scripting with WebSphere Application Server 7.0

This 3 day course covers in depth how to perform many common WebSphere tasks using the WebSphere scripting libraries.  Rather than using the Administration Console, which is prone to human error, students will learn how to create automated and repeatable procedures modify WebSphere environments with scripting.  Students learn the Jython language in addition to the commands available in a WebSphere environment.

WA1941 WebSphere Application Server 7.0 Performance Tuning

Often a key responsibility of WebSphere administrators, “performance tuning” is the process of finding ways the WebSphere environment can operate more efficiently.  This 3 day course covers performance tuning methodology, how to detect a bottleneck and common problems and solutions. After taking this class, students will be able to methodically create a stress testing plan and find bottlenecks and resolve them.

WA1849 Advanced WebSphere Application Server 7.0 Administration

This 3 day course covers some of the more advanced clustering and security aspects of a complex WebSphere environment.  After taking this course, students will be able to design a WebSphere based system that is more secure, easier to manage and performs better. Students will also be familiar with some of the new administrative and troubleshooting tools that are available with WebSphere 7.0.

WA1939 WebSphere 7.0 Problem Determination

Since troubleshooting is always a topic of great interest in our administration courses we have created this 2 day course to focus more in depth on how to resolve issues in a WebSphere environment.  Throughout the class students will learn about various advanced tools and techniques to help resolve problems in the configuration and operation of a WebSphere environment.  The class also provides details on the symptoms of many common WebSphere issues and how to resolve the issue.  Since many different products are based on the WebSphere Application Server, the issues and troubleshooting techniques covered in this class can be applied to many different WebSphere 7.0 environments.

No Comments

Coding HTML5 Pages Using Eclipse

The Helios release of the Eclipse IDE for Java EE Developers provides support for HTML5 development. Specifically, it allows you to create HTML5 pages using a new template, provides code completion for HTML5 elements, provides a Properties editor for HTML5 attributes, and provides a WYSIWYG editor for visual development of HTML5 pages.

Creating an HTML5 Page

Before creating an HTML5 page, it’s recommended to set the character encoding type to UTF-8. It defaults to ISO-8859-1. To do so:

1.   Select Window->Preferences from the menu bar.

2.   Expand Web and select HTML Files.

3.   Select ISO 10646/Unicode(UTF-8) from the Encoding drop-down.

clip_image001

4.   Click OK.

Creating an HTML5 page is easy. Simply follow these steps:

1.   Select File->New->Other.

2.   Expand Web and select HTML File. Click Next.

3.   Enter a file name, select the parent folder and click Next.

clip_image002

4.   Select New HTML File (5) for the template and click Finish.

clip_image003

The file will open with the HTML Editor, which provides syntax highlighting (coloring). The tags are displayed in green, the attributes in purple, the attribute values in blue, and the element values in black.

clip_image005

Notice that the document contains the new DOCTYPE element which is used to specify “non-quirks mode” (a.k.a. “standards mode”). It also contains the simplified meta element which is used to specify the UTF-8 character encoding.

Using Code Completion

Using code completion is the same as always. Simply press Ctrl-Space and a list of valid HTML5 elements will be listed.

clip_image001[4]

The same thing applies to attributes. Stick your cursor inside the element’s start tag, press Ctrl-Space, and you’ll see a list of valid attributes:

clip_image003[4]

Using the WYSIWYG Editor

The Helios release of Eclipse also has a WYSIWYG editor for HTML development. It allows you to visually develop your web pages by dragging and dropping widgets from a palette onto your page. Unfortunately, the palette doesn’t include any HTML5 elements at present, but the Properties view was updated to include HTML5 attributes. To make use of the new editor, follow these steps:

1.   Close the HTML file if you already have it open using the HTML Editor.

2.   Right click on the file and choose Open With->Web Page Editor.

The Web Page Editor will open. This is a multi-tab editor. By default, the Design tab is displayed, which offers a split view for easier editing. The top half of the editor displays the visual view of the page and the bottom half of the editor displays the source code. Note that there’s also a Preview tab which displays what the page will look like when rendered by Eclipse’s internal browser.

clip_image005[4]

3.   If you added the canvas element in the last part, go ahead and delete it.

4.   In the right side of the editor, click the left arrow and the Palette will be displayed.

5.   Expand the HTML 4.0 folder to see the list of HTML 4.0 elements. Once again, there are no new HTML5 elements included yet.

clip_image007

6.   Scroll down inside the Palette and drag and drop the Text Field widget onto the page.

Notice that a form element is automatically added to the page. Also, notice that even though you added a text field to the page, the type attribute is not specified. It turns out that in HTML5 the type attribute defaults to “text” if not specified.

clip_image009

7.   Select the text field in the top half of the editor.

8.   Click on the Properties view and its Attributes tab.

9.   Click on the drop-down to the right of autofocus and select autofocus.

clip_image011

10.  Verify that the autofocus attribute is listed in the source code section of the editor. This sets the focus on this field when the form is rendered. Pre-HTML5, you had to do this with JavaScript code.

clip_image013

Note: The editor uses XHTML syntax by default. You don’t need to use XHTML syntax if you don’t want to in HTML5, since HTML is not XML.

11.  Back in the Properties view, scroll down and select required from the drop-down for the required attribute. This means the user has to input a value for this field. Otherwise, he won’t be able to submit the form. Just like with the autofocus attribute, you used to have to do this with JavaScript code.

clip_image015

12.  Likewise, scroll down and verify the type attribute is set to text.

clip_image017

13.  While you’re there, click the drop-down to the right of type. Notice that it reflects the new HTML5 input types, including color, date, datetime, datetime-local, and email.

clip_image019

14.  Your input element should now look as follows:

clip_image021

15.  Drag and drop a Button element on the page to the right of the text field.

16.  Change the value attribute to Submit in the Properties view.

clip_image023

17.  Save the file.

Great! You’ve visually developed an HTML5 page using the Web Page Editor. Note that even if choose not to use this editor and continue using the HTML Editor, the Properties view is still available from there.

Opening the Web Page in a Browser

By default, if you click the browser icon in the Eclipse toolbar, it will open the internal browser, which is based on IE. Unless you’re using Windows 7, the version of IE that’s used is IE7 or IE8, neither of which provide much HTML5 support. Don’t despair. You can change the Eclipse settings to open a different browser, such as Google Chrome 10, Opera 11, or Firefox 4, which provide much better support for HTML5. To do so:

1.   Select Window->Preferences from the menu bar.

2.   Expand General and click Web Browser.

3.   Click New.

4.   Type the name of the browser and specify its location using the Browse button.

clip_image025

5.   Click OK.

6.   Click the Use external web browser button.

7.   Check the box next to the new browser (e.g., Google Chrome).

clip_image027

8.   Click OK.

9.   Click the web browser icon in the toolbar.

clip_image029

The browser should open.

10.  Enter the URL for the page you created.

clip_image031 

Notice the cursor is blinking inside the text field, which means autofocus is working.

11.  Click the Submit button without entering a value in the text field.

clip_image033

Notice an error message is displayed, which means the required attribute is working.

12.  Now input a value and click Submit. This time the form should submit successfully. However, because we didn’t specify a form action, the original page will be displayed, since the form submits to itself.

Making the WYSIWYG Editor Your Default Editor

If you’d like, you can make the Web Page Editor your default editor for HTML files. To do so, follow these steps:

1.   Select Window->Preferences from the menu bar.

2.   Expand General->Editors and select File Associations.

3.   Select .html from the File types list box.

4.   Select the Web Page Editor option in the Associated editors list box.

5.   Click the Default button to the right of it.

6.   Verify the label (default) appears to the right of the Web Page Editor option.

clip_image035

7.   Click OK.

Summary

In this blog posting, we examined how to use Eclipse Helios to create an HTML5 page using the new HTML5 template. We saw that the code completion drop-down was updated to include HTML5 elements. We sampled the new Web Page Editor, which provides us with the ability to develop pages visually. Last but not least, we learned how to change the default web browser used by Eclipse to an HTML5 compliant one.

For more information on HTML5 development, check out our new HTML5 course:

WA1925 Enterprise Web Development using HTML5

30 Comments

Data I/O in iOS

I noticed a strange lack of high performance I/O routines in Objective-C. All I see is:

  • Bulk I/O. E.g, contentsAtPath of NSFileManager or writeToFile of NSString. These are memory intensive and impractical for complex data structure.
  • Very low level buffer based I/O from NSFileHandle. This is not good for reading NSString, int and float.

It appears that most people fall back on C routines like fwrite and fscanf for the job. I decided roll out a class that handled the task of reading and writing NSString, int, float etc. I wanted to borrow Java’s readUTF and writeUTF methods for NSString. In fact, my implementation should be compatible to Java’s.

The implementation below reads and writes data using binary files. The class can improve upon more error checking. The readUTF method can be optimized by recycling the malloced buffer.

FileUtil.h

#import <Foundation/Foundation.h>


@interface FileUtil : NSObject {
    FILE *mFile;
}

- (BOOL) openRead: (NSString*) file;
- (BOOL) openWrite: (NSString*) file;
- (BOOL) openAppend: (NSString*) file;
- (void) close;
- (NSString*) readUTF;
- (void) writeUTF: (NSString*) string;
- (int) readInt;
- (void) writeInt: (int) value;
- (float) readFloat;
- (void) writeFloat: (float) value;

@end

FileUtil.m

#import "FileUtil.h"


@implementation FileUtil

- (FileUtil*) init {
    [super init];
    
    mFile = NULL;
    
    return self;
}

- (BOOL) openRead: (NSString*) file {
    [self close];
    mFile = fopen([file fileSystemRepresentation], "rb");
    
    return mFile != NULL;
}

- (BOOL) openWrite: (NSString*) file {
    [self close];
    mFile = fopen([file fileSystemRepresentation], "wb");    
    
    return mFile != NULL;
}

- (BOOL) openAppend: (NSString*) file {
    [self close];
    mFile = fopen([file fileSystemRepresentation], "ab");
    
    return mFile != NULL;
}

- (void) close {
    if (mFile != NULL) {
        fclose(mFile);
        mFile = NULL;
    }
}

- (void)dealloc {
    [self close];
    [super dealloc];
}

- (NSString*) readUTF {
    int length = 0;
    fread(&length, 2, 1, mFile); //Java's writeUTF writes length in 2 bytes only
    
    char *buff = malloc(length + 1); //Extra byte for '\0'
    fread(buff, 1, length, mFile);
    buff[length] = '\0';
    
    NSString *string = [NSString stringWithUTF8String: buff];
    
    free(buff);
    
    return string;
}

- (void) writeUTF: (NSString*) string {
    const char *utf = [string UTF8String];
    int length = strlen(utf);

    fwrite(&length, 2, 1, mFile); //Java's writeUTF writes length in 2 bytes only
    fwrite(utf, 1, length, mFile); //Write UTF-8 bytes
}

- (int) readInt {
    int i;
    
    fread(&i, sizeof(int), 1, mFile);
    
    return i;
}

- (void) writeInt: (int) value {
    fwrite(&value, sizeof(int), 1, mFile);
}

- (float) readFloat {
    float f;
    
    fread(&f, sizeof(float), 1, mFile);
    
    return f;
}

- (void) writeFloat: (float) value {
    fwrite(&value, sizeof(float), 1, mFile);
}

@end

No Comments

Struts 2 Project Template for RAD 7.5

Rational Application Developer (RAD) 7.5 supports only up to Struts 1.3. I do not anticipate IBM to support Struts 2.0 any time soon.

Adding Struts 2.0 to a web project is not rocket science but it can take up a bit of time. You need to assemble the right JAR files and create struts.xml in the right place and what not. I have created a template project file that will avoid a lot of headache and you can be up and running with Struts 2.0 in no time.

Download Stuts2Template.zip

Features of the Template Project

The dynamic web project is for Servlet 2.5 (or Java EE 5) spec. By default, Struts2 distribution uses Servlet 2.4 spec. I changed the web.xml to use the new version.

The project uses WebSphere Application Server 7.0 as the target runtime.

Using the Template Project

You should be able to create a new dynamic web project from the template very easily. Just follow these steps.

1. Launch RAD 7.5.

2. From the menubar, select File > Import. Expand Other and select Project Interchange.

3. Click Next.

4. Import the Struts2Template from the downloaded ZIP file.

5. You need to rename the project to something more suitable. Right click the project and select Refactor > Rename. Enter a different name and click OK.

RAD does not allow you to deploy a web project directly to a test server. You need to create an enterprise application project and add the Struts2 web project to it. Follow these steps.

6. From the menubar, select File > New > Enterprise Application Project.

7. Enter a project name. Click Next.

8. Select the Struts2 web project.

9. Click Finish.

That’s it. You should do a quick test to make sure that things are in order.

Validating the Project

1. Start the server if it is not running.

2. Add the enterprise application project to the server.

3. There is an index.html file in the Struts2 project. Right click it and select Run As > Run on Server.

4. Click the Hello World link. You should see the Hello World page.

Understanding the Project Structure

The WebContent/WEB-INF/lib folder contains a minimal set of JAR files needed by Struts2.

Under Java Resources/src folder, you will see the struts.xml file.  After the project is built, RAD copies all .class files and any other files from the source folder to WEB-INF/classes. You should never directly edit files in the classes folder.

A sample action class is provided as com.webage.struts.HelloWorld. The action is registered in struts.xml.

3 Comments

JBoss Java EE 6 Certification Survey

A few months ago JBoss Application Server v6.0, the open-source unsupported version, was released.  At the time in the announcement it was mentioned that the 6.0 version had been certified for the Java EE 6 ‘Web Profile’, which requires a subset of the Java EE technologies, but that the 6.0 version had not been certified against the ‘full’ Java EE 6 profile.  The reasoning given was that ‘resource constraints’ would add to the time taken to perform the full certification and JBoss felt it was important to release JBoss AS 6.0 to the community so that people who wanted to begin developing Java EE 6 applications with JBoss could do so.

It wasn’t very long before there were discussions in the community trying to clarify what this meant.  One thread in particular became very popular and has since received almost 14,000 views showing that this is clearly an important topic for JBoss users.  One of the main questions was the level of support for the technologies that JBoss has supported in the past but are not required of the Web Profile.  JBoss developers clarified that JBoss did support technologies like JMS, JAX-WS web services, and others but that they were just not “certified” because the certification had not been done for the full Java EE 6 Profile.  Of course this raised simply more questions and it was quickly clear that most of the community was unclear about the direction of JBoss, especially for the future JBoss Enterprise Application Platform (JBoss EAP) which is the supported version many clients use.

To help get the opinion of the community in a little more scientific way than just forum posts I created a survey about some of the questions and issues surrounding JBoss Java EE 6 certification.  The survey is still open so you can take it if you haven’t already but I wanted to summarize the results so they could help drive the progression of JBoss before JBoss AS 7.0, which is the open source version that will be used in JBoss EAP 6 (yeah, I know it’s confusing), is finalized.  Obviously commenting after the fact wouldn’t help anyone so this survey was a way for the community to speak up now.

Survey Summary

First of all the survey seemed to be a hit and had 269 responses when I did the analysis described here.  The thread that introduced the survey has even been listed as a “featured discussion” in the JBoss forums so maybe that is something done by some of the JBoss developers to help improve community feedback (which I appreciate) and show they are interested in the opinions of the JBoss community.

Before getting into further analysis below I think I can summarize some of the biggest things that seem to be apparent from the results.  These points are for the full set of responses, I’ll break down some other groups later.

  • By an almost 3-1 margin people were surprised that JBoss AS 6.0 doesn’t support the full Java EE 6 profile
  • Generally people are willing to wait several months if that is what it takes to certify JBoss AS for the full Java EE 6 profile
  • More people are willing to wait however long it takes for full certification compared to the number not willing to wait at all
  • By a 3-1 margin people feel both JBoss AS open source version and JBoss EAP should be certified for the full Java EE 6 profile
  • About 40% of people would be “very likely” or “would definitely” switch to another server if JBoss AS or JBoss EAP were not certified for the full Java EE 6 profile
  • There was a good sample of JBoss EAP clients with 1 out of 4 indicating they were an EAP customer

First of all, for full accountability I’ve made the summary results of the whole survey available here along with a spread sheet of all of the individual responses available here (for those statistics geeks out there).  Other files are also linked at the bottom of this post.

Detailed Analysis

So let’s look at each of the questions and see what we might deduce.

Question #1 asked about various features and how important they were.  The clear winner here is obviously performance which I think makes sense since most people have been probably using some form of JBoss AS 5.1 (even within EAP) which has the highest startup time of any recent JBoss version.  So clearly the JBoss AS 7.0/JBoss EAP 6.0 focus on performance is critical.  For the two certification options it is interesting that people generally took their position on Web Profile certification and either felt that full profile certification was either more important or less important as the full profile option had more responses on the extreme.  The average for full profile certification was higher than web profile certification though so more people felt that full certification was more important.  Ease of administration did edge out both certification options although this has long been a weakness of JBoss compared to other competitive application servers so again no surprise there and a good support for the effort on usability of JBoss currently underway.

Question1Chart

I think question #2 about if people were surprised that JBoss AS 6.0 doesn’t support the full Java EE 6 profile is pretty clear cut.  I think this makes it important for those guiding the JBoss development to clearly communicate the intentions for the upcoming versions of JBoss AS and JBoss EAP to address this gap in communication.

Arguably the question could be called misleading since you can make the argument that “doesn’t support” is different than “fully certified” but I think the result is clear that without the “fully certified” stamp of approval there will always be doubt that will be hard to justify to managers, etc.

Question2Chart

Question #3 on how long people would be willing to wait clearly indicates that the community would likely be willing to wait some time, as long as it didn’t drag on like JBoss AS 5.0 seemed to.  Hopefully the difference between being able to release a Web Profile certified version and a version certified for the full Java EE 6 profile would fall in this range.  For those not willing to wait, people can start using JBoss AS 6.0 right now for the newest cutting edge technologies, as suggested by JBoss developers.

Question3Chart

Question #4 is pretty clear that people want both the open source and supported platform to be certified for the full Java EE 6 profile.  Part of this could be people wanting to use the JBoss AS server without being an EAP client or for EAP clients to have more confidence that full Java EE 6 profile certification was not something introduced at the last minute.  Both are valid reasons though so hopefully this is what we might see (otherwise there would be a pretty big distinction between JBoss AS and JBoss EAP).

Question4Chart

Question #5 on how likely people are to switch is much more interesting when you break down by groups which I’ll do later.  Overall though the notion that JBoss might not be certified for the full Java EE 6 profile has got some people thinking about if they will stick around.  Certainly with many more open source Java EE options out there compared to 5 years ago having 17% of your users say “I’m outta here” should cause some concern.

Question5Chart

I asked question #6 to really get an idea of how many people taking the survey were JBoss EAP clients (and therefore paying JBoss money 😉 ) because a survey only advertised on the forums could attract a very different subset of people.  I think there is a good sample even if you assume all those that said “don’t know” are not EAP clients. This also lets us break down the results to focus on JBoss EAP clients only.

Question6Chart

Group Breakdown

I won’t do much more than highlight the major findings for some groups and link to the file that has the complete cross-tabulated results but I think there are some interesting findings for some groups.  I’ve also indicated how many responses are in each group compared to the 269 total responses.

EAP Customers (66) – I think the group JBoss may be most interested in is how the people who indicated they are a JBoss EAP client responded.  I think the interesting points are:

  • More likely to switch servers if full profile certification is not done (49% “very likely” or “would definitely switch” compared to 40% of all surveys)
  • More willing to let JBoss EAP be the only thing certified for full profile (since they are paying for EAP anyway and not using JBoss AS)
  • There was not really significant difference in the rating averages of the 4 features in question #1
  • There was a difference in the distribution of responses to question #1 though with actually FEWER responses of ‘Extremely Important’ for the certification options and more ‘Very Important’ so kind of bunching up around ‘Very Important’ instead of being quite so widely distributed as all responses were
  • Just a few percent higher on being surprised about question #2 on the lack of full profile in JBoss AS 6.0
  • More bunching up around waiting 0-3 or 3-6 months for full profile certification

EAP Customers “very likely” or “would definitely” switch servers (32) – You might look at the points above and think “EAP clients won’t really have a different opinion than the larger community”.  But if you look further at the subset of EAP clients who are more likely to switch servers there are some clear signs of why they would switch

  • This group feels MUCH more strongly that full profile Java EE 6 certification is ‘Extremely Important’, even more important than performance and ease of administration
  • This group is MUCH more surprised that JBoss AS 6.0 is not certified for the full Java EE 6 profile, by a factor of 9-1 compared to 3-1 from all surveys
  • MUCH more bunched up around waiting 0-3 or 3-6 months for full profile certification although this comes from losing responses on both extremes

All respondents who felt full certification was “very” or “extremely” important (172)

  • Similar 8-1 ratio of surprise as the previous group that JBoss AS 6.0 is not full profile certified
  • MUCH more interested in seeing both JBoss AS and JBoss EAP certified for the full profile
  • More likely to switch servers with the “not likely” category dropping 15% and almost all of these showing up in “very likely” or “would definitely” switch categroies
  • Fewer people not willing to wait for certification and these people shift to the 0-3 and 3-6 month range with little change at the longer wait options

All respondents who felt full certification was “not at all” or “somewhat” important (57)

  • This group is not really surprised to hear JBoss AS 6.0 is not full profile certified
  • This group places the biggest distinction between full profile and web profile certification as the difference in how “important” each are is 1.5 points out of 5 different
  • Surprisingly there are a higher percentage in this group willing to wait “however long it takes” for full profile certification although there are also more people on the “not willing to wait” and 0-3 month range so more extremes on that question
  • This group is more willing to accept having only JBoss EAP full profile certified
  • Not surprisingly this group isn’t going to switch servers if JBoss does not certify against the full Java EE 6 profile

Conclusion

Clearly this survey confirms that full Java EE 6 certification is an issue that the JBoss community cares about.  Hopefully the surprise at the approach for JBoss AS 6.0 and the value the community (especially EAP clients) place in full Java EE 6 certification will convince those involved in some of these decisions at JBoss to more clearly communicate the plans for yet-to-be-released versions of JBoss AS and JBoss EAP.  Personally I think they are and hopefully this survey has helped that process.

 

Many thanks,

Stuart Smith

Java and Administration Lead

Web Age Solutions

 

PS. If you are still reading JBoss is obviously important to you so you might be interested in some of the popular JBoss training courses my company offers… (sorry, had to plug the company on the company blog)

– JBoss 5.x (AS and EAP) Administration and Clustering on Linux or Windows

Java EE 5 Programming with JSF, EJB 3.0, and JPA on JBoss 5.x

Java Enterprise Programming with JBoss Seam 2.x

All Survey Files

Spreadsheet with all responses collected

Summary with all responses included

Summary of respondents who are EAP clients

Summary of EAP clients “very likely” or “would definitely” switch servers

Summary of all respondents who felt full certification was “very” or “extremely” important

Summary of all respondents who felt full certification was “not at all” or “somewhat” important

Summary of all respondents “not likely” or “somewhat likely” to switch servers

Summary of all respondents “very likely” or “would definitely” switch servers

5 Comments

Uninstalling XCode

I am getting ready to install XCode 4. First, I wanted to uninstall XCode 3.2. Here are the steps.

Open a terminal window.

Change to the root directory:

cd  /

Uninstall all of XCode:

sudo Developer/Library/uninstall-devtools –mode=all

sudo  Developer/Library/uninstall-devtools  –mode=all

It takes a while to uninstall everything. The uninstaller seems to leave behind the documentation files under /Developer/Platforms/iPhoneOS.platform folder.

No Comments

Understanding Memory Management in Objective-C

Mac OS X now has support for garbage collection. But that facility is not available in iOS yet. Only reference count based memory management is available. So, it pays to have a good feel for how memory is allocated and deallocated.

We will use a very simple program to learn the basics. The interface will remain unchanged throughout this article.

@interface Address : NSObject {
  NSString* street;
  NSString* city;
  NSString* zip;
}

- (Address*) initStreet: (NSString*) s city: (NSString*) c zip: (NSString*) z;
- (void) print;
@end

Our first implementation will be very basic.

@implementation Address

- (Address*) initStreet: (NSString*) s city: (NSString*) c zip: (NSString*) z {
  street = s;
  city = c;
  zip = z;
  
  return self;
}

- (void) print {
  NSLog(street);
  NSLog(city);
  NSLog(zip);
}
@end

Here, the the Address class does not take ownership of the various NSString objects sent to the initStreet method.

Let’s see a use of the class:

int main (int argc, const char * argv[]) {
  NSString *s = [[NSString alloc] initWithCString: "101 Flora"];
  NSString *c = [[NSString alloc] initWithCString: "Miami"];
  NSString *z = [[NSString alloc] initWithCString: "33139"];
  Address *a = [[Address alloc] initStreet:s city:c zip:z];

  [a print];

  return 0;
}

The code will work just fine. Except that there is mass scale memory leak. All four objects created in the main method will leak.

We can easily fix that by releasing the objects. A golden rule of memory management is that the owner of an object should free it. An entity that creates an object is the default owner of it.

int main (int argc, const char * argv[]) {
  NSString *s = [[NSString alloc] initWithCString: "101 Flora"];
  NSString *c = [[NSString alloc] initWithCString: "Miami"];
  NSString *z = [[NSString alloc] initWithCString: "33139"];
  Address *a = [[Address alloc] initStreet:s city:c zip:z];

  [a print];

  /* Free all objects */
  [a release];
  [s release];
  [ c release];
  [z release];

  return 0;
}

This is much better. Now we have stopped the memory leak.

The Address class still does not take ownership of the NSString objects. This can cause problem if an Address object needs to use the NSString objects after they are released. For example, the following is an error and will cause the program to crash.

int main (int argc, const char * argv[]) {
  NSString *s = [[NSString alloc] initWithCString: "101 Flora"];
  NSString *c = [[NSString alloc] initWithCString: "Miami"];
  NSString *z = [[NSString alloc] initWithCString: "33139"];
  Address *a = [[Address alloc] initStreet:s city:c zip:z];

  [a print];

  [s release];
  [ c release];
  [z release];

  /* Error. Will cause crash. */
  [a print];

  [a release];

  return 0;
}

Here we have a situation where an object must take ownership of other objects even though it did not create them in the first place. We will change the initStreet method to retain the NSString objects and there by taking ownership.

- (Address*) initStreet: (NSString*) s city: (NSString*) c zip: (NSString*) z {
  street = s;
  city = c;
  zip = z;
  
  /* Take ownership */
  [street retain];
  [city retain];
  [zip retain];
  
  return self;
}

Now, the program will not crash. You can safely call the print method after the main method has released the NSString objects.

There is one problem. The Address class does not release the NSString objects. Remember the golden rule. The owner of an object should release it. In this example, the NSString objects have two owners – the main method and the Address class. They should both release them. A good place to release these objects is from the destructor method – dealloc. Add this method to the implementation.

- (void) dealloc {
   
  [street release];
  [city release];
  [zip release];
  
  [super dealloc];
}

Now, we are all good. The code, in full form will look like this.

#import <Foundation/Foundation.h>

@interface Address : NSObject {
  NSString* street;
  NSString* city;
  NSString* zip;
}

- (Address*) initStreet: (NSString*) s city: (NSString*) c zip: (NSString*) z;
- (void) print;
@end

@implementation Address

- (Address*) initStreet: (NSString*) s city: (NSString*) c zip: (NSString*) z {
  street = s;
  city = c;
  zip = z;
  
  [street retain];
  [city retain];
  [zip retain];
  
  return self;
}

- (void) dealloc {
  puts("Dealloc called");
  
  [street release];
  [city release];
  [zip release];
  
  [super dealloc];
}

- (void) print {
  NSLog(street);
  NSLog(city);
  NSLog(zip);
}
@end

int main (int argc, const char * argv[]) {
  NSString *s = [[NSString alloc] initWithCString: "101 Flora"];
  NSString *c = [[NSString alloc] initWithCString: "Miami"];
  NSString *z = [[NSString alloc] initWithCString: "33139"];
  Address *a = [[Address alloc] initStreet:s city:c zip:z];
  [s release];
  [ c release];
  [z release];

  [a print];
  [a release];

  return 0;
}

No Comments

Enabling VNC In Mac OS X

Mac OS X has a VNC server built in. You just need to enable it. These steps work in OS version 10.6.4.

Open System Preferences.

image

Click Sharing.

image

Check Remote Management.

image

Check appropriate permissions as shown below.

image

Click OK.

Click Computer Settings.

image

Enable VNC and set a password.

image

Click OK.

That’s all!

You can monitor the VNC server process in the Activity Monitor tool as shown below.

image

Caveat! Not all is well with Mac’s VNC server. Watch out for these:

  1. Copy and paste between windows and Mac does not work. In fact, the moment you copy text in Windows, the VNC server crashes (and restarts) in Mac.
  2. File transfer does not work.

1 Comment

WA1853 WebSphere Process Server v7.0 Administration

Today, I was asked to compare our WA1853 with IBM’s WB722. Both are 5 days long. Both cover the basics – installation, clustering and application deployment. But, we have added a few chapters that customers have repeatedly asked for. IBM’s WB722 does not have them or covers them only lightly.

1. We have a performance tuning chapter – Chapter 17. Performance tuning is a complicated matter in a Business Process environment. We have done original research in that area that has gone into this chapter.

2. We have a troubleshooting chapter that covers most common problems – Chapter 18.

3. Chapter 16 – Process Error Recovery is crucial for companies deploying BPEL business processes. It covers what happens when a process instance fails. How to manually or automatically deal with that.

4. Chapter 19 – Routing Web Service Requests Through a Web Server is a useful one. It covers often overlooked topics, the little things you need to do to expose a web service to the outside world. They are not rocket science, but when you take care of these little things, the service offering looks professional and works reliably.

As always, we try hard to gauge what pains our clients the most. We do our best to cover those areas in our courses.

No Comments

Parallel Path Execution in WebSphere ESB 7

A mediation flow can run multiple branches in parallel but in a single thread. Basically, it uses the request with deferred response pattern. We will use an example to understand how things exactly work. But, before we get to that, let’s look at what we need to do to enable parallel processing. You will need to do two things:

1. For the Service Invoke primitives in the aggregation block, set the Invocation Style property to Async.

image

2. For the Fan Out primitive, choose Check for asynchronous responses after all messages have been fired. The Fan Out has to be in iteration mode for you to be able to choose that option.

image

Now, let’s examine an example.

image

Here, for all Service Invoke primitives, Invocation Style has been set to Async. For the Fan Out, Check for asynchronous responses after all messages have been fired has been selected.

The flow will perform as follows. First ServiceInvoke1 will be called immediately followed by ServiceInvoke3 (actually, the exact order of their invocation can not be determined and does not really matter). System will not wait for response from ServiceInvoke1 before ServiceInvoke3 is executed.

Since there are primitives left to be executed in both branches, the flow will then go to wait for responses to come back from the two already executed operations. This wait in the middle of the paths can not be avoided since the subsequent primitives may depend upon the output of the executed operations. After ServiceInvoke1 and ServiceInvoke3 return output back, system will then execute XSL4 and ServiceInvoke4. Without waiting for response from ServiceInvoke4, system will execute XSL2 and ServiceInvoke2. System will then wait for the responses to come back from these two Service Invoke primitives.

A Note About Deadlock

In the example above, request is sent but the system does not wait for a response. You need to be careful about the transaction boundary. Let us say that a request is sent by posting a message in a JMS queue. By default, the message will be actually posted if the transaction of the mediation flow commits. If the flow waits for a response, that will never come since the transaction is still active and the request message never went out in the first place. Long story short, you will have to post the request message in a separate transaction from the main transaction of the message flow. To do that, select the service reference of the mediation flow in the assembly diagram. Then set the Asynchronous invocation qualifier to Call.

image

WID v7 actually give you an error message if you setup parallel processing but do not configure the transaction boundary correctly.

7 Comments