示例#1
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;
 }
示例#2
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;
 }
示例#3
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();
  }