Package org.apache.axis2.description

Examples of org.apache.axis2.description.PolicySubject


                               Throttle defaultThrottle) throws AxisFault {
        String currentServiceName;
        if (axisDescription instanceof AxisService) {
            Throttle throttle = null;
            AxisService currentService = ((AxisService) axisDescription);
            PolicySubject policySubject = currentService.getPolicySubject();
            if (policySubject != null) {
                try {
                    List policies = new ArrayList(policySubject.getAttachedPolicyComponents());
                    Policy currentPolicy = PolicyUtil.getMergedPolicy(policies, currentService);
                    if (currentPolicy != null) {
                        throttle = ThrottleFactory.createServiceThrottle(currentPolicy);
                        if(throttle == null) {
                            //this is for the scenario when throttle policy is empty rather than
                            // null (eg: removing the throttle policy via policy editor)
                            throttle = defaultThrottle;
                        }
                        //todo - done by isuru, recheck
                    } else {
                        AxisConfiguration axisConfig = configctx.getAxisConfiguration();
                        AxisModule throttleModule = axisConfig.getModule(
                                ThrottleConstants.THROTTLE_MODULE_NAME);
                        policySubject = throttleModule.getPolicySubject();
                        if (policySubject != null) {
                            currentPolicy = ThrottleEnguageUtils.getThrottlePolicy(
                                    policySubject.getAttachedPolicyComponents());
                            if (currentPolicy != null) {
                                throttle = ThrottleFactory.createModuleThrottle(currentPolicy);
                            }
                        }
                        //todo - done by isuru
                    }
                } catch (ThrottleException e) {

                    log.error("Error was occurred when engaging throttle module for" +
                              " the service :" +
                              currentService.getName() + e.getMessage());
                    log.info("Throttling will occur using default module policy");
                    throttle = defaultThrottle;
                }
                if (throttle != null) {
                    Map throttles =
                            (Map) configctx.getPropertyNonReplicable(
                                    ThrottleConstants.THROTTLES_MAP);
                    if (throttles == null) {
                        throttles = new HashMap();
                        configctx.setNonReplicableProperty(
                                ThrottleConstants.THROTTLES_MAP, throttles);
                    }
                    String serviceName = currentService.getName();
                    throttle.setId(serviceName);
                    throttles.put(serviceName, throttle);
                    ConcurrentAccessController cac = throttle.getConcurrentAccessController();
                    if (cac != null) {
                        String cacKey = ThrottleConstants.THROTTLE_PROPERTY_PREFIX
                                        + serviceName + ThrottleConstants.CAC_SUFFIX;
                        configctx.setProperty(cacKey, cac);
                    }
                }
            }
        } else if (axisDescription instanceof AxisOperation) {

            Throttle throttle = null;
            AxisOperation currentOperation = ((AxisOperation) axisDescription);
            AxisService axisService = (AxisService) currentOperation.getParent();
            if (axisService != null) {
                currentServiceName = axisService.getName();
                PolicySubject policySubject = currentOperation.getPolicySubject();
                if (policySubject != null) {
                    try {
                        List policies = new ArrayList(policySubject.getAttachedPolicyComponents());
                        Policy currentPolicy = PolicyUtil.getMergedPolicy(policies,
                                                                          currentOperation);
                        if (currentPolicy != null) {
                            throttle = ThrottleFactory.createOperationThrottle(currentPolicy);
                        }
View Full Code Here


     */
    private List<Resource> getModulePolicies(AxisModule axisModule) throws Exception {
        // List of policies to return
        List<Resource> modulePolicies = new ArrayList<Resource>();

        PolicySubject modulePolicySubject = axisModule.getPolicySubject();
        List<PolicyComponent> policyList = new ArrayList<PolicyComponent>(modulePolicySubject
                .getAttachedPolicyComponents());

        // Get the merged module policy
        Policy policy = null;
        for (Object policyElement : policyList) {
            if (policyElement instanceof Policy) {
                policy = (policy == null) ?
                        (Policy) policyElement : policy.merge((Policy) policyElement);
            } else {
                PolicyReference policyReference = (PolicyReference) policyElement;
                String key = policyReference.getURI();
                int pos = key.indexOf("#");
                if (pos == 0) {
                    key = key.substring(1);
                } else if (pos > 0) {
                    key = key.substring(0, pos);
                }

                PolicyComponent attachedPolicyComponent = modulePolicySubject
                        .getAttachedPolicyComponent(key);

                if (attachedPolicyComponent != null && attachedPolicyComponent instanceof Policy) {
                    policy = (Policy) attachedPolicyComponent;
                }
View Full Code Here

        }
    }
   
    public static void addPoliciesAsExtensibleElement(
      AxisDescription description, OMElement descriptionElement) {
    PolicySubject policySubject = description.getPolicySubject();
    Collection attachPolicyComponents = policySubject
        .getAttachedPolicyComponents();
    ArrayList policies = new ArrayList();

    for (Iterator iterator = attachPolicyComponents.iterator(); iterator
        .hasNext();) {
View Full Code Here

    return baos.toString();
  }

  public static String generateId(AxisDescription description) {
    PolicySubject policySubject = description.getPolicySubject();
    String identifier = "-policy-1";

    if (description instanceof AxisMessage) {
      identifier = "msg-" + ((AxisMessage) description).getName()
          + identifier;
      description = description.getParent();
    }

    if (description instanceof AxisOperation) {
      identifier = "op-" + ((AxisOperation) description).getName()
          + identifier;
      description = description.getParent();
    }

    if (description instanceof AxisService) {
      identifier = "service-" + ((AxisService) description).getName()
          + identifier;
    }

    /*
     * Int 49 is the value of the Character '1'. Here we want to change '1'
     * to '2' or '2' to '3' .. etc. to construct a unique identifier.
     */
    for (int index = 49; policySubject.getAttachedPolicyComponent(identifier) != null; index++) {
      identifier = identifier.replace((char) index, (char) (index + 1));
    }

    return identifier;
  }
View Full Code Here

            return null;
        }
       
        Policy policy = null;
       
        PolicySubject policySubject = subject.getPolicySubject();
    PolicyComponent attachedPolicyComponent = policySubject
        .getAttachedPolicyComponent(key);

    if (attachedPolicyComponent != null
        && attachedPolicyComponent instanceof Policy) {
      policy = (Policy) attachedPolicyComponent;
View Full Code Here

        }
    }
   
    public static void addPoliciesAsExtensibleElement(
      AxisDescription description, OMElement descriptionElement) {
    PolicySubject policySubject = description.getPolicySubject();
    Collection attachPolicyComponents = policySubject
        .getAttachedPolicyComponents();
    ArrayList policies = new ArrayList();

    for (Iterator iterator = attachPolicyComponents.iterator(); iterator
        .hasNext();) {
View Full Code Here

        }
    }
   
    public static void addPoliciesAsExtensibleElement(
      AxisDescription description, OMElement descriptionElement) {
    PolicySubject policySubject = description.getPolicySubject();
    Collection attachPolicyComponents = policySubject
        .getAttachedPolicyComponents();
    ArrayList policies = new ArrayList();

    for (Iterator iterator = attachPolicyComponents.iterator(); iterator
        .hasNext();) {
View Full Code Here

        //  server and it is needed to call it from synapse using the main sequence
        //  2) request is to be injected into  the main sequence  .i.e. http://localhost:8280
        // This method does not cause any performance issue ...
        // Proper fix should be refractoring axis2 RestUtil in a proper way
        if (dispatching) {
            RequestURIBasedDispatcher requestDispatcher = new RequestURIBasedDispatcher();
            AxisService axisService = requestDispatcher.findService(msgContext);
            if (axisService == null) {
                String defaultSvcName = NHttpConfiguration.getInstance().getStringValue(
                        "nhttp.default.service", "__SynapseService");
                axisService = msgContext.getConfigurationContext()
                        .getAxisConfiguration().getService(defaultSvcName);
View Full Code Here

                String serverName = (String)
                        messageContext.getProperty(SynapseConstants.Axis2Param.SYNAPSE_SERVER_NAME);

                if(serverName != null && messageContext instanceof Axis2MessageContext) {

                    AxisConfiguration configuration = ((Axis2MessageContext)messageContext).
                            getAxis2MessageContext().
                            getConfigurationContext().getAxisConfiguration();

                    String myServerName = getAxis2ParameterValue(configuration,
                            SynapseConstants.Axis2Param.SYNAPSE_SERVER_NAME);
View Full Code Here

    /**
     * Start the proxy service
     * @param synCfg the synapse configuration
     */
    public void start(SynapseConfiguration synCfg) {
        AxisConfiguration axisConfig = synCfg.getAxisConfiguration();
        if (axisConfig != null) {

            Parameter param = axisConfig.getParameter(SynapseConstants.SYNAPSE_ENV);
            if (param != null && param.getValue() instanceof SynapseEnvironment)  {
                SynapseEnvironment env = (SynapseEnvironment) param.getValue();
                if (targetInLineInSequence != null) {
                    targetInLineInSequence.init(env);
                }
                if (targetInLineOutSequence != null) {
                    targetInLineOutSequence.init(env);
                }
                if (targetInLineFaultSequence != null) {
                    targetInLineFaultSequence.init(env);
                }
            } else {
                auditWarn("Unable to find the SynapseEnvironment. " +
                    "Components of the proxy service may not be initialized");
            }

            AxisService as = axisConfig.getServiceForActivation(this.getName());
            as.setActive(true);
            axisConfig.notifyObservers(new AxisEvent(AxisEvent.SERVICE_START, as), as);
            this.setRunning(true);
            auditInfo("Started the proxy service : " + name);
        } else {
            auditWarn("Unable to start proxy service : " + name +
                ". Couldn't access Axis configuration");
View Full Code Here

TOP

Related Classes of org.apache.axis2.description.PolicySubject

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.