Exemple #1
0
  public void initialise() throws InitialisationException {
    if (wireFormat == null) {
      wireFormat = new SerializationWireFormat();
    }

    try {
      if (StringUtils.isEmpty(serverUri)) {
        // no serverUrl specified, warn a user
        logger.warn(
            "No serverUriUrl specified, MuleAdminAgent will not start. E.g. use "
                + "<mule:admin-agent serverUri=\"tcp://example.com:60504\"/> ");

        // abort the agent registration process
        managementContext.getRegistry().unregisterAgent(this.getName());

        return;
      }

      // Check for override
      if (ModelHelper.isComponentRegistered(MuleManagerComponent.MANAGER_COMPONENT_NAME)) {
        logger.info("Mule manager component has already been initialised, ignoring server url");
      } else {
        if (managementContext.getRegistry().lookupConnector(DEFAULT_MANAGER_ENDPOINT) != null) {
          throw new AlreadyInitialisedException("Server Components", this);
        }

        MuleEndpoint writableEndpoint;
        // Check to see if we have an endpoint identifier
        UMOImmutableEndpoint endpoint = managementContext.getRegistry().lookupEndpoint(serverUri);
        if (endpoint == null) {
          UMOEndpointURI endpointUri = new MuleEndpointURI(serverUri);
          UMOConnector connector = TransportFactory.getOrCreateConnectorByProtocol(endpointUri);
          // If this connector has already been initialised i.e. it's a
          // pre-existing connector don't reinit
          if (managementContext.getRegistry().lookupConnector(connector.getName()) == null) {
            connector.setName(DEFAULT_MANAGER_ENDPOINT);
            connector.initialise();
            managementContext.getRegistry().registerConnector(connector);
          }
          writableEndpoint = new MuleEndpoint();
          writableEndpoint.setConnector(connector);
          writableEndpoint.setEndpointURI(endpointUri);
        } else {
          writableEndpoint = new MuleEndpoint(endpoint);
        }

        logger.info("Registering Admin listener on: " + serverUri);
        UMODescriptor descriptor =
            MuleManagerComponent.getDescriptor(
                writableEndpoint,
                wireFormat,
                RegistryContext.getConfiguration().getDefaultEncoding(),
                RegistryContext.getConfiguration().getDefaultSynchronousEventTimeout());

        ModelHelper.registerSystemComponent(descriptor);
      }
    } catch (UMOException e) {
      throw new InitialisationException(e, this);
    }
  }
Exemple #2
0
 private MuleEndpoint buildEndpoint(String urlStr)
     throws EndpointException, MalformedEndpointException, UMOException {
   MuleEndpoint endpoint = new MuleEndpoint();
   endpoint.setEndpointURI(new MuleEndpointURI(urlStr));
   endpoint.setType(UMOEndpoint.ENDPOINT_TYPE_RECEIVER);
   endpoint.setFilter(new NotFilter(new WildcardFilter("*xyz*")));
   // endpoint.setTransformer(new HttpRequestToString());
   endpoint.setConnector(buildConnector(urlStr));
   return endpoint;
 }