private final DataFolder findServicesFolder() throws Exception { Method m = DataLoaderPool.class.getDeclaredMethod("getFolderLoader"); // NOI18N m.setAccessible(true); DataLoader dl = (DataLoader) m.invoke(null); FileObject services = FileUtil.getConfigFile("Services"); // NOI18N return (DataFolder)dl.findDataObject(services, new HashSet<FileObject>()); }
/** Lazy getter for system loaders. */ private static MultiFileLoader[] getSystemLoaders () { if (systemLoaders == null) { systemLoaders = new MultiFileLoader [] { (MultiFileLoader) DataLoader.getLoader(ShadowLoader.class), (MultiFileLoader) DataLoader.getLoader(InstanceLoaderSystem.class) }; } return systemLoaders; }
/** Get the current display name of this loader. * @return display name */ public final String getDisplayName () { String dn = (String) getProperty (PROP_DISPLAY_NAME); if (dn != null) { return dn; } else { dn = defaultDisplayName(); if (dn != null) { return dn; } else { return getRepresentationClassName(); } } }
/** Get actions. * These actions are used to compose * a popup menu for the data object. Also these actions should * be customizable by the user, so he can modify the popup menu on a * data object. * * @return array of system actions or <CODE>null</CODE> if this loader does not have any * actions */ public final SystemAction[] getActions () { SystemAction[] actions = (SystemAction[])getProperty (PROP_ACTIONS); if ( actions == null ) { actions = (SystemAction[])getProperty (PROP_DEF_ACTIONS); if ( actions == null ) { actions = defaultActions(); putProperty (PROP_DEF_ACTIONS, actions, false); } } return actions; }
List before = s.getInstallBefore() == null ? null : Arrays.asList(s.getInstallBefore()); List after = s.getInstallAfter() == null ? null : Arrays.asList(s.getInstallAfter()); err.fine("add: " + l + " repclass: " + l.getRepresentationClass().getName() + " before: " + before + " after: " + after); l.removePropertyChangeListener (pool); l.addPropertyChangeListener (pool); repNames2Loaders.put(l.getRepresentationClassName(), l); if (s != null) { String[] ib = s.getInstallBefore();
boolean isdefault = true; SystemAction[] defactions = getActions (); setActions ((SystemAction[])ll.toArray(new SystemAction[ll.size()])); if ( displayName.equals("") || ( version == 0 && displayName.equals(defaultDisplayName()))) // NOI18N displayName = null; setDisplayName( displayName ); String message = NbBundle.getMessage (DataLoader.class, "EXC_missing_actions_in_loader", getDisplayName ()); ErrorManager.getDefault ().annotate (se, message); throw se;
/** Removes the loader. It is only removed from the list but * if an DataObject instance created exists it will be still * valid. * <P> * So the only difference is that when a DataObject is searched * for a FileObject this loader will not be taken into account. * <P>The loader pool may be resorted. * @param dl data loader to remove * @return true if the loader was registered and false if not */ public static synchronized boolean remove (DataLoader dl, NbLoaderPool pool) { if (loaders.remove (dl)) { if (err.isLoggable(Level.FINE)) err.fine("remove: " + dl); String cname = dl.getClass().getName(); names2Loaders.remove(cname); repNames2Loaders.remove(dl.getRepresentationClassName()); installBefores.remove(cname); installAfters.remove(cname); dl.removePropertyChangeListener (pool); if (updatingBatch) { updatingBatchUsed = true; } else { resort (pool); } modifiedLoaders.remove(dl); return true; } return false; }
/** Finds the first producer of a representation class. * Scans through the list of all loaders and returns the first one * whose representation class is a superclass of <code>clazz</code>. * * @param clazz class to find producer for * @return data loader or <CODE>null</CODE> if there is no loader that * can produce the class */ public final DataLoader firstProducerOf (Class clazz) { Enumeration en = allLoaders (); while (en.hasMoreElements ()) { DataLoader dl = (DataLoader)en.nextElement (); if (dl.getRepresentationClass ().isAssignableFrom (clazz)) { // representation class is super class of clazz return dl; } } return null; }
/** Notification that the state of pool has changed */ private static synchronized void update (NbLoaderPool lp) {; if (err.isLoggable(Level.FINE)) err.fine("update"); // clear the cache of loaders loadersArray = null; if (lp != null && installationFinished) { lp.superFireChangeEvent(); } if (lp != null) { Enumeration e = lp.allLoaders(); while (e.hasMoreElements()) { DataLoader l = (DataLoader)e.nextElement(); // so the pool is there only once l.removePropertyChangeListener(lp); l.addPropertyChangeListener(lp); } } }
if (l2 != null) { warn(loaderClassName, repClassName, l2.getRepresentationClassName());
/** Get a registered loader from the pool. * @param loaderClass exact class of the loader (<em>not</em> its data object representation class) * @return the loader instance, or <code>null</code> if there is no such loader registered * @see DataLoaderPool#allLoaders */ public static DataLoader getLoader (Class loaderClass) { return (DataLoader)findObject (loaderClass, true); }
/** Get actions for this data object. * @see DataLoader#getActions * @return array of actions or <code>null</code> */ public SystemAction[] getActions () { if (systemActions == null) { systemActions = createActions (); } if (systemActions != null) { return systemActions; } return obj.getLoader ().getActions (); }
/** for sorting data objects by their classes */ private int compareClass (DataObject obj1, DataObject obj2) { Class c1 = obj1.getClass (); Class c2 = obj2.getClass (); if (c1 == c2) { return compareNames(obj1, obj2); } // sort by classes DataLoaderPool dlp = DataLoaderPool.getDefault(); final Enumeration loaders = dlp.allLoaders (); // PENDING, very very slow while (loaders.hasMoreElements ()) { Class clazz = ((DataLoader) (loaders.nextElement ())).getRepresentationClass (); // Sometimes people give generic DataObject as representation class. // It is not always avoidable: see e.g. org.netbeans.core.windows.layers.WSLoader. // In this case the overly flexible loader would "poison" sort-by-type, so we // make sure to ignore this. if (clazz == DataObject.class) continue; boolean r1 = clazz.isAssignableFrom (c1); boolean r2 = clazz.isAssignableFrom (c2); if (r1 && r2) return compareNames(obj1, obj2); if (r1) return -1; if (r2) return 1; } return compareNames(obj1, obj2); }
/** Lazy getter for default loaders. */ private static MultiFileLoader[] getDefaultLoaders () { if (defaultLoaders == null) { defaultLoaders = new MultiFileLoader [] { (MultiFileLoader) DataLoader.getLoader(FolderLoader.class), (MultiFileLoader) DataLoader.getLoader(XMLDataObject.Loader.class), (MultiFileLoader) DataLoader.getLoader(InstanceLoader.class), (MultiFileLoader) DataLoader.getLoader(DefaultLoader.class) }; } return defaultLoaders; }
DataObject obj = pref.findDataObject (fo, r); if (obj != null) { DataLoader l = (DataLoader)en.nextElement (); DataObject obj = l.findDataObject (fo, r); if (obj != null) { return obj;
load ); return DataLoader.getLoader(loaderClass); } catch (Exception ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
private final MultiDataObject createMultiObject(FileObject fo) throws DataObjectExistsException, IOException { MultiFileLoader loader = getMultiFileLoader (); MultiDataObject obj; if (loader != null) { obj = DataObjectPool.createMultiObject(loader, fo); } else { obj = (MultiDataObject)getLoader ().findDataObject (fo, RECOGNIZER); } return obj; }
DataLoaderPool.setPreferredLoader(servletFileObject, DataLoader.getLoader(JspServletDataLoader.class));