AbstractRouterRegistry.java revision fa9b7593e9e156060babbf3a9b06de8d6b5da5a3
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013 ForgeRock AS. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/**
* A NAME does ...
*
* @author Laszlo Hordos
*/
/**
* Setup logging for the {@link AbstractRouterRegistry}.
*/
protected final BundleContext context;
new CopyOnWriteArraySet<RouteEntry>();
// the routerTracker.getTrackingCount when the router were last got
protected int routerCount;
}
throw new NullPointerException("Failure the BundleContext value is null.");
}
this.routerTracker = routerTracker;
try {
} catch (InvalidSyntaxException e) {
// not expected (filter is tested valid)
}
activate();
}
protected abstract void activate();
protected void deactivate() {
isActive.compareAndSet(true, false);
//Entries in cache has circular references to the cache set to remove themselves
entry.removeRoute();
}
}
/*
* protected RouteEntry
* bindCollectionResourceProvider(CollectionResourceProvider service, Object
* uriTemplate){ return null;};
*
* protected RouteEntry
* updatedCollectionResourceProvider(CollectionResourceProvider service,
* Object uriTemplate){ return null;};
*
* protected RouteEntry
* unbindCollectionResourceProvider(CollectionResourceProvider service,
* Object uriTemplate){ return null;};
*
* protected RouteEntry
* bindSingletonResourceProvider(SingletonResourceProvider service, Object
* uriTemplate){ return null;};
*
* protected RouteEntry
* updatedSingletonResourceProvider(SingletonResourceProvider service,
* Object uriTemplate){ return null;};
*
* protected RouteEntry
* unbindSingletonResourceProvider(SingletonResourceProvider service, Object
* uriTemplate){ return null;};
*
* protected RouteEntry bindRequestHandler(RequestHandler service, Object
* uriTemplate){ return null;};
*
* protected RouteEntry updatedRequestHandler(RequestHandler service, Object
* uriTemplate){ return null;};
*
* protected RouteEntry unbindRequestHandler(RequestHandler service, Object
* uriTemplate){ return null;};
*/
}
final RouteEntryImpl self =
public boolean removeRoute() {
routeCache.remove(this);
return super.removeRoute();
}
};
return self;
}
try {
if (newRoutes.isNotEmpty()) {
}
} catch (NullPointerException e) {
}
return null;
}
// ----- Implementation of ServiceFactory interface
return new RouterRegistryServiceImpl(bundle, this);
}
}
// ----- Implementation of ServiceTrackerCustomizer interface
if (service instanceof CollectionResourceProvider) {
} else if (service instanceof SingletonResourceProvider) {
} else if (service instanceof RequestHandler) {
}
}
return result;
}
if (newService instanceof CollectionResourceProvider) {
} else if (newService instanceof SingletonResourceProvider) {
} else if (newService instanceof RequestHandler) {
}
}
}
}
// ----- Protected methods meant to be overwritten
protected Router getInternalRouter() {
// The getTrackingCount() is synchronized, avoid it if it's possible
if (routerTracker == null) {
} else {
} else {
break;
}
}
}
}
}
return internalRouter.get();
}
protected static class RouterRegistryServiceImpl implements RouterRegistryService {
protected AbstractRouterRegistry registry;
}
void dispose() {
}
// ----- Implementation of RouterRegistryService interface
}
return entry;
}
//TODO This is NOT Authenticated!!!
}
return "OPENIDM_ROOT";
}
// // TODO Consider to move this to the parent class and avoid the
// closed
// // connection if disposed
// // ----- Implementation of RequestHandler interface
//
// public void handleAction(ServerContext context, ActionRequest
// request,
// ResultHandler<JsonValue> handler) {
// if (null != registry) {
// registry.getInternalRouter().handleAction(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handleCreate(ServerContext context, CreateRequest
// request,
// ResultHandler<Resource> handler) {
// if (null != registry) {
// registry.getInternalRouter().handleCreate(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handleDelete(ServerContext context, DeleteRequest
// request,
// ResultHandler<Resource> handler) {
// if (null != registry) {
// registry.getInternalRouter().handleDelete(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handlePatch(ServerContext context, PatchRequest request,
// ResultHandler<Resource> handler) {
// if (null != registry) {
// registry.getInternalRouter().handlePatch(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handleQuery(ServerContext context, QueryRequest request,
// QueryResultHandler handler) {
// if (null != registry) {
// registry.getInternalRouter().handleQuery(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handleRead(ServerContext context, ReadRequest request,
// ResultHandler<Resource> handler) {
// if (null != registry) {
// registry.getInternalRouter().handleRead(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
//
// public void handleUpdate(ServerContext context, UpdateRequest
// request,
// ResultHandler<Resource> handler) {
// if (null != registry) {
// registry.getInternalRouter().handleUpdate(context, request, handler);
// } else {
// handler.handleError(new
// ServiceUnavailableException("Connection has been disposed!"));
// }
// }
}
}
class RouteServiceImpl implements RouteService {
this.internalRouter = router;
}
void dispose() {
}
.getBundleContext()));
}
if (null != r) {
} else {
throw new ServiceUnavailableException();
}
}
}
protected Route[] registeredRoutes;
protected ServiceRegistration factoryServiceRegistration;
if (r == null) {
throw new NullPointerException("Router is required to register the routes to");
}
}
}
void dispose() {
removeRoute();
super.dispose();
}
public boolean removeRoute() {
boolean isModified = false;
if (null != factoryServiceRegistration) {
}
if (r != null) {
}
return isModified;
}
}
this.internalRouter = internalRouter;
}
}
}
}