001// Copyright 2007, 2011 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry5.ioc.internal; 016 017import java.io.InvalidObjectException; 018import java.io.ObjectStreamException; 019import java.io.Serializable; 020 021/** 022 * Token that replaces a service proxy when the proxy is serialized. 023 */ 024public class ServiceProxyToken implements Serializable 025{ 026 private static final long serialVersionUID = 4119675138731356650L; 027 028 private final String serviceId; 029 030 public ServiceProxyToken(String serviceId) 031 { 032 this.serviceId = serviceId; 033 } 034 035 Object readResolve() throws ObjectStreamException 036 { 037 try 038 { 039 return SerializationSupport.readResolve(serviceId); 040 } 041 catch (Exception ex) 042 { 043 ObjectStreamException ose = new InvalidObjectException(ex.getMessage()); 044 ose.initCause(ex); 045 046 throw ose; 047 } 048 } 049 050}