/** * @return the default TransientSpace */ public static Space getSpace () { return getSpace (TSPACE, DEFAULT, null); }
public static Space getSpace (String scheme, String name, String param) { Space sp = null; String uri = normalize (scheme, name, param); synchronized (SpaceFactory.class) { try { sp = (Space) NameRegistrar.get (uri); } catch (NameRegistrar.NotFoundException e) { if (SPACELET.equals (scheme) || "rspace".equals(scheme)) throw new SpaceError (uri + " not found."); sp = createSpace (scheme, name, param); NameRegistrar.register (uri, sp); } } if (sp == null) { throw new SpaceError ("Invalid space: " + uri); } return sp; } public static ScheduledThreadPoolExecutor getGCExecutor() {
public TSpace () { super(); entries = new HashMap (); expirables = new Set[] { new HashSet<K>(), new HashSet<K>() }; SpaceFactory.getGCExecutor().scheduleAtFixedRate(this, GCDELAY, GCDELAY, TimeUnit.MILLISECONDS); }
@Test public void testConstructor() throws Throwable { new SpaceFactory(); assertTrue("Test completed without Exception", true); }
private Space grabSpace (Element e) throws ConfigurationException { String uri = e != null ? e.getText() : ""; return SpaceFactory.getSpace (uri); }
public JESpace(String name, String params) throws SpaceError { super(); try { EnvironmentConfig envConfig = new EnvironmentConfig(); StoreConfig storeConfig = new StoreConfig(); String[] p = ISOUtil.commaDecode(params); String path = p[0]; envConfig.setAllowCreate (true); envConfig.setTransactional(true); envConfig.setLockTimeout(getParam("lock.timeout", p, DEFAULT_LOCK_TIMEOUT), TimeUnit.MILLISECONDS); envConfig.setTxnTimeout(getParam("txn.timeout", p, DEFAULT_TXN_TIMEOUT), TimeUnit.MILLISECONDS); storeConfig.setAllowCreate (true); storeConfig.setTransactional (true); File dir = new File(path); dir.mkdirs(); dbe = new Environment (dir, envConfig); store = new EntityStore (dbe, name, storeConfig); pIndex = store.getPrimaryIndex (Long.class, Ref.class); gcpIndex = store.getPrimaryIndex (Long.class, GCRef.class); sIndex = store.getSecondaryIndex (pIndex, String.class, "key"); gcsIndex = store.getSecondaryIndex (gcpIndex, Long.class, "expires"); gcTask = SpaceFactory.getGCExecutor().scheduleAtFixedRate(this, GC_DELAY, GC_DELAY, TimeUnit.MILLISECONDS); } catch (Exception e) { throw new SpaceError (e); } }
@SuppressWarnings("unchecked") private Space<String,Object> grabSpace (Element e) { return (Space<String,Object>) SpaceFactory.getSpace (e != null ? e.getText() : ""); }
public SpaceProxy () throws RemoteException { super(); sp = SpaceFactory.getSpace (); startService (); } public SpaceProxy (String spaceUri) throws RemoteException {
@SuppressWarnings("unchecked") private Space<String, Object> grabSpace(Element e) { return (Space<String, Object>) SpaceFactory.getSpace(e != null ? e.getText() : ""); }
public SpaceProxy (String spaceUri) throws RemoteException { super (); sp = SpaceFactory.getSpace (spaceUri); startService (); }
protected Space grabSpace (Element e) { return SpaceFactory.getSpace (e != null ? e.getText() : ""); } protected void append (StringBuffer sb, String name, int value) {
private void grabSpace (Element e) { sp = SpaceFactory.getSpace (e != null ? e.getText() : ""); } private String getScript (Element e) {
public void setSpace(String uri){ setSpace(SpaceFactory.getSpace(uri)); }
/** * @param spaceUri * @return Space for given URI or null */ public static Space getSpace (String spaceUri) { if (spaceUri == null) return getSpace (); String scheme = null; String name = null; String param = null; StringTokenizer st = new StringTokenizer (spaceUri, ":"); int count = st.countTokens(); if (count == 0) { scheme = TSPACE; name = DEFAULT; } else if (count == 1) { scheme = TSPACE; name = st.nextToken (); } else { scheme = st.nextToken (); name = st.nextToken (); } if (st.hasMoreTokens()) { param = st.nextToken (); } return getSpace (scheme, name, param); } public static Space getSpace (String scheme, String name, String param) {
protected void startService () throws Exception { if (spaceName == null) sp = SpaceFactory.getSpace (); else sp = SpaceFactory.getSpace (spaceName); objectName = new ObjectName (Q2.QBEAN_NAME + getName() + ",space=" + (spaceName != null ? spaceName : "default") ); getServer().getMBeanServer().registerMBean (sp, objectName); }
private LocalSpace grabSpace (Element e) throws ConfigurationException { String uri = e != null ? e.getText() : ""; Space sp = SpaceFactory.getSpace (uri); if (sp instanceof LocalSpace) { return (LocalSpace) sp; } throw new ConfigurationException ("Invalid space " + uri); }
private LocalSpace grabSpace (Element e) throws ConfigurationException { String uri = e != null ? e.getText() : ""; Space sp = SpaceFactory.getSpace (uri); if (sp instanceof LocalSpace) { return (LocalSpace) sp; } throw new ConfigurationException ("Invalid space " + uri); }
protected Element getSchema (String prefix, String suffix, String defSuffix) throws JDOMException, IOException { StringBuilder sb = new StringBuilder (basePath); sb.append (prefix); prefix = sb.toString(); // little hack, we'll reuse later with defSuffix sb.append (suffix); sb.append (".xml"); String uri = sb.toString (); Space sp = SpaceFactory.getSpace(); Element schema = (Element) sp.rdp (uri); if (schema == null) { schema = loadSchema(uri, defSuffix == null); if (schema == null && defSuffix != null) { sb = new StringBuilder (prefix); sb.append (defSuffix); sb.append (".xml"); schema = loadSchema(sb.toString(), true); } sp.out (uri, schema); } return schema; }
@Override protected void initService() throws GeneralSecurityException, IOException { sp = SpaceFactory.getSpace(); final SSLContext sslContext = enableTLS ? getSSLContext() : null; bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); serverBootstrap = new ServerBootstrap(); serverBootstrap .group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { int timeout = cfg.getInt("timeout", 300); ch.pipeline().addLast(new IdleStateHandler(timeout,timeout,timeout)); if (enableTLS) { ch.pipeline().addLast(new SslHandler(getSSLEngine(sslContext), true)); } ch.pipeline().addLast(new HttpServerCodec()) ; ch.pipeline().addLast(new HttpObjectAggregator(512*1024)); ch.pipeline().addLast(new RestSession(RestServer.this)); } }) .option(ChannelOption.SO_BACKLOG, 128) .option(ChannelOption.SO_REUSEADDR, true) .childOption(ChannelOption.SO_KEEPALIVE, true); if (enableTLS) { logSSLEngineInfo(getSSLEngine(sslContext)); } }
@Test(expected = NullPointerException.class) public void testGetSpaceThrowsNullPointerException2() throws Throwable { SpaceFactory.getSpace("testSpaceFactoryScheme", "testSpaceFactoryName", null); }