Example usage for org.apache.commons.lang SerializationUtils clone

List of usage examples for org.apache.commons.lang SerializationUtils clone

Introduction

In this page you can find the example usage for org.apache.commons.lang SerializationUtils clone.

Prototype

public static Object clone(Serializable object) 

Source Link

Document

Deep clone an Object using serialization.

This is many times slower than writing clone methods by hand on all objects in your object graph.

Usage

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Actor getActor(Long code) {
    return (Actor) SerializationUtils.clone(codeToActorCache.get(code));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Executor getExecutor(String name) {
    return (Executor) SerializationUtils.clone(nameToExecutorCache.get(name));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Executor getExecutor(Long id) {
    return (Executor) SerializationUtils.clone(idToExecutorCache.get(id));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Set<Executor> getGroupMembers(Group group) {
    return (Set<Executor>) SerializationUtils.clone(groupToMembersCache.get(group.getId()));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Set<Actor> getGroupActorsAll(Group group) {
    return (Set<Actor>) SerializationUtils.clone(groupToAllActorMembersCache.get(group.getId()));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Set<Group> getExecutorParents(Executor executor) {
    return (Set<Group>) SerializationUtils.clone(executorToParentGroupsCache.get(executor.getId()));
}

From source file:ru.runa.wfe.user.cache.ExecutorCacheImpl.java

@Override
public Set<Group> getExecutorParentsAll(Executor executor) {
    return (Set<Group>) SerializationUtils.clone(executorToAllParentGroupsCache.get(executor.getId()));
}

From source file:scores.MapBasedScoreRepository.java

private List<Game> deepCloneList(List<Game> original) {
    List<Game> copy = new ArrayList<Game>(original.size());
    for (Game t : original) {
        copy.add((Game) SerializationUtils.clone((Serializable) t));
    }//  ww w .  j  a  va2s . co m
    return copy;
}

From source file:se.inera.axel.shs.broker.messagestore.ShsMessageEntry.java

public static ShsMessageEntry newInstance(ShsMessageEntry shsMessageEntry) {
    return (ShsMessageEntry) SerializationUtils.clone(shsMessageEntry);
}

From source file:streamflow.service.TopologyService.java

public Topology initializeTopologyObject(Topology topology) {
    try {//from  w ww  . j a v  a2s. c  o m
        TopologyConfig topologyConfig = (TopologyConfig) SerializationUtils.clone(topology.getCurrentConfig());

        for (TopologyComponent topologyComponent : topologyConfig.getComponents().values()) {
            Component component = componentService.getComponent(topologyComponent.getFramework(),
                    topologyComponent.getName());

            if (component == null) {
                throw new ServiceException("A component with the specified "
                        + " framework and name could not be found: " + "Framework = "
                        + topologyComponent.getFramework() + "Name = " + topologyComponent.getName());
            }

            ComponentConfig componentConfig = component.getConfig();

            // Iterate over the resource config to build a mapping of names to types
            HashMap<String, String> componentPropertyTypes = new HashMap<String, String>();
            for (ComponentProperty componentProperty : componentConfig.getProperties()) {
                // Get the property type using "text" as default if not specified
                String propertyType = componentProperty.getType();
                if (propertyType == null) {
                    propertyType = "text";
                }

                componentPropertyTypes.put(componentProperty.getName(), propertyType);
            }

            topologyComponent.setPropertyTypes(componentPropertyTypes);
            topologyComponent.setMainClass(componentConfig.getMainClass());
            topologyComponent.setFrameworkHash(
                    frameworkService.getFrameworkFileInfo(component.getFramework()).getContentHash());
            topologyComponent.setVersion(component.getVersion());
            topologyComponent.getResources().clear();

            // Iterate over each of the properties looking for resource types
            for (ComponentProperty componentProperty : componentConfig.getProperties()) {
                // The property type is a resource type so fetch the resource entry details
                if (componentProperty.getType() != null
                        && componentProperty.getType().equalsIgnoreCase("resource")) {
                    String resourceFramework = componentProperty.getOptions().getResourceFramework();
                    String resourceName = componentProperty.getOptions().getResourceName();

                    Resource resource = resourceService.getResource(resourceFramework, resourceName);

                    ResourceConfig resourceConfig = resource.getConfig();

                    // Iterate over the resource config to build a mapping of names to types
                    HashMap<String, String> resourcePropertyTypes = new HashMap<String, String>();
                    for (ResourceProperty resourceProperty : resourceConfig.getProperties()) {
                        resourcePropertyTypes.put(resourceProperty.getName(), resourceProperty.getType());
                    }

                    String resourceEntryId = topologyComponent.getProperties().get(componentProperty.getName());

                    if (resourceEntryId != null) {
                        ResourceEntry resourceEntry = resourceEntryService.getResourceEntry(resourceEntryId);

                        // Create a new topology resource to store with the topology node
                        TopologyResourceEntry topologyResource = new TopologyResourceEntry();
                        topologyResource.setId(resourceEntryId);
                        topologyResource.setVersion(resource.getVersion());
                        topologyResource.setFramework(resourceFramework);
                        topologyResource.setFrameworkHash(frameworkService
                                .getFrameworkFileInfo(resource.getFramework()).getContentHash());
                        topologyResource.setResource(resourceName);
                        topologyResource.setName(resourceEntry.getName());
                        topologyResource.setDescription(resourceEntry.getDescription());
                        topologyResource.setResourceClass(resourceConfig.getResourceClass());
                        topologyResource.setProperties(resourceEntry.getConfig().getProperties());
                        topologyResource.setPropertyTypes(resourcePropertyTypes);

                        // Add the newly built topology resource to the topology ode
                        topologyComponent.getResources().add(topologyResource);
                    }
                }
            }
        }

        // Rewrite the modified topology config to the topology so the additional metadata is included
        topology.setDeployedConfig(topologyConfig);

        return topology;
    } catch (ServiceException ex) {
        LOG.error("Exception while initializing the topology config object", ex);

        throw new ServiceException(
                "Exception while initializing the " + "Topology config object: " + ex.getMessage());
    }
}