public static MVault loadDefault() { MVault vault = MApi.lookup(MVault.class); checkDefault(vault); return vault; }
public MCount() { cnt = 0; name = "Counter " + MApi.lookup(UniqueId.class).nextUniqueId(); }
@Override public synchronized Log lookupLog(Object owner) { if (mlogFactory == null) mlogFactory = MApi.lookup(MLogFactory.class); return mlogFactory.lookup(owner); }
/** * Try to adapt the entry to the given class or interface. * @param entry * @param ifc * @return The requested interface or class. * @throws NotSupportedException Thrown if the entry can't be adapted to the interface. * @throws ParseException */ public static <T> T adaptTo(VaultEntry entry, Class<? extends T> ifc) throws ParseException, NotSupportedException { // delegate to service return MApi.lookup(VaultMutator.class).adaptTo(entry, ifc); }
public static MNlsBundle lookup(Object owner) { MNlsBundleFactory factory = MApi.lookup(MNlsBundleFactory.class); MNlsBundle nlsBundle = factory.create(owner); return nlsBundle; }
public MThreadPool start() { tc = MApi.lookup(MThreadPoolManager.class).start(this, name); return this; }
/** * <p>Constructor for JdbcConnection.</p> * * @param provider a {@link de.mhus.lib.sql.DbProvider} object. * @param con a {@link java.sql.Connection} object. */ public JdbcConnection(DbProvider provider,Connection con) { this.provider=provider; this.connection = con; id = MApi.lookup(UniqueId.class).nextUniqueId(); }
/** * Create a array of 'size' with random content. * @param size * @return random content */ public static byte[] createRandom(int size) { byte[] out = new byte[size]; MRandom rnd = MApi.lookup(MRandom.class); for (int i = 0; i < out.length; i++) out[i] = rnd.getByte(); return out; }
@Override public synchronized Log lookupLog(Object owner) { if (mlogFactory == null) mlogFactory = MApi.lookup(MLogFactory.class); return mlogFactory.lookup(owner); }
public static void checkDefault(MVault vault) { VaultSource def = vault.getSource(MVault.SOURCE_DEFAULT); if (def == null) { VaultPassphrase vaultPassphrase = MApi.lookup(VaultPassphrase.class); VaultSourceFactory factory = MApi.lookup(VaultSourceFactory.class); def = factory.create(MVault.SOURCE_DEFAULT, vaultPassphrase); if (def != null) vault.registerSource(def); } }
/** * Set a DbProvider for this pool. * * @param provider */ protected void setProvider(DbProvider provider) { this.provider = provider; name = provider.getName(); if (name == null) name = "pool"; name = name + MApi.lookup(UniqueId.class).nextUniqueId(); }
public void init() throws Exception { ResourceNode<?> config = MApi.lookup(CfgManager.class).getCfg(this, null); init(config); }
/** * Create a new Bundle from configuration. * * @param config Config element or null. null will use the central MApi configuration. * @param activator Activator or null. null will use the central MApi activator. */ public DbPoolBundle(IConfig config, MActivator activator) { if (config == null) config = MApi.get().getCfgManager().getCfg(DbPoolBundle.class, null); if (activator == null) activator = MApi.lookup(MActivator.class); this.config = config; this.activator = activator; }
@Override public Message received(Message msg) throws JMSException { String txt = ""; if (msg instanceof TextMessage) txt =((TextMessage)msg).getText(); log().d("received",txt); HeartbeatListener listener = MApi.lookup(HeartbeatListener.class); if (listener != null) listener.heartbeatReceived(txt); TextMessage ret = getSession().createTextMessage(MSystem.getAppIdent()); return ret; }
/** * Create a random block using the MRandom service. * * @param size * @return CipherBlockRotate */ public static CipherBlockRotate createRandomCipherBlockRotate(int size) { CipherBlockRotate out = new CipherBlockRotate(size); byte[] b = out.getBlock(); for (int i = 0; i < b.length; i++) b[i] = MApi.lookup(MRandom.class).getByte(); return out; }
public FileWatch doStart() { if (started) return this; started = true; // do not need sync... if (!file.exists()) log().w("file not found",file); if (startHook) checkFile(); // init if (!registered) { MHousekeeper housekeeper = MApi.lookup(MHousekeeper.class); housekeeper.register(this, period); registered = true; } return this; }
protected void jmxRegister(boolean weak,String name) { if (!isJmxRegistered()) { try { setJmxName(name); MApi.lookup(MRemoteManager.class).register(this,weak); } catch (Throwable e) { log().t(e); } } } }
public MysqlDbProvider(String url, String user, String pass) { config = new NodeConfig(); config.setProperty("driver", "com.mysql.jdbc.Driver"); config.setProperty("url", url ); config.setProperty("user", user); config.setProperty("pass", pass); config.setProperty("name", url); activator = MApi.lookup(MActivator.class); }
@Override public void register(MHousekeeperTask task, long sleep, boolean weak) { log().d("register",task,sleep,weak); TimerIfc timer = MApi.lookup(TimerIfc.class); if (weak) { WeakObserver t = new WeakObserver(task); IntervalJob job = new IntervalJob(sleep, t); t.setJob(job); timer.schedule(job); } else timer.schedule(new IntervalJob(sleep, task)); }