public CamelContext getOrMakeContextByRid(String rid,Component component){ CamelContext context; Map<String,CamelContext> contextMap = Application.get().getMetaData(INTEGRATION_SESSIONS_KEY); if (contextMap.containsKey(rid)){ context = contextMap.get(rid); }else{ IOrientDbSettings dbSettings = OrientDbWebApplication.get().getOrientDbSettings(); OrientDbWebSession session = OrientDbWebSession.get(); if (session.getUsername()==null){ throw new UnauthorizedActionException(component, Component.RENDER); } context = new DefaultCamelContext(); Map<String, String> properties = context.getProperties(); properties.put(OrientDBComponent.DB_URL, dbSettings.getDBUrl()); properties.put(OrientDBComponent.DB_USERNAME, session.getUsername()); properties.put(OrientDBComponent.DB_PASSWORD, session.getPassword()); context.setProperties(properties); context.getManagementStrategy().addEventNotifier(new CamelEventHandler(new OCamelTaskSessionCallback(context),this,context)); contextMap.put(rid, context); } return context; }