001 /*
002 * Copyright 2004 Chris Nelson
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing,
008 * software distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and limitations under the License.
011 */
012 package org.trails.link;
013
014 import org.apache.hivemind.util.Defense;
015 import org.apache.tapestry.annotations.InjectObject;
016 import org.apache.tapestry.annotations.Parameter;
017 import org.apache.tapestry.annotations.ComponentClass;
018 import org.trails.util.Utils;
019 import org.trails.descriptor.DescriptorService;
020 import org.trails.descriptor.IClassDescriptor;
021
022 @ComponentClass
023 public abstract class ModelLink extends TrailsLink
024 {
025
026 @Parameter(required = true)
027 public abstract Object getModel();
028
029 public IClassDescriptor getClassDescriptor()
030 {
031 Defense.notNull(getModel(), "model");
032 return getDescriptorService().getClassDescriptor(Utils.checkForCGLIB(getModel().getClass()));
033 }
034
035 @InjectObject("spring:descriptorService")
036 public abstract DescriptorService getDescriptorService();
037
038 }