Note: These pages are being reviewed.
*.shadow files are mainly used in the system filesystem
for configuration data.
They are the functional equivalent of Unix symbolic links -
*.shadow file is a pointer to another file whose
behavior in every respect except its path and file name is the same as the original.
*.shadow files are commonly used where only a single instance of an object is needed,
but it must be registered in multiple folders.
For example, a general
Action is declared in the
Actions/ folder of the
But the action also needs to appear in menus and toolbars, possibly other places.
So, rather than create multiple instances of an action, one
is created in the module’s layer file, in the
*.shadow files are created in all of the other places the
*.instance file would be needed,
pointing to the original file.
Declaring a .shadow file in the system filesystem looks like this:
<folder name="A"> <file name="com-foo-mymodule-MyClass.instance"/> </folder> <folder name="B"> <file name="Shadow1.shadow"> <attr name="originalFile" stringvalue="A/com-foo-mymodule- MyClass.instance"/> </file> </folder> <folder name="C"> <file name="anotherShadow.shadow"> <attr name="originalFile" stringvalue="A/com-foo-mymodule-MyClass.instance"/> </file> </folder>
Shadow files can also point to real files on disk. For example, the Favorites tab in the NetBeans IDE uses shadow files to link to real directories on disk.
Creating Shadow Files Programmatically
If you need to create
.shadow files programmatically, use
DataShadow.create() — do not write `FileObject`s and try to set attributes on them. In an XML layer, a `DataShadow’s original file is pointed to by a file attribute. On disk, that is accomplished via the file’s content instead. To reliably create `DataShadow`s, let the infrastructure do it for you - do not make assumptions about how the original file is pointed to.