1 10 package org.mmbase.module.builders; 11 12 import org.mmbase.module.core.*; 13 import org.mmbase.bridge.*; 14 import org.mmbase.util.*; 15 import org.mmbase.util.logging.*; 16 17 25 public class Resources extends Attachments { 26 private static final Logger log = Logging.getLoggerInstance(Resources.class); 27 28 32 public boolean init() { 33 boolean res = super.init(); 34 if (res) { 35 ThreadPools.jobsExecutor.execute(new Runnable () { 36 public void run() { 37 Cloud cloud = null; 38 while (cloud == null) { 39 try { 40 cloud = ContextProvider.getDefaultCloudContext().getCloud("mmbase", "class", null); 41 } catch (Throwable t) { 42 log.info(t.getMessage()); 43 } 44 if (cloud == null) { 45 try { 46 log.info("No cloud found, waiting for 5 seconds"); 47 Thread.sleep(5000); 48 } catch (InterruptedException ie) { 49 return; 50 } 51 } 52 } 53 ResourceLoader.setResourceBuilder(cloud.getNodeManager(Resources.this.getTableName())); 54 } 55 }); 56 } 57 return res; 58 59 } 60 61 65 public Object getValue(MMObjectNode node, String field) { 66 if (field.equals(ResourceLoader.FILENAME_FIELD)) { 67 String s = node.getStringValue(ResourceLoader.RESOURCENAME_FIELD); 68 int i = s.lastIndexOf("/"); 69 if (i > 0) { 70 return s.substring(i + 1); 71 } else { 72 return s; 73 } 74 } else { 75 return super.getValue(node, field); 76 } 77 } 78 79 } 80 | Popular Tags |