org.apache.sling.scripting.core.impl
Class SlingScriptAdapterFactory

java.lang.Object
  extended by org.apache.sling.scripting.core.impl.SlingScriptAdapterFactory
All Implemented Interfaces:
AdapterFactory, MimeTypeProvider

public class SlingScriptAdapterFactory
extends Object
implements AdapterFactory, MimeTypeProvider

AdapterFactory that adapts Resources to the DefaultSlingScript servlet, which executes the Resources as scripts.


Field Summary
 
Fields inherited from interface org.apache.sling.api.adapter.AdapterFactory
ADAPTABLE_CLASSES, ADAPTER_CLASSES, SERVICE_NAME
 
Constructor Summary
SlingScriptAdapterFactory()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext context)
           
protected  void deactivate(org.osgi.service.component.ComponentContext context)
           
<AdapterType>
AdapterType
getAdapter(Object adaptable, Class<AdapterType> type)
          Adapt the given object to the adaptable type.
 String getExtension(String mimeType)
          Returns the first extension entry of the supported extensions of a ScriptEngineFactory which is registered for the given MIME type.
 String getMimeType(String name)
          Returns the first MIME type entry of the supported MIME types of a ScriptEngineFactory which is registered for the extension of the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlingScriptAdapterFactory

public SlingScriptAdapterFactory()
Method Detail

getAdapter

public <AdapterType> AdapterType getAdapter(Object adaptable,
                                            Class<AdapterType> type)
Description copied from interface: AdapterFactory
Adapt the given object to the adaptable type. The adaptable object is guaranteed to be an instance of one of the classes listed in the AdapterFactory.ADAPTABLE_CLASSES services registration property. The type parameter is on of the classes listed in the AdapterFactory.ADAPTER_CLASSES service registration properties.

This method may return null if the adaptable object may not be adapted to the adapter (target) type for any reason. In this case, the implementation should log a message to the log facility noting the cause for not being able to adapt.

Note that the adaptable object is not required to implement the Adaptable interface, though most of the time this method is called by means of calling the Adaptable.adaptTo(Class) method.

Specified by:
getAdapter in interface AdapterFactory
Type Parameters:
AdapterType - The generic type of the adapter (target) type.
Parameters:
adaptable - The object to adapt to the adapter type.
type - The type to which the object is to be adapted.
Returns:
The adapted object or null if this factory instance cannot adapt the object.

getMimeType

public String getMimeType(String name)
Returns the first MIME type entry of the supported MIME types of a ScriptEngineFactory which is registered for the extension of the given name. If no ScriptEngineFactory is registered for the given extension or the registered ScriptEngineFactory is not registered for a MIME type, this method returns null.

Specified by:
getMimeType in interface MimeTypeProvider
Parameters:
name - The name whose extension is to be mapped to a MIME type. The extension is the string after the last dot in the name. If the name contains no dot, the entire name is considered the extension.
Returns:
The MIME type for the extension of the name. If the extension cannot be mapped to a MIME type or name is null, null is returned.
See Also:
MimeTypeProvider.getExtension(String)

getExtension

public String getExtension(String mimeType)
Returns the first extension entry of the supported extensions of a ScriptEngineFactory which is registered for the given MIME type. If no ScriptEngineFactory is registered for the given MIME type or the registered ScriptEngineFactory is not registered for an extensions, this method returns null.

Specified by:
getExtension in interface MimeTypeProvider
Parameters:
mimeType - The MIME type to be mapped to an extension.
Returns:
A extension which maps to the given MIME type or null if no such mapping exists.
See Also:
MimeTypeProvider.getMimeType(String)

activate

protected void activate(org.osgi.service.component.ComponentContext context)

deactivate

protected void deactivate(org.osgi.service.component.ComponentContext context)


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.