1717 */
1818package com .adobe .acs .commons .models .injectors .impl ;
1919
20- import com .adobe .acs .commons .util .impl .ReflectionUtil ;
20+ import com .adobe .granite .asset .api .AssetManager ;
21+ import com .day .cq .commons .Externalizer ;
22+ import com .day .cq .search .QueryBuilder ;
2123import com .day .cq .tagging .TagManager ;
24+ import com .day .cq .wcm .api .policies .ContentPolicyManager ;
2225import org .apache .sling .xss .XSSAPI ;
2326import com .day .cq .wcm .api .Page ;
2427import com .day .cq .wcm .api .PageManager ;
3639import org .apache .sling .models .spi .DisposalCallbackRegistry ;
3740import org .apache .sling .models .spi .Injector ;
3841import org .osgi .framework .Constants ;
39- import com .adobe .acs .commons .i18n .I18nProvider ;
4042import com .adobe .acs .commons .models .injectors .annotation .AemObject ;
41- import com .day .cq .i18n .I18n ;
4243
4344import javax .jcr .Session ;
4445import java .lang .reflect .AnnotatedElement ;
4546import java .lang .reflect .Type ;
4647import java .util .Locale ;
4748
48- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getComponentContext ;
49- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getCurrentDesign ;
50- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getCurrentPage ;
51- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getCurrentStyle ;
52- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getDesigner ;
53- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getPageManager ;
54- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getResource ;
55- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getResourceDesign ;
56- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getResourcePage ;
57- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getResourceResolver ;
58- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getSession ;
59- import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .getXssApi ;
49+ import static com .adobe .acs .commons .models .injectors .impl .InjectorUtils .*;
6050import static com .adobe .acs .commons .util .impl .ReflectionUtil .getClassOrGenericParam ;
6151
6252/**
@@ -129,8 +119,6 @@ public Object getValue(Object adaptable, String name, Type declaredType, Annotat
129119 return getComponentContext (adaptable );
130120 case PAGE_MANAGER :
131121 return getPageManager (adaptable );
132- case TAG_MANAGER :
133- return getTagManager (adaptable );
134122 case CURRENT_PAGE :
135123 return getCurrentPage (adaptable );
136124 case RESOURCE_PAGE :
@@ -149,19 +137,23 @@ public Object getValue(Object adaptable, String name, Type declaredType, Annotat
149137 return resolveXssApi (adaptable );
150138 case LOCALE :
151139 return resolveLocale (adaptable );
140+ case TAG_MANAGER :
141+ return adaptFromResourceResolver (adaptable , TagManager .class );
142+ case ASSET_MANAGER :
143+ return adaptFromResourceResolver (adaptable , AssetManager .class );
144+ case ASSET_MANAGER_OLD :
145+ return adaptFromResourceResolver (adaptable , com .day .cq .dam .api .AssetManager .class );
146+ case QUERY_BUILDER :
147+ return adaptFromResourceResolver (adaptable , QueryBuilder .class );
148+ case CONTENT_POLICY_MANAGER :
149+ return adaptFromResourceResolver (adaptable ,ContentPolicyManager .class );
150+ case EXTERNALIZER :
151+ return adaptFromResourceResolver (adaptable , Externalizer .class );
152152 default :
153153 return null ;
154154 }
155155 }
156156
157- private TagManager getTagManager (Object adaptable ) {
158- final ResourceResolver resourceResolver = getResourceResolver (adaptable );
159-
160- if (resourceResolver != null ){
161- return resourceResolver .adaptTo (TagManager .class );
162- }
163- return null ;
164- }
165157
166158 private Object resolveLocale (Object adaptable ) {
167159 final Page page = getResourcePage (adaptable );
@@ -204,6 +196,11 @@ private enum ObjectType {
204196 SESSION ,
205197 LOCALE ,
206198 TAG_MANAGER ,
199+ QUERY_BUILDER ,
200+ CONTENT_POLICY_MANAGER ,
201+ ASSET_MANAGER ,
202+ ASSET_MANAGER_OLD ,
203+ EXTERNALIZER ,
207204 XSS_API ;
208205
209206 private static final String RESOURCE_PAGE_STRING = "resourcePage" ;
@@ -235,6 +232,16 @@ public static ObjectType fromClassAndName(Class<?> classOrGenericParam, String n
235232 return ObjectType .XSS_API ;
236233 } else if (classOrGenericParam .isAssignableFrom (Locale .class )){
237234 return ObjectType .LOCALE ;
235+ } else if (classOrGenericParam .isAssignableFrom (AssetManager .class )){
236+ return ObjectType .ASSET_MANAGER ;
237+ } else if (classOrGenericParam .isAssignableFrom (com .day .cq .dam .api .AssetManager .class )){
238+ return ObjectType .ASSET_MANAGER_OLD ;
239+ } else if (classOrGenericParam .isAssignableFrom (QueryBuilder .class )){
240+ return ObjectType .QUERY_BUILDER ;
241+ } else if (classOrGenericParam .isAssignableFrom (ContentPolicyManager .class )){
242+ return ObjectType .CONTENT_POLICY_MANAGER ;
243+ } else if (classOrGenericParam .isAssignableFrom (Externalizer .class )){
244+ return ObjectType .EXTERNALIZER ;
238245 }
239246
240247 return null ;
0 commit comments