@Override protected void annotateClass(Class<?> cl) throws IOException { outputStreamHelper.annotateClass(this, cl); }
@Override protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { Class<?> clazz = inputStreamHelper.resolveClass(this, desc); if( clazz == null ) { try { // First try app class loader clazz = appLoader.loadClass(desc.getName()); } catch (ClassNotFoundException e) { clazz = super.resolveClass(desc); } } return clazz; }
ObjectOutputStream oos = getFactory().createObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); final ObjectInputStream ois = getFactory().createObjectInputStream(bis); obj = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException, ClassNotFoundException {
public void saveAttachment(Serializable data, Job job, String attachmentId) throws IOException { ObjectOutputStream oos = null; FileOutputStream fos = null; CheckpointFilename cf = CheckpointFilename.createAttachment(job, attachmentId); try { fos = new FileOutputStream(cf.getFile()); oos = factory.createObjectOutputStream(fos); oos.writeObject(data); } finally { try {oos.close();} catch (Exception ex) { } try {fos.close();} catch (Exception ex) { } } }
public <T extends Serializable> T loadAttachment(Job job, String attachmentId) throws IOException, ClassNotFoundException { CheckpointFilename cf = CheckpointFilename.createAttachment(job, attachmentId); File file = cf.getFile(); if (!file.exists()) { return null; } ObjectInputStream ois = null; FileInputStream fis = null; try { fis = new FileInputStream(cf.getFile()); ois = factory.createObjectInputStream(fis); return (T) ois.readObject(); } finally { try {ois.close();} catch (Exception ex) { } try {fis.close();} catch (Exception ex) { } } }
try { fos = new FileOutputStream(cf.getFile()); oos = factory.createObjectOutputStream(fos); oos.writeObject(checkpoint); oos.close();
public JobManager.Checkpoint load(CheckpointFilename cf, Outbound outbound) throws IOException, ClassNotFoundException { FileInputStream fis = null; ObjectInputStream ois = null; JobManager.Checkpoint checkpoint; try { fis = new FileInputStream(cf.getFile()); ois = factory.createObjectInputStream(fis); checkpoint = (JobManager.Checkpoint) ois.readObject(); } finally { try {ois.close();} catch (Exception ex) { } try {fis.close();} catch (Exception ex) { } } if (outbound != null) { loadOutbound(outbound, cf.getForPayload(false).getFile()); checkpoint.getContext().setOutboundPayload(outbound); } Inbound inbound = loadInbound(cf.getForPayload(true).getFile()); checkpoint.getContext().setInboundPayload(inbound); try { String username = checkpoint.getJob().getSubjectUsernames().get(0); Subject subject = authenticationService.impersonate(username, /* groups */ null, /* subject */ null, /* virtual */ false); checkpoint.getContext().setSubject(subject); } catch (LoginException e) { throw new RuntimeException(e); } return checkpoint; }