use of com.orientechnologies.orient.server.plugin.OServerPlugin in project orientdb by orientechnologies.
the class OServer method registerPlugins.
protected void registerPlugins() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
pluginManager = new OServerPluginManager();
pluginManager.config(this);
pluginManager.startup();
if (serverSecurity != null)
serverSecurity.onAfterDynamicPlugins();
// PLUGINS CONFIGURED IN XML
final OServerConfiguration configuration = serverCfg.getConfiguration();
if (configuration.handlers != null) {
// ACTIVATE PLUGINS
final List<OServerPlugin> plugins = new ArrayList<OServerPlugin>();
for (OServerHandlerConfiguration h : configuration.handlers) {
if (h.parameters != null) {
// CHECK IF IT'S ENABLED
boolean enabled = true;
for (OServerParameterConfiguration p : h.parameters) {
if (p.name.equals("enabled")) {
enabled = false;
String value = OSystemVariableResolver.resolveSystemVariables(p.value);
if (value != null) {
value = value.trim();
if ("true".equalsIgnoreCase(value)) {
enabled = true;
break;
}
}
}
}
if (!enabled)
// SKIP IT
continue;
}
final OServerPlugin plugin = (OServerPlugin) loadClass(h.clazz).newInstance();
if (plugin instanceof ODistributedServerManager)
distributedManager = (ODistributedServerManager) plugin;
pluginManager.registerPlugin(new OServerPluginInfo(plugin.getName(), null, null, null, plugin, null, 0, null));
pluginManager.callListenerBeforeConfig(plugin, h.parameters);
plugin.config(this, h.parameters);
pluginManager.callListenerAfterConfig(plugin, h.parameters);
plugins.add(plugin);
}
// START ALL THE CONFIGURED PLUGINS
for (OServerPlugin plugin : plugins) {
pluginManager.callListenerBeforeStartup(plugin);
plugin.startup();
pluginManager.callListenerAfterStartup(plugin);
}
}
}
use of com.orientechnologies.orient.server.plugin.OServerPlugin in project orientdb by orientechnologies.
the class ONetworkProtocolBinary method openDatabase.
protected void openDatabase(OClientConnection connection) throws IOException {
setDataCommandInfo(connection, "Open database");
readConnectionData(connection);
final String dbURL = channel.readString();
String dbType = ODatabaseDocument.TYPE;
if (connection.getData().protocolVersion <= OChannelBinaryProtocol.PROTOCOL_VERSION_32)
// READ DB-TYPE FROM THE CLIENT. NOT USED ANYMORE
dbType = channel.readString();
final String user = channel.readString();
final String passwd = channel.readString();
for (OBeforeDatabaseOpenNetworkEventListener l : listener.getBeforeDatabaseOpenNetworkEventListener()) l.onBeforeDatabaseOpen(dbURL);
try {
connection.setDatabase((ODatabaseDocumentTx) server.openDatabase(dbURL, user, passwd, connection.getData()));
} catch (OException e) {
server.getClientConnectionManager().disconnect(connection);
throw e;
}
byte[] token = null;
if (Boolean.TRUE.equals(connection.getTokenBased())) {
token = server.getTokenHandler().getSignedBinaryToken(connection.getDatabase(), connection.getDatabase().getUser(), connection.getData());
// TODO: do not use the parse split getSignedBinaryToken in two methods.
getServer().getClientConnectionManager().connect(this, connection, token, server.getTokenHandler());
}
if (connection.getDatabase().getStorage() instanceof OStorageProxy && !loadUserFromSchema(connection, user, passwd)) {
sendErrorOrDropConnection(connection, clientTxId, new OSecurityAccessException(connection.getDatabase().getName(), "User or password not valid for database: '" + connection.getDatabase().getName() + "'"));
} else {
beginResponse();
try {
sendOk(connection, clientTxId);
channel.writeInt(connection.getId());
if (connection.getData().protocolVersion > OChannelBinaryProtocol.PROTOCOL_VERSION_26) {
if (Boolean.TRUE.equals(connection.getTokenBased())) {
channel.writeBytes(token);
} else
channel.writeBytes(OCommonConst.EMPTY_BYTE_ARRAY);
}
sendDatabaseInformation(connection);
final OServerPlugin plugin = server.getPlugin("cluster");
ODocument distributedCfg = null;
if (plugin != null && plugin instanceof ODistributedServerManager) {
distributedCfg = ((ODistributedServerManager) plugin).getClusterConfiguration();
final ODistributedConfiguration dbCfg = ((ODistributedServerManager) plugin).getDatabaseConfiguration(connection.getDatabase().getName());
if (dbCfg != null) {
// ENHANCE SERVER CFG WITH DATABASE CFG
distributedCfg.field("database", dbCfg.getDocument(), OType.EMBEDDED);
}
}
channel.writeBytes(distributedCfg != null ? getRecordBytes(connection, distributedCfg) : null);
if (connection.getData().protocolVersion >= 14)
channel.writeString(OConstants.getVersion());
} finally {
endResponse(connection);
}
}
}
use of com.orientechnologies.orient.server.plugin.OServerPlugin in project orientdb by orientechnologies.
the class ONetworkProtocolBinary method distributedCluster.
protected void distributedCluster(OClientConnection connection) throws IOException {
setDataCommandInfo(connection, "Cluster status");
final ODocument req = new ODocument(channel.readBytes());
ODocument response = null;
final String operation = req.field("operation");
if (operation == null)
throw new IllegalArgumentException("Cluster operation is null");
if (operation.equals("status")) {
final OServerPlugin plugin = server.getPlugin("cluster");
if (plugin != null && plugin instanceof ODistributedServerManager)
response = ((ODistributedServerManager) plugin).getClusterConfiguration();
} else
throw new IllegalArgumentException("Cluster operation '" + operation + "' is not supported");
sendResponse(connection, response);
}
Aggregations