PageRenderTime 39ms CodeModel.GetById 24ms app.highlight 13ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilePassivationStoreWriteHandler.java

#
Java | 61 lines | 31 code | 6 blank | 24 comment | 7 complexity | 9379774c11c04812fd1f11145b34af54 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
 1/*
 2 * JBoss, Home of Professional Open Source.
 3 * Copyright 2011, Red Hat, Inc., and individual contributors
 4 * as indicated by the @author tags. See the copyright.txt file in the
 5 * distribution for a full listing of individual contributors.
 6 *
 7 * This is free software; you can redistribute it and/or modify it
 8 * under the terms of the GNU Lesser General Public License as
 9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22
23package org.jboss.as.ejb3.subsystem;
24
25import org.jboss.as.controller.AttributeDefinition;
26import org.jboss.as.controller.OperationContext;
27import org.jboss.as.controller.OperationFailedException;
28import org.jboss.as.ejb3.cache.impl.factory.NonClusteredBackingCacheEntryStoreSource;
29import org.jboss.dmr.ModelNode;
30
31/**
32 * @author Paul Ferraro
33 */
34public class FilePassivationStoreWriteHandler extends PassivationStoreWriteHandler<NonClusteredBackingCacheEntryStoreSource<?, ?, ?>> {
35
36    FilePassivationStoreWriteHandler(AttributeDefinition... attributes) {
37        super(attributes);
38    }
39
40    @Override
41    protected AttributeDefinition getMaxSizeDefinition() {
42        return FilePassivationStoreResourceDefinition.MAX_SIZE;
43    }
44
45    @Override
46    protected void apply(NonClusteredBackingCacheEntryStoreSource<?, ?, ?> config, OperationContext context, String attributeName, ModelNode model) throws OperationFailedException {
47        if (FilePassivationStoreResourceDefinition.RELATIVE_TO.getName().equals(attributeName)) {
48            String relativeTo = FilePassivationStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, model).asString();
49            config.setRelativeTo(relativeTo);
50        } else if (FilePassivationStoreResourceDefinition.GROUPS_PATH.getName().equals(attributeName)) {
51            String path = FilePassivationStoreResourceDefinition.GROUPS_PATH.resolveModelAttribute(context, model).toString();
52            config.setGroupDirectoryName(path);
53        } else if (FilePassivationStoreResourceDefinition.SESSIONS_PATH.getName().equals(attributeName)) {
54            String path = FilePassivationStoreResourceDefinition.SESSIONS_PATH.resolveModelAttribute(context, model).toString();
55            config.setSessionDirectoryName(path);
56        } else if (FilePassivationStoreResourceDefinition.SUBDIRECTORY_COUNT.getName().equals(attributeName)) {
57            int count = FilePassivationStoreResourceDefinition.SUBDIRECTORY_COUNT.resolveModelAttribute(context, model).asInt();
58            config.setSubdirectoryCount(count);
59        }
60    }
61}