org.ops4j.pax.web.service.spi.model
Class ServerModel

java.lang.Object
  extended by org.ops4j.pax.web.service.spi.model.ServerModel

public class ServerModel
extends java.lang.Object

Holds web elements in a global context accross all services (all bundles usng the Http Service).

Author:
Alin Dreghiciu

Constructor Summary
ServerModel()
          Constructor.
 
Method Summary
 void addFilterModel(FilterModel model)
          Registers a filter model.
 void addServletModel(ServletModel model)
          Registers a servlet model.
 void associateHttpContext(org.osgi.service.http.HttpContext httpContext, org.osgi.framework.Bundle bundle, boolean allowReAsssociation)
          Associates a http context with a bundle if the http service is not already associated to another bundle.
 void deassociateHttpContexts(org.osgi.framework.Bundle bundle)
          Deassociate all http context assiciated to the provided bundle.
 ContextModel matchPathToContext(java.lang.String path)
           
 void removeFilterModel(FilterModel model)
          Unregister a filter model.
 void removeServletModel(ServletModel model)
          Unregisters a servlet model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerModel

public ServerModel()
Constructor.

Method Detail

addServletModel

public void addServletModel(ServletModel model)
                     throws org.osgi.service.http.NamespaceException,
                            javax.servlet.ServletException
Registers a servlet model.

Parameters:
model - servlet model to register
Throws:
javax.servlet.ServletException - - If servlet is already registered
org.osgi.service.http.NamespaceException - - If servlet alias is already registered

removeServletModel

public void removeServletModel(ServletModel model)
Unregisters a servlet model.

Parameters:
model - servlet model to unregister

addFilterModel

public void addFilterModel(FilterModel model)
Registers a filter model.

Parameters:
model - filter model to register

removeFilterModel

public void removeFilterModel(FilterModel model)
Unregister a filter model.

Parameters:
model - filter model to unregister

associateHttpContext

public void associateHttpContext(org.osgi.service.http.HttpContext httpContext,
                                 org.osgi.framework.Bundle bundle,
                                 boolean allowReAsssociation)
Associates a http context with a bundle if the http service is not already associated to another bundle. This is done in order to prevent sharinh http context between bundles. The implementation is not 100% correct as it can be that at a certain moment in time when this method is called,another thread is processing a release of the http service, process that will deassociate the bundle that releasd the http service, and that bundle could actually be related to the http context that this method is trying to associate. But this is less likely to happen as it should have as precondition that this is happening concurent and that the two bundles are sharing the http context. But this solution has the benefits of not needing synchronization.

Parameters:
httpContext - http context to be assicated to the bundle
bundle - bundle to be assiciated with the htp service
allowReAsssociation - if it should allow a context to be reassiciated to a bundle
Throws:
java.lang.IllegalStateException - - If htp context is already associated to another bundle.

deassociateHttpContexts

public void deassociateHttpContexts(org.osgi.framework.Bundle bundle)
Deassociate all http context assiciated to the provided bundle. The bellow code is only correct in the context that there is no other thread is calling the association method in the mean time. This should not happen as once a bundle is releasing the HttpService the service is first entering a stopped state ( before the call to this method is made), state that will not perform the registration calls anymore.

Parameters:
bundle - bundle to be deassociated from http contexts

matchPathToContext

public ContextModel matchPathToContext(java.lang.String path)


Copyright © 2006-2011 OPS4J - Open Participation Software for Java. All Rights Reserved.