コード例 #1
0
 /**
  * Helper method for testing which stores a copy of the message locally as the POP3
  *
  * <p>message will be deleted from the server
  *
  * @param msg the message to store
  * @throws IOException If a failure happens writing the message
  * @throws MessagingException If a failure happens reading the message
  */
 protected void storeMessage(Message msg) throws IOException, MessagingException {
   if (backupEnabled) {
     String filename = msg.getFileName();
     if (filename == null) {
       Address[] from = msg.getFrom();
       if (from != null && from.length > 0) {
         filename =
             from[0] instanceof InternetAddress
                 ? ((InternetAddress) from[0]).getAddress()
                 : from[0].toString();
       } else {
         filename = "(no from address)";
       }
       filename += "[" + UUID.getUUID() + "]";
     }
     filename = FileUtils.prepareWinFilename(filename);
     filename = backupFolder + filename + ".msg";
     if (logger.isDebugEnabled()) {
       logger.debug("Writing message to: " + filename);
     }
     File f = FileUtils.createFile(filename);
     FileOutputStream fos = new FileOutputStream(f);
     msg.writeTo(fos);
   }
 }
コード例 #2
0
  public static MessageHeader createMessageHeader(
      MessageHeader messageHeader, String hostname, GregorianCalendar timestamp, EbMSAction action)
      throws DatatypeConfigurationException {
    messageHeader =
        (MessageHeader)
            XMLUtils.xmlToObject(
                XMLUtils.objectToXML(messageHeader)); // FIXME: replace by more efficient copy
    List<PartyId> partyIds = new ArrayList<PartyId>(messageHeader.getFrom().getPartyId());
    messageHeader.getFrom().getPartyId().clear();
    messageHeader.getFrom().getPartyId().addAll(messageHeader.getTo().getPartyId());
    messageHeader.getTo().getPartyId().clear();
    messageHeader.getTo().getPartyId().addAll(partyIds);

    messageHeader.getFrom().setRole(null);
    messageHeader.getTo().setRole(null);

    messageHeader.getMessageData().setRefToMessageId(messageHeader.getMessageData().getMessageId());
    messageHeader.getMessageData().setMessageId(UUID.getUUID() + "@" + hostname);
    messageHeader
        .getMessageData()
        .setTimestamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp));
    messageHeader.getMessageData().setTimeToLive(null);

    messageHeader.setService(action.getService());
    messageHeader.setAction(action.getAction());

    messageHeader.setDuplicateElimination(null);

    return messageHeader;
  }
コード例 #3
0
 @Override
 public final void initialise() throws InitialisationException {
   if (id == null) {
     logger.warn("No unique id has been set on this registry");
     id = UUID.getUUID();
   }
   try {
     doInitialise();
   } catch (InitialisationException e) {
     throw e;
   } catch (Exception e) {
     throw new InitialisationException(e, this);
   }
   try {
     fireLifecycle(Initialisable.PHASE_NAME);
   } catch (InitialisationException e) {
     throw e;
   } catch (LifecycleException e) {
     throw new InitialisationException(e, this);
   }
 }
コード例 #4
0
  public final void initialise() throws InitialisationException {
    lifecycleManager.checkPhase(Initialisable.PHASE_NAME);

    if (getParent() != null) {
      parent.initialise();
    }

    fireSystemEvent(new RegistryNotification(this, RegistryNotification.REGISTRY_INITIALISING));
    if (id == null) {
      logger.warn("No unique id has been set on this registry");
      id = UUID.getUUID();
    }
    try {
      doInitialise();
      lifecycleManager.firePhase(getManagementContext(), Initialisable.PHASE_NAME);
    } catch (InitialisationException e) {
      throw e;
    } catch (Exception e) {
      throw new InitialisationException(e, this);
    }
  }
コード例 #5
0
 public DefaultMuleSession() {
   id = UUID.getUUID();
   properties = Collections.synchronizedMap(new CaseInsensitiveHashMap());
 }
コード例 #6
0
  public static MessageHeader createMessageHeader(
      CollaborationProtocolAgreement cpa, EbMSMessageContext context, String hostname)
      throws DatatypeConfigurationException {
    String uuid = UUID.getUUID();
    PartyInfo sendingPartyInfo =
        CPAUtils.getSendingPartyInfo(
            cpa,
            context.getFromRole(),
            context.getServiceType(),
            context.getService(),
            context.getAction());
    PartyInfo receivingPartyInfo =
        CPAUtils.getReceivingPartyInfo(
            cpa,
            context.getToRole(),
            context.getServiceType(),
            context.getService(),
            context.getAction());
    // PartyInfo receivingPartyInfo =
    // CPAUtils.getOtherReceivingPartyInfo(cpa,context.getFromRole(),context.getServiceType(),context.getService(),context.getAction());

    MessageHeader messageHeader = new MessageHeader();

    messageHeader.setVersion(Constants.EBMS_VERSION);
    messageHeader.setMustUnderstand(true);

    messageHeader.setCPAId(cpa.getCpaid());
    messageHeader.setConversationId(
        context.getConversationId() != null ? context.getConversationId() : uuid);

    messageHeader.setFrom(new From());
    PartyId from = new PartyId();
    from.setType(sendingPartyInfo.getPartyId().get(0).getType());
    from.setValue(sendingPartyInfo.getPartyId().get(0).getValue());
    messageHeader.getFrom().getPartyId().add(from);
    messageHeader
        .getFrom()
        .setRole(sendingPartyInfo.getCollaborationRole().get(0).getRole().getName());

    messageHeader.setTo(new To());
    PartyId to = new PartyId();
    to.setType(receivingPartyInfo.getPartyId().get(0).getType());
    to.setValue(receivingPartyInfo.getPartyId().get(0).getValue());
    messageHeader.getTo().getPartyId().add(to);
    messageHeader
        .getTo()
        .setRole(receivingPartyInfo.getCollaborationRole().get(0).getRole().getName());

    messageHeader.setService(new Service());
    messageHeader
        .getService()
        .setType(
            sendingPartyInfo
                .getCollaborationRole()
                .get(0)
                .getServiceBinding()
                .getService()
                .getType());
    messageHeader
        .getService()
        .setValue(
            sendingPartyInfo
                .getCollaborationRole()
                .get(0)
                .getServiceBinding()
                .getService()
                .getValue());
    messageHeader.setAction(
        sendingPartyInfo
            .getCollaborationRole()
            .get(0)
            .getServiceBinding()
            .getCanSend()
            .get(0)
            .getThisPartyActionBinding()
            .getAction());

    messageHeader.setMessageData(new MessageData());
    messageHeader.getMessageData().setMessageId(uuid + "@" + hostname);
    messageHeader.getMessageData().setRefToMessageId(context.getRefToMessageId());
    messageHeader
        .getMessageData()
        .setTimestamp(
            DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));

    ReliableMessaging rm = CPAUtils.getReliableMessaging(cpa, messageHeader);
    if (rm != null) {
      GregorianCalendar timestamp =
          messageHeader.getMessageData().getTimestamp().toGregorianCalendar();
      Duration d =
          rm.getRetryInterval().multiply(rm.getRetries().add(new BigInteger("1")).intValue());
      d.addTo(timestamp);
      timestamp.add(Calendar.SECOND, 1);
      messageHeader
          .getMessageData()
          .setTimeToLive(DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp));
    }

    DeliveryChannel channel =
        CPAUtils.getDeliveryChannel(
            sendingPartyInfo
                .getCollaborationRole()
                .get(0)
                .getServiceBinding()
                .getCanSend()
                .get(0)
                .getThisPartyActionBinding());

    messageHeader.setDuplicateElimination(
        PerMessageCharacteristicsType.ALWAYS.equals(
                channel.getMessagingCharacteristics().getDuplicateElimination())
            ? ""
            : null);

    return messageHeader;
  }
コード例 #7
0
  public static TransientRegistry createNew() throws UMOException {
    // Use the default server lifecycleManager
    // UMOLifecycleManager lifecycleManager = new DefaultLifecycleManager();
    UMOLifecycleManager lifecycleManager = new GenericLifecycleManager();

    lifecycleManager.registerLifecycle(
        new ContainerManagedLifecyclePhase(
            Initialisable.PHASE_NAME, Initialisable.class, Disposable.PHASE_NAME));
    lifecycleManager.registerLifecycle(new ManagementContextStartPhase());
    lifecycleManager.registerLifecycle(new ManagementContextStopPhase());
    lifecycleManager.registerLifecycle(
        new ContainerManagedLifecyclePhase(
            Disposable.PHASE_NAME, Disposable.class, Initialisable.PHASE_NAME));

    // Create the registry
    TransientRegistry registry = new TransientRegistry();

    RegistryContext.setRegistry(registry);

    MuleConfiguration config = new MuleConfiguration();

    registry.setConfiguration(config);

    QueueManager queueManager = new TransactionalQueueManager();
    queueManager.setPersistenceStrategy(
        new CachingPersistenceStrategy(new MemoryPersistenceStrategy()));

    ThreadingProfile tp = config.getDefaultThreadingProfile();
    UMOWorkManager workManager = new MuleWorkManager(tp, "MuleServer");

    ServerNotificationManager notificationManager = new ServerNotificationManager();
    notificationManager.registerEventType(
        ManagerNotificationListener.class, ManagerNotification.class);
    notificationManager.registerEventType(ModelNotificationListener.class, ModelNotification.class);
    notificationManager.registerEventType(
        ComponentNotificationListener.class, ComponentNotification.class);
    notificationManager.registerEventType(
        SecurityNotificationListener.class, SecurityNotification.class);
    notificationManager.registerEventType(
        ManagementNotificationListener.class, ManagementNotification.class);
    notificationManager.registerEventType(AdminNotificationListener.class, AdminNotification.class);
    notificationManager.registerEventType(
        CustomNotificationListener.class, CustomNotification.class);
    notificationManager.registerEventType(
        ConnectionNotificationListener.class, ConnectionNotification.class);
    notificationManager.registerEventType(
        RegistryNotificationListener.class, RegistryNotification.class);
    notificationManager.registerEventType(
        ExceptionNotificationListener.class, ExceptionNotification.class);
    notificationManager.registerEventType(
        TransactionNotificationListener.class, TransactionNotification.class);

    UMOSecurityManager securityManager = new MuleSecurityManager();

    UMOManagementContext context = new ManagementContext(lifecycleManager);
    context.setId(UUID.getUUID());

    registry.registerObject(
        UMOManagementContext.class, MuleProperties.OBJECT_MANAGMENT_CONTEXT, context);
    registry.registerObject(
        ObjectProcessor.class,
        MuleProperties.OBJECT_MANAGMENT_CONTEXT_PROCESSOR,
        new ManagementContextDependencyProcessor(context));

    // Register objects so we get lifecycle management
    registry.registerObject(MuleProperties.OBJECT_SECURITY_MANAGER, securityManager);
    registry.registerObject(MuleProperties.OBJECT_WORK_MANAGER, workManager);
    registry.registerObject(MuleProperties.OBJECT_NOTIFICATION_MANAGER, notificationManager);
    registry.registerObject(MuleProperties.OBJECT_QUEUE_MANAGER, queueManager);

    // Set the object explicitly on the ManagementContext
    context.setWorkManager(workManager);
    context.setSecurityManager(securityManager);
    context.setNotificationManager(notificationManager);
    context.setQueueManager(queueManager);

    // Register the system Model
    ModelServiceDescriptor sd =
        (ModelServiceDescriptor)
            registry.lookupServiceDescriptor(
                ServiceDescriptorFactory.MODEL_SERVICE_TYPE, config.getSystemModelType(), null);

    UMOModel model = sd.createModel();
    model.setName(MuleProperties.OBJECT_SYSTEM_MODEL);
    registry.registerModel(model);
    registry.initialise();
    return registry;
  }