Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
JOnAS: Java(TM) Open Application Server Copyright (C) 2008 Bull S.A.S. Contact: jonas-team@ow2.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------- $Id: CamelContextServiceFactory.java 20667 2011-01-03 17:07:21Z alitokmen $ --------------------------------------------------------------------------
 
 package org.ow2.jonas.camel.service.impl;
 
 import java.util.Map;
 
CamelContext service factory.

Author(s):
Guillaume Porcher
 
 public class CamelContextServiceFactory implements ServiceFactory {

    
Logger.
 
     private final Log logger = LogFactory.getLog(CamelContextServiceFactory.class);

    
Camel context service.
 
     private ICamelService camelService = null;

    
Map of all the contexts created by the org.osgi.framework.ServiceFactory.
 
     private Map<BundleStringcamelBundleContexts = new HashMap<BundleString>();

    
Get a CamelContext. A new camel context is created for each requiring bundle.

Parameters:
bundle The bundle using the service.
registration The ServiceRegistration object for the service.
Returns:
the camel context created for the bundle
See also:
org.osgi.framework.ServiceFactory.getService(org.osgi.framework.Bundle,org.osgi.framework.ServiceRegistration)
 
     public synchronized Object getService(final Bundle bundlefinal ServiceRegistration registration) {
         if (!this..containsKey(bundle)) {
             try {
                 this..put(bundlethis..startNewContext(bundle.getBundleContext()));
             } catch (Exception e) {
                 this..error("Camel context creation failed for bundle {0}."bundle);
             }
         }
         String contextName = this..get(bundle);
         return this..getCamelContext(contextName);
     }

    
Stop the camel context for the bundle.

Parameters:
bundle The bundle releasing the service.
registration The ServiceRegistration object for the service.
camelContext The CamelContext returned by a previous call to getService(org.osgi.framework.Bundle,org.osgi.framework.ServiceRegistration) .
See also:
org.osgi.framework.ServiceFactory.ungetService(org.osgi.framework.Bundle,org.osgi.framework.ServiceRegistration,java.lang.Object)
 
     public void ungetService(final Bundle bundlefinal ServiceRegistration registrationfinal Object camelContext) {
         String contextName = this..get(bundle);
         try {
             this..stop(contextName);
             this..debug("The camel context {0} has been stopped."contextName);
         } catch (Exception e) {
             this..warn("Cannot stop the camel context {0}."contextNamee);
         }
        this..remove(bundle);
    }

    

Parameters:
camelService the camelService to set
    public void setCamelService(final ICamelService camelService) {
        this. = camelService;
    }
New to GrepCode? Check out our FAQ X