public void storeMeemDefinition(MeemPath meemPath, MeemDefinition meemDefinition) { if (DEBUG) { logger.info("storing meem def: " + meemPath); } // only store meemstore paths if (meemPath.getSpace().equals(Space.MEEMSTORE)) { int meemVersion = meemDefinition.getMeemAttribute().getVersion(); if (meemVersion > definitionStore.getVersion(meemPath)) { definitionStore.store(meemPath, meemDefinition); synchronized (meemPaths) { if (!meemPaths.containsKey(meemPath.getLocation())) { meemPaths.put(meemPath.getLocation(), meemPath); meemStoreClient.meemStored(meemPath); } meemDefinitionClient.meemDefinitionChanged(meemPath, meemDefinition); meemContentClient.meemContentChanged(meemPath, null); } } else { // definition version number is same or smaller than the persisted one // LogTools.warn(logger, "Request to persist MeemDefinition with lower version number than // most recent version"); } } }
private void performCommission() throws Exception { if (commissionNames == null) { return; } commissionMeems = new Meem[commissionNames.length]; for (int i = 0; i < commissionMeems.length; i++) { Object meemInstance = commissionClasses[i].newInstance(); MeemDefinitionProvider mdp = (MeemDefinitionProvider) meemInstance; MeemDefinition meemDefinition = mdp.getMeemDefinition(); String name = commissionNames[i]; meemDefinition.getMeemAttribute().setIdentifier(name); indexTable.put(name, new Integer(i)); lifeCycleManagerConduit.createMeem(meemDefinition, LifeCycleState.LOADED); } }
public static MeemDefinition getCategoryDefinition() { MeemAttribute meemAttribute = new MeemAttribute(); meemAttribute.setScope(Scope.LOCAL); meemAttribute.setIdentifier("Category"); meemAttribute.setVersion(1); MeemDefinition meemDefinition = new MeemDefinition(meemAttribute); try { if (categoryWedgeDefinition == null) categoryWedgeDefinition = WedgeIntrospector.getWedgeDefinition(CategoryWedge.class); meemDefinition.addWedgeDefinition(categoryWedgeDefinition); } catch (WedgeIntrospectorException e) { e.printStackTrace(); } return meemDefinition; }
private void handleMeemCreation(Meem meem, String identifier, MeemDescription meemDescription) { // add meem to hyperspace category Meem categoryMeem = Meem.spi.get(MeemPath.spi.create(Space.HYPERSPACE, myHyperSpacePath)); Category category = (Category) MeemUtility.spi.get().getTarget(categoryMeem, "category", Category.class); category.addEntry(identifier, meem); // setup dependencies between the meem and controller meem if (controllerName != null) { // set up dependency between the meem and the controller meem setDependency(meem, controllerName, "deviceControllerInput", "deviceControllerOutput"); setDependency(meem, controllerName, "deviceControllerOutput", "deviceControllerInput"); } if (meemDescription instanceof DeviceDescription) { DeviceDescription description = (DeviceDescription) meemDescription; Device device = (Device) MeemUtility.spi.get().getTarget(meem, "deviceInput", Device.class); device.descriptionChanged(description); } MeemDefinition meemDefinition = MeemUtility.spi.get().getMeemDefinition(meem); meemDefinition.getMeemAttribute().setIdentifier(identifier); subsystemClientConduit.meemCreated(meem, meemDefinition); }
/** * Return a MeemDefinition for this Meem which lists all of the Wedges required to assemble this * Meem. * * @return The MeemDefinition for this Meem */ public MeemDefinition getMeemDefinition() { if (meemDefinition == null) { Class<?>[] wedges = new Class[] { RequestProcessorWedge.class, }; meemDefinition = MeemDefinitionFactory.spi.create().createMeemDefinition(wedges); meemDefinition.getMeemAttribute().setIdentifier("RequestProcessor"); MeemDefinitionUtility.renameFacetIdentifier( meemDefinition, "RequestProcessorWedge", "request", "variableOutput"); MeemDefinitionUtility.renameFacetIdentifier( meemDefinition, "RequestProcessorWedge", "requestProcessor", "requestProcessorInput"); } return meemDefinition; }
public void createMeem(MeemDefinition meemDefinition, MeemDescription meemDescription) { if (commissionState.equals(CommissionState.NOT_COMMISSIONED)) { logger.log( Level.WARNING, "createMeem() - can not create Meems until subsystem commissioned"); return; } if (myHyperSpacePath == null || myHyperSpacePath.length() == 0) { logger.log(Level.WARNING, "createMeem() - HyperSpace path has not been configured"); return; } String identifier = meemDefinition.getMeemAttribute().getIdentifier(); if (identifier == null || identifier.length() == 0) { logger.log(Level.WARNING, "createMeem() - identifier not set in MeemDefinition"); return; } if (meemIdentifiers.contains(identifier)) { if (DEBUG) { logger.log( Level.INFO, "createMeem() - meem with identifier, \"" + identifier + "\", is already created in the subsystem"); } // TODO check if the existing description != new description, destroy old meem and create // new one return; } // add to set of pending meem creations descriptions.put(identifier, meemDescription); lifeCycleManagerConduit.createMeem(meemDefinition, LifeCycleState.READY); }