Freitag, 20. Januar 2012

Tomcat application at port 80

If you always wanted to slim down your JSP / Tomcat application path ...

Before:
http://yourdomain:8080/yourApplicationName/(index.jsp)

After:
http://yourdomain/(index.jsp)

1. get rid of yourApplicationName
in /yourTomcatPath/webapps/ there should be a ROOT folder next to yourApplicationName, just copy the content of yourApplicationName into ROOT, of course this only makes sense if you got only one application on your server

2. get rid of the port
install an apache as reverse proxy
# apt-get install apache2
# a2enmod proxy proxy_http
# nano /etc/apache2/sites-enabled/000-default

clear out everything and insert the following (in nano use Ctrl+k to delete single lines)

<Virtualhost *:80="">
        ServerAdmin webmaster@localhost

        ProxyRequests Off

        HostnameLookups Off
        UseCanonicalName On

        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http://127.0.0.1:8080/


        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "="" doc="" share="" usr="">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</Virtualhost>


after that restart your apache by
# /etc/init.d/apache2 restart
your tomcat defaults to start on port 8080, so your good to go.

Don't ask me for any modifications ... look here for further detail
http://www.apachetutor.org/admin/reverseproxies
http://www.linux-club.de/viewtopic.php?f=22&t=105707

Montag, 26. September 2011

Installing created air packages fails

In case anybody might come across this issue:

I use to have my workspace on a remote network folder and created the exported air package there (Flex 4.5, Air 2.6). When doubleclicking to install the air package when it is still located in the remote folder the installation will fail saying the package is corrupt or damaged.

unfortunately I only got the german error:
"Die Anwendung konnte nicht installiert werden, da die Installationsdatei beschädigt ist. Bitten Sie den Anwendungsautor um eine neue Installationsdatei."

solution:
copy the file to your desktop and you're good to go.

Dienstag, 15. Februar 2011

Resizing Dynamically Loaded swfs using swfloader (Flex 4)

I needed to update some code from



http://blogs.adobe.com/cantrell/archives/2010/03/extending_air_applications_with_plugins.html




      • BoxDivider
      • SomeSideBarContainer








// Main.as (skin = MainSkin.mxml)
// viewStack, navigatorContent and loader initialization
    viewStack.addEventListener(ResizeEvent.RESIZE,function (e:ResizeEvent):void {
  if(loader.content == null 
  || SystemManager(loader.content).application ==  null)
    return; 
     
  navigatorContent.width = e.target.width;
  navigatorContent.height = e.target.height;

  (SystemManager(loader.content).application as Application).contentGroup.width = navigatorContent.width;
  (SystemManager(loader.content).application as Application).contentGroup.height = navigatorContent.height;
});

navigatorContent.addElement(loader);

loader.percentWidth = 100;
loader.percentHeight = 100;
loader.load();

viewStack.addElement(navigatorContent);

The advantage of this variant is that there is no need for a custom function "updateDimensions" in the loaded plugin application as all spark Applications have a contentGroup that can be resized (which also resized my main application).

Disadvantage or the dirty thing here is that the stage size of the loaded plugin stays the same as the main application's, just the content is resized to the visible part.

Samstag, 10. Juli 2010

How to use Eclipse RCP with OSGi Declarative Services

As I had some problems to include a RCP gui into my project I'd like to share this information. From the examples in the following books I was able to get a really nice OSGi environment to run as well as a sample Eclipse plugin project with some RCP views. I was really impressed how OSGi allows you to get some real modularization into your code and therefore a, lets call it "beatiful" architecture of my whole diploma thesis. Of course there are disadvantages to everything but for my purpose it serves really well.

OSGi Equinox Addison Wesley
OSGi Service Platform
RCP mit Eclipse 3.3


After a while of hacking my way through tutorials and getting the backend of my application to run with plain Equinox, the command line did no longer give me satisfaction ... time for a GUI! In a certain rush of blasphemy I thought declaring some services and placing some ticks in the launch configuration would do the trick ... click debug as -> osgi framework  ... error ... OH Lord of the keyboard ... I thought that would be an appropriate way to customize to LogService implementation ... thine bundle was not able to come to life and see its first millisecond of the day ....


So here is what I did to get it running:

- The whole project is realized with Declarative Services ... I know that Activators and Dynamic Services have their advantages, but I prefer DS. That was a bit of a hurdle for RCP because all of the examples I found were using Activators.
- I prefer using Equinox as implementation. I played a little with Knopflerfish though and must say I liked the desktop and the information you can get out of it during runtime.
- My project is separated in several bundles, I will not cover the backend as it only provides some services that provide the data to display. As mentioned before this tutorial describes how to get from the standard example implementation (that you get from the "new PDE plugin project wizard") to a version using Declarative Services. I will only cover the configuration, the code is just a straighforward implementation of the interfaces and bind/unbind functions declared in the component descriptors. When replacing the
  Bundle Activator, I just add activate/deactivate to the class implementing the component and copy everything from the Activator into it. Content of start/stop goes to activate/deactivate, Application now extends AbstractUiPlugin as Activator did before, and the View stays with extending ViewPart.





Project Tree of Application Bundle:
- note the Activator is excluded from build path
- the application bundle does not contain any view relevant data than the configuration in the perspective




















Manifest of Application Bundle:
- note that the Bundle-Activator tag has been replaced by the Service-Component tag


Component Descriptor of Application Bundle:
- note the bundle declares to provide an IApplication interface









Plugin Descriptor of Application Bundle:
- note the extension point referencing our view


































Project Tree of View Bundle:
- ok, you got me, forgot to exclude the Activator here, but I assure it's not used ;)





















Manifest of View Bundle:
- same Activator replacement here

















Component Descriptor of View Bundle:
- the reference to IDeviceManagerService is where the bundle gets its data model from.
















Plugin Descriptor of View Bundle:
- here we make our bundle public so that the apps perspective can include/reference it





















Now that we have our bundles configured it goes to the run configuration of the framework ... i.e. in which order the bundles are started and which arguments the runtime is started with.

Run Configuration - Bundles:
- unfortunately its a little hard to decypher, but the following counts:
- the upper right block contains one bundle which contains the data model (start level 3)
- the majority of the other bundles are controllers accessing the data (start level 4)
- the two bundles we just configured are ui related and therefore started last (start level 6)
- start level 5 is used by an interop bundle, don't care about it
- this way all the dependencies amongst bundles can be successfully resolved
- ATTENTION: start level 7+ does not seem to be used by equinox, bundles configured with that level did not start during my tests even if set to do immediately start (by component descriptor)



















Run Configuration - Arguments:
- console : lets you type commands in the eclipse console while your app is running
- consoleLog : prints logService messages to console
-Declipse.product=com......Application.product : starts the Application bundle as Eclipse Application with branding (although I haven't seen the splash screen yet when primarily running "OSGi Framework - Run Configuration" instead of "Eclipse Application - Run Configuration")
-Dosgi.noShutdown=true : keeps framwork running after gui window has been closed





















Ok, we're ready give it a run ... klick "debug -> nameOfYourRunConfigAsInPreviousScreenshot"
- the console should print a couple of "bundle event - started" messages
- now type "services" -> Enter
- you should see something like the following and by now also a window containing your view
- the first part shows that the data interface is provided by a component and used by our view
- the second shows the IApplication interface successfully registered by our Appication
- so both bundles are running via Declarative Services and the view is shown and contains data (if you implemented some model provider)








I hope this was helpful to anybody.

Cheers,
Rob