private void readLayer()

in atomos/src/main/java/org/apache/felix/atomos/impl/base/AtomosStorage.java [139:215]


    private void readLayer(DataInputStream in) throws IOException
    {
        String name = in.readUTF();
        long id = in.readLong();
        LoaderType loaderType = LoaderType.valueOf(in.readUTF());
        atomos.debug("Loading layer %s %s %s", name, id, loaderType);

        int numPaths = in.readInt();
        Path[] paths = new Path[numPaths];
        for (int i = 0; i < numPaths; i++)
        {
            String sURI = in.readUTF();
            try
            {
                URI uri = new URI(sURI);
                // TODO on Java 11 should use Path.of()
                paths[i] = new File(uri).toPath();
            }
            catch (URISyntaxException e)
            {
                throw new IOException(e);
            }
        }
        int numParents = in.readInt();
        List<AtomosLayer> parents = new ArrayList<>();
        for (int i = 0; i < numParents; i++)
        {
            long parentId = in.readLong();
            AtomosLayerBase parent = atomos.getById(parentId);
            if (parent == null)
            {
                throw new IllegalArgumentException("Missing parent with id: " + parentId);
            }
            parents.add(parent);
        }
        if (atomos.getById(id) == null)
        {
            try
            {
                atomos.addLayer(parents, name, id, loaderType, paths);
            }
            catch (Exception e)
            {
                throw new IllegalArgumentException(
                    "Error adding persistent layer: " + e.getMessage());
            }
        }

        int numBundles = in.readInt();
        for (int i = 0; i < numBundles; i++)
        {
            String atomosLocation = in.readUTF();
            atomos.debug("Found Atomos location %s", atomosLocation);
            if (in.readBoolean())
            {
                String connectLocation = in.readUTF();
                atomos.debug("Found connected location %s", connectLocation);
                if (Constants.SYSTEM_BUNDLE_LOCATION.equals(connectLocation))
                {
                    // don't do anything for the system bundle, it is already connected
                    continue;
                }
                AtomosContentBase atomosContent = atomos.getByAtomosLocation(
                    atomosLocation);
                if (atomosContent != null)
                {
                    atomos.connectAtomosContent(connectLocation, atomosContent);
                }
                else
                {
                    atomos.debug("Unable to find atomos content for location %s",
                        atomosLocation);
                }
            }

        }
    }