Filed under: actionScript, appCoreLib, contracting, development, flex
Preface
For the longest time I have been using a little set of helper classes that I have just recently named AppCoreLib. I have used this on various projects of varying sizes. Everything from Enterprise level apps to my pet projects.
Though not entirely original, the idea hasn’t really been put into an open-source swc that I know of. So I decided to do so. Thanks and credit goes out to my bud EKZ who spawned the idea in this particular flex-flavor.
Application Core Library
AppCoreLib consists of a few lite-weight classes.
- broker based classes
- a special event class
- an application interface
The idea is this: Ofttimes an application needs to load various content and settings files prior to the application’s view being shown. The reason is that if you are using an MVC framework with {bindings} and/or other mechanisms on your model, you may encounter null pointer exceptions if a view tries to load prior to content dependencies being loaded. Enter AppCoreLib. It provides a very lite-weight framework added at the <application/> level of your RIA.
How it Works
- default flex loading mechanism loads swf
- IApplicationShell implementor’s creationComplete handler instructs instances of the broker classes to retrieve data dependencies
- broker classes notify handlers that they have indeed loaded their data
- upon all dependencies being loaded, IApplicationShell.shellInitiliazed() is triggered where normally you would put your RIA’s UI classes to be loaded.
- Since certain broker classes are Singleton implementors, you can easily access their data from anywhere in your application.
Check It Out
I have set up the project home at google code. Here are some various links:
- AppCoreLib home
- AppCoreLib docs (coming soon)
- AppCoreLib swc
- AppCoreLib source
- example application
- example source view
Depending on your services setup, and if you use Cairngorm, you have probably seen or written alot of code like this:
public function execute (event:CairngormEvent):void {
var call:AbstractOperation = ServiceLocator.getInstance().getWebService("someName").getOperation("someOperation");
So suppose you have many WSDLs or if you are like me and are using AMFPHP, you might have quite a few Remote Objects logically split up. For instance, you might have 6 RemoteObjects in your ServiceLocator subclass mxml. Like so:
<?xml version="1.0" encoding="utf-8"?>
<adobe:ServiceLocator
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:adobe="http://www.adobe.com/2006/cairngorm">
<mx:RemoteObject id="userServices" source="userServices" destination="amfphp" showBusyCursor="false"/>
<mx:RemoteObject id="journalServices" source="journalServices" destination="amfphp" showBusyCursor="false"/>
<mx:RemoteObject id="adminServices" source="adminServices" destination="amfphp" showBusyCursor="false"/>
<mx:RemoteObject id="activityServices" source="activityServices" destination="amfphp" showBusyCursor="false"/>
<mx:RemoteObject id="miscServices" source="miscServices" destination="amfphp" showBusyCursor="false"/>
</adobe:ServiceLocator>
I like being able to code quickly and know that I am pointing to the correct RemoteObject without a) having to look at the mxml to get the right name or b) hope that I remember what I called it. In order to do so I added a few lines of code in my <script/> tags to my ServiceLocator subclass named ApplicationServices.mxml:
public static function getInstance ():ApplicationServices {
return ApplicationServices(ServiceLocator.getInstance());
}
Now when I am quickly making command classes that I want to ensure use a particular RemoteObject without relying on the getRemoteObject() method and my fuzzy memory of what was named I can type:
public function execute (event:CairngormEvent):void {
var call:AbstractOperation = ApplicationServices.getInstance().userServices.getOperation("someOperation");
I think this is a bit cleaner and nicer looking. And its just one less step to have to remember or reference when creating your commands.
[UPDATE]
It appears that a 10.5 friendly version of mysql has been released. Before engaging in this tutorial you might want to check with a more traditional install procedure that comes with the newest version of mysql.
======================
Firstly, I should preface this post by saying that there are probably at least a dozen posts on this topic. All are basically the same with little differences here and there. None of them worked for me. But what did work (so far) is taking bits and pieces from a post here and a post there to finally get something working. Thanks goes out to all those other bloggers who provided the information found here.
Additionally, if things keep going the way they had been, this might not work at all. I have had MySQL up and running several times only to return to find it no longer wants to start for me.
Keep in mind that this is my attempt at a new install of MySQL on my newly acquired MacBook Pro (MBP hereinafter).
Step 1: Enable your root user
- Open the Directory Utility: In the Finder, navigate to the Utilities folder (tip: click on the desktop, hit Cmd+Shift+U).
- Click on the padlock to allow edits.
- Go Edit > Enable Root User
- Enter and re-enter your password.
Now, you are set to access protected areas of the system via the terminal.
[Excerpt from StringFoo's post]
Step 2: Backup any existing databases from previous versions of MySQL
I never had anything installed so I never attempted to do so. But this goes without saying for you other folks.
Step 3: Remove previous versions of MySQL
I did attempt multiple installs so I did remove them prior to my finally working install. I had nothing to preserve so again, if you are looking to backup a previous version you might want to research it.
- Open a new Terminal window.
- Remove the installed location by typing
sudo rm -rf /usr/local/mysql(keep in mind that if you backed up your databases in this directory it is targeted to get deleted!!!). What this basically says (for all of we new Mac users is: super user remove the targeted folder and recursively do so to any subsequent folders and files from this location. - Remove any launchers by typing
sudo rm -rf /Library/StartupItems/MySQLCOM/
[Excerpt from Hivelogic's post]
Step 4: Add environment variables and some Terminal alias to launch MySQL
- Open a Terminal window.
- Use a command-line text editor to create the enviro-vars and aliases by typing
pico ~/.bash_login(that is a tilde not a dash btw). This opens the pico text editor and either opens or creates the .bash_login hidden file at your user’s folder. - Add the following text:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
alias mysql-start="sudo /usr/local/mysql/support-files/mysql.server start"
alias mysql-stop="sudo /usr/local/mysql/support-files/mysql.server stop" - type ctrl-x to initiate closing Pico.
- type y to save it.
- type enter to save to the prompted location
- You should now be back in Bash
- Now get Teminal to load those new aliases and path type:
. ~/.bash_login
Step 5: Grab the MySQL installer and install
- Grab the appropriate installer from the MySQL download page (I am using the intel based MBP)
- Install to the default locations.
- I went ahead and installed the System Preferences utility that is supposed to help you start/stop MySQL’s server, however it did not work. Do so if you wish and maybe you can get it to work. Here are some comments on how you might get it going
Step 6: Update ownership of some launch-specific files
- In a terminal window, type the following in order to create a folder where the MySQL sock file will live.
- Create the folder:
sudo mkdir /var/mysqlThis just says super user make directory mysql in the var directory - Change ownership of that directory to the user _mysql:
sudo chown _mysql /var/mysql
[Excerpt from StringFoo's post]
Step 7: Start the MySQL server and then login
Hopefully, if I remember all the steps I took to get this working and it actually works for you, then you should be able start the MySQL server and login.
- Type
mysql-start - If all is well you should see a succsss message. So now login by typing:
mysql -u rootThis just means login to the MySQL server as the user root - If that works then you should see a prompt saying
mysql> - If you want to stop the MySQL server, exit the current user by typing:
exit - You should now be back in the terminal so type:
mysql-stopYou should then see another Success message saying that you stopped the server
That’s it. Again, I should really thank the community out there for providing various approaches to getting this thing up and running on Leopard. If you are like me, a new Mac user, then hopefully this will get you working with MySQL. Keep checking the web for a Leopard supported installer so then we can make use of the System Preferences MySQL launcher.
