Search in sources :

Example 1 with URL

use of org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL in project teiid by teiid.

the class TeiidAdd method deployResources.

private void deployResources(OperationContext context) throws OperationFailedException {
    if (requiresRuntime(context)) {
        try {
            Module module = Module.forClass(getClass());
            if (module == null) {
                // during testing
                return;
            }
            // $NON-NLS-1$
            URL deployments = module.getExportedResource("deployments.properties");
            if (deployments == null) {
                // no deployments
                return;
            }
            BufferedReader in = new BufferedReader(new InputStreamReader(deployments.openStream()));
            String deployment;
            while ((deployment = in.readLine()) != null) {
                PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, deployment));
                ModelNode op = new ModelNode();
                op.get(OP).set(ADD);
                op.get(OP_ADDR).set(deploymentAddress.toModelNode());
                op.get(ENABLED).set(true);
                // prevents writing this deployment out to standalone.xml
                op.get(PERSISTENT).set(false);
                URL url = module.getExportedResource(deployment);
                String urlString = url.toExternalForm();
                ModelNode contentItem = new ModelNode();
                contentItem.get(URL).set(urlString);
                op.get(CONTENT).add(contentItem);
                ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
                OperationStepHandler handler = rootResourceRegistration.getOperationHandler(deploymentAddress, ADD);
                context.addStep(op, handler, OperationContext.Stage.MODEL);
            }
            in.close();
        } catch (IOException e) {
            throw new OperationFailedException(e.getMessage(), e);
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) BufferedReader(java.io.BufferedReader) OperationFailedException(org.jboss.as.controller.OperationFailedException) ImmutableManagementResourceRegistration(org.jboss.as.controller.registry.ImmutableManagementResourceRegistration) TeiidConstants.asString(org.teiid.jboss.TeiidConstants.asString) IOException(java.io.IOException) Module(org.jboss.modules.Module) ModelNode(org.jboss.dmr.ModelNode) URL(org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL) URL(java.net.URL)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 PathAddress (org.jboss.as.controller.PathAddress)1 URL (org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL)1 ImmutableManagementResourceRegistration (org.jboss.as.controller.registry.ImmutableManagementResourceRegistration)1 ModelNode (org.jboss.dmr.ModelNode)1 Module (org.jboss.modules.Module)1 TeiidConstants.asString (org.teiid.jboss.TeiidConstants.asString)1