Extension Initializer and Finalizer in Java

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

Do you remember when we talked about what an Extension Initializer and Finalizer are and what happens if they don’t have unique names? We also saw what they look like in C. Today we are contrasting that with their Java versions.

Extension Initializer in Java – FREExtension : initialize()

Unlike its C counterpart, which asks of you you to implement a function for the extension initializer, the AIR Java API requires you to implement a class that represents your extension: FREExtension.

The Extension Initializer is a method of this class and is called initialize:

Extension Finalizer in Java – FREExtension : dispose()

Looking at the signature for the Initializer, can you guess what the Extension Finalizer looks like? Yep, it’s another method in your implementation of the FREExtension class. Now, can you guess what it’s called? I bet you didn’t expect that:

Yeah, I agree, the section title was a bit of a spoiler…

FREExtension implementation

So what do these look like in the actual class? Here is an example:

What’s next?

Next we will look at what’s an Extension Context and what’s an Extension Context Initializer and Finalizer.

Then we will see in what order all of these initializers and finalizers are called when your ANE is loaded and when it’s unloaded.

Also, have a look at the C versions of the Extension Initializer and Finalizer.

Over to you

Do you have a convention for naming your FREExtension implementation? What is it? Tell us in the comments below.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">