Package flex.messaging.services

Examples of flex.messaging.services.Service


     *
     * @param service The <code>Service</code> managing this <code>Destination</code>.
     */
    public void setService(Service service)
    {
        Service oldService = getService();       
                                     
        setParent(service);
       
        if (oldService != null)
            oldService.removeDestination(getId());
       
        // Add the destination to the service if needed
        if (service.getDestination(getId()) != this)
            service.addDestination(this);
    }
View Full Code Here


     *
     * @return The Java class name for the <code>Service</code> manageing this <code>Destination</code>.
     */
    public String getServiceType()
    {
        Service service = getService();
        if (service == null)
        {
            return null;
        }
        else
        {
            return service.getClass().getName();
        }
    }
View Full Code Here

            ServiceSettings svcSettings = (ServiceSettings)iter.next();
            String svcId = svcSettings.getId();
            String svcClassName = svcSettings.getClassName();
           
            // Create the Service              
            Service service = broker.createService(svcId, svcClassName);

            // Service Class Name - not needed in AbstractService
                                      
            // Initialize with service properties
            service.initialize(svcId, svcSettings.getProperties());

            // Default Channels
            for (Iterator chanIter = svcSettings.getDefaultChannels().iterator(); chanIter.hasNext();)
            {
                ChannelSettings chanSettings = (ChannelSettings)chanIter.next();
                service.addDefaultChannel(chanSettings.getId());             
            }

            // Adapter Definitions
            Map svcAdapterSettings = svcSettings.getAllAdapterSettings();
            for (Iterator asIter = svcAdapterSettings.values().iterator(); asIter.hasNext();)
            {               
                AdapterSettings as = (AdapterSettings) asIter.next();
                service.registerAdapter(as.getId(), as.getClassName());
                if (as.isDefault())
                {
                    service.setDefaultAdapter(as.getId());
                }
            }                 

            // Destinations
            Map destinationSettings = svcSettings.getDestinationSettings();
View Full Code Here

    /** @exclude */
    public Service getServiceByType(String type)
    {
        for (Iterator serviceIter=services.values().iterator(); serviceIter.hasNext(); )
        {
            Service svc = (Service) serviceIter.next();
            if (svc.getClass().getName().equals(type))
            {
                return svc;
            }
        }
        return null;
View Full Code Here

                servicesConfig.addProperty("default-channels", defaultChannelsMap);
        }   
       
        for (Iterator iter = services.values().iterator(); iter.hasNext();)
        {
            Service service = (Service) iter.next();           
            ConfigMap serviceConfig = service.describeService(endpoint);
            if (serviceConfig != null && serviceConfig.size() > 0)
                servicesConfig.addProperty("service", serviceConfig);
        }
              
        // Need to send channel properties again in case the client didn't
View Full Code Here

     */
    public Service createService(String id, String className)
    {                          
        Class svcClass = ClassUtil.createClass(className, getClassLoader());
       
        Service service = (Service)ClassUtil.createDefaultInstance(svcClass, Service.class);       
        service.setId(id);
        service.setManaged(isManaged());
        service.setMessageBroker(this);
       
        return service;
    }
View Full Code Here

     * @param id The id of the <code>Service</code>.
     * @return Previous <code>Service</code> associated with the id.
     */
    public Service removeService(String id)   
    { 
        Service service = getService(id);
        if (service != null)
        {           
            service.stop();
            services.remove(id);
        }
        return service;
    }
View Full Code Here

     */
    private void startServices()
    {
        for (Iterator iter=services.values().iterator(); iter.hasNext(); )
        {
            Service svc = (Service) iter.next();

            long timeBeforeStartup = 0;
            if (Log.isDebug())
            {
                timeBeforeStartup = System.currentTimeMillis();           
                Log.getLogger(LOG_CATEGORY_STARTUP_SERVICE).debug("Service with id '{0}' is starting.",
                        new Object[]{svc.getId()});
            }
           
            svc.start();
           
            if (Log.isDebug())
            {
                long timeAfterStartup = System.currentTimeMillis();           
                Long diffMillis = new Long(timeAfterStartup - timeBeforeStartup);
                Log.getLogger(LOG_CATEGORY_STARTUP_SERVICE).debug("Service with id '{0}' is ready (startup time: '{1}' ms)",
                        new Object[]{svc.getId(), diffMillis});                  
            }
        }
    }
View Full Code Here

     */
    private void stopServices()
    {
        for (Iterator iter=services.values().iterator(); iter.hasNext(); )
        {
            Service svc = (Service) iter.next();
            svc.stop();
        }       
    }
View Full Code Here

        // Make sure message has a messageId
        checkMessageId(message);
       
        Object serviceResult = null;
        boolean serviced = false;
        Service service = null;
        String destId = message.getDestination();
        try
        {
            String serviceId = (String)destinationToService.get(destId);
            if (serviceId != null)
            {
                service = (Service)services.get(serviceId);
                serviced = true;
                Destination destination = service.getDestination(destId);
                inspectOperation(message, destination);
                // Remove the validate endopint header if it was set.
                if (message.headerExists(Message.VALIDATE_ENDPOINT_HEADER))
                    message.getHeaders().remove(Message.VALIDATE_ENDPOINT_HEADER);

                if (Log.isDebug())
                    Log.getLogger(getLogCategory(message)).debug(
                            "Before invoke service: " + service.getId() + StringUtils.NEWLINE +
                            "  incomingMessage: " + message + StringUtils.NEWLINE);

                extractRemoteCredentials(service, message);
                serviceResult = service.serviceMessage(message);
            }

            if (!serviced)
            {
                MessageException lme = new MessageException();
                // No destination with id ''{0}'' is registered with any service.
                lme.setMessage(NO_SERVICE_FOR_DEST, new Object[] {destId});
                throw lme;
            }

            if (Log.isDebug())
            {
                String debugServiceResult = Log.getPrettyPrinter().prettify(serviceResult);
                Log.getLogger(getLogCategory(message)).debug(
                     "After invoke service: " + service.getId() + StringUtils.NEWLINE +
                     "  reply: " + debugServiceResult + StringUtils.NEWLINE);
            }

            AcknowledgeMessage ack = null;
            if (serviceResult instanceof AcknowledgeMessage)
            {
                // service will return an ack if they need to transform it in some
                // service-specific way (paging is an example)
                ack = (AcknowledgeMessage)serviceResult;              
            }
            else
            {
                // most services will return a result of some sort, possibly null,
                // and expect the broker to compose a message to deliver it
                ack = new AcknowledgeMessage();
                ack.setBody(serviceResult);
            }
            ack.setCorrelationId(message.getMessageId());
            ack.setClientId(message.getClientId());
            return ack;
        }
        catch (MessageException exc)
        {
            Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
                 "Exception when invoking service: " +
                 (service == null ? "(none)" : service.getId()) +
                 StringUtils.NEWLINE +
                 "  with message: " + message + StringUtils.NEWLINE +
                 "  exception: " + exc + StringUtils.NEWLINE);

            if (exc.getRootCause() != null)
                Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
                  "Root cause: " +
                  ExceptionUtil.toString(exc.getRootCause()));

            throw exc;
        }
        catch (RuntimeException exc)
        {
            Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
                 "Exception when invoking service: " +
                 (service == null ? "(none)" : service.getId()) +
                 StringUtils.NEWLINE +
                 "  with message: " + message + StringUtils.NEWLINE +
                 "  exception: " + ExceptionUtil.toString(exc) + StringUtils.NEWLINE);

            throw exc;
        }
        catch (Error exc)
        {
            Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
                 "Error when invoking service: " +
                 (service == null ? "(none)" : service.getId()) +
                 StringUtils.NEWLINE +
                 "  with message: " + message + StringUtils.NEWLINE +
                 "  error: " + ExceptionUtil.toString(exc) + StringUtils.NEWLINE);

            throw exc;
View Full Code Here

TOP

Related Classes of flex.messaging.services.Service

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.