org.xmpp.component.ComponentManagerFactory Java Examples

The following examples show how to use org.xmpp.component.ComponentManagerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiUserChatManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public void unregisterMultiUserChatService(String subdomain, boolean allNodes) {
    Log.debug("MultiUserChatManager: Unregistering MUC service "+subdomain);
    MultiUserChatService service = mucServices.get(subdomain);
    if (service != null) {
        service.shutdown();
        try {
            ComponentManagerFactory.getComponentManager().removeComponent(subdomain);
        }
        catch (ComponentException e) {
            Log.error("MultiUserChatManager: Unable to remove "+subdomain+" from component manager.", e);
        }
        mucServices.remove(subdomain);
    }
    if (allNodes) {
        CacheFactory.doClusterTask(new ServiceRemovedEvent(subdomain));
    }
}
 
Example #2
Source File: JitsiJicofoWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the wrapped component.
 *
 * @throws Exception On any problem.
 */
public synchronized void initializeComponent() throws Exception
{
    Log.debug( "Initializing Jitsi Focus Component (jicofo)...");

    if ( jicofoComponent != null )
    {
        Log.warn( "Another Jitsi Focus Component (jicofo) appears to have been initialized earlier! Unexpected behavior might be the result of this new initialization!" );
    }

    reloadConfiguration();

    final OFMeetConfig config = new OFMeetConfig();

    // Typically, the focus user is a system user (our plugin provisions the user), but if that fails, anonymous authentication will be used.
    final boolean focusAnonymous = config.getFocusPassword() == null;

    // Start the OSGi bundle for Jicofo.
    if ( OSGi.class.getClassLoader() != Thread.currentThread().getContextClassLoader() )
    {
        // the OSGi class should not be present in Openfire itself, or in the parent plugin of these modules. The OSGi implementation does not allow for more than one bundle to be configured/started, which leads to undesired re-used of
        // configuration of one bundle while starting another bundle.
        Log.warn( "The OSGi class is loaded by a class loader different from the one that's loading this module. This suggests that residual configuration is in the OSGi class instance, which is likely to prevent Jicofo from functioning correctly." );
    }
    final OSGiBundleConfig jicofoConfig = new JicofoBundleConfig();
    OSGi.setBundleConfig(jicofoConfig);
    OSGi.setClassLoader( Thread.currentThread().getContextClassLoader() );

    jicofoComponent = new FocusComponent( XMPPServer.getInstance().getServerInfo().getHostname(), 0, XMPPServer.getInstance().getServerInfo().getXMPPDomain(), jicofoSubdomain, null, focusAnonymous, XMPPServer.getInstance().createJID( "focus", null ).toBareJID() );

    Thread.sleep(2000 ); // Intended to prevent ConcurrentModificationExceptions while starting the component. See https://github.com/igniterealtime/ofmeet-openfire-plugin/issues/4
    jicofoComponent.init(); // Note that this is a Jicoco special, not Component#initialize!
    Thread.sleep(2000 ); // Intended to prevent ConcurrentModificationExceptions while starting the component. See https://github.com/igniterealtime/ofmeet-openfire-plugin/issues/4

    ComponentManagerFactory.getComponentManager().addComponent(jicofoSubdomain, jicofoComponent);

    Log.trace( "Successfully initialized Jitsi Focus Component (jicofo).");
}
 
Example #3
Source File: JitsiJicofoWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void destroy()
{
    if ( initThread != null && initThread.isAlive() )
    {
        initThread.interrupt();
        initThread = null;
    }

    ((InternalComponentManager) ComponentManagerFactory.getComponentManager()).removeListener( this );

    try
    {
        Log.debug( "Destroying Jitsi Focus Component..." );

        if ( jicofoComponent == null)
        {
            Log.warn( "Unable to destroy the Jitsi Focus Component, as none appears to be running!" );
        }
        else
        {
            ComponentManagerFactory.getComponentManager().removeComponent(jicofoSubdomain);
            jicofoSubdomain = null;

            jicofoComponent.dispose();
            jicofoComponent = null;
        }

        Log.trace( "Successfully destroyed Jitsi Focus Component. " );
    }
    catch ( Exception ex )
    {
        Log.error( "An exception occurred while trying to destroy the Jitsi Jicofo wrapper.", ex );
    }
}
 
Example #4
Source File: ExternalComponentManager.java    From Whack with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new ExternalComponentManager that will make connections to
 * the specified XMPP server on the given port.
 *
 * @param host the IP address or name of the XMPP server to connect to (e.g. "example.com").
 * @param port the port to connect on.
 */
@Deprecated
public ExternalComponentManager(String host, int port) {
    if (host == null) {
        throw new IllegalArgumentException("Host of XMPP server cannot be null");
    }
    this.host = host;
    this.port = port;

    createDummyLogger();

    // Set this ComponentManager as the current component manager
    ComponentManagerFactory.setComponentManager(this);
}
 
Example #5
Source File: ExternalComponentManager.java    From Whack with Apache License 2.0 5 votes vote down vote up
public ExternalComponentManager(String host, int port, boolean startEncrypted) {
    if (host == null) {
        throw new IllegalArgumentException("Host of XMPP server cannot be null");
    }
    this.host = host;
    this.port = port;
    this.startEncrypted = startEncrypted;

    createDummyLogger();

    // Set this ComponentManager as the current component manager
    ComponentManagerFactory.setComponentManager(this);
}
 
Example #6
Source File: MultiUserChatManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public void registerMultiUserChatService(MultiUserChatService service, boolean allNodes) {
    Log.debug("MultiUserChatManager: Registering MUC service "+service.getServiceName());
    try {
        ComponentManagerFactory.getComponentManager().addComponent(service.getServiceName(), service);
        mucServices.put(service.getServiceName(), service);
    }
    catch (ComponentException e) {
        Log.error("MultiUserChatManager: Unable to add "+service.getServiceName()+" as component.", e);
    }
    if (allNodes) {
        CacheFactory.doClusterTask(new ServiceAddedEvent(service.getServiceName(), service.getDescription(), service.isHidden()));
    }
}
 
Example #7
Source File: JitsiJicofoWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize( final PluginManager pluginManager, final File pluginDirectory )
{
    ((InternalComponentManager) ComponentManagerFactory.getComponentManager()).addListener( this );

    ensureFocusUser();

    // The Jitsi Videobridge component must be fully loaded before focus starts to do service discovery.
    initThread = new Thread() {
        @Override
        public void run()
        {
            boolean running = true;
            while ( running )
            {
                if ( isAcceptingClientConnections() && !jvbComponents.isEmpty() )
                {
                    try
                    {
                        initializeComponent();
                        return;
                    }
                    catch ( Exception e )
                    {
                        Log.error( "An exception occurred while initializing the Jitsi Jicofo wrapper.", e );
                    }
                }

                Log.trace( "Waiting for the server to accept client connections and/or the JVB to become available ..." );
                try
                {
                    Thread.sleep( 500 );
                }
                catch ( InterruptedException e )
                {
                    Log.debug( "Interrupted wait for the server to accept client connections and/or the JVB to become available.", e );
                    running = false;
                }
            }
        }
    };
    initThread.start();
}
 
Example #8
Source File: SipComponent.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public SipComponent() {
    this.componentManager = ComponentManagerFactory.getComponentManager();
    SessionEventDispatcher.addListener(this);
}
 
Example #9
Source File: WeatherComponent.java    From Whack with Apache License 2.0 4 votes vote down vote up
/**
 * Handle the receied packet and answer the weather information of the requested station id.
 * The request must be made using Message packets where the body of the message should be the
 * station id.<p>
 *
 * Note: I don't know the list of valid station ids so if you find the list please send it to me
 * so I can add it to this example.
 *
 * @param packet the Message requesting information about a certain station id.
 */
public void processPacket(Packet packet) {
    System.out.println("Received package:"+packet.toXML());
    // Only process Message packets
    if (packet instanceof Message) {
        // Get the requested station to obtain it's weather information
        Message message = (Message) packet;
        String station = message.getBody();
        // Send the request and get the weather information
        Metar metar = Weather.getMetar(station, 5000);

        // Build the answer
        Message reply = new Message();
        reply.setTo(message.getFrom());
        reply.setFrom(message.getTo());
        reply.setType(message.getType());
        reply.setThread(message.getThread());

        // Append the discovered information if something was found
        if (metar != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("station id : " + metar.getStationID());
            sb.append("\rwind dir   : " + metar.getWindDirection() + " degrees");
            sb.append("\rwind speed : " + metar.getWindSpeedInMPH() + " mph, " +
                                                 metar.getWindSpeedInKnots() + " knots");
            if (!metar.getVisibilityLessThan()) {
                sb.append("\rvisibility : " + metar.getVisibility() + " mile(s)");
            } else {
                sb.append("\rvisibility : < " + metar.getVisibility() + " mile(s)");
            }

            sb.append("\rpressure   : " + metar.getPressure() + " in Hg");
            sb.append("\rtemperaturePrecise: " +
                               metar.getTemperaturePreciseInCelsius() + " C, " +
                               metar.getTemperaturePreciseInFahrenheit() + " F");
            sb.append("\rtemperature: " +
                               metar.getTemperatureInCelsius() + " C, " +
                               metar.getTemperatureInFahrenheit() + " F");
            sb.append("\rtemperatureMostPrecise: " +
                               metar.getTemperatureMostPreciseInCelsius() + " C, " +
                               metar.getTemperatureMostPreciseInFahrenheit() + " F");
            reply.setBody(sb.toString());
        }
        else {
            // Answer that the requested station id does not exist
            reply.setBody("Unknown station ID");
        }

        // Send the response to the sender of the request
        try {
            ComponentManagerFactory.getComponentManager().sendPacket(this, reply);
        } catch (ComponentException e) {
            e.printStackTrace();
        }
    }
}