public Object addAttachment(String name, Object attachment) { return unit.addAttachment(name, attachment); } public Object getAttachment(String name)
@Override protected AbstractRequirement hasIntegrationModuleRequirement(VFSDeploymentUnit unit, RequirementsMetaData requirements) { AbstractRequirement abstractRequirement = unit.getAttachment(REQUIREMENT_KEY, AbstractRequirement.class); if (abstractRequirement == null) { abstractRequirement = super.hasIntegrationModuleRequirement(unit, requirements); if (cacheRequirement) unit.addAttachment(REQUIREMENT_KEY, abstractRequirement, AbstractRequirement.class); } return abstractRequirement; } }
/** * Process annotations. * * @param unit the deployment unit * @param finder the annotation finder * @param classes the candidate classes */ protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes) { ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder); ApplicationClientMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class); }
/** * Process jboss app client meta data. * * @param unit the deployment unit * @param finder the finder * @param mainClassName the main class name * @throws ClassNotFoundException for any error */ protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, String mainClassName) throws ClassNotFoundException { ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder, mainClassName); Collection<Class<?>> classes = new ArrayList<Class<?>>(1); Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName); classes.add(mainClass); ApplicationClientMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class); }
/** * Process annotations. * * @param unit the deployment unit * @param finder the annotation finder * @param classes the candidate classes */ protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes) { // Create the metadata model from the annotations JBoss50Creator creator = new JBoss50Creator(finder); JBossMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class); }
/** * Process sip meta data. * * @param unit the deployment unit * @param finder the finder * @param classes */ protected void processSipMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes) { Sip11MetaDataCreator creator = new Sip11MetaDataCreator(finder); SipMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(SIP_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, SipMetaData.class); } }
protected void init(VFSDeploymentUnit unit, TldMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(TldMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
protected void init(VFSDeploymentUnit unit, WebFragmentMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(WebFragmentMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
/** * Process annotations. * * @param unit the deployment unit * @param finder the annotation finder * @param classes the candidate classes */ protected void processJBossWebMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, Map<VirtualFile, Collection<Class<?>>> classes) { Web30MetaDataCreator creator = new Web30MetaDataCreator(finder); boolean metaData = false; for (VirtualFile path : classes.keySet()) { WebMetaData annotationMetaData = creator.create(classes.get(path)); log.debug("Add annotations: " + WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName()); if (annotationMetaData != null) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class); metaData = true; } } if (metaData) unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE); }
public void deploy(VFSDeploymentUnit unit) throws DeploymentException { try { VirtualFile classes = VFS.getChild(createHost(unit)); URL dynamicClassRoot = classes.toURL(); Closeable closeable = VFS.mountTemp(classes, tempFileProvider); unit.addAttachment(MOUNT_HANDLE_KEY, closeable); unit.addAttachment(DYNAMIC_CLASS_KEY, classes); unit.addAttachment(DYNAMIC_CLASS_URL_KEY, dynamicClassRoot); unit.prependClassPath(classes); log.debug("Dynamic class root for " + unit.getName() + " is " + dynamicClassRoot); } catch (Exception e) { throw new DeploymentException("Error creating dynamic class root", e); } }
@Override public void deploy(VFSDeploymentUnit unit, SwitchYardMetaData metaData) throws DeploymentException { try { parseSwitchYardConfig(metaData); _log.debug("Successfully parsed SwitchYard configuration for deployment unit '" + unit.getName() + "'."); } catch (IOException ioe) { throw new DeploymentException(ioe); } BeanMetaData beanMetaData = createBeanMetaData(unit, metaData); unit.addAttachment(BeanMetaData.class, beanMetaData); }
@Override public void deploy(VFSDeploymentUnit unit, T metaData) throws DeploymentException { if (isIntegrationDeployment(unit, metaData)) { // mark as integration deployment unit.addAttachment(isIntegrationFlagKey, true, Boolean.class); List<VirtualFile> added = new ArrayList<VirtualFile>(); try { for (URL integrationURL : integrationURLs) { VirtualFile integration = VFS.getChild(integrationURL); unit.addClassPath(integration); added.add(integration); } } catch (Throwable t) { Collections.reverse(added); unit.removeClassPath(added.toArray(new VirtualFile[added.size()])); throw DeploymentException.rethrowAsDeploymentException("Error adding integration path.", t); } } }
/** * Process the ear VFSDeploymentUnit. * * @param unit - the parent VFSDeploymentUnit for the ear * @param root - the deployment VFS root * @param file - the deployment ear VF */ protected void deploy(VFSDeploymentUnit unit, VirtualFile root, VirtualFile file) { try { JBossAppMetaData j2eeMetaData = new JBoss50AppMetaData(); // TODO: need to scan for annotationss scanEar(unit, file, j2eeMetaData); unit.addAttachment(JBossAppMetaData.class, j2eeMetaData); } catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); } }
public void deploy(VFSDeploymentUnit unit, JBossAppMetaData jBossAppMetaData) throws DeploymentException { try { VirtualFile root = unit.getRoot(); String libDir = jBossAppMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() == 0) // take 'lib' even on empty libDir = "lib"; VirtualFile lib = root.getChild(libDir); if (lib != null) { ResourceFilter recurseFilter = new UrlExcludeResourceFilter(lib.toURL()); unit.addAttachment(ResourceFilter.class.getName() + ".recurse", recurseFilter, ResourceFilter.class); log.debug("Excluding ear's lib directory: " + lib); } } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); } }
/** * Handle multiple files. * * @param unit the vfs deployment unit * @param root possibly null pre-existing root * @param files the matching files * @return null or merged single result * @throws Exception for any error */ protected T handleMultipleFiles(VFSDeploymentUnit unit, T root, List<VirtualFile> files) throws Exception { if (allowsMultipleFiles(files) == false) throw new IllegalArgumentException("Multiple matching files not allowed: " + files); for (VirtualFile file : files) { if (ignoreFile(unit, file) == false) { T result = parse(unit, file, root); if (result != null) { init(unit, result, file); unit.addAttachment(file.toURL().toString(), result, getOutput()); } } } return null; }
/** * Process jboss meta data. * * @param unit the deployment unit * @param finder the finder */ protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder) { // Create the metadata model from the annotations EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBoss50Creator creator = new JBoss50Creator(ejbJarMetaData, unit.getClassLoader(), finder); Collection<Class<?>> classes = getClasses(unit, creator); JBossMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class); }
public void deploy(VFSDeploymentUnit unit, JBPMDeploymentMetaData deployment) throws DeploymentException { log.info("Deploy " + deployment); // associate classloader deployment.setClassloader(unit.getClassLoader()); try { DeploymentRef deploymentRef = adaptor.deploy(deployment); // TODO: mark the process 'ready', classloader assoc unit.addAttachment("jbpm.deployment.ref", deploymentRef); } catch (Throwable t) { throw new DeploymentException(t); } }
public void deploy(VFSDeploymentUnit unit, JBossWeldMetaData deployment) throws DeploymentException { ClassLoader classLoader = unit.getClassLoader(); if (!unit.isTopLevel() && unit.getParent().getClassLoader() == classLoader) { return; } if (classLoader instanceof RealClassLoader) { unit.addAttachment(ArchiveInfo.class, new ArchiveInfo(classLoader, EjbDiscoveryUtils.getVisibleEJbNames(unit))); } else // FIXME throw new NotImplementedException(); } }
/** * Visit module. * * Util method to add some behavior to Module * before we visit it. * * @param unit the deployment unit * @throws DeploymentException for any error */ protected void visitModule(VFSDeploymentUnit unit) throws DeploymentException { try { URL[] urls = ClasspathUtils.getUrls(unit); DeploymentUnitScanner scanner = new DeploymentUnitScanner(unit, urls); AnnotationsScanningPlugin plugin = createPlugin(unit); scanner.addPlugin(plugin); configureScanner(scanner); scanner.scan(); AnnotationRepository repository = unit.getAttachment(plugin.getAttachmentKey(), AnnotationRepository.class); unit.addAttachment(AnnotationRepository.class, repository); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Exception visiting module", e); } }
protected void internalDeploy(VFSDeploymentUnit unit, T deployment, Collection<VirtualFile> wbXml) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; if (isClassLoadingMetadataPresent(deployment)) return; if (isIsolated(unit, wbXml) == false) return; String domain = getJMXName(deployment, unit) + ",extension=LoaderRepository"; classLoadingMetaData = new ClassLoadingMetaData(); classLoadingMetaData.setName(unit.getName()); classLoadingMetaData.setDomain(domain); classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY); classLoadingMetaData.setImportAll(true); classLoadingMetaData.setVersion(Version.DEFAULT_VERSION); classLoadingMetaData.setJ2seClassLoadingCompliance(false); unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData); }