Package org.nuxeo.runtime.model.impl
Class ComponentPersistence
- java.lang.Object
-
- org.nuxeo.runtime.model.impl.ComponentPersistence
-
public class ComponentPersistence extends Object
Manage persistent components. Persistent components are located in ${nxserver_data_dir}/components directory, and can be dynamically removed or registered. After framework startup (after the application was completely started) the persistent components are deployed. The layout of the components directory is the following:components/ component1.xml component2.xml ... bundle_symbolicName1/ component1.xml component2.xml ... bundle_symbolicName1/ ... ...If components are put directly under the root then they will be deployed in the runtime bundle context. If they are put in a directory having as name the symbolicName of a bundle in the system, then the component will be deployed in that bundle context.Any files not ending with .xml are ignored. Any directory that doesn't match a bundle symbolic name will be ignored too.
Dynamic components must use the following name convention: (it is not mandatory but it is recommended)
- Components deployed in root directory must use as name the file name without the .xml extension.
- Components deployed in a bundle directory must use the relative file path without the .xml extensions.
components/mycomp1.xmlandcomponents/mybundle/mycomp2.xmlthe name formycomp1must be:comp1and formycomp2must bemybundle/mycomp2This service is working only with
OSGiRuntimeService- Author:
- Bogdan Stefanescu
-
-
Field Summary
Fields Modifier and Type Field Description protected ReadWriteLockfileLockprotected Set<RegistrationInfo>persistedComponentsprotected Filerootprotected OSGiRuntimeServiceruntimeprotected RuntimeContextsysrc
-
Constructor Summary
Constructors Constructor Description ComponentPersistence(OSGiRuntimeService runtime)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateComponent(byte[] bytes)voidcreateComponent(byte[] bytes, boolean isPersistent)protected voiddeploy(RuntimeContext rc, File file)RuntimeContextgetContext(String symbolicName)FilegetRoot()voidloadPersistedComponent(File file)voidloadPersistedComponents()voidloadPersistedComponents(RuntimeContext rc, File root)DocumentloadXml(File file)static DocumentloadXml(InputStream in)booleanremoveComponent(String compName)protected byte[]safeReadFile(File file)protected voidsafeWriteFile(byte[] bytes, File file)
-
-
-
Field Detail
-
root
protected final File root
-
sysrc
protected final RuntimeContext sysrc
-
runtime
protected final OSGiRuntimeService runtime
-
fileLock
protected final ReadWriteLock fileLock
-
persistedComponents
protected final Set<RegistrationInfo> persistedComponents
-
-
Constructor Detail
-
ComponentPersistence
public ComponentPersistence(OSGiRuntimeService runtime)
-
-
Method Detail
-
getRoot
public File getRoot()
-
getContext
public final RuntimeContext getContext(String symbolicName)
-
deploy
protected void deploy(RuntimeContext rc, File file) throws IOException
- Throws:
IOException
-
loadPersistedComponents
public void loadPersistedComponents() throws IOException- Throws:
IOException
-
loadPersistedComponents
public void loadPersistedComponents(RuntimeContext rc, File root) throws IOException
- Throws:
IOException
-
loadPersistedComponent
public void loadPersistedComponent(File file) throws IOException
- Throws:
IOException
-
loadXml
public Document loadXml(File file) throws IOException
- Throws:
IOException
-
loadXml
public static Document loadXml(InputStream in)
-
createComponent
public void createComponent(byte[] bytes) throws IOException- Throws:
IOException
-
createComponent
public void createComponent(byte[] bytes, boolean isPersistent) throws IOException- Throws:
IOException
-
removeComponent
public boolean removeComponent(String compName) throws IOException
- Throws:
IOException
-
safeWriteFile
protected void safeWriteFile(byte[] bytes, File file) throws IOException- Throws:
IOException
-
safeReadFile
protected byte[] safeReadFile(File file) throws IOException
- Throws:
IOException
-
-