Esempio n. 1
0
  public static synchronized void start(String repository) throws Exception {
    if (count == 0) {
      TestUtils.shutdownFailsafe(TESTING_PORT);
      ConfigurationContext er = getNewConfigurationContext(repository);

      receiver = new SimpleHttpServerExtension(er, TESTING_PORT);

      try {
        receiver.start();
        ListenerManager listenerManager = er.getListenerManager();
        TransportInDescription trsIn = new TransportInDescription(Constants.TRANSPORT_HTTP);
        trsIn.setReceiver(receiver);
        if (listenerManager == null) {
          listenerManager = new ListenerManager();
          listenerManager.init(er);
        }
        listenerManager.addListener(trsIn, true);
        System.out.print("Server started on port " + TESTING_PORT + ".....");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    try {
      Thread.sleep(2000);
    } catch (InterruptedException e1) {
      throw new AxisFault("Thread interuptted", e1);
    }

    waitForService();

    count++;
  }
Esempio n. 2
0
 public void testParameterEdit() throws Exception {
   ConfigurationContext configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
   AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
   Parameter parameter = new Parameter();
   parameter.setValue("true");
   parameter.setName("enableMTOM");
   axisConfig.addParameter(parameter);
   parameter.setValue("true");
   AxisServiceGroup serviceGroup = new AxisServiceGroupImpl();
   serviceGroup.setName("testServiceGroup");
   AxisService service = new AxisService();
   service.setName("service");
   serviceGroup.addService(service);
   axisConfig.addServiceGroup(serviceGroup);
   parameter = serviceGroup.getParameter("enableMTOM");
   parameter.setValue("true");
   Parameter para2 = serviceGroup.getParameter("enableMTOM");
   assertEquals(para2.getValue(), "true");
   Parameter test = new Parameter();
   test.setName("test");
   test.setValue("test");
   serviceGroup.addParameter(test);
   Parameter para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "test");
   para.setValue("newValue");
   para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "newValue");
 }
 /** @throws Exception */
 private void initialize() throws Exception {
   loadSecurityScenarios();
   STSConfigAdmin.configureService(
       configContext.getAxisConfiguration(), this.registryService.getConfigSystemRegistry());
   STSConfigAdmin.configureGenericSTS();
   configContext.getAxisConfiguration().addObservers(new STSObserver());
 }
 private void initThrottle(ConfigurationContext cc) {
   Object entryValue = null;
   if (throttle == null) {
     entryValue = ThrottleUtils.lookup(APIManagerConstants.APPLICATION_THROTTLE_POLICY_KEY);
   }
   if (isClusteringEnable && concurrentAccessController != null && throttle != null) {
     concurrentAccessController = null; // set null ,
     // because need to reload
   }
   if (throttle == null) {
     try {
       throttle =
           ThrottleFactory.createMediatorThrottle(PolicyEngine.getPolicy((OMElement) entryValue));
       // For non-clustered  environment , must re-initiates
       // For  clustered  environment,
       // concurrent access controller is null ,
       // then must re-initiates
       if (throttle != null && (concurrentAccessController == null || !isClusteringEnable)) {
         concurrentAccessController = throttle.getConcurrentAccessController();
         if (concurrentAccessController != null) {
           cc.setProperty(key, concurrentAccessController);
         } else {
           cc.removeProperty(key);
         }
       }
     } catch (ThrottleException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
  /**
   * @param request -Httpservlet request
   * @param accessToken
   * @return
   * @throws APIFaultException
   */
  public boolean doThrottle(HttpServletRequest request, String accessToken)
      throws APIFaultException {

    String apiName = request.getContextPath();
    String apiVersion = APIManagetInterceptorUtils.getAPIVersion(request);
    String apiIdentifier = apiName + "-" + apiVersion;

    APIThrottleHandler throttleHandler = null;
    ConfigurationContext cc = DataHolder.getServerConfigContext();

    if (cc.getProperty(apiIdentifier) == null) {
      throttleHandler = new APIThrottleHandler();
      /* Add the Throttle handler to ConfigContext against API Identifier */
      cc.setProperty(apiIdentifier, throttleHandler);
    } else {
      throttleHandler = (APIThrottleHandler) cc.getProperty(apiIdentifier);
    }

    if (throttleHandler.doThrottle(request, apiKeyValidationDTO, accessToken)) {
      return true;
    } else {
      throw new APIFaultException(
          APIManagerErrorConstants.API_THROTTLE_OUT, "You have exceeded your quota");
    }
  }
Esempio n. 6
0
  public void init(SynapseEnvironment synapseEnvironment) {
    ConfigurationContext cc =
        ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext();
    if (!initialized) {
      // The check for clustering environment
      ClusteringAgent clusteringAgent = cc.getAxisConfiguration().getClusteringAgent();
      if (clusteringAgent != null && clusteringAgent.getStateManager() != null) {
        isClusteringEnabled = Boolean.TRUE;
      } else {
        isClusteringEnabled = Boolean.FALSE;
      }

      context =
          new EndpointContext(getName(), getDefinition(), isClusteringEnabled, cc, metricsMBean);
    }
    initialized = true;

    if (children != null) {
      for (Endpoint e : children) {
        e.init(synapseEnvironment);
      }
    }

    contentAware =
        definition != null
            && ((definition.getFormat() != null
                    && !definition.getFormat().equals(SynapseConstants.FORMAT_REST))
                || definition.isSecurityOn()
                || definition.isReliableMessagingOn()
                || definition.isAddressingOn()
                || definition.isUseMTOM()
                || definition.isUseSwa());
  }
  /**
   * Create a Axis2 Based Server Environment
   *
   * @param serverConfigurationInformation ServerConfigurationInformation instance
   */
  private void createNewInstance(ServerConfigurationInformation serverConfigurationInformation) {

    try {
      configurationContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(
              serverConfigurationInformation.getAxis2RepoLocation(),
              serverConfigurationInformation.getAxis2Xml());

      configurationContext.setProperty(AddressingConstants.ADDR_VALIDATE_ACTION, Boolean.FALSE);

      startJmxAdapter();

      listenerManager = configurationContext.getListenerManager();
      if (listenerManager == null) {

        // create and initialize the listener manager but do not start
        listenerManager = new ListenerManager();
        listenerManager.init(configurationContext);
      }

      // do not use the listener manager shutdown hook, because it clashes with the
      // SynapseServer shutdown hook.
      listenerManager.setShutdownHookRequired(false);

    } catch (Throwable t) {
      handleFatal("Failed to create a new Axis2 instance...", t);
    }
  }
Esempio n. 8
0
 private void process() {
   Object ob = configContext.getProperty(JsonConstant.XMLNODES);
   if (ob != null) {
     Map<QName, XmlNode> nodeMap = (Map<QName, XmlNode>) ob;
     XmlNode requesNode = nodeMap.get(elementQname);
     if (requesNode != null) {
       xmlNodeGenerator = new XmlNodeGenerator();
       schemaList = xmlNodeGenerator.getSchemaList(requesNode);
     } else {
       xmlNodeGenerator = new XmlNodeGenerator(xmlSchemaList, elementQname);
       mainXmlNode = xmlNodeGenerator.getMainXmlNode();
       schemaList = xmlNodeGenerator.getSchemaList(mainXmlNode);
       nodeMap.put(elementQname, mainXmlNode);
       configContext.setProperty(JsonConstant.XMLNODES, nodeMap);
     }
   } else {
     Map<QName, XmlNode> newNodeMap = new HashMap<QName, XmlNode>();
     xmlNodeGenerator = new XmlNodeGenerator(xmlSchemaList, elementQname);
     mainXmlNode = xmlNodeGenerator.getMainXmlNode();
     schemaList = xmlNodeGenerator.getSchemaList(mainXmlNode);
     newNodeMap.put(elementQname, mainXmlNode);
     configContext.setProperty(JsonConstant.XMLNODES, newNodeMap);
   }
   isProcessed = true;
 }
Esempio n. 9
0
 private void notifyClusterDSChange(String dsName) throws DataSourceException {
   if (log.isDebugEnabled()) {
     log.debug("Notifying cluster DS change: " + dsName);
   }
   ConfigurationContextService configCtxService =
       DataSourceServiceComponent.getConfigContextService();
   if (configCtxService == null) {
     throw new DataSourceException(
         "ConfigurationContextService not available " + "for notifying the cluster");
   }
   ConfigurationContext configCtx = configCtxService.getServerConfigContext();
   ClusteringAgent agent = configCtx.getAxisConfiguration().getClusteringAgent();
   if (log.isDebugEnabled()) {
     log.debug("Clustering Agent: " + agent);
   }
   if (agent != null) {
     DataSourceStatMessage msg = new DataSourceStatMessage();
     msg.setTenantId(this.getTenantId());
     msg.setDsName(dsName);
     try {
       agent.sendMessage(msg, true);
     } catch (ClusteringFault e) {
       throw new DataSourceException("Error in sending out cluster message: " + e.getMessage(), e);
     }
   }
 }
Esempio n. 10
0
  /**
   * Search the service artifacts stored in the registry and find the set of services that satisfy
   * the conditions stated in the given WS-D probe. If the probe does not impose any restrictions on
   * the result set, all the services in the registry will be returned.
   *
   * @param probe a WS-D probe describing the search criteria
   * @return an array of TargetService instances matching the probe or null
   * @throws Exception if an error occurs while accessing the registry
   */
  public static TargetService[] findServices(Probe probe) throws Exception {
    ServiceManager serviceManager = new ServiceManager(getRegistry());
    DiscoveryServiceFilter filter = new DiscoveryServiceFilter(probe);

    // Check whether the inactive services should be skipped when searching
    AxisConfiguration axisConfig;
    String tenantDomain =
        PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
    ConfigurationContext mainCfgCtx = ConfigHolder.getInstance().getServerConfigurationContext();
    if (tenantDomain != MultitenantConstants.SUPER_TENANT_DOMAIN_NAME) {
      axisConfig = TenantAxisUtils.getTenantAxisConfiguration(tenantDomain, mainCfgCtx);
    } else {
      axisConfig = mainCfgCtx.getAxisConfiguration();
    }

    Parameter parameter = axisConfig.getParameter(DiscoveryConstants.SKIP_INACTIVE_SERVICES);
    filter.setSkipInactiveServices(parameter == null || "true".equals(parameter.getValue()));

    Service[] services = serviceManager.findServices(filter);
    if (services != null && services.length > 0) {
      TargetService[] targetServices = new TargetService[services.length];
      for (int i = 0; i < services.length; i++) {
        targetServices[i] = getTargetService(services[i]);
      }
      return targetServices;
    }
    return null;
  }
 public static AxisConfiguration getTenantAxisConfiguration(
     String tenant, ConfigurationContext mainConfigCtx) {
   ConfigurationContext tenantConfigCtx = getTenantConfigurationContext(tenant, mainConfigCtx);
   if (tenantConfigCtx != null) {
     return tenantConfigCtx.getAxisConfiguration();
   }
   return null;
 }
Esempio n. 12
0
 /**
  * Get the current server status
  *
  * @return The current server status
  * @throws AxisFault If an error occurs while getting the ConfigurationContext
  */
 public static String getCurrentStatus() {
   ConfigurationContext configCtx = CarbonConfigurationContextFactory.getConfigurationContext();
   String currentStatus = (String) configCtx.getProperty(CURRENT_SERVER_STATUS);
   if (currentStatus == null) {
     configCtx.setProperty(CURRENT_SERVER_STATUS, STATUS_RUNNING);
     return STATUS_RUNNING;
   }
   return currentStatus;
 }
  protected void setConfigurationContextService(ConfigurationContextService ccService) {
    ConfigurationContext serverCtx = ccService.getServerConfigContext();
    AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
    LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
    LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
    LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");

    Util.setConfigurationContextService(ccService);
  }
 public static long getLastAccessed(String tenantDomain, ConfigurationContext mainConfigCtx) {
   Map<String, ConfigurationContext> tenantConfigContexts =
       getTenantConfigurationContexts(mainConfigCtx);
   ConfigurationContext tenantConfigCtx = tenantConfigContexts.get(tenantDomain);
   if (tenantConfigCtx != null) {
     Long lastAccessed = (Long) tenantConfigCtx.getProperty(MultitenantConstants.LAST_ACCESSED);
     return lastAccessed == null ? -1 : lastAccessed;
   }
   return -1;
 }
Esempio n. 15
0
  public boolean unregister(String domain, String subDomain, String hostName)
      throws CartridgeAgentException {

    MessageContext messageContext = MessageContext.getCurrentMessageContext();
    ConfigurationContext configurationContext = messageContext.getConfigurationContext();
    ClusteringClient clusteringClient =
        (ClusteringClient)
            configurationContext.getProperty(CartridgeAgentConstants.CLUSTERING_CLIENT);
    clusteringClient.removeClusterDomain(domain, subDomain, hostName, configurationContext);
    return true;
  }
 /**
  * Get all the tenant ConfigurationContexts
  *
  * @param mainConfigCtx Super-tenant Axis2 ConfigurationContext
  * @return the tenant ConfigurationContexts as a Map of "tenant domain -> ConfigurationContext"
  */
 @SuppressWarnings("unchecked")
 public static Map<String, ConfigurationContext> getTenantConfigurationContexts(
     ConfigurationContext mainConfigCtx) {
   Map<String, ConfigurationContext> tenantConfigContexts =
       (Map<String, ConfigurationContext>)
           mainConfigCtx.getProperty(TENANT_CONFIGURATION_CONTEXTS);
   if (tenantConfigContexts == null) {
     tenantConfigContexts = new ConcurrentHashMap<String, ConfigurationContext>();
     mainConfigCtx.setProperty(TENANT_CONFIGURATION_CONTEXTS, tenantConfigContexts);
   }
   return tenantConfigContexts;
 }
  /** {@inheritDoc} */
  public SynapseConfiguration createSynapseConfiguration() {

    String synapseXMLLocation = serverConfigurationInformation.getSynapseXMLLocation();
    Properties properties = SynapsePropertiesLoader.loadSynapseProperties();
    if (serverConfigurationInformation.getResolveRoot() != null) {
      properties.put(
          SynapseConstants.RESOLVE_ROOT, serverConfigurationInformation.getResolveRoot());
    }

    if (serverConfigurationInformation.getSynapseHome() != null) {
      properties.put(
          SynapseConstants.SYNAPSE_HOME, serverConfigurationInformation.getSynapseHome());
    }

    if (synapseXMLLocation != null) {
      synapseConfiguration =
          SynapseConfigurationBuilder.getConfiguration(synapseXMLLocation, properties);
    } else {
      log.warn(
          "System property or init-parameter '"
              + SynapseConstants.SYNAPSE_XML
              + "' is not specified. Using default configuration..");
      synapseConfiguration = SynapseConfigurationBuilder.getDefaultConfiguration();
    }

    Enumeration keys = properties.keys();
    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      synapseConfiguration.setProperty(key, properties.getProperty(key));
    }

    // Set the Axis2 ConfigurationContext to the SynapseConfiguration
    synapseConfiguration.setAxisConfiguration(configurationContext.getAxisConfiguration());
    MessageContextCreatorForAxis2.setSynConfig(synapseConfiguration);

    // set the Synapse configuration into the Axis2 configuration
    Parameter synapseConfigurationParameter =
        new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration);
    try {
      configurationContext.getAxisConfiguration().addParameter(synapseConfigurationParameter);
    } catch (AxisFault e) {
      handleFatal(
          "Could not set parameters '"
              + SynapseConstants.SYNAPSE_CONFIG
              + "' to the Axis2 configuration : "
              + e.getMessage(),
          e);
    }

    addServerIPAndHostEntries();

    return synapseConfiguration;
  }
  private void addDeployers(ConfigurationContext configurationContext) {
    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
    String carbonRepoPath = configurationContext.getAxisConfiguration().getRepository().getFile();

    String mediatorsPath = carbonRepoPath + File.separator + "mediators";
    String extensionsPath = carbonRepoPath + File.separator + "extensions";
    ExtensionDeployer deployer = new ExtensionDeployer();
    deploymentEngine.addDeployer(deployer, mediatorsPath, "xar");
    deploymentEngine.addDeployer(deployer, extensionsPath, "xar");
    deploymentEngine.addDeployer(deployer, mediatorsPath, "jar");
    deploymentEngine.addDeployer(deployer, extensionsPath, "jar");
  }
Esempio n. 19
0
  public static ConfigurationContext createClientConfigurationContext() throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            "target/test-resources/integrationRepo",
            "target/test-resources/integrationRepo/conf/axis2.xml");
    AxisModule axisModule =
        DeploymentEngine.buildModule(file, configContext.getAxisConfiguration());
    configContext.getAxisConfiguration().addModule(axisModule);
    return configContext;
  }
  public void uploadHumanTask(UploadedFileItem[] fileItems) throws AxisFault {

    // First lets filter for jar resources
    ConfigurationContext configurationContext = getConfigContext();
    String repo = configurationContext.getAxisConfiguration().getRepository().getPath();

    if (CarbonUtils.isURL(repo)) {
      throw new AxisFault("URL Repositories are not supported: " + repo);
    }

    // Writting the artifacts to the proper location
    String humantaskDirectory = getHumanTaskLocation(repo);

    String humantaskTemp =
        CarbonUtils.getCarbonHome()
            + File.separator
            + HumanTaskConstants.HUMANTASK_PACKAGE_TEMP_DIRECTORY;
    File humantaskTempDir = new File(humantaskTemp);
    if (!humantaskTempDir.exists() && !humantaskTempDir.mkdirs()) {
      throw new AxisFault("Fail to create the directory: " + humantaskTempDir.getAbsolutePath());
    }

    File humantaskDir = new File(humantaskDirectory);
    if (!humantaskDir.exists() && !humantaskDir.mkdirs()) {
      throw new AxisFault("Fail to create the directory: " + humantaskDir.getAbsolutePath());
    }

    for (UploadedFileItem uploadedFile : fileItems) {
      String fileName = uploadedFile.getFileName();

      if (fileName == null || fileName.equals("")) {
        throw new AxisFault("Invalid file name. File name is not available");
      }

      if (HumanTaskConstants.HUMANTASK_PACKAGE_EXTENSION.equals(uploadedFile.getFileType())) {
        try {
          writeResource(uploadedFile.getDataHandler(), humantaskTemp, fileName, humantaskDir);
        } catch (IOException e) {
          throw new AxisFault("IOError: Writing resource failed.", e);
        }
      } else {
        throw new AxisFault(
            "Invalid file type : "
                + uploadedFile.getFileType()
                + " ."
                + HumanTaskConstants.HUMANTASK_PACKAGE_EXTENSION
                + " file type is expected");
      }
    }
  }
  public static void main(String[] args) throws AxisFault {

    ConfigurationContext cc =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            args[0], args[1] + "/axis2.xml");
    OMElement payload = createPayLoad();
    ServiceClient serviceclient = new ServiceClient(cc, null);

    Options opts = new Options();
    opts.setTo(new EndpointReference(args[2] + "/RMProxy"));
    opts.setAction("urn:add");
    opts.setUseSeparateListener(true);
    opts.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

    serviceclient.setOptions(opts);
    serviceclient.engageModule("Mercury");
    serviceclient.engageModule("addressing");

    for (int i = 0; i < 4; i++) {
      try {
        OMElement response = serviceclient.sendReceive(payload);
        System.out.println(response);
      } catch (RemoteException e) {
        e.printStackTrace();
      }

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    // Setting the last message
    serviceclient.getOptions().setProperty("MercuryLastMessage", Constants.VALUE_TRUE);

    try {
      OMElement response = serviceclient.sendReceive(payload);
    } catch (RemoteException e) {
      e.printStackTrace();
    }

    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    cc.getListenerManager().stop();
  }
  private void setServerURLParam(ConfigurationContext configurationContext) {
    // Adding server url as a parameter to webapps servlet context init parameter
    Map<String, WebApplicationsHolder> webApplicationsHolderList =
        WebAppUtils.getAllWebappHolders(configurationContext);

    WebContextParameter serverUrlParam =
        new WebContextParameter(
            "webServiceServerURL",
            CarbonUtils.getServerURL(ServerConfiguration.getInstance(), configurationContext));

    List<WebContextParameter> servletContextParameters =
        (ArrayList<WebContextParameter>)
            configurationContext.getProperty(CarbonConstants.SERVLET_CONTEXT_PARAMETER_LIST);

    if (servletContextParameters != null) {
      servletContextParameters.add(serverUrlParam);
    }

    for (WebApplicationsHolder webApplicationsHolder : webApplicationsHolderList.values()) {
      if (webApplicationsHolder != null) {
        for (WebApplication application : webApplicationsHolder.getStartedWebapps().values()) {
          application
              .getContext()
              .getServletContext()
              .setAttribute(serverUrlParam.getName(), serverUrlParam.getValue());
        }
      }
    }
  }
  public void terminatingConfigurationContext(ConfigurationContext configurationContext) {
    String tenantDomain =
        SuperTenantCarbonContext.getCurrentContext(configurationContext).getTenantDomain();

    log.info("Shutting down the persistence manager for the tenant: " + tenantDomain);

    Parameter p =
        configurationContext
            .getAxisConfiguration()
            .getParameter(ServiceBusConstants.PERSISTENCE_MANAGER);
    if (p != null && p.getValue() instanceof MediationPersistenceManager) {
      ((MediationPersistenceManager) p.getValue()).destroy();
    }

    // unregister the service so that components get to know about the tenant termination
    int tenantId = SuperTenantCarbonContext.getCurrentContext(configurationContext).getTenantId();
    ServiceRegistration tenantRegistration =
        ConfigurationHolder.getInstance().getSynapseRegistration(tenantId);

    if (tenantRegistration != null) {
      ConfigurationHolder.getInstance()
          .getBundleContext()
          .ungetService(tenantRegistration.getReference());
    }
  }
 /**
  * Set the transports for the tenants
  *
  * @param mainConfigCtx The main config context
  * @throws AxisFault If an error occurs while initializing tenant transports
  */
 @SuppressWarnings("unchecked")
 public static void initializeTenantTransports(ConfigurationContext mainConfigCtx)
     throws AxisFault {
   AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration();
   Map<String, ConfigurationContext> tenantConfigContexts =
       getTenantConfigurationContexts(mainConfigCtx);
   if (tenantConfigContexts != null) {
     for (Map.Entry<String, ConfigurationContext> entry : tenantConfigContexts.entrySet()) {
       String tenantDomain = entry.getKey();
       ConfigurationContext tenantConfigCtx = entry.getValue();
       AxisConfiguration tenantAxisConfig = tenantConfigCtx.getAxisConfiguration();
       // Add the transports that are made available in the main axis2.xml file
       setTenantTransports(mainAxisConfig, tenantDomain, tenantAxisConfig);
     }
   }
 }
  /** Endpoint has processed a message successfully */
  public void onSuccess() {
    if (isClustered) {
      Integer state = (Integer) cfgCtx.getPropertyNonReplicable(STATE_KEY);

      if ((state != null) && ((state != ST_ACTIVE) && (state != ST_OFF))) {
        log.info(
            "Endpoint : "
                + endpointName
                + " currently "
                + getStateAsString()
                + " will now be marked active since it processed its last message");
        setState(ST_ACTIVE);
      }
    } else {
      if (localState != ST_ACTIVE && localState != ST_OFF) {
        log.info(
            "Endpoint : "
                + endpointName
                + " currently "
                + getStateAsString()
                + " will now be marked active since it processed its last message");
        setState(ST_ACTIVE);
      }
    }
  }
Esempio n. 26
0
  public void process(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final ConfigurationContext configurationContext)
      throws Exception {

    WSDLPrinter wsdlPrinter =
        new WSDLPrinter() {
          public void printWSDL(AxisService axisService) throws IOException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            String importedWSDL = getImportedWSDL(request, "wsdl");
            if ("".equals(importedWSDL)) {
              axisService.printWSDL(baos, NetworkUtils.getLocalHostname());
            } else {
              axisService.printUserWSDL(baos, importedWSDL);
            }
            RequestProcessorUtil.writeDocument(
                baos,
                response.getOutputStream(),
                "annotated-wsdl.xsl",
                configurationContext.getContextRoot(),
                checkForAnnotation(request));
          }
        };
    String requestURI = request.getRequestURI();
    String contextPath = configurationContext.getServiceContextPath();
    String serviceName =
        requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    printWSDL(configurationContext, serviceName, response, wsdlPrinter);
  }
  /**
   * Adds the synapse handlers to the inflow Dispatch phase and starts the listener manager if the
   * axis2 instance is created by the Synapse
   */
  public void start() {

    // add the Synapse handlers
    if (configurationContext != null) {
      List<Phase> inflowPhases = configurationContext.getAxisConfiguration().getInFlowPhases();
      for (Phase inPhase : inflowPhases) {
        // we are interested about the Dispatch phase in the inflow
        if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) {
          try {
            inPhase.addHandler(prepareSynapseDispatcher());
            inPhase.addHandler(prepareMustUnderstandHandler());
          } catch (PhaseException e) {
            handleFatal("Couldn't start Synapse, " + "Cannot add the required Synapse handlers", e);
          }
        }
      }
    } else {
      handleFatal("Couldn't start Synapse, ConfigurationContext not found");
    }

    // if the axis2 instance is created by us, then start the listener manager
    if (serverConfigurationInformation.isCreateNewInstance()) {
      if (listenerManager != null) {
        listenerManager.start();
      } else {
        handleFatal("Couldn't start Synapse, ListenerManager not found");
      }
      /* if JMX Adapter has been configured and started, output usage information rather
      at the end of the startup process to make it more obvious */
      if (jmxAdapter != null && jmxAdapter.isRunning()) {
        log.info(
            "Management using JMX available via: " + jmxAdapter.getJmxInformation().getJmxUrl());
      }
    }
  }
Esempio n. 28
0
  public ConfigurationContext getClientCfgCtx() throws Exception {
    ConfigurationContext cfgCtx =
        ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
    AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
    axisCfg.engageModule("addressing");

    TransportInDescription trpInDesc = new TransportInDescription("udp");
    trpInDesc.setReceiver(new UDPListener());
    axisCfg.addTransportIn(trpInDesc);

    TransportOutDescription trpOutDesc = new TransportOutDescription("udp");
    trpOutDesc.setSender(new UDPSender());
    axisCfg.addTransportOut(trpOutDesc);

    return cfgCtx;
  }
 /*
 Deploying CSV configuration
  */
 public void processDeployStreamConfig(DeploymentFileData deploymentFileData)
     throws DeploymentException {
   CSVFileInfo csvFileInfo =
       DeploymentHelper.getCSVFileInfo(
           deploymentFileData.getFile(), configurationContext.getAxisConfiguration());
   CarbonEventSimulator eventSimulator = EventSimulatorValueHolder.getEventSimulator();
   eventSimulator.addCSVFileInfo(csvFileInfo);
 }
 /**
  * Register a new ThreadContextMigrator.
  *
  * @param configurationContext
  * @param threadContextMigratorListID The name of the parameter in the AxisConfiguration that
  *     contains the list of migrators.
  * @param migrator
  */
 public static void addThreadContextMigrator(
     ConfigurationContext configurationContext,
     String threadContextMigratorListID,
     ThreadContextMigrator migrator)
     throws AxisFault {
   AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
   addThreadContextMigrator(axisConfiguration, threadContextMigratorListID, migrator);
 }