Exemplo n.º 1
0
  private void initParams(List params) throws ClassNotFoundException {

    NamedParameter param;
    for (Iterator iterator = params.iterator(); iterator.hasNext(); ) {
      String s = (String) iterator.next();

      for (StringTokenizer tokenizer = new StringTokenizer(s, ";"); tokenizer.hasMoreTokens(); ) {
        String name = tokenizer.nextToken();
        String type = tokenizer.nextToken();
        if (name.equalsIgnoreCase("return")) {
          returnType = NamedParameter.createQName(type);
        } else if (name.equalsIgnoreCase("returnClass")) {
          returnClass = ClassHelper.loadClass(type, getClass());
        } else {
          String mode = tokenizer.nextToken();
          QName paramName = (QName) converter.convert(QName.class, name);
          QName qtype = null;
          if (type.startsWith("qname{")) {
            qtype = (QName) converter.convert(QName.class, name);
          } else {
            qtype = NamedParameter.createQName(type);
          }
          param = new NamedParameter(paramName, qtype, mode);
          addNamedParameter(param);
        }
      }
    }
  }
Exemplo n.º 2
0
  /** application entry point */
  public static void main(String[] args) {
    Server server = new Server();
    List opts = Arrays.asList(args);
    String config = null;

    if (opts.size() > 0) {
      config = getOption("-config", opts);
      if (config != null) {
        server.setConfigurationResources(config);
      }
    } else {
      URL configUrl = ClassHelper.getResource("mule-jbi.xml", org.mule.MuleServer.class);
      if (configUrl != null) {
        config = configUrl.toExternalForm();
        server.setConfigurationResources(config);
      }
    }

    if (config == null) {
      Message message = new Message(Messages.CONFIG_NOT_FOUND_USAGE);
      logger.fatal(message.toString());
      System.exit(0);
    }

    String builder = getOption("-builder", opts);
    if (builder != null) {
      try {
        configBuilder =
            (JbiContainerBuilder) ClassHelper.loadClass(builder, Server.class).newInstance();
      } catch (Exception e) {
        logger.fatal(new Message(Messages.FAILED_LOAD_X, "Builder: " + builder), e);
      }
    } else {
      // use this by default
      // try {
      configBuilder = new MuleXmlJbiContainerBuilder();
      //            } catch (ConfigurationException e) {
      //                logger.fatal(e.getMessage(), e);
      //                System.exit(0);
      //            }
    }

    server.start(false);
  }
Exemplo n.º 3
0
  public static Properties getJmsProperties(String propertyFile) throws IOException {
    InputStream is = ClassHelper.getResourceAsStream(propertyFile, JmsTestUtils.class);

    Properties p = new Properties();
    p.load(is);
    is.close();

    fixProviderUrl(p);
    return p;
  }
Exemplo n.º 4
0
  public static Properties getJmsProperties() throws IOException {
    InputStream is = ClassHelper.getResourceAsStream(JMS_PROPERTIES, JmsTestUtils.class);

    String jmsProps = OPEN_JMS_PROPERTIES;
    if (is != null) {
      Properties p = new Properties();
      p.load(is);
      jmsProps = p.getProperty("jms.provider.properties", OPEN_JMS_PROPERTIES);
      is.close();
    }
    return getJmsProperties(jmsProps);
  }
Exemplo n.º 5
0
  public static Object lookupObject(Context context, String reference) throws NamingException {
    Object ref = context.lookup(reference);
    if (ref instanceof Reference) {
      String className = ((Reference) ref).getClassName();
      try {

        ref = ClassHelper.loadClass(className, JmsTestUtils.class).newInstance();
      } catch (Exception e) {
        throw new NamingException(
            "Failed to instanciate class: " + className + ". Exception was: " + e.toString());
      }
    }
    return ref;
  }
Exemplo n.º 6
0
  /*
   * (non-Javadoc)
   *
   * @see org.mule.providers.AbstractConnector#create()
   */
  public void doInitialise() throws InitialisationException {
    super.doInitialise();
    if (queueEvents) {
      if (queueProfile == null) {
        queueProfile = MuleManager.getConfiguration().getQueueProfile();
      }
    }

    try {
      adapterClass = ClassHelper.loadClass(serviceDescriptor.getMessageAdapter(), getClass());
    } catch (ClassNotFoundException e) {
      throw new InitialisationException(
          new Message(
              Messages.FAILED_LOAD_X, "Message Adapter: " + serviceDescriptor.getMessageAdapter()),
          e);
    }
  }
Exemplo n.º 7
0
 public void doInitialise() throws InitialisationException {
   super.doInitialise();
   try {
     if (scheduler == null) {
       if (factory == null) {
         Object[] args = null;
         if (factoryProperties != null) {
           args = new Object[] {factoryProperties};
         }
         factory = (SchedulerFactory) ClassHelper.instanciateClass(factoryClassName, args);
       }
       scheduler = factory.getScheduler();
     }
   } catch (Exception e) {
     throw new InitialisationException(
         new Message(Messages.INITIALISATION_FAILURE_X, "Quartz provider"), e);
   }
 }
Exemplo n.º 8
0
 /**
  * Loads the script for this component
  *
  * @param script the script file location
  * @throws InitialisationException if anything fails while starting up
  */
 protected void loadInterpreter(String script) throws InitialisationException {
   try {
     File f = new File(script);
     if (f.exists()) {
       fileChanged(f);
     } else {
       GroovyClassLoader loader =
           new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
       URL url = ClassHelper.getResource(script, getClass());
       if (url == null) {
         throw new InitialisationException(
             new Message(Messages.FAILED_LOAD_X, "Groovy script: " + script), this);
       }
       Class groovyClass = loader.parseClass(new GroovyCodeSource(url));
       component = (GroovyObject) groovyClass.newInstance();
     }
   } catch (Exception e) {
     if (e instanceof InitialisationException) throw (InitialisationException) e;
     throw new InitialisationException(
         new Message(Messages.FAILED_LOAD_X, "Groovy component"), e, this);
   }
 }