Java Code Examples for org.apache.wicket.Application#getMetaData()

The following examples show how to use org.apache.wicket.Application#getMetaData() . 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: SimpleWebSocketConnectionRegistry.java    From onedev with MIT License 6 votes vote down vote up
@Override
public IWebSocketConnection getConnection(Application application, String sessionId, IKey key)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");
	Args.notNull(key, "key");

	IWebSocketConnection connection = null;
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage != null)
		{
			connection = connectionsByPage.get(key);
		}
	}
	return connection;
}
 
Example 2
Source File: SimpleWebSocketConnectionRegistry.java    From onedev with MIT License 6 votes vote down vote up
@Override
public Collection<IWebSocketConnection> getConnections(Application application, String sessionId)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");

	Collection<IWebSocketConnection> connections = Collections.emptyList();
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage != null)
		{
			connections = connectionsByPage.values();
		}
	}
	return connections;
}
 
Example 3
Source File: SimpleWebSocketConnectionRegistry.java    From onedev with MIT License 6 votes vote down vote up
/**
 * Returns a collection of currently active websockets. The connections might close at any time.
 *
 * @param application
 *          The application
 * @return a collection of currently active websockets
 */
public Collection<IWebSocketConnection> getConnections(Application application)
{
	Args.notNull(application, "application");

	Collection<IWebSocketConnection> connections = new ArrayList<>();
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		for (ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage : connectionsBySession.values())
		{
			connections.addAll(connectionsByPage.values());
		}
	}
	return connections;
}
 
Example 4
Source File: SimpleWebSocketConnectionRegistry.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void setConnection(Application application, String sessionId, IKey key, IWebSocketConnection connection)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");
	Args.notNull(key, "key");

	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession == null)
	{
		synchronized (KEY)
		{
			connectionsBySession = application.getMetaData(KEY);
			if (connectionsBySession == null)
			{
				connectionsBySession = Generics.newConcurrentHashMap();
				application.setMetaData(KEY, connectionsBySession);
			}
		}
	}

	ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
	if (connectionsByPage == null && connection != null)
	{
		connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage == null)
		{
			connectionsByPage = Generics.newConcurrentHashMap();
			ConcurrentMap<IKey, IWebSocketConnection> old = connectionsBySession.putIfAbsent(sessionId, connectionsByPage);
			if (old != null)
			{
				connectionsByPage = old;
			}
		}
	}

	if (connection != null)
	{
		connectionsByPage.put(key, connection);
	}
	else if (connectionsByPage != null)
	{
		connectionsByPage.remove(key);
		if (connectionsByPage.isEmpty())
		{
			connectionsBySession.remove(sessionId);
		}
	}
}
 
Example 5
Source File: SassCacheManager.java    From webanno with Apache License 2.0 2 votes vote down vote up
/**
 * @param application
 *            the application that keeps the cache manage
 * @return The registered instance of this manager during the start up of the application
 */
private static SassCacheManager get(Application application)
{
    return application.getMetaData(KEY);
}