Deploying content installed after server start
brian.stansberry Jun 25, 2008 1:57 PMBeen digging into why my old VFSDeploymentScanner-based approach to deploying deploy-hasingleton content doesn't work to see if a temporary workaround was feasible for CR1 (tnot feasible and too late anyway, but that's not the point of this post). The problem I'm seeing looks like it would be a general one for any addition to a profile that's made after ProfileServiceBootstrap.start() executes.
Basic issue is the VFSDeploymentScanner-based approach responds to becoming the singleton master by scanning deploy-hasingleton and invoking Profile.addDeployment(VFSDeployment, DeploymentPhase) for each item found. That works fine.
What breaks is the profile impl ends up storing the deployment in a Map<String,VFSDeployment>. The deployment then gets added to the runtime by an HDScanner, which looks for modified deployments. The relevant bit can be boiled down to this pseudo-code:
Iterator<VFSDeployment> iter = apps.iterator(); while( iter.hasNext() ) { VFSDeployment ctx = iter.next(); VirtualFile root = ctx.getRoot(); if ( root.hasBeenModified() ) // PROBLEM!!! { ... add to a list of things to deploy } } // Assume applicationDir points to deploy-hasingleton VirtualFile deployDir = VFS.getRoot(applicationDir.toURI()); List<VirtualFile> children = deployDir.getChildren(); for(VirtualFile vf : children) { String key = vf.toURI().toString(); if( applicationCtxs.containsKey(key) == false ) // PROBLEM!!! { ... add to a list of things to deploy } }
Problem is the 2 areas commented "PROBLEM!!!". In the first one, the newly added deployment doesn't get included in the modification list because the VirtualFile hasn't been modified. In the second case the newly added deployment doesn't get included in the modification list because the call to Profile.addDeployment() resulted in it getting added to the applicationCtxs map.
So, the new content doesn't ever get deployed. I would expect that with any code that calls Profile.addDeployment(), the result would be the same -- the new deployment doesn't get installed into the runtime.
For sure I see this with the basic ProfileService impl. Looking at the code I expect the same behavior with the repository-based impl, although I haven't confirmed that yet.
I'll look around some more; also see if there are unit tests that cover this.