001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 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 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.ecm.webengine.jaxrs.servlet.config; 020 021import org.nuxeo.ecm.webengine.jaxrs.ApplicationManager; 022import org.nuxeo.ecm.webengine.jaxrs.views.BundleResource; 023import org.nuxeo.common.xmap.annotation.XNode; 024import org.nuxeo.common.xmap.annotation.XObject; 025import org.osgi.framework.Bundle; 026 027/** 028 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 029 */ 030@XObject("resource") 031public class ResourceExtension { 032 033 private Bundle bundle; 034 035 @XNode("@class") 036 protected Class<? extends BundleResource> clazz; 037 038 @XNode("@target") 039 protected String target; 040 041 @XNode("@segment") 042 protected String segment; 043 044 @XNode("@application") 045 protected String application = ApplicationManager.DEFAULT_HOST; 046 047 public ResourceExtension() { 048 049 } 050 051 public ResourceExtension(Bundle bundle, Class<? extends BundleResource> clazz) { 052 this.bundle = bundle; 053 this.clazz = clazz; 054 } 055 056 public void setBundle(Bundle bundle) { 057 this.bundle = bundle; 058 } 059 060 public Bundle getBundle() { 061 return bundle; 062 } 063 064 public String getTarget() { 065 return target; 066 } 067 068 public String getSegment() { 069 return segment; 070 } 071 072 public void setTarget(String target) { 073 this.target = target; 074 } 075 076 public void setSegment(String segment) { 077 this.segment = segment; 078 } 079 080 public String getApplication() { 081 return application; 082 } 083 084 public void setApplication(String application) { 085 this.application = application; 086 } 087 088 public Class<? extends BundleResource> getResourceClass() { 089 return clazz; 090 } 091 092 public String getId() { 093 return target + "#" + segment; 094 } 095 096 @Override 097 public String toString() { 098 return bundle.getSymbolicName() + ":" + target + "#" + segment; 099 } 100}