/**
   * Starts the JMX Adaptor.
   *
   * @throws SynapseException if the JMX configuration is erroneous and/or the connector server
   *     cannot be started
   */
  private void startJmxAdapter() {
    Properties synapseProperties = SynapsePropertiesLoader.loadSynapseProperties();
    JmxInformation jmxInformation =
        JmxInformationFactory.createJmxInformation(
            synapseProperties, serverConfigurationInformation.getHostName());

    // Start JMX Adapter only if at least a JMX JNDI port is configured
    if (jmxInformation.getJndiPort() != -1) {
      jmxAdapter = new JmxAdapter(jmxInformation);
      jmxAdapter.start();
    }
  }
 private synchronized void initEnterpriseBeanstalkHolder(
     ServerContextInformation serverContextInformation) {
   if (serverContextInformation.getProperty(
           EnterpriseBeanstalkConstants.BEANSTALK_MANAGER_PROP_NAME)
       == null) {
     EnterpriseBeanstalkManager beanstalkHolder = new EnterpriseBeanstalkManager();
     Properties synapseProperties = SynapsePropertiesLoader.reloadSynapseProperties();
     beanstalkHolder.init(synapseProperties);
     serverContextInformation.addProperty(
         EnterpriseBeanstalkConstants.BEANSTALK_MANAGER_PROP_NAME, beanstalkHolder);
   }
 }
  /** {@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;
  }
 /**
  * Initiating DataSourceRepositoryHolder with a new data source information repository or reusing
  * an existing repository.
  *
  * @param serverContextInformation ServerContextInformation instance
  */
 private void initDataSourceHelper(ServerContextInformation serverContextInformation) {
   DataSourceRepositoryHolder repositoryHolder = DataSourceRepositoryHolder.getInstance();
   Properties synapseProperties = SynapsePropertiesLoader.reloadSynapseProperties();
   Object repo =
       serverContextInformation.getProperty(
           DataSourceConstants.DATA_SOURCE_INFORMATION_REPOSITORY);
   if (repo instanceof DataSourceInformationRepository) {
     repositoryHolder.init((DataSourceInformationRepository) repo, synapseProperties);
   } else {
     repositoryHolder.init(null, synapseProperties);
   }
 }
Exemplo n.º 5
0
  public static Entry createEntry(OMElement elem, Properties properties) {
    String customFactory = SynapsePropertiesLoader.getPropertyValue("synapse.entry.factory", "");
    if (customFactory != null && !"".equals(customFactory)) {
      try {
        Class c = Class.forName(customFactory);
        Object o = c.newInstance();
        if (o instanceof IEntryFactory) {
          return ((IEntryFactory) o).createEntry(elem);
        }
      } catch (ClassNotFoundException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property not found: "
                + customFactory,
            e);
      } catch (InstantiationException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property cannot be instantiated: "
                + customFactory,
            e);
      } catch (IllegalAccessException e) {
        handleException(
            "Class specified by the synapse.entry.factory "
                + "synapse property cannot be accessed: "
                + customFactory,
            e);
      }
    }

    OMAttribute key = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
    if (key == null) {
      handleException("The 'key' attribute is required for a local registry entry");
      return null;

    } else {

      Entry entry = new Entry(key.getAttributeValue());

      OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
      if (descriptionElem != null) {
        entry.setDescription(descriptionElem.getText());
        descriptionElem.detach();
      }

      String src = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "src"));

      // if a src attribute is present, this is a URL source resource,
      // it would now be loaded from the URL source, as all static properties
      // are initialized at startup
      if (src != null) {
        try {
          entry.setSrc(new URL(src.trim()));
          entry.setType(Entry.URL_SRC);
          entry.setValue(SynapseConfigUtils.getObject(entry.getSrc(), properties));
        } catch (MalformedURLException e) {
          handleException("The entry with key : " + key + " refers to an invalid URL");
        }

      } else {
        OMNode nodeValue = elem.getFirstOMChild();
        OMElement elemValue = elem.getFirstElement();

        if (elemValue != null) {
          entry.setType(Entry.INLINE_XML);
          entry.setValue(elemValue);
        } else if (nodeValue != null && nodeValue instanceof OMText) {
          entry.setType(Entry.INLINE_TEXT);
          entry.setValue(elem.getText().trim());
        }
      }

      return entry;
    }
  }