Package org.wso2.carbon.throttle

Examples of org.wso2.carbon.throttle.ThrottleComponentException


    }

    public byte[] getProcessImage(String processId) {

        QName qName = decode(processId);
        SVGInterface svg = createSVG(qName);
        return svg.toPNGBytes();
    }
View Full Code Here


    private SVGInterface createSVG(QName qName) {

        // generate new
        InputStream in = getBpelDescriptor(qName);

        SVGInterface svg = null;

        try {
            svg = BPEL2SVGUtil.generate(in);

            if (svg == null)
View Full Code Here

   
    protected static SVGImpl generateSVGImpl(java.io.InputStream is) throws java.io.IOException {
      byte[] b=new byte[is.available()];
      is.read(b);
   
      BPELInterface bpel = new BPELImpl();
        OMElement bpelStr = bpel.load(new String(b));
       
        bpel.processBpelString(bpelStr);

        LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

   * @param transformer The optional image transformer
   * @throws java.io.IOException Failed to generate the representation
   */
    public static void generate(java.io.InputStream is, java.io.OutputStream os,
                SVGImageTransformer transformer) throws java.io.IOException {
        SVGImpl svg = generateSVGImpl(is);
       
        if (transformer == null) {
          String str=svg.getHeaders()+svg.generateSVGString();
          os.write(str.getBytes());
        } else {
          transformer.transform(svg, os);
        }
    }
View Full Code Here

        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

                registry.addAssociation(servicePath, getModuleResourcePath(module),
                        RegistryResources.Associations.ENGAGED_MODULES);
            }
        } catch (RegistryException e) {
            log.error("Error occured in engaging throttlin at registry", e);
            throw new ThrottleComponentException("errorEngagingModuleAtRegistry");
        }

        XmlPrimtiveAssertion assertion = this.getThrottlePolicy(axisService
                .getPolicySubject().getAttachedPolicyComponents());

        //build builtPolicy according to received parameters
        OMElement policyElement = this.buildPolicy(policy,
                assertion, ThrottleComponentConstants.SERVICE_LEVEL);
        Policy builtPolicy = PolicyEngine.getPolicy(policyElement);

        //if we didn't find an already existing builtPolicy, attach a new one
        Policy policyToPersist = builtPolicy;
        if (assertion == null) {
            axisService.getPolicySubject().attachPolicy(builtPolicy);
        } else {
            axisService.getPolicySubject().updatePolicy(policyToUpdate);
            policyToPersist = policyToUpdate;
        }

        //persist the throttle builtPolicy into registry
        try {
            Resource policyResource = registry.newResource();
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_TYPE,
                    "" + PolicyInclude.AXIS_SERVICE_POLICY);
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_UUID,
                    policyToPersist.getId());
            this.persistPoliciesToRegistry(policyToPersist, servicePath, servicePath, policyResource);
        } catch (Exception e) {
            log.error("Error occured while saving the builtPolicy in registry", e);
            throw new ThrottleComponentException("errorSavingPolicy");
        }

        //engage the module only if it is not already engaged
        axisService.engageModule(module);
    }
View Full Code Here

                globalResource.addProperty(GLOBALLY_ENGAGED_CUSTOM, Boolean.TRUE.toString());
                registry.put(globalPath, globalResource);
            }
        } catch (RegistryException e) {
            log.error("Error occured in globally engaging throttlin at registry", e);
            throw new ThrottleComponentException("errorEngagingModuleAtRegistry");
        }

        XmlPrimtiveAssertion assertion = this.getThrottlePolicy(module
                .getPolicySubject().getAttachedPolicyComponents());

        //build builtPolicy according to received parameters
        OMElement policyElement = this.buildPolicy(policy,
                assertion, ThrottleComponentConstants.GLOBAL_LEVEL);
        Policy builtPolicy = PolicyEngine.getPolicy(policyElement);

        //if we didn't find an already existing builtPolicy, attach a new one
        Policy policyToPersist = builtPolicy;
        if (assertion == null) {
            module.getPolicySubject().attachPolicy(builtPolicy);
        } else {
            module.getPolicySubject().updatePolicy(policyToUpdate);
            policyToPersist = policyToUpdate;
        }

        //persist the throttle builtPolicy into registry
        try {
            Resource policyResource = registry.newResource();
            policyResource.setProperty(RegistryResources.ModuleProperties.POLICY_TYPE,
                    "" + PolicyInclude.AXIS_MODULE_POLICY);
            policyResource.setProperty(RegistryResources.ModuleProperties.POLICY_UUID,
                    policyToPersist.getId());
            policyResource.setProperty(RegistryResources.ModuleProperties.VERSION,
                    module.getVersion().toString());
            this.persistPoliciesToRegistry(policyToPersist, resourcePath, null, policyResource);
        } catch (Exception e) {
            log.error("Error occured while saving the builtPolicy in registry", e);
            throw new ThrottleComponentException("errorSavingPolicy");
        }

        module.addParameter(new Parameter(GLOBALLY_ENGAGED_PARAM_NAME, Boolean.TRUE.toString()));

        //engage the module for every service which is not an admin service
        try {
            registry.beginTransaction();
            for (Iterator serviceIter = this.axisConfig.getServices().values().iterator();
                 serviceIter.hasNext();) {
                AxisService service = (AxisService) serviceIter.next();
                String adminParamValue =
                        (String) service.getParent().getParameterValue(ADMIN_SERICE_PARAM_NAME);

                //avoid admin services
                if (adminParamValue != null && adminParamValue.length() != 0 &&
                        Boolean.parseBoolean(adminParamValue.trim())) {
                    continue;
                }
                this.enableThrottling(service.getName(), policy);
            }
            registry.commitTransaction();
        } catch (Exception e) {
            log.error("Error occured in globally engaging throttlin at registry", e);
            try {
                registry.rollbackTransaction();
            } catch (RegistryException ex) {
                log.error("Unable to rollback transaction", ex);
            }
            throw new ThrottleComponentException("errorEngagingModuleAtRegistry");
        }
    }
View Full Code Here

        AxisOperation operation = axisService.getOperation(new QName(operationName));
        if (operation == null) {
            log.error("No operation found from the name " + operationName
                    + ", in service : " + serviceName);
            throw new ThrottleComponentException("noSuchOperation", new String[]{serviceName});
        }

        String servicePath = RegistryResources.SERVICE_GROUPS
                + axisService.getAxisServiceGroup().getServiceGroupName()
                + RegistryResources.SERVICES + serviceName;

        String operationPath = servicePath + RegistryResources.OPERATIONS
                + operationName;

        // engage at registry
        try {
            // Check if an association exist between servicePath and moduleResourcePath.
            Association[] associations = registry.getAssociations(operationPath,
                    RegistryResources.Associations.ENGAGED_MODULES);
            boolean associationExist = false;
            for (Association association : associations) {
                if (association.getDestinationPath().equals(getModuleResourcePath(module))) {
                    associationExist = true;
                    break;
                }
            }

            //if throttling is not found, add a new association
            if (!associationExist) {
                registry.addAssociation(operationPath, getModuleResourcePath(module),
                        RegistryResources.Associations.ENGAGED_MODULES);
            }
        } catch (RegistryException e) {
            log.error("Error occured in engaging throttling for operation : "
                    + operationName + " at registry", e);
            throw new ThrottleComponentException("errorEngagingModuleAtRegistry");
        }

        XmlPrimtiveAssertion assertion = this.getThrottlePolicy(operation
                .getPolicySubject().getAttachedPolicyComponents());

        //build builtPolicy according to received parameters
        OMElement policyElement = this.buildPolicy(policy,
                assertion, ThrottleComponentConstants.OPERATION_LEVEL);
        Policy builtPolicy = PolicyEngine.getPolicy(policyElement);

        //if we didn't find an already existing builtPolicy, attach a new one
        Policy policyToPersist = builtPolicy;
        if (assertion == null) {
            operation.getPolicySubject().attachPolicy(builtPolicy);
        } else {
            operation.getPolicySubject().updatePolicy(policyToUpdate);
            policyToPersist = policyToUpdate;
        }

        //persist the throttle builtPolicy into registry
        try {
            Resource policyResource = registry.newResource();
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_TYPE,
                    "" + PolicyInclude.AXIS_OPERATION_POLICY);
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_UUID,
                    policyToPersist.getId());
            this.persistPoliciesToRegistry(policyToPersist,
                    servicePath, operationPath, policyResource);
        } catch (Exception e) {
            log.error("Error occured while saving the builtPolicy in registry", e);
            throw new ThrottleComponentException("errorSavingPolicy");
        }

        //engage the module at operation
        operation.engageModule(module);
        return false;
View Full Code Here

            AxisOperation operation = axisService.getOperation(new QName(operationName));
            if (operation == null) {
                log.error("No operation found from the name " + operationName
                        + ", in service : " + serviceName);
                throw new ThrottleComponentException("noSuchOperation", new String[]{serviceName});
            }

            String operationPath = RegistryResources.SERVICE_GROUPS
                    + axisService.getAxisServiceGroup().getServiceGroupName()
                    + RegistryResources.SERVICES + serviceName + RegistryResources.OPERATIONS
                    + operationName;

            //disengage the throttling module
            try {
                // disengage at registry
                registry.removeAssociation(operationPath, getModuleResourcePath(module),
                        RegistryResources.Associations.ENGAGED_MODULES);

                // disengage at Axis
                operation.disengageModule(module);

            } catch (RegistryException e) {
                log.error("Error occured while removing assertion from registry", e);
                throw new ThrottleComponentException("errorDisablingAtRegistry");
            }

        } catch (AxisFault e) {
            log.error("Error occured while disengaging module from AxisService", e);
            throw new ThrottleComponentException("errorDisablingThrottling", e);
        }
        return false;
    }
View Full Code Here

                // disengage at Axis
                axisService.disengageModule(module);

            } catch (RegistryException e) {
                log.error("Error occured while removing assertion from registry", e);
                throw new ThrottleComponentException("errorDisablingAtRegistry");
            }

        } catch (AxisFault e) {
            log.error("Error occured while disengaging module from AxisService", e);
            throw new ThrottleComponentException("errorDisablingThrottling", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.throttle.ThrottleComponentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.