Example #1
0
 /**
  * Sets the factory of the <code>FactoryDestination</code>. <code>MessageBroker</code> has to know
  * the factory before it can be assigned to the destination.
  *
  * @param id The id of the factory.
  */
 public void setFactory(String id) {
   if (isStarted()) {
     MessageBroker broker = getService().getMessageBroker();
     FlexFactory factory = broker.getFactory(id);
     if (factory == null) {
       ConfigurationException ex = new ConfigurationException();
       ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factory});
       throw ex;
     }
     setFactory(factory);
   }
   factoryId = id;
 }
Example #2
0
 /**
  * Sets the throttling settings of the throttle manager.
  *
  * @param throttleSettings The throttling settings for the throttle manager.
  */
 public void setThrottleSettings(ThrottleSettings throttleSettings) {
   // Make sure that we have valid outbound policies.
   Policy outPolicy = throttleSettings.getOutboundPolicy();
   if (outPolicy != Policy.NONE && outPolicy != Policy.IGNORE) {
     ConfigurationException ex = new ConfigurationException();
     ex.setMessage(
         "Invalid outbound throttle policy '"
             + outPolicy
             + "' for destination '"
             + throttleSettings.getDestinationName()
             + "'. Valid values are 'NONE' and 'IGNORE'.");
     throw ex;
   }
   settings = throttleSettings;
 }
Example #3
0
  /**
   * Creates a <code>MessageDestination</code> instance, sets its id, sets it manageable if the
   * <code>AbstractService</code> that created it is manageable, and sets its <code>Service</code>
   * to the <code>AbstractService</code> that created it.
   *
   * @param id The id of the <code>MessageDestination</code>.
   * @return The <code>Destination</code> instanced created.
   */
  @Override
  public Destination createDestination(String id) {
    if (id == null) {
      // Cannot add ''{0}'' with null id to the ''{1}''
      ConfigurationException ex = new ConfigurationException();
      ex.setMessage(
          ConfigurationConstants.NULL_COMPONENT_ID, new Object[] {"Destination", "Service"});
      throw ex;
    }

    // check with the message broker to make sure that no destination with the id already exists
    getMessageBroker().isDestinationRegistered(id, getId(), true);

    MessageDestination destination = new MessageDestination();
    destination.setId(id);
    destination.setManaged(isManaged());
    destination.setService(this);

    return destination;
  }
Example #4
0
 /**
  * Returns the factory of the <code>FactoryDestination</code>. Before a valid <code>FlexFactory
  * </code> can be returned, <code>MessageBroker</code> and hence <code>Service</code> of the
  * <code>Destination</code> has to be set.
  */
 public FlexFactory getFactory() {
   if (factory == null) {
     if (factoryId == null) {
       factoryId = DEFAULT_FACTORY;
     }
     if (getService() == null) {
       // Factory cannot be returned without ''{0}'' set.
       ConfigurationException ex = new ConfigurationException();
       ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"Service"});
       throw ex;
     }
     if (getService().getMessageBroker() == null) {
       // Factory cannot be returned without ''{0}'' set.
       ConfigurationException ex = new ConfigurationException();
       ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"MessageBroker"});
       throw ex;
     }
     MessageBroker broker = getService().getMessageBroker();
     FlexFactory f = broker.getFactory(factoryId);
     if (f == null) {
       ConfigurationException ex = new ConfigurationException();
       ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
       throw ex;
     }
     factory = f;
   }
   return factory;
 }
Example #5
0
  /** Verifies that the <code>FactoryDestination</code> is in valid state before it is started. */
  protected void validate() {
    if (isValid()) return;

    super.validate();

    if (factory == null) {
      if (factoryId == null) {
        factoryId = DEFAULT_FACTORY;
      }
      MessageBroker broker = getService().getMessageBroker();
      FlexFactory f = broker.getFactory(factoryId);
      if (f == null) {
        ConfigurationException ex = new ConfigurationException();
        ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
        throw ex;
      }
      factory = f;
    }

    if (scope == null) scope = FlexFactory.SCOPE_REQUEST;

    if (source == null) source = getId();
  }