/** * * @param oldProfileTableName * @param newProfileTableName * @throws ProfileTableAlreadyExistsException * @throws NullPointerException * @throws UnrecognizedProfileTableNameException */ public void renameProfileTable(String oldProfileTableName, String newProfileTableName) throws ProfileTableAlreadyExistsException, NullPointerException, UnrecognizedProfileTableNameException { // Get the old table ProfileTableImpl oldProfileTable = getProfileTable(oldProfileTableName); // Create the new one addProfileTable(newProfileTableName, oldProfileTable.getProfileSpecificationComponent()); // Move contents oldProfileTable.rename(newProfileTableName); // Remove the old one - this wont remove profiles/mbeans, since they are already part of new table, this has to be done // above. removeProfileTable(oldProfileTableName); }
/** * * @param profileTableName * @param component * @return * @throws ProfileTableAlreadyExistsException * @throws SLEEException */ public ProfileTableImpl addProfileTable(final String profileTableName, ProfileSpecificationComponent component) throws ProfileTableAlreadyExistsException, SLEEException { try { getProfileTable(profileTableName); throw new ProfileTableAlreadyExistsException("there is already a profile table named "+profileTableName); } catch (UnrecognizedProfileTableNameException e) { // expected } return addProfileTableLocally(createProfileTableInstance(profileTableName, component),true,true); }
public void uninstallProfileSpecification(ProfileSpecificationComponent component) throws UnrecognizedProfileSpecificationException { Collection<String> profileTableNames = getDeclaredProfileTableNames(component.getProfileSpecificationID()); for(String profileTableName:profileTableNames) { try { this.removeProfileTable(profileTableName, true); } catch (Throwable e) { throw new SLEEException(e.getMessage(),e); } } // FIXME: For JBoss 7.2.0.Final: // we have a problem with org.hibernate.service.UnknownServiceException: // Unknown service requested [org.hibernate.event.service.spi.EventListenerRegistry] // see https://hibernate.atlassian.net/browse/HHH-8586 //component.getProfileEntityFramework().uninstall(); }
profileManagement.getSleeContainer().getTransactionManager().mandateTransaction(); return profileManagement.getProfileTable( profileTableName).getProfiles(); } catch (NullPointerException e) {
public Collection<ProfileID> getProfiles(String profileTableName) throws NullPointerException, UnrecognizedProfileTableNameException, ManagementException { if (logger.isDebugEnabled()) { logger.debug("getProfiles( profileTableName = " + profileTableName + " )"); } boolean b = sleeTransactionManagement.requireTransaction(); try { return sleeProfileManagement.getProfileTable(profileTableName).getProfiles(); } catch (NullPointerException e) { throw e; } catch (UnrecognizedProfileTableNameException e) { throw e; } catch (Throwable e) { throw new ManagementException(e.getMessage(), e); } finally { try { sleeTransactionManagement.requireTransactionEnd(b,false); } catch (Throwable e) { throw new ManagementException(e.getMessage(),e); } } }
/** * @param profileTableName * @param component */ public void loadProfileTableLocally(String profileTableName, ProfileSpecificationComponent component) throws IllegalArgumentException { if(profileTableFramework.getProfileTableNames(component.getProfileSpecificationID()).contains(profileTableName)) { boolean createAC = sleeContainer.getSleeState() != null && sleeContainer.getSleeState().isRunning(); addProfileTableLocally(createProfileTableInstance(profileTableName, component), createAC, false); } else { throw new IllegalArgumentException("Either profile table named "+profileTableName+" does not exists or its component is not the specified one"); } }
/** * */ private void startAllProfileTableActivities() { if (logger.isDebugEnabled()) { logger.debug("starting all profile table activities"); } for (String profileTableName : this.getDeclaredProfileTableNames()) { try { ProfileTableImpl pt = getProfileTable(profileTableName); ActivityContext ac = pt.getActivityContext(); if (ac == null) { pt.startActivity(); } } catch (Throwable e) { if (logger.isDebugEnabled()){ logger.debug("Not starting activity for profile table named "+profileTableName+". The profile spec component is not deployed."); } } } }
/** * Retrieves a local object valid for thus current transaction. * * @param profilePojo * @return * @throws TransactionRequiredLocalException */ ProfileObjectImpl getProfileObjectValidInCurrentTransaction(ProfileEntity profileEntity) throws TransactionRequiredLocalException { // check tx final SleeTransactionManager txManager = profileManagement.getSleeContainer().getTransactionManager(); txManager.mandateTransaction(); // look for an assigned object in local map if (txData == null) { txData = new HashMap<ProfileEntity, ProfileObjectImpl>(); } ProfileObjectImpl profileObject = (ProfileObjectImpl) txData.get(profileEntity); if (profileObject == null) { // get an object from the table profileEntity.setReadOnly(true); profileEntity.setDirty(false); ProfileObjectPool pool = profileManagement.getObjectPoolManagement().getObjectPool(profileEntity.getTableName()); profileObject = pool.borrowObject(); profileObject.profileActivate(profileEntity); ProfileTableTransactionView.passivateProfileObjectOnTxEnd(txManager, profileObject, pool); txData.put(profileEntity, profileObject); } return profileObject; }
/** * * @param profileName * @return * @throws TransactionRequiredLocalException * @throws SLEEException * @throws CreateException */ public ProfileObjectImpl createProfile(String profileName) throws TransactionRequiredLocalException, SLEEException, CreateException { Map txData = getTxData(); ProfileTransactionID key = new ProfileTransactionID(profileName, profileTable.getProfileTableName()); ProfileObjectImpl value = (ProfileObjectImpl) txData.get(key); if (value == null) { ProfileObjectPool pool = profileTable.getProfileManagement() .getObjectPoolManagement().getObjectPool( profileTable.getProfileTableName()); value = pool.borrowObject(); passivateProfileObjectOnTxEnd(profileTable.getSleeContainer() .getTransactionManager(), value, pool); value.profileCreate(profileName); txData.put(key, value); } return value; }
@Override public String toString() { return "Profile Table Manager: " + "\n+-- Profile Tables: " + getDeclaredProfileTableNames(); }
public void loadProfileTables(ProfileSpecificationComponent component) throws SLEEException, ProfileTableAlreadyExistsException { if (logger.isTraceEnabled()) { logger.trace("Loading from backend storage profile tables for " + component.getProfileSpecificationID()); } for (String profileTableName : _getProfileTableNames(component.getProfileSpecificationID())) { if (logger.isDebugEnabled()) { logger.debug("Profile Table named " + profileTableName + " found in JPA data source."); } synchronized (this) { // ask for the profile table, the manager will build the local object try { sptm.loadProfileTableLocally(profileTableName, component); } catch (Throwable e) { if (logger.isDebugEnabled()) { logger.debug("Unable to load profile table named " + profileTableName, e); } } } } }
try { Thread.currentThread().setContextClassLoader(component.getClassLoader()); sleeProfileManagement.addProfileTable(profileTableName,component); doRollback =false; } catch (ProfileTableAlreadyExistsException e) {
public void installProfileSpecification(ProfileSpecificationComponent component) throws DeploymentException { if (logger.isDebugEnabled()) { logger.debug("Installing " + component); } try { JndiManagement jndiManagement = sleeContainer.getJndiManagement(); logger.debug("JndiManagement: "+jndiManagement+" for ProfileSpecificationComponent: "+component); jndiManagement.componentInstall(component); jndiManagement.pushJndiContext(component); try { this.createJndiSpace(component); } finally { jndiManagement.popJndiContext(); } // FIXME: we wont use trace and alarm in 1.0 way wont we? ProfileEntityFramework profileEntityFramework = new JPAProfileEntityFramework(component,configuration,sleeContainer.getTransactionManager()); profileEntityFramework.install(); sleeProfileClassCodeGenerator.process(component); profileTableFramework.loadProfileTables(component); } catch (DeploymentException de) { throw de; } catch (Throwable t) { t.printStackTrace(); throw new SLEEException(t.getMessage(),t); } }
/** * */ public ProfileTableActivityImpl getActivity() { if (profileTableActivity == null) { Address clusterLocalAddress = null; if (!profileManagement.getJPAConfiguration().isClusteredProfiles()) { // special scenario, we may run in a cluster but without clustered // profiles, so the activity must be unique for each cluster node clusterLocalAddress = sleeContainer.getCluster(CacheType.ACTIVITIES).getLocalAddress(); } profileTableActivity = new ProfileTableActivityImpl(new ProfileTableActivityHandleImpl(this.profileTableName, clusterLocalAddress)); } return profileTableActivity; }
/** * * @param profileTableName * @param component * @param sleeContainer */ public ProfileTableImpl(final String profileTableName, ProfileSpecificationComponent component, ProfileManagementImpl profileManagement) { ProfileTableImpl.validateProfileTableName(profileTableName); if (profileManagement == null || component == null) { throw new NullPointerException(); } this.component = component; this.profileManagement = profileManagement; this.sleeContainer = profileManagement.getSleeContainer(); this.profileTableName = profileTableName; this.profileTableNotification = new NotificationSourceWrapperImpl( new ProfileTableNotification(this.profileTableName)); this.fireEvents = component.getDescriptor().getEventsEnabled(); this.transactionView = new ProfileTableTransactionView(this); }
final SleeTransactionManager sleeTransactionManager = profileManagement.getSleeContainer() .getTransactionManager(); boolean terminateTx = sleeTransactionManager.requireTransaction(); try { return profileManagement.getProfileTable(profileTableName); } catch (NullPointerException e) { throw e;
public ProfileSpecificationID getProfileSpecification(String profileTableName) throws NullPointerException, UnrecognizedProfileTableNameException, ManagementException { if (logger.isDebugEnabled()) { logger.debug("getProfileSpecification( profileTableName = " + profileTableName +" )"); } if (profileTableName == null) throw new NullPointerException("Argument[ProfileTableName] must not be null"); boolean b = false; try { b = this.sleeTransactionManagement.requireTransaction(); ProfileTableImpl profileTable = this.sleeProfileManagement.getProfileTable(profileTableName); return profileTable.getProfileSpecificationComponent().getProfileSpecificationID(); } catch (SLEEException e) { throw new ManagementException("Failed to obtain ProfileSpecID name for ProfileTable: " + profileTableName, e); } catch (UnrecognizedProfileTableNameException e) { throw e; } catch (Exception e) { throw new ManagementException("Failed to obtain ProfileSpecID name for ProfileTable: " + profileTableName, e); } finally { // never rollbacks try { sleeTransactionManagement.requireTransactionEnd(b,false); } catch (Throwable e) { throw new ManagementException(e.getMessage(),e); } } }
profileTable = addProfileTableLocally(createProfileTableInstance(profileTableName, component),false, false);
profileManagement.getObjectPoolManagement().removeObjectPool(this, sleeContainer.getTransactionManager());
public Collection<String> getProfileTables(ProfileSpecificationID id) throws java.lang.NullPointerException, UnrecognizedProfileSpecificationException, ManagementException { if (logger.isDebugEnabled()) { logger.debug("getProfileTables( id = "+ id + " )"); } if (id == null) { throw new NullPointerException("null profile spec id"); } boolean b = sleeTransactionManagement.requireTransaction(); try { return sleeProfileManagement.getDeclaredProfileTableNames(id); } catch (UnrecognizedProfileSpecificationException x) { throw x; } catch (Throwable x) { throw new ManagementException("Failed createProfileTable", x); } finally { try { sleeTransactionManagement.requireTransactionEnd(b,false); } catch (Throwable e) { throw new ManagementException(e.getMessage(),e); } } }