private static Artifact toArtifact(String attrValue) { try { return Artifact.create(attrValue); } catch (Exception e) { return new Artifact(DEFAULT_GROUPID, attrValue.replace('/', '_'), DEFAULT_VERSION, "car"); } }
public void newServerInstance(String serverName) throws Exception { try { PluginListType pluginList = new PluginListType(); for (String artifactString : defaultPlugins) { Artifact artifact = Artifact.create(artifactString); PluginType plugin = getPlugin(artifact); pluginList.getPlugin().add(plugin); } Artifact query = Artifact.createPartial("///"); for (PersistentConfigurationList persistentConfigurationList : persistentConfigurationLists) { for (Artifact installed : persistentConfigurationList.getListedConfigurations(query)) { PluginType plugin = getPlugin(installed); pluginList.getPlugin().add(plugin); } } Kernel kernel = new BasicKernel("assembly", bundleContext); try { PluginInstallerGBean pluginInstallerGBean = oldPluginInstallerGBean.pluginInstallerCopy(serverName, kernel); GeronimoSourceRepository localSourceRepository = new GeronimoSourceRepository(configManager.getRepositories(), configManager.getArtifactResolver()); DownloadResults downloadPoller = new DownloadResults(); pluginInstallerGBean.install(pluginList, localSourceRepository, true, null, null, downloadPoller); } finally { kernel.shutdown(); } } catch (Throwable t) { t.printStackTrace(); } }
private void notifyWatchers(List<String> list) { Artifact[] arts = new Artifact[list.size()]; for (int i = 0; i < list.size(); i++) { String s = list.get(i); arts[i] = Artifact.create(s); } for (Iterator<DeploymentWatcher> it = watchers.iterator(); it.hasNext();) { DeploymentWatcher watcher = it.next(); for (int i = 0; i < arts.length; i++) { Artifact art = arts[i]; watcher.deployed(art); } } }
public static Artifact getConfigurationID(ObjectName objectName) { if (isConfigurationObjectName(objectName)) { String name = ObjectName.unquote(objectName.getKeyProperty("name")); return Artifact.create(name); } else { throw new IllegalArgumentException("ObjectName " + objectName + " is not a Configuration name"); } }
private void loadHistory() { if (installedPluginsList != null) { File historyFile = serverInfo.resolveServer(installedPluginsList); Properties properties = new Properties(); try { InputStream in = new FileInputStream(historyFile); try { properties.load(in); for (Object key : properties.keySet()) { Artifact artifact = Artifact.create((String) key); installedArtifacts.add(artifact); } } finally { in.close(); } } catch (IOException e) { //give up } } }
private static ConfigurationInfo readConfigurationInfo(String prefix, Properties properties, AbstractName storeName, File inPlaceLocation) throws IOException { String id = properties.getProperty(prefix+"id"); Artifact configId = Artifact.create(id); if (name.startsWith(prefix+"owned.")) { String value = (String) entry.getValue(); Artifact ownedConfiguration = Artifact.create(value); ownedConfigurations.add(ownedConfiguration);
/** * Puts the name and ID of a plugin into the argument map of plugins, * by reading the values out of the provided plugin descriptor file. * * @param xml The geronimo-plugin.xml for this plugin * @param plugins The result map to populate */ private void readNameAndID(File xml, Map<String, Artifact> plugins) { try { SAXParserFactory factory = XmlUtil.newSAXParserFactory(); SAXParser parser = factory.newSAXParser(); PluginNameIDHandler handler = new PluginNameIDHandler(); parser.parse(xml, handler); if (handler.isComplete()) { plugins.put(handler.getName(), Artifact.create(handler.getID())); } } catch (Exception e) { log.warn("Invalid XML at " + xml.getAbsolutePath(), e); } }
String startLevel = line.substring(pos + 1).trim(); String mvnLocation = getMvnLocationFromArtifact(Artifact.create(name)); Bundle bundle = findBundle(mvnLocation); if (bundle == null) {
public void deployPlan(File moduleFile, File planFile) { try { Kernel kernel = KernelRegistry.getSingleKernel(); List list = (List) kernel.invoke(ObjectNameConstants.DEPLOYER_OBJECT_NAME, DEPLOY_METHOD, new Object[] {moduleFile, planFile}, DEPLOYER_ARGS); ConfigurationManager configurationManager = ConfigurationUtil .getConfigurationManager(kernel); for (Iterator iterator = list.iterator(); iterator.hasNext();) { Artifact configID = Artifact.create((String)iterator.next()); if (!configurationManager.isLoaded(configID)) { configurationManager.loadConfiguration(configID); } configurationManager.startConfiguration(configID); } } catch (DeploymentException e) { StringBuilder buf = new StringBuilder(256); Throwable cause = e; while (cause != null) { buf.append(cause.getMessage()); buf.append(LINE_SEP); cause = cause.getCause(); } log.error("Problem deploying the ActiveMQ connector: " + buf); } catch (URISyntaxException e) { log.error("Newly installed app has invalid config ID", e); } catch (Exception e) { log.error("Problem creating the datasource", e); } }
/** * Puts the name and ID of a plugin into the argument map of plugins, * by reading the values out of the provided plugin descriptor stream. * * @param xml The geronimo-plugin.xml for this plugin * @param plugins The result map to populate */ private void readNameAndID(InputStream xml, Map plugins) { try { SAXParserFactory factory = XmlUtil.newSAXParserFactory(); SAXParser parser = factory.newSAXParser(); PluginNameIDHandler handler = new PluginNameIDHandler(); parser.parse(xml, handler); if (handler.isComplete()) { plugins.put(handler.getName(), Artifact.create(handler.getID())); } } catch (Exception e) { log.warn("Invalid XML", e); } }
public void mergeOverrides(String server, AttributesType overrides) throws InvalidGBeanException, IOException { ServerInstance serverInstance = servers.get(server); if (serverInstance == null) { throw new NullPointerException("No such server: " + server + ", known servers: " + servers.keySet()); } PluginAttributeStore attributeStore = serverInstance.getAttributeStore(); for (ModuleType module : overrides.getModule()) { Artifact artifact = Artifact.create(module.getName()); attributeStore.setModuleGBeans(artifact, module.getGbean(), module.isLoad(), module.getCondition()); attributeStore.save(); } if (overrides.getConfiguration().size() > 0) { throw new UnsupportedOperationException("Use modules, not configurations"); } }
public JpaPluginInstance(String artifactUri) { Artifact artifact = Artifact.create(artifactUri); this.groupId = artifact.getGroupId(); this.artifactId = artifact.getArtifactId(); this.version = artifact.getVersion().toString(); this.type = artifact.getType(); }
ConfigurationManager configurationManager = ConfigurationUtil .getConfigurationManager(kernel); Artifact destinationConfigArtifact = Artifact.create(destinationConfigURIName); AbstractName configurationObjectName = Configuration.getConfigurationAbstractName(destinationConfigArtifact);
String target = name.substring(0, pos); String module = name.substring(pos+1); Artifact artifact = Artifact.create(module); artifact = new Artifact(artifact.getGroupId() == null && fromPlan ? Artifact.DEFAULT_GROUP_ID : artifact.getGroupId(), artifact.getArtifactId(), fromPlan ? (Version)null : artifact.getVersion(), artifact.getType()); if(allModules[i].getTarget().getName().equals(target) && artifact.matches(Artifact.create(allModules[i].getModuleID()))) { list.add(allModules[i]); artifact = Artifact.create(name); artifact = new Artifact(artifact.getGroupId() == null && fromPlan ? Artifact.DEFAULT_GROUP_ID : artifact.getGroupId(), artifact.getArtifactId(), fromPlan ? (Version)null : artifact.getVersion(), artifact.getType()); if(artifact.matches(Artifact.create(allModules[i].getModuleID()))) { list.add(allModules[i]);
commandContext.setInPlace(inPlaceConfiguration.booleanValue()); doDeploy(target, false); Artifact configID = Artifact.create(getResultTargetModuleIDs()[0].getModuleID()); LifecycleResults results = manager.reloadConfiguration(previous, configID.getVersion());
private void populateDependency(DependencyType dep, String dependencyString) { Artifact artifact = Artifact.create(dependencyString.trim()); dep.setArtifactId(artifact.getArtifactId()); if (artifact.getGroupId() != null) { dep.setGroupId(artifact.getGroupId()); } if (artifact.getType() != null) { dep.setType(artifact.getType()); } if (artifact.getVersion() != null) { dep.setVersion(artifact.getVersion().toString()); } }
public static Bundle getRepositoryEntryBundle(PortletRequest request, String repositoryURI) { J2EEServer server = getCurrentServer(request); Artifact uri = Artifact.create(repositoryURI); if (!uri.isResolved()) { Artifact[] all = server.getConfigurationManager().getArtifactResolver().queryArtifacts(uri); if (all.length == 0) { return null; } else { uri = all[all.length - 1]; } } try { Kernel kernel = getKernel(); BundleContext bundleContext = kernel.getBundleFor(kernel.getKernelName()).getBundleContext(); //TODO Figure out who should be responsible for uninstalling it, and whether we need to start the bundle //Currently, this method is only used for resource reading, seems no need to start the bundle. return bundleContext.installBundle("mvn:" + uri.getGroupId() + "/" + uri.getArtifactId() + "/" + uri.getVersion() + ("jar".equals(uri.getType()) ? "" : "/" + uri.getType())); } catch (Exception e) { return null; } }
public static File getRepositoryEntry(PortletRequest request, String repositoryURI) { J2EEServer server = getCurrentServer(request); Repository[] repos = server.getRepositories(); Artifact uri = Artifact.create(repositoryURI); if (!uri.isResolved()) { Artifact[] all = server.getConfigurationManager().getArtifactResolver().queryArtifacts(uri); if (all.length == 0) { return null; } else { uri = all[all.length - 1]; } } for (int i = 0; i < repos.length; i++) { Repository repo = repos[i]; if (repo.contains(uri)) { return repo.getLocation(uri); } } return null; }
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); String config = getConfigID(actionRequest); Artifact configId = Artifact.create(config);
TargetModuleIDImpl module = (TargetModuleIDImpl) modules[i]; Artifact moduleID = Artifact.create(module.getModuleID()); try { if(!configurationManager.isOnline()) {