- /** Session is logged out. */
- private void prepareDataModel(Session adminSession) {
- try {
- Set<String> processed = new HashSet<String>();
- bundles: for (Bundle bundle : bc.getBundles()) {
- BundleWiring wiring = bundle.adapt(BundleWiring.class);
- if (wiring == null) {
- if (log.isTraceEnabled())
- log.error("No wiring for " + bundle.getSymbolicName());
- continue bundles;
+ // Readiness
+ private boolean nodeAvailable = false;
+ private boolean userAdminAvailable = false;
+ private boolean httpExpected = false;
+ private boolean httpAvailable = false;
+
+ public CmsDeployment() {
+// ServiceReference<NodeState> nodeStateSr = bc.getServiceReference(NodeState.class);
+// if (nodeStateSr == null)
+// throw new CmsException("No node state available");
+
+// NodeState nodeState = bc.getService(nodeStateSr);
+// cleanState = nodeState.isClean();
+
+// nodeHttp = new NodeHttp();
+ initTrackers();
+ }
+
+ private void initTrackers() {
+ ServiceTracker<?, ?> httpSt = new ServiceTracker<HttpService, HttpService>(bc, HttpService.class, null) {
+
+ @Override
+ public HttpService addingService(ServiceReference<HttpService> sr) {
+ httpAvailable = true;
+ Object httpPort = sr.getProperty("http.port");
+ Object httpsPort = sr.getProperty("https.port");
+ log.info(httpPortsMsg(httpPort, httpsPort));
+ checkReadiness();
+ return super.addingService(sr);
+ }
+ };
+ // httpSt.open();
+ KernelUtils.asyncOpen(httpSt);
+
+ ServiceTracker<?, ?> userAdminSt = new ServiceTracker<UserAdmin, UserAdmin>(bc, UserAdmin.class, null) {
+ @Override
+ public UserAdmin addingService(ServiceReference<UserAdmin> reference) {
+ UserAdmin userAdmin = super.addingService(reference);
+ addStandardSystemRoles(userAdmin);
+ userAdminAvailable = true;
+ checkReadiness();
+ return userAdmin;
+ }
+ };
+ // userAdminSt.open();
+ KernelUtils.asyncOpen(userAdminSt);
+
+ ServiceTracker<?, ?> confAdminSt = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>(bc,
+ ConfigurationAdmin.class, null) {
+ @Override
+ public ConfigurationAdmin addingService(ServiceReference<ConfigurationAdmin> reference) {
+ ConfigurationAdmin configurationAdmin = bc.getService(reference);
+ boolean isClean;
+ try {
+ Configuration[] confs = configurationAdmin
+ .listConfigurations("(service.factoryPid=" + NodeConstants.NODE_USER_ADMIN_PID + ")");
+ isClean = confs == null || confs.length == 0;
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot analyse clean state", e);