It was totallly ridiculous how many of the deployers had been written
without the thought that the deployment might not be backed by a VFS file.
One of the aims of the new deployers is to provide a "programmatic"
api so you can deploy things without having a file system at all.
e.g. Create a datasource (psuedo code)
| Deployment deployment = ...;
| DataSourceMetaData ds = ...;
| deployment.addAttachment(ds);
| deploy(deployment);
|
This would break with the way those deployers were written, they were
doing things like:
| public void deploy(DeploymentUnit unit)
| {
| // Oops NPE because getRoot() returns null!
| URL url = unit.getRoot().getURL();
| }
|
Now there are seperate subclasses VFSDeployment and VFSDeploymentUnit
that include the VFS based api like getRoot().
There is not such api for the plain Deployments.
So if your deployer needs access to the VFS api then it should subclass
one of the VFS deployers that will automatically ignore deployments that
aren't backed by the VFS.
These will give you an api callback like:
| public void deploy(VFSDeploymentUnit unit)
| {
| // Your code here
| }
|
| The check for there being a VFS is already done for you!
| e.g. AbstractSimpleVFSRealDeployer
|
| |
| | @Override
| | public void deploy(DeploymentUnit unit, T deployment) throws
DeploymentException
| | {
| | if (unit instanceof VFSDeploymentUnit == false)
| | return;
| |
| | VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
| | deploy(vfsDeploymentUnit, deployment);
| | }
| | /**
| | * Deploy a deployment
| | *
| | * @param unit the unit
| | * @param deployment the attachment
| | * @throws DeploymentException for any error
| | */
| | public abstract void deploy(VFSDeploymentUnit unit, T deployment) throws
DeploymentException;
| |
|
| NOTE: All the parsing deployers (since they need the VFS to access xml files, etc.)
| have this pattern automatically as well.
|
| So now you no longer have to worry about the NPE described above. :-)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4058757#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...