List of usage examples for java.io ObjectOutput writeObject
public void writeObject(Object obj) throws IOException;
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.WebApplicationContext.java
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException { out.writeObject(getContextPath()); out.writeObject(getVirtualHosts());//from w w w . j ava2 s .c om HttpHandler[] handlers = getHandlers(); for (int i = 0; i < handlers.length; i++) { if (handlers[i] instanceof WebApplicationHandler) break; out.writeObject(handlers[i]); } out.writeObject(getAttributes()); out.writeBoolean(isRedirectNullPath()); out.writeInt(getMaxCachedFileSize()); out.writeInt(getMaxCacheSize()); out.writeBoolean(getStatsOn()); out.writeObject(getPermissions()); out.writeBoolean(isClassLoaderJava2Compliant()); out.writeObject(_defaultsDescriptor); out.writeObject(_war); out.writeBoolean(_extract); out.writeBoolean(_ignorewebjetty); out.writeBoolean(_distributable); out.writeObject(_configurationClassNames); }
From source file:org.nuxeo.ecm.platform.ui.web.component.list.StampState.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(rows.size());//from w ww . j ava 2 s . c o m if (rows.isEmpty()) { return; } Map<DualKey, Object> map = new HashMap<DualKey, Object>(rows.size()); map.putAll(rows); if (log.isDebugEnabled()) { for (Map.Entry<DualKey, Object> entry : map.entrySet()) { log.debug("Saving " + entry.getKey() + ", " + entry.getValue()); } } out.writeObject(map); }
From source file:com.linkedin.pinot.common.utils.DataTableBuilder.java
/** * * @param value//w w w . jav a 2 s . co m * @return */ private byte[] serializeObject(Object value) { byte[] bytes; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { try { out = new ObjectOutputStream(bos); out.writeObject(value); } catch (IOException e) { LOGGER.error("Caught exception", e); Utils.rethrowException(e); } bytes = bos.toByteArray(); } finally { IOUtils.closeQuietly((Closeable) out); IOUtils.closeQuietly(bos); } return bytes; }
From source file:qauth.djd.qauthclient.main.ContentFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments();// w w w. j a va2 s.c o m if (args.getCharSequence(KEY_TITLE).toString().equals("Providers")) { View rootView = inflater.inflate(R.layout.providers_view_frag, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mLayoutManager = new LinearLayoutManager(getActivity()); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState .getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); pAdapter = new ProviderAdapter(pDataset); mRecyclerView.setAdapter(pAdapter); final PackageManager pm = getActivity().getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : packages) { //Log.i(TAG, "Installed package :" + packageInfo.packageName); //Log.i(TAG, "Source dir : " + packageInfo.sourceDir); //Log.i(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)); if (packageInfo.packageName.equals("qauth.djd.dummyclient")) { Provider provider = new Provider("DummyClient", packageInfo.packageName); pDataset.add(provider); pAdapter.notifyDataSetChanged(); } } //get local package names and cross reference with providers on server ("/provider/available") //display package names in listview //allow user to click on item to activate or deactivate // '-> have check box with progress bar indicating status return rootView; } else { View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mLayoutManager = new LinearLayoutManager(getActivity()); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState .getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); wAdapter = new WatchAdapter(wDataset); mRecyclerView.setAdapter(wAdapter); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.attachToRecyclerView(mRecyclerView); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("test", "clicked!"); AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); builderSingle.setIcon(R.drawable.ic_launcher); builderSingle.setTitle("Select Bluetooth Device"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_singlechoice); new Thread(new Runnable() { public void run() { for (String s : getNodes()) { arrayAdapter.add(s); } } }).start(); builderSingle.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String nodeId = arrayAdapter.getItem(which); String privKey = null; String pubKey = null; try { SecureRandom random = new SecureRandom(); RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(1024, RSAKeyGenParameterSpec.F4); KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "SC"); generator.initialize(spec, random); KeyPair pair = generator.generateKeyPair(); privKey = Base64.encodeToString(pair.getPrivate().getEncoded(), Base64.DEFAULT); pubKey = Base64.encodeToString(pair.getPublic().getEncoded(), Base64.DEFAULT); } catch (Exception e) { Log.i("generate", "error: " + e); } //Log.i("keys", "priv key : " + privKey); //String privKey = Base64.encodeToString(MainTabsActivity.privKey.getEncoded(), Base64.DEFAULT); //String pubKey = Base64.encodeToString(MainTabsActivity.pubKey.getEncoded(), Base64.DEFAULT); Keys keys = new Keys(privKey, pubKey); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); } catch (Exception e) { } try { out.writeObject(keys); } catch (Exception e) { } byte b[] = bos.toByteArray(); try { out.close(); } catch (Exception e) { } try { bos.close(); } catch (Exception e) { } Wearable.MessageApi.sendMessage(mGoogleApiClient, nodeId, "REGISTER", b) .setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() { @Override public void onResult(MessageApi.SendMessageResult sendMessageResult) { if (!sendMessageResult.getStatus().isSuccess()) { Log.i("MessageApi", "Failed to send message with status code: " + sendMessageResult.getStatus().getStatusCode()); } else if (sendMessageResult.getStatus().isSuccess()) { Log.i("MessageApi", "onResult successful!"); } } }); } }); builderSingle.show(); } }); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addConnectionCallbacks(this) .addOnConnectionFailedListener( new com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(ConnectionResult result) { Log.i("mGoogleApiClient", "onConnectionFailed: " + result); } }) // Request access only to the Wearable API .addApi(Wearable.API).build(); mGoogleApiClient.connect(); /*BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices(); for(BluetoothDevice bt : pairedDevices) Log.i("BluetoothDevice", "pairedDevice: " + bt.toString());*/ return rootView; } }
From source file:ddf.catalog.cache.impl.FileSystemPersistenceProvider.java
@Override public void store(String key, Object value) { OutputStream file = null;/*from ww w.j a v a 2 s.co m*/ ObjectOutput output = null; LOGGER.trace("Entering: store - key: {}", key); try { File dir = new File(getMapStorePath()); if (!dir.exists()) { boolean success = dir.mkdir(); if (!success) { LOGGER.error("Could not make directory: {}", dir.getAbsolutePath()); } } LOGGER.debug("file name: {}{}{}", getMapStorePath(), key, SER); file = new FileOutputStream(getMapStoreFile(key)); OutputStream buffer = new BufferedOutputStream(file); output = new ObjectOutputStream(buffer); output.writeObject(value); } catch (IOException e) { LOGGER.info("IOException storing value in cache with key = {}", key, e); } finally { try { if (output != null) { output.close(); } } catch (IOException e) { // Intentionally ignored } IOUtils.closeQuietly(file); } LOGGER.trace("Exiting: store"); }
From source file:org.apache.shindig.gadgets.http.HttpResponse.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(httpStatusCode);/*from www .j a v a 2 s . c om*/ // Write out multimap as a map (see above) Map<String, List<String>> map = Maps.newHashMap(); for (String key : headers.keySet()) { map.put(key, Lists.newArrayList(headers.get(key))); } out.writeObject(Maps.newHashMap(map)); out.writeInt(responseBytes.length); out.write(responseBytes); }
From source file:com.inmobi.grill.driver.hive.HiveDriver.java
@Override public void writeExternal(ObjectOutput out) throws IOException { // Write the query handle to hive handle map to output synchronized (hiveHandles) { out.writeInt(hiveHandles.size()); for (Map.Entry<QueryHandle, OperationHandle> entry : hiveHandles.entrySet()) { out.writeObject(entry.getKey()); out.writeObject(entry.getValue().toTOperationHandle()); LOG.debug("Hive driver persisted " + entry.getKey() + ":" + entry.getValue()); }/* w w w . j a va 2 s. c om*/ LOG.info("HiveDriver persisted " + hiveHandles.size() + " queries"); out.writeInt(grillToHiveSession.size()); for (Map.Entry<String, SessionHandle> entry : grillToHiveSession.entrySet()) { out.writeUTF(entry.getKey()); out.writeObject(entry.getValue().toTSessionHandle()); } LOG.info("HiveDriver persisted " + grillToHiveSession.size() + " sessions"); } }
From source file:ArraySet.java
public final void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(listTable.length);/*from w w w.j av a 2 s . co m*/ out.writeInt(size); for (int i = 0; i < size; i++) { out.writeObject(listTable[i].key); out.writeObject(listTable[i].value); } }
From source file:com.linkedin.pinot.common.utils.DataTable.java
/** * * @param value/*from ww w. ja v a 2 s.co m*/ * @return */ private byte[] serializeObject(Object value) { long start = System.nanoTime(); byte[] bytes; final ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { try { out = new ObjectOutputStream(bos); out.writeObject(value); } catch (final IOException e) { LOGGER.error("Caught exception", e); Utils.rethrowException(e); } bytes = bos.toByteArray(); } finally { IOUtils.closeQuietly((Closeable) out); IOUtils.closeQuietly(bos); } long end = System.nanoTime(); return bytes; }
From source file:com.splicemachine.derby.impl.sql.execute.operations.SpliceBaseOperation.java
@Override public void writeExternal(ObjectOutput out) throws IOException { SpliceLogUtils.trace(LOG, "writeExternal"); out.writeDouble(optimizerEstimatedCost); out.writeDouble(optimizerEstimatedRowCount); out.writeObject(operationInformation); out.writeBoolean(isTopResultSet);/*from w ww .j a v a2 s .co m*/ }