package org.torquebox.stomp.component;

import org.projectodd.stilts.stomp.StompException;
import org.projectodd.stilts.stomp.StompMessage;
import org.projectodd.stilts.stomplet.Stomplet;
import org.projectodd.stilts.stomplet.StompletConfig;
import org.projectodd.stilts.stomplet.Subscriber;

public class DirectStompletComponent implements Stomplet {

    public DirectStompletComponent(XAStompletComponent component) {
        this.component = component;
    }
    
    @Override
    public void initialize(StompletConfig config) throws StompException {
        this.component._callRubyMethod( "configure", config );
    }

    @Override
    public void destroy() throws StompException {
        this.component._callRubyMethod( "destroy" );
    }

    @Override
    public void onMessage(StompMessage message) throws StompException {
        this.component._callRubyMethod( "on_message", message );
    }

    @Override
    public void onSubscribe(Subscriber subscriber) throws StompException {
        this.component._callRubyMethod( "on_subscribe", subscriber );
    }

    @Override
    public void onUnsubscribe(Subscriber subscriber) throws StompException {
        this.component._callRubyMethod( "on_unsubscribe", subscriber );
    }
    
    private XAStompletComponent component;

}

@@ -587,16 +587,25 @@
 byMethod
+IfDefined
 ( %22confi
@@ -617,24 +617,24 @@
 , config );%0A
-
     %7D%0A%0A    @
@@ -730,16 +730,25 @@
 byMethod
+IfDefined
 ( %22destr
@@ -881,24 +881,33 @@
 llRubyMethod
+IfDefined
 ( %22on_messag
@@ -1051,24 +1051,33 @@
 llRubyMethod
+IfDefined
 ( %22on_subscr
@@ -1186,32 +1186,32 @@
 tompException %7B%0A
-
         this.com
@@ -1232,16 +1232,25 @@
 byMethod
+IfDefined
 ( %22on_un

Call the methods only if they exist.