protected Object switchObjectContext()

in src/java/org/apache/fulcrum/factory/DefaultFactoryService.java [353:394]


	protected Object switchObjectContext(Object object, ClassLoader loader) 
	{
		ByteArrayOutputStream bout = new ByteArrayOutputStream();

		try 
		{
			ObjectOutputStream out = new ObjectOutputStream(bout);
			out.writeObject(object);
			out.flush();
		} 
		catch (IOException x) 
		{
			return object;
		}

		ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
		ObjectInputStreamForContext in = null;

		try 
		{
			in = new ObjectInputStreamForContext(bin, loader);
			return in.readObject();
		} 
		catch (Exception x) 
		{
			return object;
		} 
		finally 
		{
			if (in != null) 
			{
				try 
				{
					in.close();
				} 
				catch (IOException e) 
				{
					// close quietly
				}
			}
		}
	}