IData fileName=IDataFactory.create(); IData body=IDataFactory.create(); IData string=IDataFactory.create(); IDataCursor fileNameCursor=null; IDataCursor pipeLineCursor=pipeline.getCursor(); IDataCursor bodyCursor=null; IDataCursor stringCursor=null; Object keyObject=null; Context context=null; String server="some value"; String username="some value"; String password="some value"; String keyToCache=null; String dataToCache=null; String xmlFileData=null; String xmlFileName=null; CacheManager cacheManager=null; CacheConfiguration cacheConfig=null; Ehcache cacheObject=null; Element element=null; Searchable searchable=new Searchable(); SearchAttribute sa=null; File file=new File("ehcache.xml"); Map mapObject=null; try { try { context=new Context(); context.connect(server,username,password); } catch(Exception e) { e.printStackTrace(); throw new ServiceException("\n"+"Could not connect to the Server"); } try { keyToCache=IDataUtil.getString(pipeLineCursor,"KeyToCache"); dataToCache=IDataUtil.getString(pipeLineCursor,"DataToCache"); } catch(Exception e) { e.printStackTrace(); throw new ServiceException("\n"+"Could not retrieve data from pipeline"); } element=new Element(keyToCache,dataToCache); mapObject=new HashMap(); xmlFileName=file.getAbsolutePath(); cacheManager=new CacheManager(xmlFileName); cacheConfig=new CacheConfiguration("cache",300).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU) .overflowToDisk(false).eternal(false).timeToLiveSeconds(60).timeToIdleSeconds(30) .diskPersistent(false).diskExpiryThreadIntervalSeconds(0); cacheObject=new Cache(cacheConfig); cacheManager.addCache(cacheObject); cacheObject=cacheManager.getEhcache("cache"); cacheObject.put(element); for(Object key:cacheObject.getKeys()) { mapObject.put((String) key, cacheObject.get(key).getObjectValue()); keyObject=key; sa=new SearchAttribute(); sa.setName((String) keyObject); sa.setExpression((String) cacheObject.get(keyObject).getObjectValue()); cacheConfig.addSearchable(searchable); searchable.addSearchAttribute(sa); } fileNameCursor=fileName.getCursor(); bodyCursor=body.getCursor(); stringCursor=string.getCursor(); fileNameCursor.insertAfter("fileName",xmlFileName); try { string=context.invoke("pub.file","getFile",fileName); } catch(Exception e) { e.printStackTrace(); throw new ServiceException("\n"+"Could not invoke the file"); } try { if(pipeLineCursor.first("body")) { body=IDataUtil.getIData(pipeLineCursor,"body"); bodyCursor=body.getCursor(); if(bodyCursor.first("string")) { string=IDataUtil.getIData(bodyCursor,"string"); stringCursor=string.getCursor(); xmlFileData=(String) stringCursor.getValue(); } } /*if(pipeLineCursor.first("body") && bodyCursor.first("string")) { xmlFileData=(String) stringCursor.getValue(); }*/ } catch(Exception e) { e.printStackTrace(); throw new ServiceException("\n"+"Could not retrieve data from the file"); } } catch(Exception e) { e.printStackTrace(); } finally { IData key=null; IData value=null; IDataCursor keyCursor=null; IDataCursor valueCursor=null; try { IDataUtil.put(pipeLineCursor, "XMLData", (Object) xmlFileData); key=IDataFactory.create(); value=IDataFactory.create(); keyCursor=key.getCursor(); valueCursor=value.getCursor(); for(int i=0;i