Saturday, September 12, 2009

Steps for connecting flex with drupal

1) Make sure AMFPHP 1.9 Beta 1 is in the root of your installation of the amfphp module. The path to it should be: your_drupal_install/modules/amfphp/amfphp

2) Confirm AMFPHP is working. To do this go to administer->site building->services and click on the AMFPHP - /services/amfphp link. If it's working properly you should see something like this:

amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.

Note: If you're reading an old tutorial, it will tell you that you should see a download window instead of this message. This confused people so this is the new behaviour starting from amfphp 1.2.

View the amfphp documentation

If you get an error make sure you have the correct beta I noted above.

3) Once you've confirmed it's working, create a new Flex project of type "Basic". I called mine AMFPHPTest.

4) Now create a new file anywhere in your project and call it services-config.xml. I created a folder in my project called "services" and put it in there.

5) In this file, you'll want the following. You will need to change the endpoint uri to reflect the location of your own install of the amfphp module:




class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">





*










6) Now add a compiler directive for the services-config.xml file you just created. To do this, do the following:

  1. Right click on your project in Flex Builder and select "Properties".
  2. In the Properties dialog, click on "Flex Compiler".
  3. In the "Additional compiler arguments" textfield, you need to add an additional directive telling Flex the location of your services-config.xml file and its location on your machine. In my case this file is in my default Flex Project location, and my directive looks like the block below. What I added starts with "-services":
  4. -locale en_US -services "/Users/my-user-name/Documents/Flex Builder 2/AMFPHPTest/services/services-config.xml".

    Note that in my case it was necessary to provide the full path to the file. This may not be necessary in your case.
  5. Click OK in the Properties dialog.
  6. If you get errors in Flex stating that the services-config.xml file can't be found, then the path to it is wrong. If it is wrong, an error will show up immediately in the "Problems" pane of Flex Builder. If you do not get errors, then your services-config.xml file is being compiled into your project when you click debug or run.

6) In the Application mxml file for your Flex Project, you're going to want something like this:







import mx.rpc.remoting.RemoteObject;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;

[Bindable]
public var resObject:Object;

public function resultHandler(event:ResultEvent):void {
// Do something
resObject = event.result;
result_text.text = "Success! The title of your node is: " + event.result.title;
}

public function faultHandler (event:FaultEvent):void {
// Deal with event.faultstring, etc.
result_text.text = "fault: " + event.fault.toString();
}
]]>




Here's a quick piece-by-piece of the really important bits:

  1. Declare the RemoteObject and method with which we will connect to the node service. That looks like this:


    • The ID is local to the flex project, specific to the RemoteObject, and is not associated with our services-config.xml
    • The Source is the node service
    • The destination matches the destination ID of the service we declared in services-config.xml
    • The method name is the method of the node service we want to call
    • The rest should be relatively self-explanatory
  2. Import the classes / packages we need. That looks like this:
  3. import mx.rpc.remoting.RemoteObject;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
  4. Declare the button used to invoke the call to the service. That looks like this:
    • The click event uses the ID we gave our RemoteObject to first get the specific operation (method) we want to call and then send the request with a NID of 1. In my case this is a Drupal page with a title of "TestPage". You can change the NID to any node you have published.

Monday, September 7, 2009

JAR (file format)

This article’s introduction section may not adequately summarize its
contents. To comply with Wikipedia’s lead section guidelines, please
consider expanding the lead to provide an accessible overview of the
article’s key points.
This article does not cite any references or sources. Please help
improve this article by adding citations to reliable sources.
Unsourced material may be challenged and removed.
In computing, a JAR file (or Java ARchive) aggregates many files into one.
Software developers generally use .jar files to distribute Java classes and
associated metadata.
Overview
JAR files build on the ZIP file format. Computer users can create or extract
JAR files using the jar command that comes with the JDK. They can also
use zip tools.
A JAR file has an optional manifest file located in the path META-INF/MANIFEST.MF.
The entries in the manifest file determine how one can use the JAR file. JAR files
intended to be executed as standalone programs will have one of their
classes specified as the “main” class. The manifest file would have an entry
such as Main-Class: myPrograms.MyClass
Users can typically start such JAR files with a command similar to:
java -jar foo.jar
These files can also include a Classpath entry, which identifies other JAR files
for loading with the JAR. This entry consists of a list of absolute or relative
paths to other JAR files. Although intended to simplify JAR use, in practice it
turns out to be notoriously brittle, as it depends on all the relevant JARs
being in the exact locations specified when the entry-point JAR was built. To
change versions or locations of libraries, a new manifest is needed.
Developers can digitally sign JAR files. In that case, the signature
information becomes part of the manifest file. The JAR itself is not signed,
but instead every file inside the archive is listed along with its checksum; it is
these checksums that are signed.
Multiple entities may sign the JAR file, changing the JAR file itself with each
signing, although the signed files themselves remain valid. When the Java
runtime loads signed JAR files, it can validate the signatures and refuse to
load classes that do not match the signature. It can also support ’sealed’
packages, in which the Classloader will only permit Java classes to be loaded
into the same package if they are all signed by the same entities. This
prevents malicious code from being inserted into an existing
package, and so gaining access to package-scoped classes and data.Developers can obfuscate JAR files so that a user of the JAR file doesn’t get
much information regarding the code it contains, or to reduce its size, which
is useful in mobile phone applications.Microsoft Windows users who prefer having Windows EXE files can use tools
such as JSmooth, Launch4J, WinRun4J or NSIS – Java Launcher with
automatic JRE installation to wrap JAR files into executables. Eclipse uses a
small EXE launcher (eclipse.exe) to display the splash screen on startup and
launch the application from the main JAR
(startup.jar).
Apache Ant Zip/JAR support
The Apache Ant build tool has its own package to read and write Zip and JAR
archives, including support for the Unix filesystem extensions. The
org.apache.tools.zip packageis released under the Apache Software
Foundation license and is designed to be usable outside Ant. This code is fast,
widely used, and creates most JAR files that are not created with Sun’s utility.
[citation needed] Problems with the JAR format
The Ant team found that most of their support calls related to JAR file
creation have two underlying causes.[citation needed]The first relates to manifest creation, specifically how long lines in the
manifest are wrapped. This is a complex and somewhat ambiguous part of the
specification.
Ant wraps long lines at 68 characters and continues on the following line with
a space at the front to indicate a continuation. This is viewed as erroneous by
people who have not read the specification in detail and believe that the
Classpath should be split at a file boundary, instead of partly across a file
name. Unfortunately, if that is done, the Java runtime does not detect a split
line as the first line ends before the 68 character boundary.
The second is WinZip converting how file and directory names are viewed so
that all uppercase names do not appear as such. When set with the default
configuration older versions of WinZip (11.1 and earlier) will display all
upper case names with only the first letter being uppercase (i.e.
Manifest/Manifest.mf). The configuration option “Allow all uppercase
filenames” can be checked in the View tab of the Configuration dialog in these
versions to remedy the situation. WinZip versions later than 11.1 have this
option checked by default.
Some mobile phone Java runtimes appear to parse the manifest in ways that
are,incompatible with the specification, and require a strict ordering of
entries in the manifest. They also do not implement the line wrapping
algorithm correctly.
This may imply a problem in the test-suite for the Java ME mobile Java
runtime.Related formats
Several related file formats build on the JAR format:
WAR (Web Application aRchive) files, also Java archives, store XML files,
Java classes, JavaServer Pages and other objects for Web Applications.
RAR (Resource Adapter aRchive) files (not to be confused with the RAR file
format), also Java archives, store XML files, Java classes and other objects
for J2EE Connector Architecture (JCA) applications.
EAR (Enterprise ARchive) files provide composite Java archives which
combine XML files, Java classes and other objects including JAR, WAR and
RAR Java archive files for Enterprise Applications.
See also
WAR (file format)
EAR (file format)
Classpath
JAR hell
Open Packaging Convention References
External links
JAR File Specification
Using JAR files: The Basics (from Sun)
Lesson: Packaging Programs in JAR Files (from Sun)
Jar File Overview (from Sun)
Jar Class Loader (dynamically loading classes directly from Jar files)
fastjar – alternative .jar creation program written in C
v • d • eArchive formats (comparison by type) Archiving only ar · cpio · shar · tar · LBR Compression only bzip2 · gzip · LZMA · SQ · compress Archiving and compression 7z · ACE · ARC · Cabinet · cpt · DGCA · .dmg · GCA
· kgb · LHA · LZX · RAR · qda · sit · SQX · zoo · ZIP Software packaging and distribution deb · pkg · RPM · RUNZ · MSI · JAR
(WAR · RAR
(Java) · EAR) Document packaging and distribution OEB Package Format · OEBPS
Container Format ·
Open Packaging Conventions
v • d • eData compression software implementations Video compression
(Comparison) MPEG-4 ASP 3ivx · DivX · Nero Digital · FFmpeg MPEG-4 ·
HDX4 · Xvid H.264/MPEG-4 AVC CoreAVC · Blu-code · DivX H.264 · Nero Digital AVC ·
QuickTime
H.264 · x264 Lossless CorePNG · FFV1 · Huffyuv · Lagarith · MSU Lossless · SheerVideo Others CineForm · DNxHD · Helix DNA Producer · Indeo · libavcodec ·
Schrödinger
(Dirac) · SBC · Sorenson · VP7 · libtheora · Windows Media Encoder Audio compression
(Comparison) Lossy Freeware Advanced Audio Coding (FAAC) · Helix DNA
Producer ·
l3enc · LAME · TooLAME · libavcodec · Musepack · libvorbis · Windows
Media Encoder Lossless FLAC · ALAC · Monkey’s Audio · OptimFROG · TTA · WavPack Archivers
(Comparison) Free software 7-Zip · Ark · bzip2 · compress · File Roller · gzip ·
Info-ZIP · KGB Archiver · lzop · PAQ · PeaZip · The Unarchiver · tar ·
Xarchiver Freeware 7zX · DGCA · Filzip · IZArc · LHA · StuffIt Expander · TUGZip ·
UHarc/WinUHA
· Zipeg · ZipGenius Proprietary ARC · ALZip · Archive Utility · ARJ · JAR · MacBinary ·
PKZIP/SecureZIP
· PowerArchiver · Squeez · StuffIt · WinAce · WinRAR · WinZip Command line ARC · ARJ · JAR · Info-ZIP · LHA · lzop · PAQ · PKZIP · RAR ·
UPX
· UHarc · tar See Compression Methods for methods and Compression Formats and
Standards for formats
Retrieved from “http://en.wikipedia.org/wiki/JAR_(file_format)”
Categories: Archive formats Java platform
Hidden categories: Cleanup from May 2009 All pages needing cleanup
Articles lacking
sources from June 2008 All articles lacking sources All articles with
unsourced
statements Articles with unsourced statements from March 2008 Articles
with unsourced statements from June 2008
External Links:
JAR File Specification
Using JAR files: The Basics (from Sun)
Lesson: Packaging Programs in JAR Files (from Sun)
Jar File Overview (from Sun)
Jar Class Loader (dynamically loading classes directly from Jar files)
fastjar – alternative .jar creation program written in C
[hide]
vde
Archive formats (comparison by type)

Archiving only
ar · cpio · shar · tar · LBR

Compression only
bzip2 · gzip · LZMA · SQ · compress

Archiving and compression
7z · ACE · ARC · Cabinet · cpt · DGCA · .dmg · GCA · kgb · LHA · LZX · RAR · qda · sit · SQX · zoo · ZIP

Software packaging and distribution
deb · pkg · RPM · RUNZ · MSI · JAR (WAR · RAR (Java) · EAR)

Document packaging and distribution
OEB Package Format · OEBPS Container Format · Open Packaging Conventions
[hide]
vde
Data compression software implementations

Video compression(Comparison)
MPEG-4 ASP
3ivx · DivX · Nero Digital · FFmpeg MPEG-4 · HDX4 · Xvid

H.264/MPEG-4 AVC
CoreAVC · Blu-code · DivX H.264 · Nero Digital AVC · QuickTime H.264 · x264

Lossless
CorePNG · FFV1 · Huffyuv · Lagarith · MSU Lossless · SheerVideo

Others
CineForm · DNxHD · Helix DNA Producer · Indeo · libavcodec · Schrödinger (Dirac) · SBC · Sorenson · VP7 · libtheora · Windows Media Encoder

Audio compression(Comparison)
Lossy
Freeware Advanced Audio Coding (FAAC) · Helix DNA Producer · l3enc · LAME · TooLAME · libavcodec · Musepack · libvorbis · Windows Media Encoder

Lossless
FLAC · ALAC · Monkey’s Audio · OptimFROG · TTA · WavPack

Archivers(Comparison)
Free software
7-Zip · Ark · bzip2 · compress · File Roller · gzip · Info-ZIP · KGB Archiver · lzop · PAQ · PeaZip · The Unarchiver · tar · Xarchiver

Freeware
7zX · DGCA · Filzip · IZArc · LHA · StuffIt Expander · TUGZip · UHarc/WinUHA · Zipeg · ZipGenius

Proprietary
ARC · ALZip · Archive Utility · ARJ · JAR · MacBinary · PKZIP/SecureZIP · PowerArchiver · Squeez · StuffIt · WinAce · WinRAR · WinZip

Command line
ARC · ARJ · JAR · Info-ZIP · LHA · lzop · PAQ · PKZIP · RAR · UPX · UHarc · tar

Images for Flash lite