Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antonioalegria/320673 to your computer and use it in GitHub Desktop.
Save antonioalegria/320673 to your computer and use it in GitHub Desktop.
module Pulso
module Esper
module View
class JRubyDispatcherViewFactory
def initialize
puts "Hello, World!"
end
end
class JRubyDispatcherView
def initialize
puts "Hello, World!"
end
end
end
end
end
package pt.ptp.pulso.esper.view;
import com.espertech.esper.client.EventType;
import com.espertech.esper.core.StatementContext;
import com.espertech.esper.epl.expression.ExprNode;
import com.espertech.esper.view.View;
import com.espertech.esper.view.ViewFactory;
import com.espertech.esper.view.ViewFactoryContext;
import com.espertech.esper.view.ViewFactorySupport;
import com.espertech.esper.view.ViewParameterException;
import java.util.List;
import org.jruby.embed.ScriptingContainer;
import org.jruby.embed.PathType;
public class JRubyDispatcherViewFactory extends ViewFactorySupport {
private final static String JRUBY_SCRIPT = "src/main/ruby/dispatcher_view.rb";
private ScriptingContainer jruby;
private EventType eventType;
public JRubyDispatcherViewFactory() {
super();
this.jruby = new ScriptingContainer();
Object jrubyDelegateFactoryClass = jruby.runScriptlet(PathType.CLASSPATH, JRUBY_SCRIPT);
Object jrubyDelegateFactory = jruby.callMethod(jrubyDelegateFactoryClass, "new", Object.class);
}
public void setViewParameters(ViewFactoryContext context,
List<ExprNode> expressionParams) throws ViewParameterException {
List<Object> viewParameters = ViewFactorySupport.validateAndEvaluate("'Custom Size' view",
context.getStatementContext(), expressionParams);
if (!viewParameters.isEmpty()) {
throw new ViewParameterException("'Custom Size' view does not take any parameters");
}
}
public void attach(EventType parentEvtType, StatementContext context,
ViewFactory viewFactory, List<ViewFactory> parentViewFactories) throws ViewParameterException {
this.eventType = JRubyDispatcherView.createEventType(context);
}
public View makeView(StatementContext context) {
return new JRubyDispatcherView(context);
}
public EventType getEventType() { return this.eventType; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment