/**
 * Copyright (C) 2014 Antonin Stefanutti (antonin.stefanutti@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.cdi;

import org.apache.camel.impl.DefaultCamelContext;

import javax.annotation.PostConstruct;
import javax.enterprise.inject.Vetoed;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;

@Vetoed
public class CdiCamelContext extends DefaultCamelContext {

    @Inject
    private BeanManager manager;

    @PostConstruct
    private void postConstruct() {
        setRegistry(new CdiBeanRegistry(manager));
        setInjector(new CdiInjector(getInjector(), manager));
        // Explicitly load the properties component as NPE can be thrown when the Camel context is interacted with but not started yet
        lookupPropertiesComponent();
    }
}

@@ -715,16 +715,59 @@
 Context;
+%0Aimport org.apache.camel.util.ObjectHelper;
 %0A%0Aimport
@@ -799,16 +799,52 @@
 struct;%0A
+import javax.annotation.PreDestroy;%0A
 import j
@@ -1092,39 +1092,111 @@
     
-private void postConstruct() %7B%0A
+@Override%0A    public void start() %7B%0A        try %7B%0A            // Add BeanRegistry & Camel Injector%0A    
     
@@ -1234,32 +1234,36 @@
 stry(manager));%0A
+    
         setInjec
@@ -1316,16 +1316,20 @@
         
+   
+ 
 // Expli
@@ -1455,16 +1455,20 @@
         
+    
 lookupPr
@@ -1487,16 +1487,386 @@
 onent();
+%0A%0A            // Start CamelContext%0A            super.start();%0A        %7D catch (Exception e) %7B%0A            throw ObjectHelper.wrapRuntimeCamelException(e);%0A        %7D%0A    %7D%0A%0A    @PreDestroy%0A    @Override%0A    public void stop() %7B%0A        try %7B%0A            super.stop();%0A        %7D catch (Exception e) %7B%0A            throw ObjectHelper.wrapRuntimeCamelException(e);%0A        %7D
 %0A    %7D%0A%7D

Add method to start/stop CamelContext