Skip to content

Instantly share code, notes, and snippets.

View danbev's full-sized avatar
🖥️
Studying AI

Daniel Bevenius danbev

🖥️
Studying AI
View GitHub Profile
@danbev
danbev / gist:1097034
Created July 21, 2011 11:50
CamelTestSupport example
public class SwitchyardComponentTest extends CamelTestSupport {
private String _serviceName = "testServiceName";
@Before
public void setup() throws Exception {
ServiceReferences.clear();
}
@Test
public void sendToSwitchyardInOut() throws Exception {
@danbev
danbev / CamelJMSBindingTest
Created July 13, 2012 06:42
SwitchYard Completion Event Notifier
@SwitchYardTestCaseConfig(
config = SwitchYardTestCaseConfig.SWITCHYARD_XML,
mixins = {CDIMixIn.class, HornetQMixIn.class},
scanners = BeanSwitchYardScanner.class)
@RunWith(SwitchYardRunner.class)
public class CamelJMSBindingTest {
private static final String QUEUE_NAME = "GreetingServiceQueue";
private SwitchYardTestKit _testKit;
@danbev
danbev / gist:3128042
Created July 17, 2012 08:31
SwitchYardTestKit enhancements
/**
* Waits for an Exchange to complete and returns the content of the message that
* was recieved.
*
* @param type The type of the contents of the Message
* @return T an instance of type that is contents of the message.
*/
public <T> T waitForCompletion(Class<T> type) {
final CompletionNotifier<T> notifier = new CompletionNotifier<T>(type);
getServiceDomain().addEventObserver(notifier, ExchangeCompletionEvent.class);
@danbev
danbev / gist:3170072
Created July 24, 2012 14:05
Netty 4 WebSocket suggestion

Suggestion for Netty 4 WebSockets

This document is intended to explain a suggestion for an enhancement of the WebSocket support in Netty 4 and was only created to get feedback from the Netty team to see if this is a valid suggestion before putting any time and effort into it.

Netty has a very nice support for WebSockets and the examples provided work like a charm. This is one of the examples that come with Netty WebSocketServerHandler.java. In this example the WebSocketServerHandler takes care of everything in regard to the WebSocket request, and also acts as a simple web server to produce the html page used for running the example using a web browser.

The reason for this suggestion is that I wanted to implement a simple handler that receives a TextWebSocketFrame and not have to deal with other things like the Http Handshake.So I've created the following [branch](https

@danbev
danbev / gist:3305522
Created August 9, 2012 16:09
Route definitions explained

Below is how routes are defined in aerogear-controller:

Routes routes = new AbstractRoutingModule() {
    @Override
    public void configuration() {
        route()
                .from("/home")
                .on(GET)
                .to(SampleController.class).index();
 }
@danbev
danbev / xcodebuild.md
Created August 26, 2012 13:44
Building aerogear-ios with xcodebuild

Using xcodebuild to build AeroGear-iOS

The goal of this gist is to document the steps to build AeroGear-iOS using the command line tool xcodebuild. The reason for this could be that an CI server would require these steps, but it might also be handy for developers to be able to trigger a full build and run tests from the command line without having to start XCode.

Start with a newly cloned aerogear-ios, and change into the aerogear-ios directory (or what if you specified a different name when cloning use that name)

Some of the information in this gist was taken from different resources and this blog was a great help.

List the schemes in the workspace

When trying to list the schemes from the aerogear-ios from the command line I get the following (this is using a newly cloned gitrepo):

@danbev
danbev / websocket-enhancement.md
Created September 2, 2012 12:30
Netty 4 WebSocket enhancement

Netty 4 WebSocket

Netty has had WebSocket support for quite a while now and it is easy to get up an running quickly with the existing examples. The example provided with Netty, consists of a handler which takes care of the HTTP Upgrade handshake, and also manages the WebSocket protocol. If you need to service http requests, for example serving static files, in addition to WebSocket calls then this approach works great.

But if all you want to do is create a custom application protocol on top of WebSocket and only service WebSocket requests, then the above solution is a fair amount of code that you'll have to maintain yourself. So, we set out to try to simplify this and this post describes what we came up with.

Below is an example of implementing a handler that will receive a [TextWebSocketFrame](https://github.com/netty/netty/blob/master/codec-http/src/main/java/io/nett

@danbev
danbev / gist:3706418
Created September 12, 2012 12:57
Multiple Routes in a single deployment

What happens if you declare multiple implementations of AbstractRoutingModule?

You get the following deployment error:

13:41:36,425 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."aerogear-controller-demo.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."aerogear-controller-demo.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [RoutingModule] with qualifiers [@Default] at injection point [[parameter 1] of [constructor] @Inject public org.jboss.aerogear.controller.router.DefaultRouter(RoutingModule, BeanManager, ViewResolver, ControllerFactory, SecurityProvider)]. Possible dependencies [[Managed Bean [class org.jboss.aerogear.controller.demo.Routes2] with qualifiers [@Any @Default], Managed Bean [class org.jboss.aerogear.controller.demo.Routes] with qualifiers [@Any @Default]]]
	at org.jboss.as.weld.services.WeldService.start(WeldServic
@danbev
danbev / gist:3706552
Created September 12, 2012 13:21
What is Iogi used for in AeroGear Controller?

Iogi is used to unmarshall the HTTP Request and create a instance of a class, and populate that instance using values from the request parameters.

For example, when using the aerogear-controller-demo and entering the color and model of the car, the following parameters will be passed in the HTTP POST as form data:

car.color:red
car.brand:BMW

AeroGear Controller knows the type of the parameter for the target method, which it has gathered from the route configuration. By utilizing Iogi, it is very easy to create an instance of Car and populate its members color and brand:

@danbev
danbev / gist:3737360
Created September 17, 2012 13:50
AeroGear-Controller: Exception Handling