private Unmarshaller getUnmarshaller(boolean isV10) throws DeploymentException { try { if(isV10) { return jaxbContext10.createUnmarshaller(); } else { return jaxbContext11.createUnmarshaller(); } }catch(NullPointerException npe) { throw new DeploymentException("Failed to create unmarshaler, probably context has not been create, see console for error.", npe); } catch (Exception e) { throw new DeploymentException("Failed to create unmarshaler!",e); } }
protected void createSetActivityContextInterfaceMethod( CtClass activityContextInterface) throws DeploymentException { String methodToAdd = "public void sbbSetActivityContextInterface( Object aci ) {" + "this.sbbActivityContextInterface = (" + activityContextInterface.getName() + ") aci ; } "; CtMethod methodTest; try { methodTest = CtNewMethod.make(methodToAdd, sbbConcreteClass); sbbConcreteClass.addMethod(methodTest); logger.trace("Method " + methodToAdd + " added"); } catch (CannotCompileException e) { throw new DeploymentException(e.getMessage(), e); } }
public DeployableUnitDescriptorImpl(org.mobicents.slee.container.component.deployment.jaxb.slee.du.DeployableUnit duDescriptor10) throws DeploymentException { try { this.isSlee11 = false; buildDescriptionMap(duDescriptor10.getJarOrServiceXml()); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw new DeploymentException( "Failed to parse descriptor due to: ", e); } }
private void exploreDULib() throws DeploymentException { // explore the library directory // TODO: The proper way to explore the library directories is to follow the JSLEE 1.1 // spec for adding the proper library descriptor Enumeration entries = unitJarFile.entries(); try { for (JarEntry entry = (JarEntry) entries.nextElement(); entries.hasMoreElements(); ) { entry = (JarEntry) entries.nextElement(); if (entry.getName().indexOf("library")!=-1 && entry.getName().indexOf("jar")!=-1 && !entry.isDirectory()) { File f = DeploymentManager.extractFile(entry.getName(),unitJarFile,getClasspathDirectory()); DeploymentManager.extractJar(new JarFile(f), getClasspathDirectory()); } } } catch (IOException ex) { throw new DeploymentException(ex.getMessage(), ex); } }
public void process(ResourceAdaptorTypeComponent component) throws DeploymentException { try { new ConcreteActivityContextInterfaceFactoryGenerator(component).generateClass(); } catch (DeploymentException ex) { throw ex; } catch (Throwable ex) { throw new DeploymentException( "Failed to generate ra type class(es)", ex); } }
public DeployableUnitDescriptorImpl(org.mobicents.slee.container.component.deployment.jaxb.slee11.du.DeployableUnit duDescriptor11) throws DeploymentException { try { this.isSlee11 = true; buildDescriptionMap(duDescriptor11 .getJarOrServiceXml()); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw new DeploymentException( "Failed to parse descriptor due to: ", e); } } public DeployableUnitDescriptorImpl(org.mobicents.slee.container.component.deployment.jaxb.slee.du.DeployableUnit duDescriptor10)
private void createFields(CtClass[] parameters) throws DeploymentException { for (int i = 0; i < parameters.length; i++) { String parameterName = parameters[i].getName(); parameterName = parameterName.substring(parameterName .lastIndexOf(".") + 1); String firstCharLowerCase = parameterName.substring(0, 1) .toLowerCase(); parameterName = firstCharLowerCase.concat(parameterName .substring(1)); try { CtField ctField = new CtField(parameters[i], parameterName, sbbConcreteClass); ctField.setModifiers(Modifier.PRIVATE); sbbConcreteClass.addField(ctField); } catch (CannotCompileException e) { throw new DeploymentException(e.getMessage(), e); } } }
/** * Inits and parses * @param jarEntry JarFile * @param componentContainer the container where the component should be * deployed. * @throws DeploymentException */ protected void initDeployer(File serviceXML, ComponentContainer container) throws DeploymentException { this.serviceXML = serviceXML; this.componentContainer = container; try { this.componentDescriptors = parseServiceDescriptors(); } catch (Exception ex) { DeploymentException de = new DeploymentException("Failed to parse deployment descriptor of " + serviceXML.getName(), ex); log.error(de.getMessage(), ex); throw de; } }
@Override public void processSecurityPermissions() throws DeploymentException { try { if (this.descriptor.getSecurityPermissions() != null) { super.permissions.add(new PermissionHolderImpl(super.getDeploymentDir().toURI(), this.descriptor.getSecurityPermissions())); } } catch (Exception e) { throw new DeploymentException("Failed to make permissions usable.", e); } }
@Override public void processSecurityPermissions() throws DeploymentException { try { if (this.descriptor.getSecurityPermissions() != null) { super.permissions.add(new PermissionHolderImpl(super.getDeploymentDir().toURI(), this.descriptor.getSecurityPermissions())); } } catch (Exception e) { throw new DeploymentException("Failed to make permissions usable.", e); } }
@Override public void processSecurityPermissions() throws DeploymentException { try { if (this.descriptor.getSecurityPermissions() != null) { super.permissions.add(new PermissionHolderImpl(super.getDeploymentDir().toURI(), this.descriptor.getSecurityPermissions())); } } catch (Exception e) { throw new DeploymentException("Failed to make permissions usable.", e); } }
/** * Create a method to retrive the entity from the SbbObject. * * @param sbbConcrete * @throws DeploymentException */ private void createSbbEntityGetterAndSetter(CtClass sbbConcrete) throws DeploymentException { try { CtMethod getSbbEntity = CtNewMethod .make("public " + SbbEntity.class.getName() + " getSbbEntity() { return this.sbbEntity; }", sbbConcrete); getSbbEntity.setModifiers(Modifier.PUBLIC); sbbConcrete.addMethod(getSbbEntity); CtMethod setSbbEntity = CtNewMethod.make( "public void setSbbEntity ( " + SbbEntity.class.getName() + " sbbEntity )" + "{" + "this.sbbEntity = sbbEntity;" + "}", sbbConcrete); setSbbEntity.setModifiers(Modifier.PUBLIC); sbbConcrete.addMethod(setSbbEntity); } catch (Exception e) { throw new DeploymentException(e.getMessage(), e); } }
/** * @return the ClassLoader that will be associated with the DU. It will load * the classes in the DU and will be also used for JNDI objects * under ENC - java:comp/env * @throws DeploymentException */ protected RepositoryClassLoader createDUClassLoader() throws DeploymentException { try { UnifiedClassLoader ucl = (UnifiedClassLoader) Thread .currentThread().getContextClassLoader(); UnifiedLoaderRepository3 lr = (UnifiedLoaderRepository3) ucl .getLoaderRepository(); RepositoryClassLoader cl = lr.newClassLoader( getTempClassDeploymentDir().toURL(), new File( getUnitJarFile().getName()).toURL(), true); // make sure to call ucl.unregister() on undeploy() return cl; } catch (MalformedURLException e1) { throw new DeploymentException( "Bad ULR for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } catch (Exception e) { throw new DeploymentException( "Failed Creating ClassLoader for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } }
public MDeployableUnit(org.mobicents.slee.container.component.deployment.jaxb.slee.du.DeployableUnit deployableUnit10) throws DeploymentException { this.description = deployableUnit10.getDescription() == null ? null : deployableUnit10.getDescription().getvalue(); for(Object entryObject : deployableUnit10.getJarOrServiceXml()) { if(entryObject instanceof org.mobicents.slee.container.component.deployment.jaxb.slee.du.Jar) { org.mobicents.slee.container.component.deployment.jaxb.slee.du.Jar jarEntry = (org.mobicents.slee.container.component.deployment.jaxb.slee.du.Jar)entryObject; String jarEntryString = jarEntry.getvalue(); this.jarEntries.add(jarEntryString); this.sortedEntries.add(jarEntryString); } else if(entryObject instanceof org.mobicents.slee.container.component.deployment.jaxb.slee.du.ServiceXml) { org.mobicents.slee.container.component.deployment.jaxb.slee.du.ServiceXml serviceXmlEntry = (org.mobicents.slee.container.component.deployment.jaxb.slee.du.ServiceXml)entryObject; String serviceXmlEntryString = serviceXmlEntry.getvalue(); this.serviceXmlEntries.add(serviceXmlEntryString); this.sortedEntries.add(serviceXmlEntryString); } else { throw new DeploymentException("Unknown type of entry in deployable unit " + deployableUnit10.getId() + ": " + entryObject.getClass().getName() ); } } }
public MDeployableUnit(org.mobicents.slee.container.component.deployment.jaxb.slee11.du.DeployableUnit deployableUnit11) throws DeploymentException { this.description = deployableUnit11.getDescription() == null ? null : deployableUnit11.getDescription().getvalue(); for(Object entryObject : deployableUnit11.getJarOrServiceXml()) { if(entryObject instanceof org.mobicents.slee.container.component.deployment.jaxb.slee11.du.Jar) { org.mobicents.slee.container.component.deployment.jaxb.slee11.du.Jar jarEntry = (org.mobicents.slee.container.component.deployment.jaxb.slee11.du.Jar)entryObject; String jarEntryString = jarEntry.getvalue(); this.jarEntries.add(jarEntryString); this.sortedEntries.add(jarEntryString); } else if(entryObject instanceof org.mobicents.slee.container.component.deployment.jaxb.slee11.du.ServiceXml) { org.mobicents.slee.container.component.deployment.jaxb.slee11.du.ServiceXml serviceXmlEntry = (org.mobicents.slee.container.component.deployment.jaxb.slee11.du.ServiceXml)entryObject; String serviceXmlEntryString = serviceXmlEntry.getvalue(); this.serviceXmlEntries.add(serviceXmlEntryString); this.sortedEntries.add(serviceXmlEntryString); } else { throw new DeploymentException("Unknown type of entry in deployable unit " + deployableUnit11.getId() + ": " + entryObject.getClass().getName() ); } } }
/** * Create a default constructor on the Sbb Concrete Class * * @throws DeploymentException */ protected void createDefaultConstructor() throws DeploymentException { CtConstructor defaultConstructor = new CtConstructor(null, sbbConcreteClass); // We need a "do nothing" constructor because the // convergence name creation method may need to actually // create the object instance to run the method that // creates the convergence name. String constructorBody = "{ }"; try { defaultConstructor.setBody(constructorBody); sbbConcreteClass.addConstructor(defaultConstructor); logger.trace("DefaultConstructor created"); } catch (CannotCompileException e) { throw new DeploymentException(e.getMessage(), e); } }
@Override protected void deployAndInstall(DeployableUnitIDImpl deployableUnitID) throws Exception { super.deployAndInstall(deployableUnitID); for(Object o: this.eventTypeDefinitions) { MobicentsEventTypeDescriptorInternalImpl descriptorImpl = (MobicentsEventTypeDescriptorInternalImpl) o; if(!EventVerifier.verify(descriptorImpl)) { throw new DeploymentException("Failed to verify event type: "+descriptorImpl.getName()+"#"+descriptorImpl.getVendor()+"#"+descriptorImpl.getVersion()); } } }
public LibraryDescriptorImpl(MLibrary library, MSecurityPermissions mSecurityPermissions, boolean isSlee11) throws DeploymentException { super(isSlee11); super.setLibraryRefs(library.getLibraryRefs()); try { this.jars = library.getJar(); this.securityPermissions = mSecurityPermissions == null ? null : mSecurityPermissions.getSecurityPermissionSpec(); this.libraryID = new LibraryID(library.getLibraryName(), library.getLibraryVendor(),library.getLibraryVersion()); // add other type deps for (EventTypeID eventTypeID : library.getEventTypeRefs()) { super.dependenciesSet.add(eventTypeID); } for (ProfileSpecificationID profileSpecificationID : library.getProfileSpecRefs()) { super.dependenciesSet.add(profileSpecificationID); } for (ResourceAdaptorTypeID raTypeID : library.getRaTypeRefs()) { super.dependenciesSet.add(raTypeID); } for (SbbID sbbID : library.getSbbRefs()) { super.dependenciesSet.add(sbbID); } } catch (Exception e) { throw new DeploymentException("Failed to build library descriptor", e); } }
public EventTypeDescriptorImpl(MEventDefinition eventDefinition, List<LibraryID> libraryRefs, boolean isSlee11) throws DeploymentException { super(isSlee11); super.setLibraryRefs(libraryRefs); try { this.eventTypeID = new EventTypeID(eventDefinition .getEventTypeName(), eventDefinition.getEventTypeVendor(), eventDefinition.getEventTypeVersion()); this.eventClassName = eventDefinition.getEventClassName(); } catch (Exception e) { throw new DeploymentException( "failed to build event type descriptor", e); } }
public ServiceDescriptorImpl(MService mService) throws DeploymentException { super(mService.isSlee11()); try { this.defaultPriority = mService.getDefaultPriority(); this.serviceID = new ServiceID(mService.getServiceName(),mService.getServiceVendor(),mService.getServiceVersion()); this.rootSbbID = new SbbID(mService.getRootSbb().getSbbName(),mService.getRootSbb().getSbbVendor(),mService.getRootSbb().getSbbVersion()); this.addressProfileTable = mService.getAddressProfileTable(); this.resourceInfoProfileTable = mService.getResourceInfoProfileTable(); dependenciesSet.add(rootSbbID); // even if the root sbb does not declares it, all services depend on standard service started event(s) dependenciesSet.add(new EventTypeID("javax.slee.serviceactivity.ServiceStartedEvent", "javax.slee", "1.0")); if (isSlee11()) { dependenciesSet.add(new EventTypeID("javax.slee.serviceactivity.ServiceStartedEvent", "javax.slee", "1.1")); } } catch (Exception e) { throw new DeploymentException("failed to build service descriptor",e); } }