use of com.orientechnologies.orient.server.config.OServerHookConfiguration in project orientdb by orientechnologies.
the class OConfigurableHooksManager method onOpen.
public void onOpen(ODatabaseInternal iDatabase) {
if (!iDatabase.getStorage().isRemote()) {
final ODatabase<?> db = (ODatabase<?>) iDatabase;
for (OServerHookConfiguration hook : configuredHooks) {
try {
final ORecordHook.HOOK_POSITION pos = ORecordHook.HOOK_POSITION.valueOf(hook.position);
final ORecordHook h = (ORecordHook) Class.forName(hook.clazz).newInstance();
if (hook.parameters != null && hook.parameters.length > 0)
try {
final Method m = h.getClass().getDeclaredMethod("config", new Class[] { OServerParameterConfiguration[].class });
m.invoke(h, new Object[] { hook.parameters });
} catch (Exception e) {
OLogManager.instance().warn(this, "[configure] Failed to configure hook '%s'. Parameters specified but hook don support parameters. Should have a method config with parameters OServerParameterConfiguration[] ", hook.clazz);
}
db.registerHook(h, pos);
} catch (Exception e) {
OLogManager.instance().error(this, "[configure] Failed to configure hook '%s' due to the an error : ", e, hook.clazz, e.getMessage());
}
}
}
}
use of com.orientechnologies.orient.server.config.OServerHookConfiguration in project orientdb by orientechnologies.
the class HookInstallServerTest method before.
@Before
public void before() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ClassNotFoundException, NullPointerException, IOException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
server = new OServer();
OServerConfigurationManager ret = new OServerConfigurationManager(this.getClass().getClassLoader().getResourceAsStream("com/orientechnologies/orient/server/network/orientdb-server-config.xml"));
OServerHookConfiguration hc = new OServerHookConfiguration();
hc.clazz = MyHook.class.getName();
ret.getConfiguration().hooks = new ArrayList<OServerHookConfiguration>();
ret.getConfiguration().hooks.add(hc);
server.startup(ret.getConfiguration());
server.activate();
OServerAdmin admin = new OServerAdmin("remote:localhost");
admin.connect("root", "D2AFD02F20640EC8B7A5140F34FCA49D2289DB1F0D0598BB9DE8AAA75A0792F3");
admin.createDatabase("test", "nothign", "memory");
admin.close();
}
Aggregations