Example usage for java.lang Object Object

List of usage examples for java.lang Object Object

Introduction

In this page you can find the example usage for java.lang Object Object.

Prototype

@HotSpotIntrinsicCandidate
public Object() 

Source Link

Document

Constructs a new object.

Usage

From source file:FileBaseDataMap.java

/**
 * .<br>/*from ww w .j a v a2s.  c  om*/
 *
 * @param baseDirs
 * @param numberOfKeyData
 * @return 
 * @throws
 */
public FileBaseDataMap(String[] baseDirs, int numberOfKeyData) {
    this.dirs = baseDirs;
    this.numberOfCoreMap = baseDirs.length;
    this.coreFileBaseKeyMaps = new CoreFileBaseKeyMap[baseDirs.length];
    this.syncObjs = new Object[baseDirs.length];
    int oneCacheSizePer = innerCacheSizeTotal / numberOfCoreMap;
    int oneMapSizePer = numberOfKeyData / numberOfCoreMap;

    for (int idx = 0; idx < baseDirs.length; idx++) {
        syncObjs[idx] = new Object();
        String[] dir = { baseDirs[idx] };
        this.coreFileBaseKeyMaps[idx] = new CoreFileBaseKeyMap(dir, oneCacheSizePer, oneMapSizePer);
    }
}

From source file:com.lucidtechnics.blackboard.Launcher.java

public void launch() {
    final Blackboard blackboard = new Blackboard();

    java.io.File currentDirectory = new java.io.File(".");
    TargetSpace targetSpace = new TargetSpaceImpl();
    targetSpace.setBlackboard(blackboard);

    logger.info("the current directory is: " + currentDirectory.getName());
    java.io.File[] generatorArray = currentDirectory.listFiles();

    for (int i = 0; i < generatorArray.length; i++) {
        com.lucidtechnics.blackboard.Plan plan = null;

        if (generatorArray[i].isDirectory() == false
                && generatorArray[i].getName().endsWith("blackboard.configuration.js") == false) {
            if (generatorArray[i].isDirectory() == false
                    && generatorArray[i].getName().endsWith(".js") == true) {
                logger.info("Executing generator: " + generatorArray[i].getName());

                plan = new JavaScriptPlan();
            } else if (generatorArray[i].isDirectory() == false
                    && generatorArray[i].getName().contains("blackboard.configuration") == false) {
                String[] tokenArray = generatorArray[i].getName().split("\\.");
                String extension = tokenArray[tokenArray.length - 1];

                if (Jsr223Plan.hasScriptingEngine(extension) == true) {
                    logger.info("Executing generator: " + generatorArray[i].getName());
                    plan = new Jsr223Plan(extension);
                }/*  w w  w .j a v a 2s  . com*/
            }

            if (plan != null) {
                plan.setName(generatorArray[i].getName());
                plan.setPath(generatorArray[i].getAbsolutePath());
                plan.execute(new com.lucidtechnics.blackboard.WorkspaceContext(targetSpace, plan));
            }
        }
    }

    logger.info("Driver execution is completed. Plans may still be processing.");

    Object object = new Object();

    synchronized (object) {
        try {
            object.wait();
        } catch (InterruptedException e) {
        }
    }
}

From source file:shiver.me.timbers.spring.security.jwt.AuthenticationRequestJwtTokenParserTest.java

@Test
@SuppressWarnings("unchecked")
public void Can_parse_a_jwt_token_from_a_cookie() throws JwtInvalidTokenException {

    final HttpServletRequest request = mock(HttpServletRequest.class);

    final Cookie cookie = mock(Cookie.class);
    final String token = someString();
    final Object principal = new Object();
    final Authentication expected = mock(Authentication.class);

    // Given//from   www .  ja  v  a  2s  .  c  o m
    given(request.getCookies()).willReturn(new Cookie[] { mock(Cookie.class), cookie, mock(Cookie.class) });
    given(cookie.getName()).willReturn(tokenName);
    given(cookie.getValue()).willReturn(token);
    given(principleTokenParser.parse(token)).willReturn(principal);
    given(authenticationConverter.convert(principal)).willReturn(expected);

    // When
    final Authentication actual = tokenParser.parse(request);

    // Then
    assertThat(actual, is(expected));
}

From source file:org.deviceconnect.message.http.event.HttpEventManager.java

/**
 * ???private.
 */
private HttpEventManager() {
    mLock = new Object();
    mStatus = Status.CLOSE;
}

From source file:com.nestlabs.sdk.MetadataTest.java

@Test
public void testEquals_shouldReturnFalseWithNonMetadata() {
    Object o = new Object();
    Metadata metadata = new Metadata();
    assertFalse(metadata.equals(o));/*from w  ww  .ja  v a 2s.  co m*/
}

From source file:com.redhat.red.build.koji.http.httpclient4.ObjectResponseHandler.java

@Override
public T handleResponse(final HttpResponse resp) throws IOException {
    Logger logger = LoggerFactory.getLogger(getClass());
    final StatusLine status = resp.getStatusLine();
    logger.debug(status.toString());//  ww w .  ja v  a 2s .c om
    if (status.getStatusCode() > 199 && status.getStatusCode() < 203) {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copy(resp.getEntity().getContent(), baos);

        if (logger.isTraceEnabled()) {
            File recording = null;
            FileOutputStream stream = null;
            try {
                recording = File.createTempFile("xml-rpc.response.", ".xml");
                stream = new FileOutputStream(recording);
                stream.write(baos.toByteArray());
            } catch (final IOException e) {
                logger.debug("Failed to record xml-rpc response to file.", e);
                // this is an auxilliary function. ignore errors.
            } finally {
                IOUtils.closeQuietly(stream);
                logger.info("\n\n\nRecorded response to: {}\n\n\n", recording);
            }
        }

        try {
            logger.trace("Got response: \n\n{}", new Object() {
                @Override
                public String toString() {
                    try {
                        return new String(baos.toByteArray(), "UTF-8");
                    } catch (final UnsupportedEncodingException e) {
                        return new String(baos.toByteArray());
                    }
                }
            });

            return new RWXMapper().parse(new ByteArrayInputStream(baos.toByteArray()), responseType);
        } catch (final XmlRpcException e) {
            error = e;
            return null;
        }
    } else {
        error = new XmlRpcException("Invalid response status: '" + status + "'.");
        return null;
    }
}

From source file:com.sap.core.odata.core.debug.DebugInfoBodyTest.java

@Test(expected = ClassCastException.class)
public void jsonUnsupportedContent() throws Exception {
    ODataResponse response = mock(ODataResponse.class);
    when(response.getEntity()).thenReturn(new Object());
    when(response.getContentHeader()).thenReturn(HttpContentType.APPLICATION_OCTET_STREAM);

    appendJson(response);/*from w  w w.ja  v a2  s .  co m*/
}

From source file:com.github.brandtg.switchboard.FileLogAggregator.java

/**
 * An agent that aggregates logs from multiple sources and multiplexes them.
 *
 * @param sources//w ww.j a  va  2s.  c o  m
 *  A set of source switchboard servers from which to pull logs
 * @param separator
 *  The line delimiter (after this is reached, lines will be output to outputStream)
 * @param outputStream
 *  OutputStream to which all multiplexed logs are piped
 */
public FileLogAggregator(Set<InetSocketAddress> sources, char separator, OutputStream outputStream)
        throws IOException {
    this.separator = separator;
    this.outputStream = outputStream;
    this.isShutdown = new AtomicBoolean(true);
    this.eventExecutors = new NioEventLoopGroup();
    this.logReceivers = new HashMap<>();
    this.inputStreams = new HashMap<>();
    this.listener = new Object();
    this.muxExecutor = Executors.newSingleThreadExecutor();
    this.stringBuffers = new HashMap<>();

    for (InetSocketAddress source : sources) {
        PipedOutputStream pos = new PipedOutputStream();
        PipedInputStream pis = new PipedInputStream(pos);
        LogReceiver logReceiver = new LogReceiver(new InetSocketAddress(0), eventExecutors, pos);
        logReceiver.registerListener(listener);
        logReceivers.put(source, logReceiver);
        inputStreams.put(source, pis);
        stringBuffers.put(source, new StringBuffer());
    }
}

From source file:edu.illinois.enforcemop.examples.apache.pool.TestKeyedObjectPool.java

public void testClosedPoolBehavior() throws Exception {
    final KeyedObjectPool pool;
    try {//ww  w  . j av a  2  s . co  m
        pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() {
            public Object makeObject(final Object key) throws Exception {
                return new Object();
            }
        });
    } catch (UnsupportedOperationException uoe) {
        return; // test not supported
    }

    Object o1 = pool.borrowObject(KEY);
    Object o2 = pool.borrowObject(KEY);

    pool.close();

    try {
        pool.addObject(KEY);
        fail("A closed pool must throw an IllegalStateException when addObject is called.");
    } catch (IllegalStateException ise) {
        // expected
    }

    try {
        pool.borrowObject(KEY);
        fail("A closed pool must throw an IllegalStateException when borrowObject is called.");
    } catch (IllegalStateException ise) {
        // expected
    }

    // The following should not throw exceptions just because the pool is closed.
    assertEquals("A closed pool shouldn't have any idle objects.", 0, pool.getNumIdle(KEY));
    assertEquals("A closed pool shouldn't have any idle objects.", 0, pool.getNumIdle());
    pool.getNumActive();
    pool.getNumActive(KEY);
    pool.returnObject(KEY, o1);
    assertEquals("returnObject should not add items back into the idle object pool for a closed pool.", 0,
            pool.getNumIdle(KEY));
    assertEquals("returnObject should not add items back into the idle object pool for a closed pool.", 0,
            pool.getNumIdle());
    pool.invalidateObject(KEY, o2);
    pool.clear(KEY);
    pool.clear();
    pool.close();
}

From source file:org.apache.mina.springrpc.DefaultMinaRequestExecutorTest.java

@Test
public void executeRequest() throws Exception {
    ReturnAddress returnAddress = new UniqueStringReturnAddress();
    Object value = new Object();
    ReturnAddressAwareRemoteInvocationResult expected = new ReturnAddressAwareRemoteInvocationResult(
            returnAddress, value);/* w w  w .  j  a va2 s.co m*/

    MinaClientConfiguration configuration = new StaticConfiguration();
    IoConnector connector = EasyMock.createMock(IoConnector.class);
    connector.setHandler((IoHandler) EasyMock.anyObject());
    EasyMock.expectLastCall().asStub();

    ResultReceiver resultReceiver = EasyMock.createMock(ResultReceiver.class);
    resultReceiver.interrupt();
    EasyMock.expectLastCall().asStub();

    ConnectFuture connectFuture = EasyMock.createMock(ConnectFuture.class);
    InetSocketAddress socketAddress = new InetSocketAddress(configuration.getHostName(),
            configuration.getPort());
    EasyMock.expect(connector.connect(socketAddress)).andReturn(connectFuture);
    EasyMock.expect(connectFuture.awaitUninterruptibly()).andReturn(connectFuture);
    IoSession session = EasyMock.createMock(IoSession.class);
    EasyMock.expect(connectFuture.getSession()).andReturn(session);

    RemoteInvocation decorated = RemoteInvocationFactory.createHashCodeRemoteInvocation();
    ReturnAddressAwareRemoteInvocation invocation = new ReturnAddressAwareRemoteInvocation(returnAddress,
            decorated);
    WriteFuture writeFuture = EasyMock.createMock(WriteFuture.class);
    EasyMock.expect(session.write(invocation)).andReturn(writeFuture);
    //      EasyMock.expect(writeFuture.awaitUninterruptibly()).andReturn(writeFuture);

    resultReceiver.resultReceived(expected);
    EasyMock.expectLastCall().asStub();
    EasyMock.expect(resultReceiver.takeResult(returnAddress)).andReturn(expected);

    CloseFuture closeFuture = EasyMock.createMock(CloseFuture.class);
    EasyMock.expect(session.close(true)).andReturn(closeFuture);
    //      EasyMock.expect(closeFuture.awaitUninterruptibly()).andReturn(closeFuture);
    connector.dispose();
    EasyMock.expectLastCall().asStub();

    Object[] mocks = new Object[] { connector, connectFuture, session, writeFuture, resultReceiver,
            closeFuture };

    EasyMock.replay(mocks);

    MinaRequestExecutor executor = new DefaultMinaRequestExecutor();
    executor.setMinaClientConfiguration(configuration);
    executor.setConnector(connector);
    executor.setResultReceiver(resultReceiver);
    executor.afterPropertiesSet();
    ReturnAddressAwareRemoteInvocationResult result = executor.executeRequest(invocation);
    assertEquals(expected, result);
    executor.destroy();

    EasyMock.verify(mocks);
}